Commit cb11b928 authored by zhangjinpeng1987's avatar zhangjinpeng1987

Merge branch 'master' of https://github.com/ngaut/rust-rocksdb

parents 2aebd37e ebf9de0f
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
#![feature(plugin)]
extern crate libc; extern crate libc;
...@@ -27,6 +26,7 @@ pub mod comparator; ...@@ -27,6 +26,7 @@ pub mod comparator;
pub use librocksdb_sys::{DBCompactionStyle, DBComparator, DBCompressionType, pub use librocksdb_sys::{DBCompactionStyle, DBComparator, DBCompressionType,
new_bloom_filter, self as rocksdb_ffi}; new_bloom_filter, self as rocksdb_ffi};
pub use rocksdb::{DB, DBIterator, DBVector, Kv, SeekKey, Writable, WriteBatch, ReadOptions}; pub use rocksdb::{DB, DBIterator, DBVector, Kv, ReadOptions, SeekKey,
Writable, WriteBatch};
pub use rocksdb_options::{BlockBasedOptions, Options, WriteOptions}; pub use rocksdb_options::{BlockBasedOptions, Options, WriteOptions};
pub use merge_operator::MergeOperands; pub use merge_operator::MergeOperands;
...@@ -143,7 +143,7 @@ fn main() { ...@@ -143,7 +143,7 @@ fn main() {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use rocksdb::{BlockBasedOptions, DB, Options, DBCompressionType}; use rocksdb::{BlockBasedOptions, DB, DBCompressionType, Options};
use rocksdb::DBCompactionStyle::DBUniversal; use rocksdb::DBCompactionStyle::DBUniversal;
#[allow(dead_code)] #[allow(dead_code)]
...@@ -151,13 +151,14 @@ mod tests { ...@@ -151,13 +151,14 @@ mod tests {
opts: &mut Options, opts: &mut Options,
blockopts: &mut BlockBasedOptions) blockopts: &mut BlockBasedOptions)
-> DB { -> DB {
let per_level_compression: [DBCompressionType; 7] = [DBCompressionType::DBNo, let per_level_compression: [DBCompressionType; 7] =
DBCompressionType::DBNo, [DBCompressionType::DBNo,
DBCompressionType::DBNo, DBCompressionType::DBNo,
DBCompressionType::DBLz4, DBCompressionType::DBNo,
DBCompressionType::DBLz4, DBCompressionType::DBLz4,
DBCompressionType::DBLz4, DBCompressionType::DBLz4,
DBCompressionType::DBLz4]; DBCompressionType::DBLz4,
DBCompressionType::DBLz4];
opts.create_if_missing(true); opts.create_if_missing(true);
opts.set_max_open_files(10000); opts.set_max_open_files(10000);
......
This diff is collapsed.
...@@ -193,7 +193,8 @@ impl Options { ...@@ -193,7 +193,8 @@ impl Options {
} }
} }
pub fn compression_per_level(&mut self, level_types: &[DBCompressionType]) { pub fn compression_per_level(&mut self,
level_types: &[DBCompressionType]) {
unsafe { unsafe {
rocksdb_ffi::rocksdb_options_set_compression_per_level(self.inner, rocksdb_ffi::rocksdb_options_set_compression_per_level(self.inner,
level_types.as_ptr(), level_types.as_ptr(),
...@@ -402,9 +403,11 @@ impl Options { ...@@ -402,9 +403,11 @@ impl Options {
pub fn set_report_bg_io_stats(&mut self, enable: bool) { pub fn set_report_bg_io_stats(&mut self, enable: bool) {
unsafe { unsafe {
if enable { if enable {
rocksdb_ffi::rocksdb_options_set_report_bg_io_stats(self.inner, 1); rocksdb_ffi::rocksdb_options_set_report_bg_io_stats(self.inner,
1);
} else { } else {
rocksdb_ffi::rocksdb_options_set_report_bg_io_stats(self.inner, 0); rocksdb_ffi::rocksdb_options_set_report_bg_io_stats(self.inner,
0);
} }
} }
} }
......
...@@ -33,6 +33,7 @@ pub fn test_column_family() { ...@@ -33,6 +33,7 @@ pub fn test_column_family() {
panic!("could not create column family: {}", e); panic!("could not create column family: {}", e);
} }
} }
assert_eq!(db.cf_names(), vec!["cf1", "default"]);
} }
// should fail to open db without specifying same column families // should fail to open db without specifying same column families
...@@ -56,7 +57,7 @@ pub fn test_column_family() { ...@@ -56,7 +57,7 @@ pub fn test_column_family() {
{ {
let mut opts = Options::new(); let mut opts = Options::new();
opts.add_merge_operator("test operator", test_provided_merge); opts.add_merge_operator("test operator", test_provided_merge);
match DB::open_cf(&opts, path_str, &["cf1"]) { match DB::open_cf(&opts, path_str, &["cf1"], &[&opts]) {
Ok(_) => println!("successfully opened db with column family"), Ok(_) => println!("successfully opened db with column family"),
Err(e) => panic!("failed to open db with column family: {}", e), Err(e) => panic!("failed to open db with column family: {}", e),
} }
...@@ -65,7 +66,7 @@ pub fn test_column_family() { ...@@ -65,7 +66,7 @@ pub fn test_column_family() {
{ {
let mut opts = Options::new(); let mut opts = Options::new();
opts.add_merge_operator("test operator", test_provided_merge); opts.add_merge_operator("test operator", test_provided_merge);
let db = match DB::open_cf(&opts, path_str, &["cf1"]) { let db = match DB::open_cf(&opts, path_str, &["cf1"], &[&opts]) {
Ok(db) => { Ok(db) => {
println!("successfully opened db with column family"); println!("successfully opened db with column family");
db db
...@@ -113,7 +114,11 @@ pub fn test_column_family() { ...@@ -113,7 +114,11 @@ pub fn test_column_family() {
} }
// should b able to drop a cf // should b able to drop a cf
{ {
let mut db = DB::open_cf(&Options::new(), path_str, &["cf1"]).unwrap(); let mut db = DB::open_cf(&Options::new(),
path_str,
&["cf1"],
&[&Options::new()])
.unwrap();
match db.drop_cf("cf1") { match db.drop_cf("cf1") {
Ok(_) => println!("cf1 successfully dropped."), Ok(_) => println!("cf1 successfully dropped."),
Err(e) => panic!("failed to drop column family: {}", e), Err(e) => panic!("failed to drop column family: {}", e),
......
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