Commit 20a331b1 authored by Huachao Huang's avatar Huachao Huang

address comment

parent a7c9bd69
......@@ -2935,8 +2935,8 @@ struct crocksdb_user_collected_properties_t {
};
struct crocksdb_user_collected_properties_iterator_t {
const UserCollectedProperties* rep_ = nullptr;
UserCollectedProperties::const_iterator iter_;
UserCollectedProperties* rep_ = nullptr;
UserCollectedProperties::iterator iter_;
};
void crocksdb_user_collected_properties_add(crocksdb_user_collected_properties_t* props,
......@@ -3038,8 +3038,7 @@ const char* crocksdb_table_properties_get_str(crocksdb_table_properties_t* props
crocksdb_user_collected_properties_t*
crocksdb_table_properties_get_user_properties(crocksdb_table_properties_t* props) {
props->user_props_.rep_ =
const_cast<UserCollectedProperties*>(&props->rep_->user_collected_properties);
props->user_props_.rep_ = &props->rep_->user_collected_properties;
return &props->user_props_;
}
......@@ -3058,8 +3057,8 @@ struct crocksdb_table_properties_collection_t {
};
struct crocksdb_table_properties_collection_iterator_t {
const TablePropertiesCollection* rep_ = nullptr;
TablePropertiesCollection::const_iterator iter_;
TablePropertiesCollection* rep_ = nullptr;
TablePropertiesCollection::iterator iter_;
crocksdb_table_properties_t props_;
};
......@@ -3147,8 +3146,7 @@ struct crocksdb_table_properties_collector_t : public TablePropertiesCollector {
virtual UserCollectedProperties GetReadableProperties() const override {
// Seems rocksdb will not return the readable properties and we don't need them too.
UserCollectedProperties props;
return props;
return UserCollectedProperties();
}
const char* Name() const override {
......@@ -3258,7 +3256,10 @@ void crocksdb_get_properties_of_tables_in_range(
ranges.emplace_back(Range(Slice(start_keys[i], start_keys_lens[i]),
Slice(limit_keys[i], limit_keys_lens[i])));
}
auto s = db->rep->GetPropertiesOfTablesInRange(cf->rep, &ranges[0], ranges.size(), props->rep_);
auto s = db->rep->GetPropertiesOfTablesInRange(cf->rep,
ranges.data(),
ranges.size(),
props->rep_);
if (!s.ok()) {
SaveError(errptr, s);
}
......
......@@ -902,9 +902,8 @@ extern "C" {
pub fn crocksdb_table_properties_collection_iter_next
(it: *mut DBTablePropertiesCollectionIterator);
pub fn crocksdb_table_properties_collection_iter_key(it: *mut DBTablePropertiesCollectionIterator,
klen: *mut size_t)
-> *const uint8_t;
pub fn crocksdb_table_properties_collection_iter_key(
it: *mut DBTablePropertiesCollectionIterator, klen: *mut size_t) -> *const uint8_t;
pub fn crocksdb_table_properties_collection_iter_value
(it: *mut DBTablePropertiesCollectionIterator) -> *mut DBTableProperties;
......@@ -921,7 +920,8 @@ extern "C" {
c_int,
uint64_t,
uint64_t),
finish: extern "C" fn(*mut c_void,
finish: extern "C" fn(
*mut c_void,
*mut DBUserCollectedProperties))
-> *mut DBTablePropertiesCollector;
......
......@@ -35,7 +35,7 @@ pub struct CFHandle {
}
impl CFHandle {
fn get_id(&self) -> u32 {
pub fn get_id(&self) -> u32 {
unsafe { crocksdb_ffi::crocksdb_column_family_handle_get_id(self.inner) }
}
}
......
......@@ -169,9 +169,8 @@ impl TablePropertiesCollectionIter {
fn key(&self) -> Result<String, String> {
unsafe {
let mut klen: size_t = 0;
let k =
crocksdb_ffi::crocksdb_table_properties_collection_iter_key(self.inner,
&mut klen as *mut size_t);
let k = crocksdb_ffi::crocksdb_table_properties_collection_iter_key(
self.inner, &mut klen as *mut size_t);
let bytes = slice::from_raw_parts(k, klen);
String::from_utf8(bytes.to_owned()).or_else(|e| Err(format!("{}", e)))
}
......@@ -226,9 +225,8 @@ impl UserCollectedPropertiesIter {
fn value(&self) -> &[u8] {
unsafe {
let mut vlen: size_t = 0;
let v =
crocksdb_ffi::crocksdb_user_collected_properties_iter_value(self.inner,
&mut vlen as *mut size_t);
let v = crocksdb_ffi::crocksdb_user_collected_properties_iter_value(
self.inner, &mut vlen as *mut size_t);
slice::from_raw_parts(v, vlen)
}
}
......
......@@ -157,9 +157,10 @@ fn check_collection(collection: &TablePropertiesCollection,
#[test]
fn test_table_properties_collector_factory() {
let f = ExampleFactory::new();
let mut opts = Options::new();
opts.create_if_missing(true);
opts.add_table_properties_collector_factory(Box::new(ExampleFactory::new()));
opts.add_table_properties_collector_factory(Box::new(f));
let path = TempDir::new("_rust_rocksdb_collectortest").expect("");
let db = DB::open(opts, path.path().to_str().unwrap()).unwrap();
......
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