From 42c5bb92dcb25c4224770e7ea3ca1ff6b9f800fb Mon Sep 17 00:00:00 2001 From: zhangjinpeng1987 Date: Fri, 30 Sep 2016 16:57:45 +0800 Subject: [PATCH] set num levels --- src/ffi.rs | 1 + src/rocksdb_options.rs | 6 ++++++ test/test.rs | 1 + test/test_rocksdb_options.rs | 12 ++++++++++++ 4 files changed, 20 insertions(+) create mode 100644 test/test_rocksdb_options.rs diff --git a/src/ffi.rs b/src/ffi.rs index 19634fc..15c7ac1 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -208,6 +208,7 @@ extern "C" { pub fn rocksdb_options_set_wal_recovery_mode(options: DBOptions, mode: DBRecoveryMode); pub fn rocksdb_options_enable_statistics(options: DBOptions); pub fn rocksdb_options_set_stats_dump_period_sec(options: DBOptions, v: usize); + pub fn rocksdb_options_set_num_levels(options: DBOptions, v: c_int); pub fn rocksdb_filterpolicy_create_bloom_full(bits_per_key: c_int) -> DBFilterPolicy; pub fn rocksdb_filterpolicy_create_bloom(bits_per_key: c_int) diff --git a/src/rocksdb_options.rs b/src/rocksdb_options.rs index 9cdfc87..568d5d1 100644 --- a/src/rocksdb_options.rs +++ b/src/rocksdb_options.rs @@ -385,6 +385,12 @@ impl Options { period); } } + + pub fn set_num_levels(&mut self, n: c_int) { + unsafe { + rocksdb_ffi::rocksdb_options_set_num_levels(self.inner, n); + } + } } impl Default for Options { diff --git a/test/test.rs b/test/test.rs index 20a1b69..06e09ad 100644 --- a/test/test.rs +++ b/test/test.rs @@ -3,3 +3,4 @@ extern crate rocksdb; mod test_iterator; mod test_multithreaded; mod test_column_family; +mod test_rocksdb_options; diff --git a/test/test_rocksdb_options.rs b/test/test_rocksdb_options.rs new file mode 100644 index 0000000..cf1accf --- /dev/null +++ b/test/test_rocksdb_options.rs @@ -0,0 +1,12 @@ +use rocksdb::{DB, Options}; + + +#[test] +fn test_set_num_levels() { + let path = "_rust_rocksdb_test_set_num_levels"; + let mut opts = Options::default(); + opts.create_if_missing(true); + opts.set_num_levels(2); + let db = DB::open(&opts, path).unwrap(); + drop(db); +}