]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
kv: add per-prefix space estimation
authorSage Weil <sage@redhat.com>
Tue, 3 Oct 2017 03:17:54 +0000 (22:17 -0500)
committerJosh Durgin <jdurgin@redhat.com>
Tue, 2 Jul 2019 04:32:45 +0000 (00:32 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit c6da00b418764ca8fec248b768f3744ca1e655ed)

backport: remove column family handling, which doesn't exist in luminous

src/kv/KeyValueDB.h
src/kv/RocksDBStore.cc
src/kv/RocksDBStore.h

index eca9ddfa6a7c4db2e23c890240d39c1a39a78097..2c31944edc73fd67b77c69c8fa71aa55e58be912 100644 (file)
@@ -370,6 +370,11 @@ public:
 
   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() {}
 
index 08bb6408735b8a21cad456d6d4530bb4a450b85b..1cfa7548b40b1f381ae4b8adfaac465e13e23db6 100644 (file)
@@ -451,6 +451,18 @@ void RocksDBStore::split_stats(const std::string &s, char delim, std::vector<std
     }
 }
 
+int64_t RocksDBStore::estimate_prefix_size(const string& prefix)
+{
+  uint64_t size = 0;
+  uint8_t flags =
+    //rocksdb::DB::INCLUDE_MEMTABLES |  // do not include memtables...
+    rocksdb::DB::INCLUDE_FILES;
+  string limit = prefix + "\xff\xff\xff\xff";
+  rocksdb::Range r(prefix, limit);
+  db->GetApproximateSizes(&r, 1, &size, flags);
+  return size;
+}
+
 void RocksDBStore::get_statistics(Formatter *f)
 {
   if (!g_conf->rocksdb_perf)  {
index ffae58d3cf19dd9ffefb0b204226ad57b2f4106b..0b0d31d12ded00b709246e2dcc5ab8df197a1d02 100644 (file)
@@ -166,6 +166,8 @@ public:
     return logger;
   }
 
+  int64_t estimate_prefix_size(const string& prefix) override;
+
   struct  RocksWBHandler: public rocksdb::WriteBatch::Handler {
     std::string seen ;
     int num_seen = 0;