]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
leveldbstore: handle old versions of leveldb
authorGreg Farnum <greg@inktank.com>
Wed, 17 Apr 2013 20:21:04 +0000 (13:21 -0700)
committerSage Weil <sage@inktank.com>
Wed, 17 Apr 2013 22:14:35 +0000 (15:14 -0700)
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>
configure.ac
src/os/LevelDBStore.cc
src/os/LevelDBStore.h

index 7be84b40b6f8947eaecae34b8a64b73547e6bc2c..23e21133e6acd0f0a42f31dcc8d36cab75c3e1bf 100644 (file)
@@ -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],
index d7d125343a69ceaa83b0903b87ece7c383a0b66e..8e10281724842af7dc38cb1a608fc97e16bb989c 100644 (file)
@@ -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;
index 3d3b8e818f1d61b55bdbacbfba225c4a7e0f3ccf..6b1afceb75377d10f104095aa15914feac427afb 100644 (file)
@@ -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()
   {}