Commit 21942bf9 authored by siddontang's avatar siddontang Committed by GitHub

Merge pull request #14 from siddontang/siddontang/delete-file-in-range

parents 561f1bf8 ca977812
...@@ -456,6 +456,19 @@ extern "C" { ...@@ -456,6 +456,19 @@ extern "C" {
range_limit_key: *const *const u8, range_limit_key: *const *const u8,
range_limit_key_len: *const size_t, range_limit_key_len: *const size_t,
sizes: *mut uint64_t); sizes: *mut uint64_t);
pub fn rocksdb_delete_file_in_range(db: DBInstance,
range_start_key: *const u8,
range_start_key_len: size_t,
range_limit_key: *const u8,
range_limit_key_len: size_t,
err: *mut *const i8);
pub fn rocksdb_delete_file_in_range_cf(db: DBInstance,
cf: DBCFHandle,
range_start_key: *const u8,
range_start_key_len: size_t,
range_limit_key: *const u8,
range_limit_key_len: size_t,
err: *mut *const i8);
pub fn rocksdb_property_value(db: DBInstance, pub fn rocksdb_property_value(db: DBInstance,
propname: *const c_char) propname: *const c_char)
-> *mut c_char; -> *mut c_char;
...@@ -538,6 +551,14 @@ mod test { ...@@ -538,6 +551,14 @@ mod test {
assert_eq!(sizes.len(), 1); assert_eq!(sizes.len(), 1);
assert!(sizes[0] > 0); assert!(sizes[0] > 0);
rocksdb_delete_file_in_range(db,
b"\x00\x00".as_ptr(),
2,
b"\xff\x00".as_ptr(),
2,
&mut err);
assert!(err.is_null(), error_message(err));
let propname = CString::new("rocksdb.total-sst-files-size") let propname = CString::new("rocksdb.total-sst-files-size")
.unwrap(); .unwrap();
let value = rocksdb_property_value(db, propname.as_ptr()); let value = rocksdb_property_value(db, propname.as_ptr());
......
...@@ -831,6 +831,48 @@ impl DB { ...@@ -831,6 +831,48 @@ impl DB {
sizes sizes
} }
pub fn delete_file_in_range(&self,
start_key: &[u8],
end_key: &[u8])
-> Result<(), String> {
unsafe {
let mut err: *const i8 = 0 as *const i8;
rocksdb_ffi::rocksdb_delete_file_in_range(self.inner,
start_key.as_ptr(),
start_key.len() as size_t,
end_key.as_ptr(),
end_key.len() as size_t,
&mut err);
if !err.is_null() {
return Err(error_message(err));
}
Ok(())
}
}
pub fn delete_file_in_range_cf(&self,
cf: DBCFHandle,
start_key: &[u8],
end_key: &[u8])
-> Result<(), String> {
unsafe {
let mut err: *const i8 = 0 as *const i8;
rocksdb_ffi::rocksdb_delete_file_in_range_cf(self.inner,
cf,
start_key.as_ptr(),
start_key.len() as size_t,
end_key.as_ptr(),
end_key.len() as size_t,
&mut err);
if !err.is_null() {
return Err(error_message(err));
}
Ok(())
}
}
pub fn get_property_value(&self, name: &str) -> Option<String> { pub fn get_property_value(&self, name: &str) -> Option<String> {
self.get_property_value_cf_opt(None, name) self.get_property_value_cf_opt(None, name)
} }
......
...@@ -91,7 +91,9 @@ impl BlockBasedOptions { ...@@ -91,7 +91,9 @@ impl BlockBasedOptions {
} }
} }
pub fn set_bloom_filter(&mut self, bits_per_key: c_int, block_based: bool) { pub fn set_bloom_filter(&mut self,
bits_per_key: c_int,
block_based: bool) {
unsafe { unsafe {
let bloom = if block_based { let bloom = if block_based {
rocksdb_ffi::rocksdb_filterpolicy_create_bloom(bits_per_key) rocksdb_ffi::rocksdb_filterpolicy_create_bloom(bits_per_key)
......
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