virtual ~KeyValueDB() {}
+ /// estimate space utilization for a prefix (in bytes)
+ virtual int64_t estimate_prefix_size(const string& prefix) {
+ return 0;
+ }
+
/// compact the underlying store
virtual void compact() {}
}
}
+int64_t RocksDBStore::estimate_prefix_size(const string& prefix)
+{
+ auto cf = get_cf_handle(prefix);
+ uint64_t size = 0;
+ uint8_t flags =
+ //rocksdb::DB::INCLUDE_MEMTABLES | // do not include memtables...
+ rocksdb::DB::INCLUDE_FILES;
+ if (cf) {
+ string start(1, '\x00');
+ string limit("\xff\xff\xff\xff");
+ rocksdb::Range r(start, limit);
+ db->GetApproximateSizes(cf, &r, 1, &size, flags);
+ } else {
+ string limit = prefix + "\xff\xff\xff\xff";
+ rocksdb::Range r(prefix, limit);
+ db->GetApproximateSizes(default_cf,
+ &r, 1, &size, flags);
+ }
+ return size;
+}
+
void RocksDBStore::get_statistics(Formatter *f)
{
if (!g_conf->rocksdb_perf) {