Repository: marmotta
Updated Branches:
  refs/heads/develop bc09d2747 -> ed49359d8


support for RocksDB as alternative to LevelDB


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/9aa5c2aa
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/9aa5c2aa
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/9aa5c2aa

Branch: refs/heads/develop
Commit: 9aa5c2aa560eae77b59bbdbfab3bc657bc0f79b4
Parents: 0fe6531
Author: Sebastian Schaffert <[email protected]>
Authored: Mon Aug 22 01:05:57 2016 +0200
Committer: Sebastian Schaffert <[email protected]>
Committed: Mon Aug 22 01:05:57 2016 +0200

----------------------------------------------------------------------
 libraries/ostrich/backend/CMakeLists.txt        |  10 ++
 .../ostrich/backend/cmake/FindRocksDB.cmake     |  18 +++
 .../ostrich/backend/persistence/CMakeLists.txt  |   2 +-
 .../backend/persistence/leveldb_persistence.cc  | 111 ++++++++++---------
 .../backend/persistence/leveldb_persistence.h   |  38 ++++---
 libraries/ostrich/backend/util/time_logger.cc   |   4 +-
 6 files changed, 114 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/9aa5c2aa/libraries/ostrich/backend/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/libraries/ostrich/backend/CMakeLists.txt 
b/libraries/ostrich/backend/CMakeLists.txt
index 61156a5..50efd24 100644
--- a/libraries/ostrich/backend/CMakeLists.txt
+++ b/libraries/ostrich/backend/CMakeLists.txt
@@ -15,6 +15,7 @@ find_package (GRPC REQUIRED)
 find_package (LevelDB REQUIRED)
 find_package (GLog REQUIRED)
 find_package (Boost 1.54.0 COMPONENTS iostreams filesystem system)
+find_package (RocksDB)
 find_package (Tcmalloc)
 
 add_definitions(-DNDEBUG)
@@ -24,6 +25,15 @@ if (Boost_IOSTREAMS_FOUND)
     add_definitions(-DHAVE_IOSTREAMS)
 endif (Boost_IOSTREAMS_FOUND)
 
+if (RocksDB_FOUND)
+    message(STATUS "Enabling RocksDB support (RocksDB found)")
+    add_definitions(-DHAVE_ROCKSDB)
+    set(PERSISTENCE_LIBRARY ${RocksDB_LIBRARY})
+else (RocksDB_FOUND)
+    message(STATUS "Using standard LevelDB (RocksDB not found)")
+    set(PERSISTENCE_LIBRARY ${LevelDB_LIBRARY})
+endif (RocksDB_FOUND)
+
 if (Tcmalloc_FOUND)
     message(STATUS "Enabling profiling support (Tcmalloc found)")
 endif (Tcmalloc_FOUND)

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9aa5c2aa/libraries/ostrich/backend/cmake/FindRocksDB.cmake
----------------------------------------------------------------------
diff --git a/libraries/ostrich/backend/cmake/FindRocksDB.cmake 
b/libraries/ostrich/backend/cmake/FindRocksDB.cmake
new file mode 100644
index 0000000..63eb049
--- /dev/null
+++ b/libraries/ostrich/backend/cmake/FindRocksDB.cmake
@@ -0,0 +1,18 @@
+# Find libleveldb.a - key/value storage system
+
+find_path(RocksDB_INCLUDE_PATH NAMES rocksdb/db.h)
+find_library(RocksDB_LIBRARY NAMES rocksdb)
+
+if(RocksDB_INCLUDE_PATH AND RocksDB_LIBRARY)
+    set(RocksDB_FOUND TRUE)
+endif(RocksDB_INCLUDE_PATH AND RocksDB_LIBRARY)
+
+if(RocksDB_FOUND)
+    if(NOT RocksDB_FIND_QUIETLY)
+        message(STATUS "Found RocksDB: ${RocksDB_LIBRARY}; includes - 
${RocksDB_INCLUDE_PATH}")
+    endif(NOT RocksDB_FIND_QUIETLY)
+else(RocksDB_FOUND)
+    if(RocksDB_FIND_REQUIRED)
+        message(FATAL_ERROR "Could not find rocksdb library.")
+    endif(RocksDB_FIND_REQUIRED)
+endif(RocksDB_FOUND)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9aa5c2aa/libraries/ostrich/backend/persistence/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/libraries/ostrich/backend/persistence/CMakeLists.txt 
b/libraries/ostrich/backend/persistence/CMakeLists.txt
index 8392c61..b6ec1b5 100644
--- a/libraries/ostrich/backend/persistence/CMakeLists.txt
+++ b/libraries/ostrich/backend/persistence/CMakeLists.txt
@@ -5,7 +5,7 @@ add_library(marmotta_leveldb
         leveldb_persistence.cc leveldb_persistence.h leveldb_sparql.cc 
leveldb_sparql.h)
 target_link_libraries(marmotta_leveldb
         marmotta_model marmotta_util marmotta_sparql marmotta_service
-        ${LevelDB_LIBRARY} ${GLOG_LIBRARY} ${PROTOBUF_LIBRARIES})
+        ${PERSISTENCE_LIBRARY} ${GLOG_LIBRARY} ${PROTOBUF_LIBRARIES})
 
 # Server binary
 add_executable(marmotta_persistence

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9aa5c2aa/libraries/ostrich/backend/persistence/leveldb_persistence.cc
----------------------------------------------------------------------
diff --git a/libraries/ostrich/backend/persistence/leveldb_persistence.cc 
b/libraries/ostrich/backend/persistence/leveldb_persistence.cc
index 0a29841..fbb1cb2 100644
--- a/libraries/ostrich/backend/persistence/leveldb_persistence.cc
+++ b/libraries/ostrich/backend/persistence/leveldb_persistence.cc
@@ -18,6 +18,8 @@
 #define KEY_LENGTH 16
 
 #include <chrono>
+#include <stdlib.h>
+#include <malloc.h>
 
 #include <gflags/gflags.h>
 #include <glog/logging.h>
@@ -33,11 +35,11 @@
 
 #define CHECK_STATUS(s) CHECK(s.ok()) << "Writing to database failed: " << 
s.ToString()
 
-DEFINE_int64(write_batch_size, 10000,
+DEFINE_int64(write_batch_size, 1000000,
              "Maximum number of statements to write in a single batch to the 
database");
 
-using leveldb::WriteBatch;
-using leveldb::Slice;
+using dbimpl::WriteBatch;
+using dbimpl::Slice;
 using marmotta::rdf::proto::Statement;
 using marmotta::rdf::proto::Namespace;
 using marmotta::rdf::proto::Resource;
@@ -211,7 +213,7 @@ template<typename T>
 class LevelDBIterator : public util::CloseableIterator<T> {
  public:
 
-    LevelDBIterator(leveldb::Iterator *it)
+    LevelDBIterator(dbimpl::Iterator *it)
         : it(it) {
         it->SeekToFirst();
     }
@@ -236,7 +238,7 @@ class LevelDBIterator : public util::CloseableIterator<T> {
     }
 
  protected:
-    leveldb::Iterator* it;
+    dbimpl::Iterator* it;
     T proto;
 };
 
@@ -246,9 +248,9 @@ class LevelDBIterator : public util::CloseableIterator<T> {
 class StatementRangeIterator : public LevelDBIterator<Statement> {
  public:
 
-    StatementRangeIterator(leveldb::Iterator *it, char *loKey, char *hiKey)
+    StatementRangeIterator(dbimpl::Iterator *it, char *loKey, char *hiKey)
             : LevelDBIterator(it), loKey(loKey), hiKey(hiKey) {
-        it->Seek(leveldb::Slice(loKey, 4 * KEY_LENGTH));
+        it->Seek(dbimpl::Slice(loKey, 4 * KEY_LENGTH));
     }
 
     ~StatementRangeIterator() override {
@@ -257,7 +259,7 @@ class StatementRangeIterator : public 
LevelDBIterator<Statement> {
     };
 
     bool hasNext() override {
-        return it->Valid() && it->key().compare(leveldb::Slice(hiKey, 4 * 
KEY_LENGTH)) <= 0;
+        return it->Valid() && it->key().compare(dbimpl::Slice(hiKey, 4 * 
KEY_LENGTH)) <= 0;
     }
 
  private:
@@ -288,17 +290,21 @@ bool Matches(const Statement& pattern, const Statement& 
stmt) {
 /**
  * Build database with default options.
  */
-leveldb::DB* buildDB(const std::string& path, const std::string& suffix, const 
leveldb::Options& options) {
-    leveldb::DB* db;
-    leveldb::Status status = leveldb::DB::Open(options, path + "/" + suffix + 
".db", &db);
+dbimpl::DB* buildDB(const std::string& path, const std::string& suffix, const 
dbimpl::Options& options) {
+    dbimpl::DB* db;
+    dbimpl::Status status = dbimpl::DB::Open(options, path + "/" + suffix + 
".db", &db);
     assert(status.ok());
     return db;
 }
 
-leveldb::Options* buildOptions(KeyComparator* cmp, leveldb::Cache* cache) {
-    leveldb::Options *options = new leveldb::Options();
+dbimpl::Options* buildOptions(KeyComparator* cmp, dbimpl::Cache* cache) {
+    dbimpl::Options *options = new dbimpl::Options();
     options->create_if_missing = true;
 
+#ifdef HAVE_ROCKSDB
+    options->IncreaseParallelism();
+    options->OptimizeLevelStyleCompaction();
+#else
     // Custom comparator for our keys.
     options->comparator = cmp;
 
@@ -309,19 +315,20 @@ leveldb::Options* buildOptions(KeyComparator* cmp, 
leveldb::Cache* cache) {
     options->write_buffer_size = 16384 * 1024;
 
     // Set a bloom filter of 10 bits.
-    options->filter_policy = leveldb::NewBloomFilterPolicy(10);
+    options->filter_policy = dbimpl::NewBloomFilterPolicy(10);
+#endif
     return options;
 }
 
-leveldb::Options buildNsOptions() {
-    leveldb::Options options;
+dbimpl::Options buildNsOptions() {
+    dbimpl::Options options;
     options.create_if_missing = true;
     return options;
 }
 
 LevelDBPersistence::LevelDBPersistence(const std::string &path, int64_t 
cacheSize)
         : comparator(new KeyComparator())
-        , cache(leveldb::NewLRUCache(cacheSize))
+        , cache(dbimpl::NewLRUCache(cacheSize))
         , options(buildOptions(comparator.get(), cache.get()))
         , db_ns_prefix(buildDB(path, "ns_prefix", buildNsOptions()))
         , db_ns_url(buildDB(path, "ns_url", buildNsOptions()))
@@ -360,14 +367,14 @@ int64_t 
LevelDBPersistence::AddNamespaces(NamespaceIterator& it) {
     DLOG(INFO) << "Starting batch namespace import operation.";
     int64_t count = 0;
 
-    leveldb::WriteBatch batch_prefix, batch_url;
+    dbimpl::WriteBatch batch_prefix, batch_url;
 
     while (it.hasNext()) {
         AddNamespace(it.next(), batch_prefix, batch_url);
         count++;
     }
-    CHECK_STATUS(db_ns_prefix->Write(leveldb::WriteOptions(), &batch_prefix));
-    CHECK_STATUS(db_ns_url->Write(leveldb::WriteOptions(), &batch_url));
+    CHECK_STATUS(db_ns_prefix->Write(dbimpl::WriteOptions(), &batch_prefix));
+    CHECK_STATUS(db_ns_url->Write(dbimpl::WriteOptions(), &batch_url));
 
     DLOG(INFO) << "Imported " << count << " namespaces";
 
@@ -380,7 +387,7 @@ std::unique_ptr<LevelDBPersistence::NamespaceIterator> 
LevelDBPersistence::GetNa
 
     Namespace ns;
 
-    leveldb::DB *db = nullptr;
+    dbimpl::DB *db = nullptr;
     std::string key, value;
     if (pattern.prefix() != "") {
         key = pattern.prefix();
@@ -391,7 +398,7 @@ std::unique_ptr<LevelDBPersistence::NamespaceIterator> 
LevelDBPersistence::GetNa
     }
     if (db != nullptr) {
         // Either prefix or uri given, report the correct namespace value.
-        leveldb::Status s = db->Get(leveldb::ReadOptions(), key, &value);
+        dbimpl::Status s = db->Get(dbimpl::ReadOptions(), key, &value);
         if (s.ok()) {
             ns.ParseFromString(value);
             return 
util::make_unique<util::SingletonIterator<Namespace>>(std::move(ns));
@@ -401,7 +408,7 @@ std::unique_ptr<LevelDBPersistence::NamespaceIterator> 
LevelDBPersistence::GetNa
     } else {
         // Pattern was empty, iterate over all namespaces and report them.
         return util::make_unique<LevelDBIterator<Namespace>>(
-                db_ns_prefix->NewIterator(leveldb::ReadOptions()));
+                db_ns_prefix->NewIterator(dbimpl::ReadOptions()));
     }
 }
 
@@ -425,23 +432,23 @@ int64_t 
LevelDBPersistence::AddStatements(StatementIterator& it) {
     LOG(INFO) << "Starting batch statement import operation.";
     int64_t count = 0;
 
-    leveldb::WriteBatch batch_spoc, batch_cspo, batch_opsc, batch_pcos;
+    dbimpl::WriteBatch batch_spoc, batch_cspo, batch_opsc, batch_pcos;
     auto writeBatches = [&]{
         std::vector<std::thread> writers;
         writers.push_back(std::thread([&]() {
-            CHECK_STATUS(db_pcos->Write(leveldb::WriteOptions(), &batch_pcos));
+            CHECK_STATUS(db_pcos->Write(dbimpl::WriteOptions(), &batch_pcos));
             batch_pcos.Clear();
         }));
         writers.push_back(std::thread([&]() {
-            CHECK_STATUS(db_opsc->Write(leveldb::WriteOptions(), &batch_opsc));
+            CHECK_STATUS(db_opsc->Write(dbimpl::WriteOptions(), &batch_opsc));
             batch_opsc.Clear();
         }));
         writers.push_back(std::thread([&]() {
-            CHECK_STATUS(db_cspo->Write(leveldb::WriteOptions(), &batch_cspo));
+            CHECK_STATUS(db_cspo->Write(dbimpl::WriteOptions(), &batch_cspo));
             batch_cspo.Clear();
         }));
         writers.push_back(std::thread([&]() {
-            CHECK_STATUS(db_spoc->Write(leveldb::WriteOptions(), &batch_spoc));
+            CHECK_STATUS(db_spoc->Write(dbimpl::WriteOptions(), &batch_spoc));
             batch_spoc.Clear();
         }));
 
@@ -476,7 +483,7 @@ std::unique_ptr<LevelDBPersistence::StatementIterator> 
LevelDBPersistence::GetSt
 
     PatternQuery query(pattern);
 
-    leveldb::DB* db;
+    dbimpl::DB* db;
     switch (query.Type()) {
         case PatternQuery::SPOC:
             db = db_spoc.get();
@@ -500,12 +507,12 @@ std::unique_ptr<LevelDBPersistence::StatementIterator> 
LevelDBPersistence::GetSt
         DLOG(INFO) << "Retrieving statements with filter.";
         return util::make_unique<util::FilteringIterator<Statement>>(
                 new StatementRangeIterator(
-                        db->NewIterator(leveldb::ReadOptions()), 
query.MinKey(), query.MaxKey()),
+                        db->NewIterator(dbimpl::ReadOptions()), 
query.MinKey(), query.MaxKey()),
                 [&pattern](const Statement& stmt) -> bool { return 
Matches(pattern, stmt); });
     } else {
         DLOG(INFO) << "Retrieving statements without filter.";
         return util::make_unique<StatementRangeIterator>(
-                db->NewIterator(leveldb::ReadOptions()), query.MinKey(), 
query.MaxKey());
+                db->NewIterator(dbimpl::ReadOptions()), query.MinKey(), 
query.MaxKey());
     }
 }
 
@@ -535,22 +542,22 @@ int64_t LevelDBPersistence::RemoveStatements(const 
rdf::proto::Statement& patter
     int64_t count = 0;
 
     Statement stmt;
-    leveldb::WriteBatch batch_spoc, batch_cspo, batch_opsc, batch_pcos;
+    dbimpl::WriteBatch batch_spoc, batch_cspo, batch_opsc, batch_pcos;
 
     count = RemoveStatements(pattern, batch_spoc, batch_cspo, batch_opsc, 
batch_pcos);
 
     std::vector<std::thread> writers;
     writers.push_back(std::thread([&]() {
-        CHECK_STATUS(db_pcos->Write(leveldb::WriteOptions(), &batch_pcos));
+        CHECK_STATUS(db_pcos->Write(dbimpl::WriteOptions(), &batch_pcos));
     }));
     writers.push_back(std::thread([&]() {
-        CHECK_STATUS(db_opsc->Write(leveldb::WriteOptions(), &batch_opsc));
+        CHECK_STATUS(db_opsc->Write(dbimpl::WriteOptions(), &batch_opsc));
     }));
     writers.push_back(std::thread([&]() {
-        CHECK_STATUS(db_cspo->Write(leveldb::WriteOptions(), &batch_cspo));
+        CHECK_STATUS(db_cspo->Write(dbimpl::WriteOptions(), &batch_cspo));
     }));
     writers.push_back(std::thread([&]() {
-        CHECK_STATUS(db_spoc->Write(leveldb::WriteOptions(), &batch_spoc));
+        CHECK_STATUS(db_spoc->Write(dbimpl::WriteOptions(), &batch_spoc));
     }));
 
     for (auto& t : writers) {
@@ -574,27 +581,27 @@ UpdateStatistics 
LevelDBPersistence::Update(LevelDBPersistence::UpdateIterator &
     auto writeBatches = [&]{
         std::vector<std::thread> writers;
         writers.push_back(std::thread([&]() {
-            CHECK_STATUS(db_pcos->Write(leveldb::WriteOptions(), &b_pcos));
+            CHECK_STATUS(db_pcos->Write(dbimpl::WriteOptions(), &b_pcos));
             b_pcos.Clear();
         }));
         writers.push_back(std::thread([&]() {
-            CHECK_STATUS(db_opsc->Write(leveldb::WriteOptions(), &b_opsc));
+            CHECK_STATUS(db_opsc->Write(dbimpl::WriteOptions(), &b_opsc));
             b_opsc.Clear();
         }));
         writers.push_back(std::thread([&]() {
-            CHECK_STATUS(db_cspo->Write(leveldb::WriteOptions(), &b_cspo));
+            CHECK_STATUS(db_cspo->Write(dbimpl::WriteOptions(), &b_cspo));
             b_cspo.Clear();
         }));
         writers.push_back(std::thread([&]() {
-            CHECK_STATUS(db_spoc->Write(leveldb::WriteOptions(), &b_spoc));
+            CHECK_STATUS(db_spoc->Write(dbimpl::WriteOptions(), &b_spoc));
             b_spoc.Clear();
         }));
         writers.push_back(std::thread([&]() {
-            CHECK_STATUS(db_ns_prefix->Write(leveldb::WriteOptions(), 
&b_prefix));
+            CHECK_STATUS(db_ns_prefix->Write(dbimpl::WriteOptions(), 
&b_prefix));
             b_prefix.Clear();
         }));
         writers.push_back(std::thread([&]() {
-            CHECK_STATUS(db_ns_url->Write(leveldb::WriteOptions(), &b_url));
+            CHECK_STATUS(db_ns_url->Write(dbimpl::WriteOptions(), &b_url));
             b_url.Clear();
         }));
 
@@ -675,19 +682,19 @@ void LevelDBPersistence::AddStatement(
 
     char *k_spoc = (char *) calloc(4 * KEY_LENGTH, sizeof(char));
     computeKey(&bufs, &bufp, &bufo, &bufc, k_spoc);
-    spoc.Put(leveldb::Slice(k_spoc, 4 * KEY_LENGTH), buffer);
+    spoc.Put(dbimpl::Slice(k_spoc, 4 * KEY_LENGTH), buffer);
 
     char *k_cspo = (char *) calloc(4 * KEY_LENGTH, sizeof(char));
     orderKey(k_cspo, k_spoc, C, S, P, O);
-    cspo.Put(leveldb::Slice(k_cspo, 4 * KEY_LENGTH), buffer);
+    cspo.Put(dbimpl::Slice(k_cspo, 4 * KEY_LENGTH), buffer);
 
     char *k_opsc = (char *) calloc(4 * KEY_LENGTH, sizeof(char));
     orderKey(k_opsc, k_spoc, O, P, S, C);
-    opsc.Put(leveldb::Slice(k_opsc, 4 * KEY_LENGTH), buffer);
+    opsc.Put(dbimpl::Slice(k_opsc, 4 * KEY_LENGTH), buffer);
 
     char *k_pcos = (char *) calloc(4 * KEY_LENGTH, sizeof(char));
     orderKey(k_pcos, k_spoc, P, C, O, S);
-    pcos.Put(leveldb::Slice(k_pcos, 4 * KEY_LENGTH), buffer);
+    pcos.Put(dbimpl::Slice(k_pcos, 4 * KEY_LENGTH), buffer);
 
     free(k_spoc);
     free(k_cspo);
@@ -712,19 +719,19 @@ int64_t LevelDBPersistence::RemoveStatements(
 
         char* k_spoc = (char*)calloc(4 * KEY_LENGTH, sizeof(char));
         computeKey(&bufs, &bufp, &bufo, &bufc, k_spoc);
-        spoc.Delete(leveldb::Slice(k_spoc, 4 * KEY_LENGTH));
+        spoc.Delete(dbimpl::Slice(k_spoc, 4 * KEY_LENGTH));
 
         char* k_cspo = (char*)calloc(4 * KEY_LENGTH, sizeof(char));
         orderKey(k_cspo, k_spoc, C, S, P, O);
-        cspo.Delete(leveldb::Slice(k_cspo, 4 * KEY_LENGTH));
+        cspo.Delete(dbimpl::Slice(k_cspo, 4 * KEY_LENGTH));
 
         char* k_opsc = (char*)calloc(4 * KEY_LENGTH, sizeof(char));
         orderKey(k_opsc, k_spoc, O, P, S, C);
-        opsc.Delete(leveldb::Slice(k_opsc, 4 * KEY_LENGTH));
+        opsc.Delete(dbimpl::Slice(k_opsc, 4 * KEY_LENGTH));
 
         char* k_pcos = (char*)calloc(4 * KEY_LENGTH, sizeof(char));
         orderKey(k_pcos, k_spoc, P, C, O, S);
-        pcos.Delete(leveldb::Slice(k_pcos, 4 * KEY_LENGTH));
+        pcos.Delete(dbimpl::Slice(k_pcos, 4 * KEY_LENGTH));
 
         free(k_spoc);
         free(k_cspo);
@@ -739,14 +746,14 @@ int64_t LevelDBPersistence::RemoveStatements(
     return count;
 }
 
-int KeyComparator::Compare(const leveldb::Slice& a, const leveldb::Slice& b) 
const {
+int KeyComparator::Compare(const dbimpl::Slice& a, const dbimpl::Slice& b) 
const {
     return memcmp(a.data(), b.data(), 4 * KEY_LENGTH);
 }
 
 
 int64_t LevelDBPersistence::Size() {
     int64_t count = 0;
-    leveldb::Iterator* it = db_cspo->NewIterator(leveldb::ReadOptions());
+    dbimpl::Iterator* it = db_cspo->NewIterator(dbimpl::ReadOptions());
     for (it->SeekToFirst(); it->Valid(); it->Next()) {
         count++;
     }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9aa5c2aa/libraries/ostrich/backend/persistence/leveldb_persistence.h
----------------------------------------------------------------------
diff --git a/libraries/ostrich/backend/persistence/leveldb_persistence.h 
b/libraries/ostrich/backend/persistence/leveldb_persistence.h
index 7a3da17..9fd1924 100644
--- a/libraries/ostrich/backend/persistence/leveldb_persistence.h
+++ b/libraries/ostrich/backend/persistence/leveldb_persistence.h
@@ -22,10 +22,20 @@
 #include <string>
 #include <functional>
 
+#ifdef HAVE_ROCKSDB
+#include <rocksdb/db.h>
+#include <rocksdb/cache.h>
+#include <rocksdb/comparator.h>
+
+namespace dbimpl = rocksdb;
+#else
 #include <leveldb/db.h>
 #include <leveldb/cache.h>
 #include <leveldb/comparator.h>
 
+namespace dbimpl = leveldb;
+#endif
+
 #include "model/rdf_model.h"
 #include "service/sail.pb.h"
 #include "util/iterator.h"
@@ -36,13 +46,13 @@ namespace persistence {
 /**
  * A custom comparator treating the bytes in the key as unsigned char.
  */
-class KeyComparator : public leveldb::Comparator {
+class KeyComparator : public dbimpl::Comparator {
  public:
-    int Compare(const leveldb::Slice& a, const leveldb::Slice& b) const;
+    int Compare(const dbimpl::Slice& a, const dbimpl::Slice& b) const override 
;
 
-    const char* Name() const { return "KeyComparator"; }
-    void FindShortestSeparator(std::string*, const leveldb::Slice&) const { }
-    void FindShortSuccessor(std::string*) const { }
+    const char* Name() const override { return "KeyComparator"; }
+    void FindShortestSeparator(std::string*, const dbimpl::Slice&) const 
override { }
+    void FindShortSuccessor(std::string*) const override { }
 };
 
 
@@ -134,11 +144,11 @@ class LevelDBPersistence {
  private:
 
     std::unique_ptr<KeyComparator> comparator;
-    std::unique_ptr<leveldb::Cache> cache;
-    std::unique_ptr<leveldb::Options> options;
+    std::shared_ptr<dbimpl::Cache> cache;
+    std::unique_ptr<dbimpl::Options> options;
 
     // We currently support efficient lookups by subject, context and object.
-    std::unique_ptr<leveldb::DB>
+    std::unique_ptr<dbimpl::DB>
             // Statement databases, indexed for query performance
             db_spoc, db_cspo, db_opsc, db_pcos,
             // Namespace databases
@@ -150,20 +160,20 @@ class LevelDBPersistence {
      * Add the namespace to the given database batch operations.
      */
     void AddNamespace(const rdf::proto::Namespace& ns,
-                      leveldb::WriteBatch& ns_prefix, leveldb::WriteBatch& 
ns_url);
+                      dbimpl::WriteBatch& ns_prefix, dbimpl::WriteBatch& 
ns_url);
 
     /**
      * Add the namespace to the given database batch operations.
      */
     void RemoveNamespace(const rdf::proto::Namespace& ns,
-                         leveldb::WriteBatch& ns_prefix, leveldb::WriteBatch& 
ns_url);
+                         dbimpl::WriteBatch& ns_prefix, dbimpl::WriteBatch& 
ns_url);
 
     /**
      * Add the statement to the given database batch operations.
      */
     void AddStatement(const rdf::proto::Statement& stmt,
-                      leveldb::WriteBatch& spoc, leveldb::WriteBatch& cspo,
-                      leveldb::WriteBatch& opsc, leveldb::WriteBatch&pcos);
+                      dbimpl::WriteBatch& spoc, dbimpl::WriteBatch& cspo,
+                      dbimpl::WriteBatch& opsc, dbimpl::WriteBatch&pcos);
 
 
     /**
@@ -171,8 +181,8 @@ class LevelDBPersistence {
      * unset to indicate wildcards) from the given database batch operations.
      */
     int64_t RemoveStatements(const rdf::proto::Statement& pattern,
-                             leveldb::WriteBatch& spoc, leveldb::WriteBatch& 
cspo,
-                             leveldb::WriteBatch& opsc, 
leveldb::WriteBatch&pcos);
+                             dbimpl::WriteBatch& spoc, dbimpl::WriteBatch& 
cspo,
+                             dbimpl::WriteBatch& opsc, 
dbimpl::WriteBatch&pcos);
 
 
 };

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9aa5c2aa/libraries/ostrich/backend/util/time_logger.cc
----------------------------------------------------------------------
diff --git a/libraries/ostrich/backend/util/time_logger.cc 
b/libraries/ostrich/backend/util/time_logger.cc
index e836b61..a4650ca 100644
--- a/libraries/ostrich/backend/util/time_logger.cc
+++ b/libraries/ostrich/backend/util/time_logger.cc
@@ -6,8 +6,8 @@
 #include "time_logger.h"
 
 marmotta::util::TimeLogger::TimeLogger(const std::string &name)
-        : start_(std::chrono::steady_clock::now())
-        , name_(name) {
+        : name_(name)
+        , start_(std::chrono::steady_clock::now()) {
     LOG(INFO) << name << " started.";
 }
 

Reply via email to