summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2013-04-29 15:01:05 -0700
committerSage Weil <sage@inktank.com>2013-04-29 15:45:41 -0700
commita2f7d1d1f15831c48f0b934d9c25ea8b0c1737d4 (patch)
tree859e2cb5acb55d3c0a13e3f1394af0e1ad3910ce
parent90b6b6df319d946b441ea296eaf321dd3ffcf498 (diff)
downloadceph-a2f7d1d1f15831c48f0b934d9c25ea8b0c1737d4.tar.gz
leveldb: add compact_prefix method
Signed-off-by: Sage Weil <sage@inktank.com>
-rw-r--r--src/os/LevelDBStore.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/os/LevelDBStore.h b/src/os/LevelDBStore.h
index 9f8cd52ca9c..83f2ed3b4c4 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.