From: Sage Weil Date: Mon, 29 Apr 2013 22:01:05 +0000 (-0700) Subject: leveldb: add compact_prefix method X-Git-Tag: v0.61~32^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a2f7d1d1f15831c48f0b934d9c25ea8b0c1737d4;p=ceph.git leveldb: add compact_prefix method Signed-off-by: Sage Weil --- diff --git a/src/os/LevelDBStore.h b/src/os/LevelDBStore.h index 9f8cd52ca9c7..83f2ed3b4c45 100644 --- a/src/os/LevelDBStore.h +++ b/src/os/LevelDBStore.h @@ -38,6 +38,17 @@ public: db->CompactRange(NULL, NULL); } + /// compact leveldb for all keys with a given prefix + void compact_prefix(const string& prefix) { + // if we combine the prefix with key by adding a '\0' separator, + // a char(1) will capture all such keys. + string end = prefix; + end += (char)1; + leveldb::Slice cstart(prefix); + leveldb::Slice cend(end); + db->CompactRange(&cstart, &cend); + } + /** * options_t: Holds options which are minimally interpreted * on initialization and then passed through to LevelDB.