From 2a29b0ae5f7e44b3d205ff4352aebf94a92cefcf Mon Sep 17 00:00:00 2001 From: Tyler Neely Date: Sun, 18 Dec 2016 18:35:31 -0500 Subject: [PATCH] cut version 0.6.0 --- CHANGELOG.txt | 13 ++++++++--- Cargo.toml | 4 ++-- README.md | 2 +- librocksdb-sys/Cargo.toml | 2 +- src/compaction_filter.rs | 45 ++++++++++++++++++++++++--------------- src/db.rs | 8 +++---- src/db_options.rs | 7 +++--- src/ffi_util.rs | 2 +- 8 files changed, 50 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 22eb219..4440924 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,16 +1,23 @@ Changelog ========= -0.6 (in development) +0.7 (in development) ~~~~~~~~~~~~~~~~~~~~ -**Breaking changes** +0.6 (2016-12-18) +~~~~~~~~~~~~~~~~~~~~ + + **Breaking changes** * Comparator function now returns an Ordering (alexreg) + **New features** + * Compaction filter (tmccombs) + * Support for backups (alexreg) + 0.5 (2016-11-20) ~~~~~~~~~~~~~~~~ -**Breaking changes** + **Breaking changes** * No more Writable trait, as WriteBatch is not thread-safe as a DB (spacejam) * All imports of `rocksdb::rocksdb::*` should now be simply `rocksdb::*` (alexreg) diff --git a/Cargo.toml b/Cargo.toml index 54ebbe6..6c7433a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rocksdb" description = "Rust wrapper for Facebook's RocksDB embeddable database" -version = "0.5.0" +version = "0.6.0" authors = ["Tyler Neely ", "David Greenberg "] license = "Apache-2.0" keywords = ["database", "embedded", "LSM-tree", "persistence"] @@ -23,4 +23,4 @@ path = "test/test.rs" [dependencies] libc = "0.2" -librocksdb-sys = { path = "librocksdb-sys", version = "0.4.0" } +librocksdb-sys = { path = "librocksdb-sys", version = "0.4.1" } diff --git a/README.md b/README.md index 6e7fdbf..b9c2c05 100644 --- a/README.md +++ b/README.md @@ -9,5 +9,5 @@ Feedback and pull requests welcome! If a particular feature of RocksDB is impor ```rust [dependencies] -rocksdb = "0.5.0" +rocksdb = "0.6.0" ``` diff --git a/librocksdb-sys/Cargo.toml b/librocksdb-sys/Cargo.toml index 58f3223..df7f6a0 100644 --- a/librocksdb-sys/Cargo.toml +++ b/librocksdb-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "librocksdb-sys" -version = "0.4.0" +version = "0.4.1" authors = ["Karl Hobley ", "Arkadiy Paronyan "] license = "MIT/Apache-2.0/BSD-3-Clause" description = "Native bindings to librocksdb" diff --git a/src/compaction_filter.rs b/src/compaction_filter.rs index 6638c8a..efdbf89 100644 --- a/src/compaction_filter.rs +++ b/src/compaction_filter.rs @@ -29,7 +29,7 @@ pub enum Decision { /// Remove the object from the database Remove, /// Change the value for the key - Change(&'static [u8]) + Change(&'static [u8]), } @@ -42,31 +42,44 @@ pub enum Decision { /// /// [set_compaction_filter]: ../struct.Options.html#method.set_compaction_filter pub trait CompactionFilterFn: FnMut(u32, &[u8], &[u8]) -> Decision {} -impl CompactionFilterFn for F where F: FnMut(u32, &[u8], &[u8]) -> Decision, F: Send + 'static {} +impl CompactionFilterFn for F + where F: FnMut(u32, &[u8], &[u8]) -> Decision, + F: Send + 'static +{ +} -pub struct CompactionFilterCallback where F: CompactionFilterFn { +pub struct CompactionFilterCallback + where F: CompactionFilterFn +{ pub name: CString, - pub filter_fn: F + pub filter_fn: F, } -pub unsafe extern "C" fn destructor_callback(raw_cb: *mut c_void) where F: CompactionFilterFn { +pub unsafe extern "C" fn destructor_callback(raw_cb: *mut c_void) + where F: CompactionFilterFn +{ let _: Box> = mem::transmute(raw_cb); } -pub unsafe extern "C" fn name_callback(raw_cb: *mut c_void) -> *const c_char where F: CompactionFilterFn { +pub unsafe extern "C" fn name_callback(raw_cb: *mut c_void) -> *const c_char + where F: CompactionFilterFn +{ let cb = &*(raw_cb as *mut CompactionFilterCallback); cb.name.as_ptr() } pub unsafe extern "C" fn filter_callback(raw_cb: *mut c_void, - level: c_int, - raw_key: *const c_char, - key_length: size_t, - existing_value: *const c_char, - value_length: size_t, - new_value: *mut *mut c_char, - new_value_length: *mut size_t, - value_changed: *mut c_uchar) -> c_uchar where F: CompactionFilterFn { + level: c_int, + raw_key: *const c_char, + key_length: size_t, + existing_value: *const c_char, + value_length: size_t, + new_value: *mut *mut c_char, + new_value_length: *mut size_t, + value_changed: *mut c_uchar) + -> c_uchar + where F: CompactionFilterFn +{ use self::Decision::*; let cb = &mut *(raw_cb as *mut CompactionFilterCallback); @@ -92,7 +105,7 @@ fn test_filter(level: u32, key: &[u8], value: &[u8]) -> Decision { match key.first() { Some(&b'_') => Remove, Some(&b'%') => Change(b"secret"), - _ => Keep + _ => Keep, } } @@ -116,5 +129,3 @@ fn compaction_filter_test() { } } - - diff --git a/src/db.rs b/src/db.rs index b963440..56f709c 100644 --- a/src/db.rs +++ b/src/db.rs @@ -676,16 +676,14 @@ impl DB { self.delete_cf_opt(cf, key, &WriteOptions::default()) } - pub fn compact_range(&self, - start: Option<&[u8]>, - end: Option<&[u8]>) { + pub fn compact_range(&self, start: Option<&[u8]>, end: Option<&[u8]>) { unsafe { ffi::rocksdb_compact_range(self.inner, opt_bytes_to_ptr(start), start.map_or(0, |s| s.len()) as size_t, opt_bytes_to_ptr(end), end.map_or(0, |e| e.len()) as size_t); - } + } } pub fn compact_range_cf(&self, @@ -699,7 +697,7 @@ impl DB { start.map_or(0, |s| s.len()) as size_t, opt_bytes_to_ptr(end), end.map_or(0, |e| e.len()) as size_t); - } + } } } diff --git a/src/db_options.rs b/src/db_options.rs index 18422cb..5c5ede9 100644 --- a/src/db_options.rs +++ b/src/db_options.rs @@ -22,8 +22,7 @@ use ffi; use libc::{self, c_int, c_uchar, c_uint, c_void, size_t, uint64_t}; use merge_operator::{self, MergeFn, MergeOperatorCallback, full_merge_callback, partial_merge_callback}; -use compaction_filter::{self, CompactionFilterFn, CompactionFilterCallback, - filter_callback}; +use compaction_filter::{self, CompactionFilterCallback, CompactionFilterFn, filter_callback}; use std::ffi::{CStr, CString}; use std::mem; @@ -230,7 +229,9 @@ impl Options { /// /// If multi-threaded compaction is used, `filter_fn` may be called multiple times /// simultaneously. - pub fn set_compaction_filter(&mut self, name: &str, filter_fn: F) where F: CompactionFilterFn + Send + 'static { + pub fn set_compaction_filter(&mut self, name: &str, filter_fn: F) + where F: CompactionFilterFn + Send + 'static + { let cb = Box::new(CompactionFilterCallback { name: CString::new(name.as_bytes()).unwrap(), filter_fn: filter_fn, diff --git a/src/ffi_util.rs b/src/ffi_util.rs index e7a1790..e9b3119 100644 --- a/src/ffi_util.rs +++ b/src/ffi_util.rs @@ -29,7 +29,7 @@ pub fn error_message(ptr: *const c_char) -> String { pub fn opt_bytes_to_ptr(opt: Option<&[u8]>) -> *const c_char { match opt { Some(v) => v.as_ptr() as *const c_char, - None => ptr::null() + None => ptr::null(), } }