@ -2,7 +2,7 @@ rust-rocksdb
============
============
[![Build Status ](https://travis-ci.org/spacejam/rust-rocksdb.svg?branch=master )](https://travis-ci.org/spacejam/rust-rocksdb)
[![Build Status ](https://travis-ci.org/spacejam/rust-rocksdb.svg?branch=master )](https://travis-ci.org/spacejam/rust-rocksdb)
This library has been tested against RocksDB 3.8.1 on linux and OSX. The 0.0.6 crate should work with the Rust nightly release as of 7/12 /15.
This library has been tested against RocksDB 3.8.1 on linux and OSX. The 0.0.7 crate should work with the Rust nightly release as of 7/16 /15.
### status
### status
- [x] basic open/put/get/delete/close
- [x] basic open/put/get/delete/close
@ -12,7 +12,7 @@ This library has been tested against RocksDB 3.8.1 on linux and OSX. The 0.0.6
- [x] LRU cache
- [x] LRU cache
- [x] destroy/repair
- [x] destroy/repair
- [x] iterator
- [x] iterator
- [ ] comparator
- [x ] comparator
- [x] snapshot
- [x] snapshot
- [ ] column family operations
- [ ] column family operations
- [ ] slicetransform
- [ ] slicetransform
@ -31,12 +31,12 @@ sudo make install
###### Cargo.toml
###### Cargo.toml
```rust
```rust
[dependencies]
[dependencies]
rocksdb = "~0.0.6 "
rocksdb = "~0.0.7 "
```
```
###### Code
###### Code
```rust
```rust
extern crate rocksdb;
extern crate rocksdb;
use rocksdb::RocksDB;
use rocksdb::{ RocksDB, Writable} ;
fn main() {
fn main() {
let mut db = RocksDB::open_default("/path/for/rocksdb/storage").unwrap();
let mut db = RocksDB::open_default("/path/for/rocksdb/storage").unwrap();
@ -107,7 +107,7 @@ fn main() {
###### Rustic Merge Operator
###### Rustic Merge Operator
```rust
```rust
extern crate rocksdb;
extern crate rocksdb;
use rocksdb::{RocksDB Options, RocksDB, MergeOperands};
use rocksdb::{Options, RocksDB, MergeOperands, Writable };
fn concat_merge(new_key: & [u8], existing_val: Option< & [u8]>,
fn concat_merge(new_key: & [u8], existing_val: Option< & [u8]>,
operands: & mut MergeOperands) -> Vec< u8 > {
operands: & mut MergeOperands) -> Vec< u8 > {
@ -121,10 +121,10 @@ fn concat_merge(new_key: &[u8], existing_val: Option<&[u8]>,
fn main() {
fn main() {
let path = "/path/to/rocksdb";
let path = "/path/to/rocksdb";
let opts = RocksDB Options::new();
let mut opts = Options::new();
opts.create_if_missing(true);
opts.create_if_missing(true);
opts.add_merge_operator("test operator", concat_merge);
opts.add_merge_operator("test operator", concat_merge);
let mut db = RocksDB::open(opts, path).unwrap();
let mut db = RocksDB::open(& opts, path).unwrap();
let p = db.put(b"k1", b"a");
let p = db.put(b"k1", b"a");
db.merge(b"k1", b"b");
db.merge(b"k1", b"b");
db.merge(b"k1", b"c");
db.merge(b"k1", b"c");
@ -138,14 +138,13 @@ fn main() {
###### Apply Some Tunings
###### 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.
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
```rust
use rocksdb::{RocksDB Options, RocksDB, new_bloom_filter };
use rocksdb::{Options, RocksDB};
use rocksdb::RocksDBCompactionStyle::RocksDBUniversalCompaction;
use rocksdb::RocksDBCompactionStyle::RocksDBUniversalCompaction;
fn tuned_for_somebody_elses_disk() -> RocksDB {
fn badly_ tuned_for_somebody_elses_disk() -> RocksDB {
let path = "_rust_rocksdb_optimizetest";
let path = "_rust_rocksdb_optimizetest";
let opts = RocksDB Options::new();
let mut opts = Options::new();
opts.create_if_missing(true);
opts.create_if_missing(true);
opts.set_block_size(524288);
opts.set_max_open_files(10000);
opts.set_max_open_files(10000);
opts.set_use_fsync(false);
opts.set_use_fsync(false);
opts.set_bytes_per_sync(8388608);
opts.set_bytes_per_sync(8388608);
@ -164,10 +163,7 @@ fn tuned_for_somebody_elses_disk() -> RocksDB {
opts.set_filter_deletes(false);
opts.set_filter_deletes(false);
opts.set_disable_auto_compactions(true);
opts.set_disable_auto_compactions(true);
let filter = new_bloom_filter(10);
RocksDB::open(& opts, path).unwrap()
opts.set_filter(filter);
RocksDB::open(opts, path).unwrap()
}
}
```
```