summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2013-04-29 09:43:17 -0700
committerSage Weil <sage@inktank.com>2013-04-29 09:46:11 -0700
commitdc0797932ec5f1d68f23a5f11b8a395bafe28265 (patch)
tree10b03706597d5f754a8b2147c5d3780c1cdca55d
parentcea2ff86153b3193d2a6e320615e519ba41b1f3b (diff)
downloadceph-dc0797932ec5f1d68f23a5f11b8a395bafe28265.tar.gz
leveldb: add compact() method
This will compact the entire store; it will be slow! Signed-off-by: Sage Weil <sage@inktank.com>
-rw-r--r--src/mon/MonitorDBStore.h4
-rw-r--r--src/mon/MonitorStore.h2
-rw-r--r--src/os/LevelDBStore.h5
3 files changed, 11 insertions, 0 deletions
diff --git a/src/mon/MonitorDBStore.h b/src/mon/MonitorDBStore.h
index ac2703ec5e6..b14c5aaae46 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/mon/MonitorStore.h b/src/mon/MonitorStore.h
index 76b8363369e..fcb574fde5e 100644
--- a/src/mon/MonitorStore.h
+++ b/src/mon/MonitorStore.h
@@ -39,6 +39,8 @@ public:
int umount();
void sync();
+ void compact();
+
// ints (stored as ascii)
version_t get_int(const char *a, const char *b=0) WARN_UNUSED_RESULT;
void put_int(version_t v, const char *a, const char *b=0);
diff --git a/src/os/LevelDBStore.h b/src/os/LevelDBStore.h
index 6b1afceb753..9f8cd52ca9c 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.