From b5db8d8d1e820c6dcfc790f88387776948a4fc25 Mon Sep 17 00:00:00 2001 From: Marko Budiselic Date: Tue, 30 Aug 2016 06:26:27 +0100 Subject: [PATCH] match vertex by id, label and from main vertex store --- include/query_engine/code_generator/handlers/return.hpp | 2 +- include/query_engine/query_engine.hpp | 3 ++- include/query_engine/traverser/code.hpp | 4 ++-- include/query_engine/traverser/cpp_traverser.hpp | 6 +++++- src/communication/bolt/v1/states/executor.cpp | 8 +++++--- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/include/query_engine/code_generator/handlers/return.hpp b/include/query_engine/code_generator/handlers/return.hpp index 11dbf9f7c..e4d631fd4 100644 --- a/include/query_engine/code_generator/handlers/return.hpp +++ b/include/query_engine/code_generator/handlers/return.hpp @@ -38,6 +38,7 @@ auto return_query_action = code += code_line(code::write_all_edges, entity); } + // the client will receive entities from label index if (cypher_data.source(entity) == EntitySource::LabelIndex) { if (cypher_data.type(entity) == EntityType::Node) { @@ -47,7 +48,6 @@ auto return_query_action = code += code_line(code::fine_and_write_vertices_by_label, entity, label); } - // TODO: code_line } } else if (element.is_projection()) diff --git a/include/query_engine/query_engine.hpp b/include/query_engine/query_engine.hpp index 33f756dce..bdf3344b3 100644 --- a/include/query_engine/query_engine.hpp +++ b/include/query_engine/query_engine.hpp @@ -36,7 +36,8 @@ public: } catch (QueryEngineException &e) { // in this case something fatal went wrong logger.error("QueryEngineException: {}", std::string(e.what())); - return false; + // return false; + throw e; } } diff --git a/include/query_engine/traverser/code.hpp b/include/query_engine/traverser/code.hpp index 4cb6caf54..5bdd58834 100644 --- a/include/query_engine/traverser/code.hpp +++ b/include/query_engine/traverser/code.hpp @@ -74,12 +74,12 @@ const std::string write_all_vertices = const std::string fine_and_write_vertices_by_label = "auto &label = t.label_find_or_create(\"{1}\");\n" " stream.write_field(\"{0}\");\n" - " label.index().for_range(t).for_all([&](auto vertex) {\n" + " label.index().for_range(t)->for_all([&](auto vertex) {{\n" " stream.write_record();\n" " stream.write_list_header(1);\n" " stream.write(vertex);\n" " stream.chunk();\n" - " });\n" + " }});\n" " stream.write_meta(\"rw\");\n"; const std::string write_all_edges = diff --git a/include/query_engine/traverser/cpp_traverser.hpp b/include/query_engine/traverser/cpp_traverser.hpp index fe01a55d0..466500943 100644 --- a/include/query_engine/traverser/cpp_traverser.hpp +++ b/include/query_engine/traverser/cpp_traverser.hpp @@ -3,12 +3,12 @@ #include #include "cypher/visitor/traverser.hpp" - #include "query_engine/code_generator/cpp_generator.hpp" #include "query_engine/code_generator/entity_search.hpp" #include "query_engine/code_generator/structures.hpp" #include "query_engine/exceptions/exceptions.hpp" #include "query_engine/traverser/code.hpp" +#include "logging/default.hpp" struct SetElementState { @@ -99,7 +99,11 @@ private: generator.clear(); } + Logger logger; + public: + CppTraverser() : logger(logging::log->logger("CppTraverser")) {} + void semantic_check() const { if (!has_return) diff --git a/src/communication/bolt/v1/states/executor.cpp b/src/communication/bolt/v1/states/executor.cpp index a0c062f73..589860ba5 100644 --- a/src/communication/bolt/v1/states/executor.cpp +++ b/src/communication/bolt/v1/states/executor.cpp @@ -61,9 +61,11 @@ void Executor::run(Session& session, Query& query) auto &db = session.active_db(); logger.debug("[ActiveDB] '{}'", db.name()); - // TODO: error handling - - query_engine.execute(query.statement, db, session.output_stream); + try { + query_engine.execute(query.statement, db, session.output_stream); + } catch (QueryEngineException &e) { + // return error to user + } } void Executor::pull_all(Session& session)