Refactor GraphDb
Summary: GraphDb is refactored to become an API exposing different parts necessary for the database to function. These different parts can have different implementations in SingleNode or distributed Master/Server GraphDb implementations. Interally GraphDb is implemented using two class heirarchies. One contains all the members and correct wiring for each situation. The other takes care of initialization and shutdown. This architecture is practical because it can guarantee that the initialization of the object structure is complete, before initializing state. Reviewers: buda, mislav.bradac, dgleich, teon.banek Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1093
This commit is contained in:
@@ -15,12 +15,12 @@
|
||||
class InterpreterTest : public ::testing::Test {
|
||||
protected:
|
||||
query::Interpreter interpreter_;
|
||||
GraphDb db_;
|
||||
database::SingleNode db_;
|
||||
|
||||
ResultStreamFaker Interpret(
|
||||
const std::string &query,
|
||||
const std::map<std::string, query::TypedValue> params = {}) {
|
||||
GraphDbAccessor dba(db_);
|
||||
database::GraphDbAccessor dba(db_);
|
||||
ResultStreamFaker result;
|
||||
interpreter_(query, dba, params, false).PullAll(result);
|
||||
return result;
|
||||
@@ -87,7 +87,7 @@ TEST_F(InterpreterTest, AstCache) {
|
||||
// Run query with same ast multiple times with different parameters.
|
||||
TEST_F(InterpreterTest, Parameters) {
|
||||
query::Interpreter interpreter;
|
||||
GraphDb db;
|
||||
database::SingleNode db;
|
||||
{
|
||||
auto stream = Interpret("RETURN $2 + $`a b`", {{"2", 10}, {"a b", 15}});
|
||||
ASSERT_EQ(stream.GetHeader().size(), 1U);
|
||||
@@ -146,7 +146,7 @@ TEST_F(InterpreterTest, Bfs) {
|
||||
|
||||
// Set up.
|
||||
{
|
||||
GraphDbAccessor dba(db_);
|
||||
database::GraphDbAccessor dba(db_);
|
||||
auto add_node = [&](int level, bool reachable) {
|
||||
auto node = dba.InsertVertex();
|
||||
node.PropsSet(dba.Property(kId), id++);
|
||||
@@ -199,7 +199,7 @@ TEST_F(InterpreterTest, Bfs) {
|
||||
dba.Commit();
|
||||
}
|
||||
|
||||
GraphDbAccessor dba(db_);
|
||||
database::GraphDbAccessor dba(db_);
|
||||
ResultStreamFaker stream;
|
||||
interpreter_(
|
||||
"MATCH (n {id: 0})-[r *bfs..5 (e, n | n.reachable and "
|
||||
@@ -245,7 +245,7 @@ TEST_F(InterpreterTest, Bfs) {
|
||||
|
||||
TEST_F(InterpreterTest, CreateIndexInMulticommandTransaction) {
|
||||
ResultStreamFaker stream;
|
||||
GraphDbAccessor dba(db_);
|
||||
database::GraphDbAccessor dba(db_);
|
||||
ASSERT_THROW(
|
||||
interpreter_("CREATE INDEX ON :X(y)", dba, {}, true).PullAll(stream),
|
||||
query::IndexInMulticommandTxException);
|
||||
|
||||
Reference in New Issue
Block a user