Add cf getters for properties

master
Martin Ek 7 years ago
parent 22b34a40cb
commit 312ad80f98
  1. 26
      src/db.rs

@ -1167,12 +1167,38 @@ impl DB {
} }
} }
pub fn property_value_cf(&self, column_family: ColumnFamily, name: &str) -> Option<String> {
let prop_name = CString::new(name).unwrap();
unsafe {
let value = ffi::rocksdb_property_value_cf(
self.inner,
column_family.inner,
prop_name.as_ptr()
);
if value.is_null() {
return None;
}
let s = CStr::from_ptr(value).to_str().unwrap().to_owned();
libc::free(value as *mut c_void);
Some(s)
}
}
pub fn property_int_value(&self, name: &str) -> Option<u64> { pub fn property_int_value(&self, name: &str) -> Option<u64> {
match self.property_value(name) { match self.property_value(name) {
Some(value) => value.parse::<u64>().ok(), Some(value) => value.parse::<u64>().ok(),
None => None, None => None,
} }
} }
pub fn property_int_value_cf(&self, column_family: ColumnFamily, name: &str) -> Option<u64> {
match self.property_value_cf(column_family, name) {
Some(value) => value.parse::<u64>().ok(),
None => None,
}
}
} }
impl WriteBatch { impl WriteBatch {

Loading…
Cancel
Save