You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ss...@apache.org on 2016/08/26 09:55:52 UTC
marmotta git commit: Ostrich: C++14 has support for make_unique,
remove custom version
Repository: marmotta
Updated Branches:
refs/heads/develop 7c12e69e1 -> d3f9f7383
Ostrich: C++14 has support for make_unique, remove custom version
Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/d3f9f738
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/d3f9f738
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/d3f9f738
Branch: refs/heads/develop
Commit: d3f9f7383b7eb5360b33eab9f6285ab4ff2cc42d
Parents: 7c12e69
Author: Sebastian Schaffert <ss...@apache.org>
Authored: Fri Aug 26 11:54:47 2016 +0200
Committer: Sebastian Schaffert <ss...@apache.org>
Committed: Fri Aug 26 11:54:47 2016 +0200
----------------------------------------------------------------------
.../backend/persistence/leveldb_persistence.cc | 14 +++----
.../backend/persistence/leveldb_service.cc | 9 +++--
.../backend/persistence/rocksdb_persistence.cc | 42 +++-----------------
.../ostrich/backend/test/PersistenceTest.cc | 2 +
libraries/ostrich/backend/util/CMakeLists.txt | 2 +-
libraries/ostrich/backend/util/unique.h | 23 -----------
6 files changed, 20 insertions(+), 72 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/marmotta/blob/d3f9f738/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 23e2df4..a14542b 100644
--- a/libraries/ostrich/backend/persistence/leveldb_persistence.cc
+++ b/libraries/ostrich/backend/persistence/leveldb_persistence.cc
@@ -18,8 +18,7 @@
#define KEY_LENGTH 16
#include <chrono>
-#include <stdlib.h>
-#include <malloc.h>
+#include <memory>
#include <gflags/gflags.h>
#include <glog/logging.h>
@@ -30,7 +29,6 @@
#include "leveldb_persistence.h"
#include "model/rdf_operators.h"
-#include "util/unique.h"
#define CHECK_STATUS(s) CHECK(s.ok()) << "Writing to database failed: " << s.ToString()
@@ -190,13 +188,13 @@ std::unique_ptr<LevelDBPersistence::NamespaceIterator> LevelDBPersistence::GetNa
leveldb::Status s = db->Get(leveldb::ReadOptions(), key, &value);
if (s.ok()) {
ns.ParseFromString(value);
- return util::make_unique<util::SingletonIterator<Namespace>>(std::move(ns));
+ return std::make_unique<util::SingletonIterator<Namespace>>(std::move(ns));
} else {
- return util::make_unique<util::EmptyIterator<Namespace>>();
+ return std::make_unique<util::EmptyIterator<Namespace>>();
}
} else {
// Pattern was empty, iterate over all namespaces and report them.
- return util::make_unique<LevelDBIterator<Namespace>>(
+ return std::make_unique<LevelDBIterator<Namespace>>(
db_ns_prefix->NewIterator(leveldb::ReadOptions()));
}
}
@@ -296,13 +294,13 @@ std::unique_ptr<LevelDBPersistence::StatementIterator> LevelDBPersistence::GetSt
if (query.NeedsFilter()) {
DLOG(INFO) << "Retrieving statements with filter.";
- return util::make_unique<util::FilteringIterator<Statement>>(
+ return std::make_unique<util::FilteringIterator<Statement>>(
new StatementRangeIterator(
db->NewIterator(leveldb::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>(
+ return std::make_unique<StatementRangeIterator>(
db->NewIterator(leveldb::ReadOptions()), query.MinKey(), query.MaxKey());
}
}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/d3f9f738/libraries/ostrich/backend/persistence/leveldb_service.cc
----------------------------------------------------------------------
diff --git a/libraries/ostrich/backend/persistence/leveldb_service.cc b/libraries/ostrich/backend/persistence/leveldb_service.cc
index 9f02607..c417252 100644
--- a/libraries/ostrich/backend/persistence/leveldb_service.cc
+++ b/libraries/ostrich/backend/persistence/leveldb_service.cc
@@ -18,9 +18,10 @@
#include "leveldb_service.h"
#include "leveldb_sparql.h"
+#include <memory>
+
#include <unordered_set>
#include <model/rdf_operators.h>
-#include <util/unique.h>
#include <util/time_logger.h>
#include <glog/logging.h>
@@ -235,7 +236,7 @@ grpc::Status LevelDBSparqlService::TupleQuery(
grpc::ServerContext* context, const spq::SparqlRequest* query,
grpc::ServerWriter<spq::SparqlResponse>* result) {
- SparqlService svc(util::make_unique<LevelDBTripleSource>(persistence));
+ SparqlService svc(std::make_unique<LevelDBTripleSource>(persistence));
rdf::URI base_uri = query->base_uri();
@@ -263,7 +264,7 @@ grpc::Status LevelDBSparqlService::GraphQuery(grpc::ServerContext* context,
const spq::SparqlRequest* query,
grpc::ServerWriter<rdf::proto::Statement>* result) {
- SparqlService svc(util::make_unique<LevelDBTripleSource>(persistence));
+ SparqlService svc(std::make_unique<LevelDBTripleSource>(persistence));
rdf::URI base_uri = query->base_uri();
@@ -284,7 +285,7 @@ grpc::Status LevelDBSparqlService::AskQuery(grpc::ServerContext* context,
const spq::SparqlRequest* query,
google::protobuf::BoolValue* result) {
- SparqlService svc(util::make_unique<LevelDBTripleSource>(persistence));
+ SparqlService svc(std::make_unique<LevelDBTripleSource>(persistence));
rdf::URI base_uri = query->base_uri();
http://git-wip-us.apache.org/repos/asf/marmotta/blob/d3f9f738/libraries/ostrich/backend/persistence/rocksdb_persistence.cc
----------------------------------------------------------------------
diff --git a/libraries/ostrich/backend/persistence/rocksdb_persistence.cc b/libraries/ostrich/backend/persistence/rocksdb_persistence.cc
index 4b5879d..db64b4d 100644
--- a/libraries/ostrich/backend/persistence/rocksdb_persistence.cc
+++ b/libraries/ostrich/backend/persistence/rocksdb_persistence.cc
@@ -18,8 +18,7 @@
#define KEY_LENGTH 16
#include <chrono>
-#include <stdlib.h>
-#include <malloc.h>
+#include <memory>
#include <gflags/gflags.h>
#include <glog/logging.h>
@@ -31,8 +30,6 @@
#include "rocksdb_persistence.h"
#include "model/rdf_operators.h"
-#include "util/murmur3.h"
-#include "util/unique.h"
#define CHECK_STATUS(s) CHECK(s.ok()) << "Writing to database failed: " << s.ToString()
@@ -91,33 +88,6 @@ class StatementRangeIterator : public RocksDBIterator<Statement> {
} // namespace
-/**
- * Build database with default options.
- */
-rocksdb::DB* buildDB(const std::string& path, const std::string& suffix, const rocksdb::Options& options) {
- rocksdb::DB* db;
- rocksdb::Status status = rocksdb::DB::Open(options, path + "/" + suffix + ".db", &db);
- CHECK_STATUS(status);
- return db;
-}
-
-rocksdb::Options* buildOptions(KeyComparator* cmp) {
- rocksdb::Options *options = new rocksdb::Options();
- options->create_if_missing = true;
- options->create_missing_column_families = true;
-
- options->IncreaseParallelism();
- options->OptimizeLevelStyleCompaction();
-
- // Custom comparator for our keys.
- options->comparator = cmp;
-
- // Write buffer size 16MB (fast bulk imports)
- options->write_buffer_size = 16384 * 1024;
-
- return options;
-}
-
RocksDBPersistence::RocksDBPersistence(const std::string &path, int64_t cacheSize)
: workers_(8) {
rocksdb::Options options;
@@ -202,13 +172,13 @@ std::unique_ptr<RocksDBPersistence::NamespaceIterator> RocksDBPersistence::GetNa
rocksdb::Status s = database_->Get(rocksdb::ReadOptions(), h, key, &value);
if (s.ok()) {
ns.ParseFromString(value);
- return util::make_unique<util::SingletonIterator<Namespace>>(std::move(ns));
+ return std::make_unique<util::SingletonIterator<Namespace>>(std::move(ns));
} else {
- return util::make_unique<util::EmptyIterator<Namespace>>();
+ return std::make_unique<util::EmptyIterator<Namespace>>();
}
} else {
// Pattern was empty, iterate over all namespaces and report them.
- return util::make_unique<RocksDBIterator<Namespace>>(
+ return std::make_unique<RocksDBIterator<Namespace>>(
database_->NewIterator(rocksdb::ReadOptions(), handles_[Handles::NSPREFIX]));
}
}
@@ -285,13 +255,13 @@ std::unique_ptr<RocksDBPersistence::StatementIterator> RocksDBPersistence::GetSt
if (query.NeedsFilter()) {
DLOG(INFO) << "Retrieving statements with filter.";
- return util::make_unique<util::FilteringIterator<Statement>>(
+ return std::make_unique<util::FilteringIterator<Statement>>(
new StatementRangeIterator(
database_->NewIterator(rocksdb::ReadOptions(), h), 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>(
+ return std::make_unique<StatementRangeIterator>(
database_->NewIterator(rocksdb::ReadOptions(), h), query.MinKey(), query.MaxKey());
}
}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/d3f9f738/libraries/ostrich/backend/test/PersistenceTest.cc
----------------------------------------------------------------------
diff --git a/libraries/ostrich/backend/test/PersistenceTest.cc b/libraries/ostrich/backend/test/PersistenceTest.cc
index 4fe1ca9..7b415e1 100644
--- a/libraries/ostrich/backend/test/PersistenceTest.cc
+++ b/libraries/ostrich/backend/test/PersistenceTest.cc
@@ -24,6 +24,7 @@ bool lessThan(const char* key1, const char* key2) {
return memcmp(key1, key2, 4 * kKeyLength) < 0;
}
+// Test that the keys generated for different statements are also different.
TEST(KeyTest, StatementsDiffer) {
rdf::Statement stmt1(rdf::URI("http://example.com/s1"), rdf::URI("http://example.com/p1"),
rdf::URI("http://example.com/o1"));
@@ -42,6 +43,7 @@ TEST(KeyTest, StatementsDiffer) {
}
}
+// Test that the upper and lower bound of a range over context are different.
TEST(KeyTest, BoundsDiffer) {
rdf::Statement stmt(rdf::URI("http://example.com/s1"), rdf::URI("http://example.com/p1"),
rdf::URI("http://example.com/o1"));
http://git-wip-us.apache.org/repos/asf/marmotta/blob/d3f9f738/libraries/ostrich/backend/util/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/libraries/ostrich/backend/util/CMakeLists.txt b/libraries/ostrich/backend/util/CMakeLists.txt
index d7e13e0..56e9346 100644
--- a/libraries/ostrich/backend/util/CMakeLists.txt
+++ b/libraries/ostrich/backend/util/CMakeLists.txt
@@ -1,7 +1,7 @@
include_directories(.. ${CMAKE_CURRENT_BINARY_DIR}/..)
add_library(marmotta_util murmur3.cc murmur3.h split.cc split.h
- iterator.h unique.h time_logger.cc time_logger.h threadpool.h)
+ iterator.h time_logger.cc time_logger.h threadpool.h)
add_library(marmotta_raptor_util raptor_util.h raptor_util.cc)
target_link_libraries(marmotta_raptor_util marmotta_model ${CMAKE_THREAD_LIBS_INIT} ${RAPTOR_LIBRARY} ${GFLAGS_LIBRARY})
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/marmotta/blob/d3f9f738/libraries/ostrich/backend/util/unique.h
----------------------------------------------------------------------
diff --git a/libraries/ostrich/backend/util/unique.h b/libraries/ostrich/backend/util/unique.h
deleted file mode 100644
index d212af2..0000000
--- a/libraries/ostrich/backend/util/unique.h
+++ /dev/null
@@ -1,23 +0,0 @@
-//
-// Created by wastl on 20.12.15.
-//
-
-#include <memory>
-
-#ifndef MARMOTTA_UNIQUE_H
-#define MARMOTTA_UNIQUE_H
-namespace marmotta {
-namespace util {
-
-/**
- * Backport of C++14 make_unique implementation.
- */
-template<typename T, typename ...Args>
-std::unique_ptr<T> make_unique( Args&& ...args )
-{
- return std::unique_ptr<T>( new T( std::forward<Args>(args)... ) );
-}
-
-} // namespace util
-} // namespace marmotta
-#endif //MARMOTTA_UNIQUE_H