From: Greg Farnum Date: Wed, 17 Apr 2013 20:21:04 +0000 (-0700) Subject: leveldbstore: handle old versions of leveldb X-Git-Tag: v0.61~181 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8f21beb23cf0ca1834f5cc42737530b3cbcb72ec;p=ceph.git 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 --- diff --git a/configure.ac b/configure.ac index 7be84b40b6f8..23e21133e6ac 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 d7d125343a69..8e1028172484 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 3d3b8e818f1d..6b1afceb7537 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 db; boost::scoped_ptr db_cache; +#ifdef HAVE_LEVELDB_FILTER_POLICY boost::scoped_ptr 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() {}