diff --git a/CMakeLists.txt b/CMakeLists.txt index 036d36574..553f1e9f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -362,9 +362,9 @@ set(memgraph_src_files ${src_dir}/query/console.cpp ${src_dir}/query/frontend/ast/cypher_main_visitor.cpp ${src_dir}/query/typed_value.cpp - ${src_dir}/query/frontend/interpret/awesome_memgraph_functions.cpp - ${src_dir}/query/frontend/logical/operator.cpp - ${src_dir}/query/frontend/logical/planner.cpp + ${src_dir}/query/interpret/awesome_memgraph_functions.cpp + ${src_dir}/query/plan/operator.cpp + ${src_dir}/query/plan/planner.cpp ${src_dir}/query/frontend/semantic/symbol_generator.cpp ) # ----------------------------------------------------------------------------- diff --git a/src/query/engine.hpp b/src/query/engine.hpp index 0d276f002..00f5093f5 100644 --- a/src/query/engine.hpp +++ b/src/query/engine.hpp @@ -142,7 +142,7 @@ private: auto generated_path = fs::path(CONFIG(config::COMPILE_PATH) + std::to_string(stripped.hash) + ".cpp"); - frontend::opencypher::Parser parser(stripped.query); + query::frontend::opencypher::Parser parser(stripped.query); // backend::cpp::Generator(parser.tree(), stripped.query, stripped.hash, // generated_path); return LoadCpp(generated_path, stripped.hash); diff --git a/src/query/frontend/ast/cypher_main_visitor.cpp b/src/query/frontend/ast/cypher_main_visitor.cpp index 6808bf824..ba0b8f30f 100644 --- a/src/query/frontend/ast/cypher_main_visitor.cpp +++ b/src/query/frontend/ast/cypher_main_visitor.cpp @@ -11,7 +11,7 @@ #include "database/graph_db.hpp" #include "query/exceptions.hpp" -#include "query/frontend/interpret/awesome_memgraph_functions.hpp" +#include "query/interpret/awesome_memgraph_functions.hpp" #include "utils/assert.hpp" namespace query { diff --git a/src/query/frontend/opencypher/parser.hpp b/src/query/frontend/opencypher/parser.hpp index d077c20bb..ec4a434fe 100644 --- a/src/query/frontend/opencypher/parser.hpp +++ b/src/query/frontend/opencypher/parser.hpp @@ -7,6 +7,7 @@ #include "query/frontend/opencypher/generated/CypherLexer.h" #include "query/frontend/opencypher/generated/CypherParser.h" +namespace query { namespace frontend { namespace opencypher { @@ -59,5 +60,6 @@ class Parser { CypherParser parser_{&tokens_}; tree::ParseTree *tree_ = nullptr; }; -} -} +} // namespace opencypher +} // namespace frontend +} // namespace query diff --git a/src/query/frontend/interpret/awesome_memgraph_functions.cpp b/src/query/interpret/awesome_memgraph_functions.cpp similarity index 93% rename from src/query/frontend/interpret/awesome_memgraph_functions.cpp rename to src/query/interpret/awesome_memgraph_functions.cpp index 9a38750b4..fbb00f779 100644 --- a/src/query/frontend/interpret/awesome_memgraph_functions.cpp +++ b/src/query/interpret/awesome_memgraph_functions.cpp @@ -1,4 +1,4 @@ -#include "query/frontend/interpret/awesome_memgraph_functions.hpp" +#include "query/interpret/awesome_memgraph_functions.hpp" #include #include diff --git a/src/query/frontend/interpret/awesome_memgraph_functions.hpp b/src/query/interpret/awesome_memgraph_functions.hpp similarity index 100% rename from src/query/frontend/interpret/awesome_memgraph_functions.hpp rename to src/query/interpret/awesome_memgraph_functions.hpp diff --git a/src/query/frontend/interpret/interpret.hpp b/src/query/interpret/eval.hpp similarity index 94% rename from src/query/frontend/interpret/interpret.hpp rename to src/query/interpret/eval.hpp index 636725574..566288d99 100644 --- a/src/query/frontend/interpret/interpret.hpp +++ b/src/query/interpret/eval.hpp @@ -5,28 +5,13 @@ #include "query/frontend/ast/ast.hpp" #include "query/frontend/semantic/symbol_table.hpp" +#include "query/interpret/frame.hpp" #include "query/typed_value.hpp" #include "utils/assert.hpp" #include "utils/exceptions/not_yet_implemented.hpp" namespace query { -class Frame { - public: - Frame(int size) : size_(size), elems_(size_) {} - - TypedValue &operator[](const Symbol &symbol) { - return elems_[symbol.position_]; - } - const TypedValue &operator[](const Symbol &symbol) const { - return elems_[symbol.position_]; - } - - private: - int size_; - std::vector elems_; -}; - class ExpressionEvaluator : public TreeVisitorBase { public: ExpressionEvaluator(Frame &frame, const SymbolTable &symbol_table) diff --git a/src/query/interpret/frame.hpp b/src/query/interpret/frame.hpp new file mode 100644 index 000000000..091575216 --- /dev/null +++ b/src/query/interpret/frame.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include + +#include "query/frontend/semantic/symbol_table.hpp" +#include "query/typed_value.hpp" + +namespace query { + +class Frame { + public: + Frame(int size) : size_(size), elems_(size_) {} + + TypedValue &operator[](const Symbol &symbol) { + return elems_[symbol.position_]; + } + const TypedValue &operator[](const Symbol &symbol) const { + return elems_[symbol.position_]; + } + + private: + int size_; + std::vector elems_; +}; + +} // namespace query diff --git a/src/query/interpreter.hpp b/src/query/interpreter.hpp index e2d1bbde2..de072474c 100644 --- a/src/query/interpreter.hpp +++ b/src/query/interpreter.hpp @@ -5,10 +5,10 @@ #include "database/graph_db_accessor.hpp" #include "query/context.hpp" #include "query/frontend/ast/cypher_main_visitor.hpp" -#include "query/frontend/interpret/interpret.hpp" -#include "query/frontend/logical/planner.hpp" #include "query/frontend/opencypher/parser.hpp" #include "query/frontend/semantic/symbol_generator.hpp" +#include "query/interpret/frame.hpp" +#include "query/plan/planner.hpp" namespace query { @@ -22,7 +22,7 @@ void Interpret(const std::string &query, GraphDbAccessor &db_accessor, std::map summary; // query -> AST - ::frontend::opencypher::Parser parser(query); + frontend::opencypher::Parser parser(query); auto low_level_tree = parser.tree(); // AST -> high level tree diff --git a/src/query/frontend/logical/operator.cpp b/src/query/plan/operator.cpp similarity index 99% rename from src/query/frontend/logical/operator.cpp rename to src/query/plan/operator.cpp index 2d7f2ce5d..2a239a36d 100644 --- a/src/query/frontend/logical/operator.cpp +++ b/src/query/plan/operator.cpp @@ -1,10 +1,10 @@ #include -#include "query/frontend/logical/operator.hpp" +#include "query/plan/operator.hpp" #include "query/exceptions.hpp" #include "query/frontend/ast/ast.hpp" -#include "query/frontend/interpret/interpret.hpp" +#include "query/interpret/eval.hpp" namespace query { namespace plan { diff --git a/src/query/frontend/logical/operator.hpp b/src/query/plan/operator.hpp similarity index 100% rename from src/query/frontend/logical/operator.hpp rename to src/query/plan/operator.hpp diff --git a/src/query/frontend/logical/planner.cpp b/src/query/plan/planner.cpp similarity index 99% rename from src/query/frontend/logical/planner.cpp rename to src/query/plan/planner.cpp index 4c7222905..477bb5298 100644 --- a/src/query/frontend/logical/planner.cpp +++ b/src/query/plan/planner.cpp @@ -1,4 +1,4 @@ -#include "query/frontend/logical/planner.hpp" +#include "query/plan/planner.hpp" #include #include diff --git a/src/query/frontend/logical/planner.hpp b/src/query/plan/planner.hpp similarity index 89% rename from src/query/frontend/logical/planner.hpp rename to src/query/plan/planner.hpp index d784d204a..1dada21a2 100644 --- a/src/query/frontend/logical/planner.hpp +++ b/src/query/plan/planner.hpp @@ -2,7 +2,7 @@ #include -#include "query/frontend/logical/operator.hpp" +#include "query/plan/operator.hpp" namespace query { diff --git a/tests/unit/query_expression_evaluator.cpp b/tests/unit/query_expression_evaluator.cpp index 88c785482..abc6fccc1 100644 --- a/tests/unit/query_expression_evaluator.cpp +++ b/tests/unit/query_expression_evaluator.cpp @@ -11,9 +11,9 @@ #include "gtest/gtest.h" #include "query/frontend/ast/ast.hpp" -#include "query/frontend/interpret/awesome_memgraph_functions.hpp" -#include "query/frontend/interpret/interpret.hpp" #include "query/frontend/opencypher/parser.hpp" +#include "query/interpret/awesome_memgraph_functions.hpp" +#include "query/interpret/eval.hpp" using namespace query; diff --git a/tests/unit/query_plan_accumulate_aggregate.cpp b/tests/unit/query_plan_accumulate_aggregate.cpp index 70b9bec48..32b67732e 100644 --- a/tests/unit/query_plan_accumulate_aggregate.cpp +++ b/tests/unit/query_plan_accumulate_aggregate.cpp @@ -15,8 +15,7 @@ #include "dbms/dbms.hpp" #include "query/context.hpp" #include "query/exceptions.hpp" -#include "query/frontend/interpret/interpret.hpp" -#include "query/frontend/logical/operator.hpp" +#include "query/plan/operator.hpp" #include "query_plan_common.hpp" diff --git a/tests/unit/query_plan_common.hpp b/tests/unit/query_plan_common.hpp index 0d1fbe774..f1b5e2489 100644 --- a/tests/unit/query_plan_common.hpp +++ b/tests/unit/query_plan_common.hpp @@ -8,7 +8,7 @@ #include #include "query/frontend/semantic/symbol_table.hpp" -#include "query/frontend/interpret/interpret.hpp" +#include "query/interpret/frame.hpp" #include "query_common.hpp" diff --git a/tests/unit/query_plan_create_set_remove_delete.cpp b/tests/unit/query_plan_create_set_remove_delete.cpp index af49d66ea..99835b363 100644 --- a/tests/unit/query_plan_create_set_remove_delete.cpp +++ b/tests/unit/query_plan_create_set_remove_delete.cpp @@ -14,8 +14,8 @@ #include "dbms/dbms.hpp" #include "query/context.hpp" #include "query/exceptions.hpp" -#include "query/frontend/interpret/interpret.hpp" -#include "query/frontend/logical/operator.hpp" +#include "query/interpret/frame.hpp" +#include "query/plan/operator.hpp" #include "query_plan_common.hpp" diff --git a/tests/unit/query_plan_match_filter_return.cpp b/tests/unit/query_plan_match_filter_return.cpp index 09ba73614..b05639e08 100644 --- a/tests/unit/query_plan_match_filter_return.cpp +++ b/tests/unit/query_plan_match_filter_return.cpp @@ -14,8 +14,7 @@ #include "dbms/dbms.hpp" #include "query/context.hpp" #include "query/exceptions.hpp" -#include "query/frontend/interpret/interpret.hpp" -#include "query/frontend/logical/operator.hpp" +#include "query/plan/operator.hpp" #include "query_plan_common.hpp" diff --git a/tests/unit/query_planner.cpp b/tests/unit/query_planner.cpp index b4c0fb59a..c999760e4 100644 --- a/tests/unit/query_planner.cpp +++ b/tests/unit/query_planner.cpp @@ -6,10 +6,10 @@ #include "dbms/dbms.hpp" #include "query/frontend/ast/ast.hpp" -#include "query/frontend/logical/operator.hpp" -#include "query/frontend/logical/planner.hpp" #include "query/frontend/semantic/symbol_generator.hpp" #include "query/frontend/semantic/symbol_table.hpp" +#include "query/plan/operator.hpp" +#include "query/plan/planner.hpp" #include "query_common.hpp" diff --git a/tests/unit/query_semantic.cpp b/tests/unit/query_semantic.cpp index 287f5bfd0..f5cd3e658 100644 --- a/tests/unit/query_semantic.cpp +++ b/tests/unit/query_semantic.cpp @@ -4,7 +4,6 @@ #include "dbms/dbms.hpp" #include "query/frontend/ast/ast.hpp" -#include "query/frontend/interpret/interpret.hpp" #include "query/frontend/semantic/symbol_table.hpp" #include "query/frontend/semantic/symbol_generator.hpp"