summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Farnum <greg@inktank.com>2013-04-17 13:21:04 -0700
committerSage Weil <sage@inktank.com>2013-04-17 15:14:35 -0700
commit8f21beb23cf0ca1834f5cc42737530b3cbcb72ec (patch)
tree0bd9bbe06e0bcdd260c44e9a043c000e63d43941
parent4bf244821027ead759687c5d3bdfe708caa6d89a (diff)
downloadceph-8f21beb23cf0ca1834f5cc42737530b3cbcb72ec.tar.gz
leveldbstore: handle old versions of leveldb
The filter_policy (bloom filter) stuff is fairly new in LevelDB's life, and it turns out that precise's version is too old for it. Add conditional compilation for those members in order to build and work properly. Signed-off-by: Greg Farnum <greg@inktank.com>
-rw-r--r--configure.ac4
-rw-r--r--src/os/LevelDBStore.cc4
-rw-r--r--src/os/LevelDBStore.h6
3 files changed, 14 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 7be84b40b6f..23e21133e6a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -416,6 +416,10 @@ AM_CONDITIONAL(WITH_OCF, [ test "$with_ocf" = "yes" ])
AC_CHECK_LIB([snappy], [snappy_compress], [], [AC_MSG_FAILURE([libsnappy not found])])
# use system leveldb
AC_CHECK_LIB([leveldb], [leveldb_open], [], [AC_MSG_FAILURE([libleveldb not found])], [-lsnappy -lpthread])
+# see if we can use bloom filters with leveldb
+AC_LANG_PUSH([C++])
+AC_CHECK_HEADER([leveldb/filter_policy.h], [AC_DEFINE([HAVE_LEVELDB_FILTER_POLICY], [1], [Defined if LevelDB supports bloom filters ])])
+AC_LANG_POP([C++])
# use system libs3?
AC_ARG_WITH([system-libs3],
diff --git a/src/os/LevelDBStore.cc b/src/os/LevelDBStore.cc
index d7d125343a6..8e102817248 100644
--- a/src/os/LevelDBStore.cc
+++ b/src/os/LevelDBStore.cc
@@ -25,10 +25,14 @@ int LevelDBStore::init(ostream &out, bool create_if_missing)
if (options.block_size)
ldoptions.block_size = options.block_size;
if (options.bloom_size) {
+#ifdef HAVE_LEVELDB_FILTER_POLICY
const leveldb::FilterPolicy *_filterpolicy =
leveldb::NewBloomFilterPolicy(options.bloom_size);
filterpolicy.reset(_filterpolicy);
ldoptions.filter_policy = filterpolicy.get();
+#else
+ assert(0 == "bloom size set but installed leveldb doesn't support bloom filters");
+#endif
}
if (!options.compression_enabled)
ldoptions.compression = leveldb::kNoCompression;
diff --git a/src/os/LevelDBStore.h b/src/os/LevelDBStore.h
index 3d3b8e818f1..6b1afceb753 100644
--- a/src/os/LevelDBStore.h
+++ b/src/os/LevelDBStore.h
@@ -15,7 +15,9 @@
#include "leveldb/write_batch.h"
#include "leveldb/slice.h"
#include "leveldb/cache.h"
+#ifdef HAVE_LEVELDB_FILTER_POLICY
#include "leveldb/filter_policy.h"
+#endif
/**
* Uses LevelDB to implement the KeyValueDB interface
@@ -24,7 +26,9 @@ class LevelDBStore : public KeyValueDB {
string path;
boost::scoped_ptr<leveldb::DB> db;
boost::scoped_ptr<leveldb::Cache> db_cache;
+#ifdef HAVE_LEVELDB_FILTER_POLICY
boost::scoped_ptr<const leveldb::FilterPolicy> filterpolicy;
+#endif
int init(ostream &out, bool create_if_missing);
@@ -68,7 +72,9 @@ public:
LevelDBStore(const string &path) :
path(path),
db_cache(NULL),
+#ifdef HAVE_LEVELDB_FILTER_POLICY
filterpolicy(NULL),
+#endif
options()
{}