const std::string& key_prefix) {
return 0;
}
+ /// estimate space utilization for a specified range (in bytes)
+ virtual int64_t estimate_range_size(
+ const std::string& prefix,
+ const std::string& key_from,
+ const std::string& key_to) {
+ return 0;
+ };
/// compact the underlying store
virtual void compact() {}
return size;
}
+int64_t RocksDBStore::estimate_range_size(
+ const string& prefix,
+ const string& key_from,
+ const string& key_to)
+{
+ // The default mode is to derive estimates based on
+ // sst files alone (INCLUDE_FILES).
+ // This gives an irritating result when a batch of keys is
+ // just commited but estimate keeps showing 0.
+ rocksdb::DB::SizeApproximationFlags flags(
+ rocksdb::DB::SizeApproximationFlags::INCLUDE_FILES |
+ rocksdb::DB::SizeApproximationFlags::INCLUDE_MEMTABLES);
+ uint64_t size = 0;
+ auto p_iter = cf_handles.find(prefix);
+ if (p_iter != cf_handles.end()) {
+ for (const auto cf : p_iter->second.handles) {
+ uint64_t s = 0;
+ rocksdb::Range r(key_from, key_to);
+ db->GetApproximateSizes(cf, &r, 1, &s, flags);
+ size += s;
+ }
+ } else {
+ string start = combine_strings(prefix , key_from);
+ string limit = combine_strings(prefix , key_to);
+ rocksdb::Range r(start, limit);
+ db->GetApproximateSizes(default_cf, &r, 1, &size, flags);
+ }
+ return size;
+}
+
void RocksDBStore::get_statistics(Formatter *f)
{
if (!cct->_conf->rocksdb_perf) {
int64_t estimate_prefix_size(const std::string& prefix,
const std::string& key_prefix) override;
+ int64_t estimate_range_size(const std::string& prefix,
+ const std::string& key_from,
+ const std::string& key_to) override;
struct RocksWBHandler;
class RocksDBTransactionImpl : public KeyValueDB::TransactionImpl {
public: