From 6a00f33251d8c5046f2b6de60d37c2d9bb203c42 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 29 Apr 2013 09:43:17 -0700 Subject: [PATCH] leveldb: add compact() method This will compact the entire store; it will be slow! Signed-off-by: Sage Weil --- src/mon/MonitorDBStore.h | 4 ++++ src/os/LevelDBStore.h | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/mon/MonitorDBStore.h b/src/mon/MonitorDBStore.h index ac2703ec5e659..b14c5aaae46aa 100644 --- a/src/mon/MonitorDBStore.h +++ b/src/mon/MonitorDBStore.h @@ -456,6 +456,10 @@ class MonitorDBStore return db->create_and_open(out); } + void compact() { + db->compact(); + } + MonitorDBStore(const string& path) : db(0) { string::const_reverse_iterator rit; int pos = 0; diff --git a/src/os/LevelDBStore.h b/src/os/LevelDBStore.h index 6b1afceb75377..9f8cd52ca9c75 100644 --- a/src/os/LevelDBStore.h +++ b/src/os/LevelDBStore.h @@ -33,6 +33,11 @@ class LevelDBStore : public KeyValueDB { int init(ostream &out, bool create_if_missing); public: + /// compact the underlying leveldb store + void compact() { + db->CompactRange(NULL, NULL); + } + /** * options_t: Holds options which are minimally interpreted * on initialization and then passed through to LevelDB. -- 2.39.5