cut version 0.6.0

master
Tyler Neely 8 years ago
parent 253ce55b47
commit 2a29b0ae5f
  1. 13
      CHANGELOG.txt
  2. 4
      Cargo.toml
  3. 2
      README.md
  4. 2
      librocksdb-sys/Cargo.toml
  5. 31
      src/compaction_filter.rs
  6. 4
      src/db.rs
  7. 7
      src/db_options.rs
  8. 2
      src/ffi_util.rs

@ -1,16 +1,23 @@
Changelog 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) * Comparator function now returns an Ordering (alexreg)
**New features**
* Compaction filter (tmccombs)
* Support for backups (alexreg)
0.5 (2016-11-20) 0.5 (2016-11-20)
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
**Breaking changes** **Breaking changes**
* No more Writable trait, as WriteBatch is not thread-safe as a DB (spacejam) * 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) * All imports of `rocksdb::rocksdb::*` should now be simply `rocksdb::*` (alexreg)

@ -1,7 +1,7 @@
[package] [package]
name = "rocksdb" name = "rocksdb"
description = "Rust wrapper for Facebook's RocksDB embeddable database" description = "Rust wrapper for Facebook's RocksDB embeddable database"
version = "0.5.0" version = "0.6.0"
authors = ["Tyler Neely <t@jujit.su>", "David Greenberg <dsg123456789@gmail.com>"] authors = ["Tyler Neely <t@jujit.su>", "David Greenberg <dsg123456789@gmail.com>"]
license = "Apache-2.0" license = "Apache-2.0"
keywords = ["database", "embedded", "LSM-tree", "persistence"] keywords = ["database", "embedded", "LSM-tree", "persistence"]
@ -23,4 +23,4 @@ path = "test/test.rs"
[dependencies] [dependencies]
libc = "0.2" libc = "0.2"
librocksdb-sys = { path = "librocksdb-sys", version = "0.4.0" } librocksdb-sys = { path = "librocksdb-sys", version = "0.4.1" }

@ -9,5 +9,5 @@ Feedback and pull requests welcome! If a particular feature of RocksDB is impor
```rust ```rust
[dependencies] [dependencies]
rocksdb = "0.5.0" rocksdb = "0.6.0"
``` ```

@ -1,6 +1,6 @@
[package] [package]
name = "librocksdb-sys" name = "librocksdb-sys"
version = "0.4.0" version = "0.4.1"
authors = ["Karl Hobley <karlhobley10@gmail.com>", "Arkadiy Paronyan <arkadiy@ethcore.io>"] authors = ["Karl Hobley <karlhobley10@gmail.com>", "Arkadiy Paronyan <arkadiy@ethcore.io>"]
license = "MIT/Apache-2.0/BSD-3-Clause" license = "MIT/Apache-2.0/BSD-3-Clause"
description = "Native bindings to librocksdb" description = "Native bindings to librocksdb"

@ -29,7 +29,7 @@ pub enum Decision {
/// Remove the object from the database /// Remove the object from the database
Remove, Remove,
/// Change the value for the key /// Change the value for the key
Change(&'static [u8]) Change(&'static [u8]),
} }
@ -42,18 +42,28 @@ pub enum Decision {
/// ///
/// [set_compaction_filter]: ../struct.Options.html#method.set_compaction_filter /// [set_compaction_filter]: ../struct.Options.html#method.set_compaction_filter
pub trait CompactionFilterFn: FnMut(u32, &[u8], &[u8]) -> Decision {} pub trait CompactionFilterFn: FnMut(u32, &[u8], &[u8]) -> Decision {}
impl<F> CompactionFilterFn for F where F: FnMut(u32, &[u8], &[u8]) -> Decision, F: Send + 'static {} impl<F> CompactionFilterFn for F
where F: FnMut(u32, &[u8], &[u8]) -> Decision,
F: Send + 'static
{
}
pub struct CompactionFilterCallback<F> where F: CompactionFilterFn { pub struct CompactionFilterCallback<F>
where F: CompactionFilterFn
{
pub name: CString, pub name: CString,
pub filter_fn: F pub filter_fn: F,
} }
pub unsafe extern "C" fn destructor_callback<F>(raw_cb: *mut c_void) where F: CompactionFilterFn { pub unsafe extern "C" fn destructor_callback<F>(raw_cb: *mut c_void)
where F: CompactionFilterFn
{
let _: Box<CompactionFilterCallback<F>> = mem::transmute(raw_cb); let _: Box<CompactionFilterCallback<F>> = mem::transmute(raw_cb);
} }
pub unsafe extern "C" fn name_callback<F>(raw_cb: *mut c_void) -> *const c_char where F: CompactionFilterFn { pub unsafe extern "C" fn name_callback<F>(raw_cb: *mut c_void) -> *const c_char
where F: CompactionFilterFn
{
let cb = &*(raw_cb as *mut CompactionFilterCallback<F>); let cb = &*(raw_cb as *mut CompactionFilterCallback<F>);
cb.name.as_ptr() cb.name.as_ptr()
} }
@ -66,7 +76,10 @@ pub unsafe extern "C" fn filter_callback<F>(raw_cb: *mut c_void,
value_length: size_t, value_length: size_t,
new_value: *mut *mut c_char, new_value: *mut *mut c_char,
new_value_length: *mut size_t, new_value_length: *mut size_t,
value_changed: *mut c_uchar) -> c_uchar where F: CompactionFilterFn { value_changed: *mut c_uchar)
-> c_uchar
where F: CompactionFilterFn
{
use self::Decision::*; use self::Decision::*;
let cb = &mut *(raw_cb as *mut CompactionFilterCallback<F>); let cb = &mut *(raw_cb as *mut CompactionFilterCallback<F>);
@ -92,7 +105,7 @@ fn test_filter(level: u32, key: &[u8], value: &[u8]) -> Decision {
match key.first() { match key.first() {
Some(&b'_') => Remove, Some(&b'_') => Remove,
Some(&b'%') => Change(b"secret"), Some(&b'%') => Change(b"secret"),
_ => Keep _ => Keep,
} }
} }
@ -116,5 +129,3 @@ fn compaction_filter_test() {
} }
} }

@ -676,9 +676,7 @@ impl DB {
self.delete_cf_opt(cf, key, &WriteOptions::default()) self.delete_cf_opt(cf, key, &WriteOptions::default())
} }
pub fn compact_range(&self, pub fn compact_range(&self, start: Option<&[u8]>, end: Option<&[u8]>) {
start: Option<&[u8]>,
end: Option<&[u8]>) {
unsafe { unsafe {
ffi::rocksdb_compact_range(self.inner, ffi::rocksdb_compact_range(self.inner,
opt_bytes_to_ptr(start), opt_bytes_to_ptr(start),

@ -22,8 +22,7 @@ use ffi;
use libc::{self, c_int, c_uchar, c_uint, c_void, size_t, uint64_t}; use libc::{self, c_int, c_uchar, c_uint, c_void, size_t, uint64_t};
use merge_operator::{self, MergeFn, MergeOperatorCallback, full_merge_callback, use merge_operator::{self, MergeFn, MergeOperatorCallback, full_merge_callback,
partial_merge_callback}; partial_merge_callback};
use compaction_filter::{self, CompactionFilterFn, CompactionFilterCallback, use compaction_filter::{self, CompactionFilterCallback, CompactionFilterFn, filter_callback};
filter_callback};
use std::ffi::{CStr, CString}; use std::ffi::{CStr, CString};
use std::mem; use std::mem;
@ -230,7 +229,9 @@ impl Options {
/// ///
/// If multi-threaded compaction is used, `filter_fn` may be called multiple times /// If multi-threaded compaction is used, `filter_fn` may be called multiple times
/// simultaneously. /// simultaneously.
pub fn set_compaction_filter<F>(&mut self, name: &str, filter_fn: F) where F: CompactionFilterFn + Send + 'static { pub fn set_compaction_filter<F>(&mut self, name: &str, filter_fn: F)
where F: CompactionFilterFn + Send + 'static
{
let cb = Box::new(CompactionFilterCallback { let cb = Box::new(CompactionFilterCallback {
name: CString::new(name.as_bytes()).unwrap(), name: CString::new(name.as_bytes()).unwrap(),
filter_fn: filter_fn, filter_fn: filter_fn,

@ -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 { pub fn opt_bytes_to_ptr(opt: Option<&[u8]>) -> *const c_char {
match opt { match opt {
Some(v) => v.as_ptr() as *const c_char, Some(v) => v.as_ptr() as *const c_char,
None => ptr::null() None => ptr::null(),
} }
} }

Loading…
Cancel
Save