Unverified Commit 064ab221 authored by Huachao Huang's avatar Huachao Huang Committed by GitHub

*: improve build process and update rocksdb (#243)

Some trivial changes are applied:
- Refactor Makefile
- Refactor README.md
- Add the rust-toolchain
- Update RocksDB submodule
- Reorganize the tests structure
parent 79b56519
[submodule "librocksdb_sys/rocksdb"]
[submodule "rocksdb"]
path = librocksdb_sys/rocksdb
url = https://github.com/pingcap/rocksdb.git
branch = release-5.15
shallow = true
......@@ -19,10 +19,6 @@ valgrind = []
portable = ["librocksdb_sys/portable"]
sse = ["librocksdb_sys/sse"]
[[test]]
name = "test"
path = "tests/test.rs"
[dependencies]
libc = "0.2.11"
crc = "1.2"
......
.PHONY: all format
# format rust code using the specified command for the specified file or directory.
# $(call do-format-with-cmd,cmd,file-or-dir)
define do-format-with-cmd
$1 --write-mode diff $2 | grep -E "Diff .*at line" > /dev/null && $1 --write-mode overwrite $2 || exit 0
endef
# format rust code in the specified file or directory
# a file of rust code follows the convention of having suffix '.rs'
# $(call format-code-in,file-or-dir)
define format-code-in
$(if $(filter %.rs, $1), \
$(call do-format-with-cmd, rustfmt, $1), \
cd $1 && $(call do-format-with-cmd, cargo fmt --))
endef
all: format build test
format:
@cargo fmt --all
@librocksdb_sys/crocksdb/format-diff.sh > /dev/null || true
build:
@cargo build
test:
@export RUST_BACKTRACE=1 && cargo test -- --nocapture
format:
@$(call format-code-in, .)
@$(call format-code-in, tests/test.rs)
@$(call format-code-in, librocksdb_sys)
# User may not install clang-format-diff.py, ignore any error here.
@librocksdb_sys/crocksdb/format-diff.sh > /dev/null || true
clean:
@cargo clean
@cd librocksdb_sys && cargo clean
update-rocksdb:
@git subtree pull -P librocksdb_sys/rocksdb https://github.com/pingcap/rocksdb.git release-5.15 --squash
rust-rocksdb
============
# rust-rocksdb
This library has been tested against RocksDB 5.15 on Linux and macOS.
### status
## Status
- [x] basic open/put/get/delete/close
- [x] rustic merge operator
- [x] write batch (thanks @dgrnbrg!)
......@@ -28,25 +27,24 @@ This library has been tested against RocksDB 5.15 on Linux and macOS.
Feedback and pull requests welcome! If a particular feature of RocksDB is important to you, please let us know by opening an issue, and we will prioritize it.
###### Prerequisite: RocksDB
## Build
First, use your system's package manager to install snappy. This is optional, but lets rocksdb take advantage of better compression, and some code may require it.
To install rocksdb, please refer to it's installation guide. For Windows users, please make sure you configure rocksdb with `CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS` enabled.
Or enable feature `static-link`, the crate will download and complie RocksDB automatically, including its dependencies.
```bash
cargo build --features static-link
```
$ git submodule update --init --recursive # if you just cloned the repository
$ cargo build
```
### Running
## Running
###### Cargo.toml
```rust
[dependencies.rocksdb]
git = "https://github.com/pingcap/rust-rocksdb.git"
```
###### Code
```rust
extern crate rocksdb;
use rocksdb::{DB, Writable};
......@@ -65,6 +63,7 @@ fn main() {
```
###### Doing an atomic commit of several writes
```rust
extern crate rocksdb;
use rocksdb::{DB, WriteBatch, Writable};
......@@ -83,6 +82,7 @@ fn main() {
```
###### Getting an Iterator
```rust
extern crate rocksdb;
use rocksdb::{DB, Direction, IteratorMode};
......@@ -112,6 +112,7 @@ fn main() {
```
###### Getting an Iterator from a Snapshot
```rust
extern crate rocksdb;
use rocksdb::{DB, Direction};
......@@ -125,6 +126,7 @@ fn main() {
```
###### Rustic Merge Operator
```rust
extern crate rocksdb;
use rocksdb::{Options, DB, MergeOperands, Writable};
......@@ -162,7 +164,9 @@ fn main() {
```
###### Apply Some Tunings
Please read [the official tuning guide](https://github.com/facebook/rocksdb/wiki/RocksDB-Tuning-Guide), and most importantly, measure performance under realistic workloads with realistic hardware.
```rust
use rocksdb::{Options, DB};
use rocksdb::DBCompactionStyle::DBUniversalCompaction;
......
Subproject commit adf83d4ce771ea188292e4da427eafd2667b9338
Subproject commit 84eaf9c23a1a277835608dcb979ae97229391981
extern crate byteorder;
extern crate crc;
extern crate rand;
extern crate rocksdb;
extern crate tempdir;
mod test_column_family;
mod test_compact_range;
mod test_compaction_filter;
......
......@@ -11,11 +11,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use cases::test_ingest_external_file::gen_sst;
use rocksdb::*;
use std::sync::atomic::*;
use std::sync::Arc;
use tempdir::TempDir;
use test_ingest_external_file::gen_sst;
#[derive(Default, Clone)]
struct EventCounter {
......
extern crate byteorder;
extern crate crc;
extern crate rand;
extern crate rocksdb;
extern crate tempdir;
mod cases;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment