Merge pull request #290 from baptistejamin/master

Updates RocksDB to 5.18.3 & implement delete_range and delete_range_cf
master
Jordan Terrell 6 years ago committed by GitHub
commit 218edeffcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      Cargo.toml
  2. 2
      librocksdb-sys/Cargo.toml
  3. 4
      librocksdb-sys/build_version.cc
  4. 2
      librocksdb-sys/rocksdb
  5. 2
      librocksdb-sys/rocksdb_lib_sources.txt
  6. 61
      src/db.rs

@ -25,4 +25,4 @@ bzip2 = ["librocksdb-sys/bzip2"]
[dependencies]
libc = "0.2"
librocksdb-sys = { path = "librocksdb-sys", version = "5.17.2" }
librocksdb-sys = { path = "librocksdb-sys", version = "5.18.3" }

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

@ -1,4 +1,4 @@
#include "build_version.h"
const char* rocksdb_build_git_sha = "rocksdb_build_git_sha:f438b98e552010613cff8684a7d84191ed785148";
const char* rocksdb_build_git_date = "rocksdb_build_git_date:2018-11-18";
const char* rocksdb_build_git_sha = "rocksdb_build_git_sha:641fae60f63619ed5d0c9d9e4c4ea5a0ffa3e253";
const char* rocksdb_build_git_date = "rocksdb_build_git_date:2019-02-11";
const char* rocksdb_build_compile_date = __DATE__;

@ -1 +1 @@
Subproject commit f438b98e552010613cff8684a7d84191ed785148
Subproject commit 641fae60f63619ed5d0c9d9e4c4ea5a0ffa3e253

File diff suppressed because one or more lines are too long

@ -1657,6 +1657,52 @@ impl WriteBatch {
}
}
/// Remove database entries from start key to end key.
///
/// Removes the database entries in the range ["begin_key", "end_key"), i.e.,
/// including "begin_key" and excluding "end_key". It is not an error if no
/// keys exist in the range ["begin_key", "end_key").
pub fn delete_range<K: AsRef<[u8]>>(&mut self, from: K, to: K) -> Result<(), Error> {
let (start_key, end_key) = (from.as_ref(), to.as_ref());
unsafe {
ffi::rocksdb_writebatch_delete_range(
self.inner,
start_key.as_ptr() as *const c_char,
start_key.len() as size_t,
end_key.as_ptr() as *const c_char,
end_key.len() as size_t,
);
Ok(())
}
}
/// Remove database entries in column family from start key to end key.
///
/// Removes the database entries in the range ["begin_key", "end_key"), i.e.,
/// including "begin_key" and excluding "end_key". It is not an error if no
/// keys exist in the range ["begin_key", "end_key").
pub fn delete_range_cf<K: AsRef<[u8]>>(
&mut self,
cf: ColumnFamily,
from: K,
to: K,
) -> Result<(), Error> {
let (start_key, end_key) = (from.as_ref(), to.as_ref());
unsafe {
ffi::rocksdb_writebatch_delete_range_cf(
self.inner,
cf.inner,
start_key.as_ptr() as *const c_char,
start_key.len() as size_t,
end_key.as_ptr() as *const c_char,
end_key.len() as size_t,
);
Ok(())
}
}
/// Clear all updates buffered in this batch.
pub fn clear(&mut self) -> Result<(), Error> {
unsafe {
@ -1952,7 +1998,9 @@ fn writebatch_works() {
assert_eq!(batch.len(), 0);
assert!(batch.is_empty());
let _ = batch.put(b"k1", b"v1111");
assert_eq!(batch.len(), 1);
let _ = batch.put(b"k2", b"v2222");
let _ = batch.put(b"k3", b"v3333");
assert_eq!(batch.len(), 3);
assert!(!batch.is_empty());
assert!(db.get(b"k1").unwrap().is_none());
let p = db.write(batch);
@ -1970,6 +2018,17 @@ fn writebatch_works() {
assert!(p.is_ok());
assert!(db.get(b"k1").unwrap().is_none());
}
{
// test delete_range
let mut batch = WriteBatch::default();
let _ = batch.delete_range(b"k2", b"k4");
assert_eq!(batch.len(), 1);
assert!(!batch.is_empty());
let p = db.write(batch);
assert!(p.is_ok());
assert!(db.get(b"k2").unwrap().is_none());
assert!(db.get(b"k3").unwrap().is_none());
}
{
// test size_in_bytes
let mut batch = WriteBatch::default();

Loading…
Cancel
Save