From c312c2e36983e4739062bd4d33e9a559a5ed4d4f Mon Sep 17 00:00:00 2001 From: Marko Budiselic Date: Wed, 19 Oct 2016 02:41:06 +0200 Subject: [PATCH] iterators, properties, search by properties in index hardcoded query; TODO: implement in compiler --- .../code_generator/handlers/return.hpp | 7 +- include/query_engine/hardcode/queries.hpp | 77 ++++++++++++++----- .../storage/model/properties/properties.hpp | 4 +- .../model/properties/property_holder.hpp | 28 +++---- .../model/properties/stored_property.hpp | 3 +- include/storage/record_accessor.hpp | 5 ++ include/storage/vertex_accessor.hpp | 16 ++-- include/utils/iterator/composable.hpp | 2 +- include/utils/iterator/lambda_iterator.hpp | 1 + include/utils/iterator/limited_map.hpp | 1 + include/utils/iterator/map.hpp | 1 + include/utils/iterator/range_iterator.hpp | 10 +-- include/utils/iterator/virtual_iter.hpp | 2 +- src/storage/model/properties/properties.cpp | 14 ++++ tests/CMakeLists.txt | 12 --- tests/integration/cleaning.cpp | 26 +++---- tests/integration/memgraph_bolt.cpp | 7 -- tests/integration/queries.cpp | 28 ++++--- tests/integration/query_engine.cpp | 7 -- tests/manual/queries.cpp | 15 ++-- tests/try/iterator/main.cpp | 15 ++++ 21 files changed, 174 insertions(+), 107 deletions(-) delete mode 100644 tests/integration/memgraph_bolt.cpp delete mode 100644 tests/integration/query_engine.cpp create mode 100644 tests/try/iterator/main.cpp diff --git a/include/query_engine/code_generator/handlers/return.hpp b/include/query_engine/code_generator/handlers/return.hpp index b5b254899..30a53a644 100644 --- a/include/query_engine/code_generator/handlers/return.hpp +++ b/include/query_engine/code_generator/handlers/return.hpp @@ -41,9 +41,12 @@ auto return_query_action = // the client will receive entities from label index if (cypher_data.source(entity) == EntitySource::LabelIndex) { + if (cypher_data.tags(entity).size() == 0) + throw CppGeneratorException("node has no labels"); + + // node and no other property if (cypher_data.type(entity) == EntityType::Node) { - if (cypher_data.tags(entity).size() == 0) - throw CppGeneratorException("node has no labels"); + // TODO: solve the case with more labels auto label = cypher_data.tags(entity).at(0); code += code_line(code::find_and_write_vertices_by_label, entity, label); diff --git a/include/query_engine/hardcode/queries.hpp b/include/query_engine/hardcode/queries.hpp index 9fc41fa84..141e13608 100644 --- a/include/query_engine/hardcode/queries.hpp +++ b/include/query_engine/hardcode/queries.hpp @@ -18,25 +18,25 @@ namespace barrier #include #include #include +#include "communication/bolt/v1/serialization/bolt_serializer.hpp" +#include "communication/bolt/v1/serialization/record_stream.hpp" +#include "database/db.hpp" +#include "database/db.hpp" +#include "database/db_accessor.hpp" +#include "database/db_accessor.hpp" +#include "io/network/socket.hpp" #include "mvcc/id.hpp" +#include "storage/edge_type/edge_type.hpp" +#include "storage/edge_x_vertex.hpp" #include "storage/indexes/index_definition.hpp" +#include "storage/label/label.hpp" #include "storage/model/properties/all.hpp" #include "storage/model/properties/property.hpp" #include "utils/border.hpp" #include "utils/iterator/iterator.hpp" +#include "utils/iterator/iterator.hpp" #include "utils/option_ptr.hpp" #include "utils/reference_wrapper.hpp" -#include "database/db.hpp" -#include "database/db_accessor.hpp" -#include "utils/iterator/iterator.hpp" -#include "communication/bolt/v1/serialization/bolt_serializer.hpp" -#include "communication/bolt/v1/serialization/record_stream.hpp" -#include "database/db.hpp" -#include "database/db_accessor.hpp" -#include "io/network/socket.hpp" -#include "storage/edge_type/edge_type.hpp" -#include "storage/edge_x_vertex.hpp" -#include "storage/label/label.hpp" #endif @@ -44,38 +44,35 @@ auto load_queries(Db &db) { std::map> queries; - // CREATE (n {prop: 0}) RETURN n) + // CREATE (n {prop: 0}) RETURN n auto create_node = [&db](properties_t &&args) { DbAccessor t(db); auto property_key = t.vertex_property_key("prop", args[0].key.flags()); - auto vertex_accessor = t.vertex_insert(); vertex_accessor.set(property_key, std::move(args[0])); return t.commit(); }; queries[11597417457737499503u] = create_node; + // CREATE (n:LABEL {name: "TEST"}) RETURN n; auto create_labeled_and_named_node = [&db](properties_t &&args) { DbAccessor t(db); auto property_key = t.vertex_property_key("name", args[0].key.flags()); auto &label = t.label_find_or_create("LABEL"); - auto vertex_accessor = t.vertex_insert(); vertex_accessor.set(property_key, std::move(args[0])); vertex_accessor.add_label(label); - // cout_properties(vertex_accessor.properties()); return t.commit(); }; + // CREATE (n:OTHER {name: "TEST"}) RETURN n; auto create_labeled_and_named_node_v2 = [&db](properties_t &&args) { DbAccessor t(db); auto property_key = t.vertex_property_key("name", args[0].key.flags()); auto &label = t.label_find_or_create("OTHER"); - auto vertex_accessor = t.vertex_insert(); vertex_accessor.set(property_key, std::move(args[0])); vertex_accessor.add_label(label); - // cout_properties(vertex_accessor.properties()); return t.commit(); }; @@ -88,14 +85,12 @@ auto load_queries(Db &db) auto prop_created = t.vertex_property_key("created_at", args[3].key.flags()); auto &label = t.label_find_or_create("ACCOUNT"); - auto vertex_accessor = t.vertex_insert(); vertex_accessor.set(prop_id, std::move(args[0])); vertex_accessor.set(prop_name, std::move(args[1])); vertex_accessor.set(prop_country, std::move(args[2])); vertex_accessor.set(prop_created, std::move(args[3])); vertex_accessor.add_label(label); - // cout_properties(vertex_accessor.properties()); return t.commit(); }; @@ -226,6 +221,11 @@ auto load_queries(Db &db) auto match_all_delete = [&db](properties_t &&args) { DbAccessor t(db); + // DETACH DELETE + // t.edge_access().fill().for_all( + // [&](auto e) { e.remove(); } + // ); + t.vertex_access().fill().isolated().for_all( [&](auto a) { a.remove(); }); @@ -470,6 +470,45 @@ auto load_queries(Db &db) }; + // MATCH (n:LABEL {name: "TEST01"}) RETURN n; + auto match_label_property = [&db](properties_t &&args) { + std::map properties{{"name", 0}}; + DbAccessor t(db); + try { + auto &label = t.label_find_or_create("LABEL"); + label.index().for_range(t).for_all( + [&](auto vertex_accessor) -> void { + // TODO: record_accessor.match_execute(properties, op); + bool match = true; + for (auto &property_index : properties) { + auto property_key = t.vertex_property_key( + property_index.first, + args[property_index.second].key.flags()); + if (!vertex_accessor.contains(property_key)) { + match = false; + break; + } + auto vertex_property_value = + vertex_accessor.at(property_key); + auto query_property_value = args[property_index.second]; + if (!(vertex_property_value == query_property_value)) { + match = false; + break; + } + } + if (match) { + std::cout << "MATCH" << std::endl; + } + } + ); + return t.commit(); + } catch (...) { + t.abort(); + return false; + } + }; + queries[17721584194272598838u] = match_label_property; + // Blueprint: // auto = [&db](properties_t &&args) { // DbAccessor t(db); diff --git a/include/storage/model/properties/properties.hpp b/include/storage/model/properties/properties.hpp index 06de11c94..4eb8076e7 100644 --- a/include/storage/model/properties/properties.hpp +++ b/include/storage/model/properties/properties.hpp @@ -15,7 +15,7 @@ template using type_key_t = typename PropertyFamily::PropertyType::template PropertyTypeKey; -// Collcetion of stored properties. +// Collection of stored properties. // NOTE: Currently underlying strucutre is a vector which is fine for smaller // number of properties. template @@ -37,6 +37,8 @@ public: size_t size() const { return props.size(); } + const bool contains(property_key &key) const; + const StoredProperty &at(PropertyFamily &key) const; const StoredProperty &at(property_key &key) const; diff --git a/include/storage/model/properties/property_holder.hpp b/include/storage/model/properties/property_holder.hpp index 1b6c0fd31..95ecd40bb 100644 --- a/include/storage/model/properties/property_holder.hpp +++ b/include/storage/model/properties/property_holder.hpp @@ -70,7 +70,7 @@ // Generates signatures define_generator(type_name, union_name ); // for every pair type,property -#define GENERATE_FOR_ALL_PROPERTYS(define_generator) \ +#define GENERATE_FOR_ALL_PROPERTIES(define_generator) \ define_generator(Null, null_v); \ define_generator(Bool, bool_v); \ define_generator(Int32, int32_v); \ @@ -97,12 +97,12 @@ class PropertyHolder public: PropertyHolder() = delete; - GENERATE_FOR_ALL_PROPERTYS(GENERATE_CONSTRUCTOR_FOR_DATA); + GENERATE_FOR_ALL_PROPERTIES(GENERATE_CONSTRUCTOR_FOR_DATA); PropertyHolder(PropertyHolder const &other) : key(other.key) { switch (other.key.get_type().flags()) { - GENERATE_FOR_ALL_PROPERTYS( + GENERATE_FOR_ALL_PROPERTIES( GENERATE_CASE_CLAUSE_FOR_CONSTRUCTOR_COPY); default: assert(false); @@ -113,7 +113,7 @@ public: PropertyHolder(PropertyHolder &&other) : key(other.key) { switch (other.key.get_type().flags()) { - GENERATE_FOR_ALL_PROPERTYS( + GENERATE_FOR_ALL_PROPERTIES( GENERATE_CASE_CLAUSE_FOR_CONSTRUCTOR_MOVE); default: assert(false); @@ -125,7 +125,7 @@ public: { assert(other.key.get_type() == key.get_type()); switch (key.get_type().flags()) { - GENERATE_FOR_ALL_PROPERTYS( + GENERATE_FOR_ALL_PROPERTIES( GENERATE_CASE_CLAUSE_FOR_CONSTRUCTOR_MOVE); default: assert(false); @@ -136,7 +136,7 @@ public: ~PropertyHolder() { switch (key.get_type().flags()) { - GENERATE_FOR_ALL_PROPERTYS(GENERATE_CASE_CLAUSE_FOR_DESTRUCTOR); + GENERATE_FOR_ALL_PROPERTIES(GENERATE_CASE_CLAUSE_FOR_DESTRUCTOR); default: assert(false); } @@ -164,7 +164,7 @@ public: void accept(Handler &h) const { switch (key.get_type().flags()) { - GENERATE_FOR_ALL_PROPERTYS(GENERATE_CASE_CLAUSE_FOR_HANDLER); + GENERATE_FOR_ALL_PROPERTIES(GENERATE_CASE_CLAUSE_FOR_HANDLER); default: assert(false); } @@ -175,7 +175,7 @@ public: void accept_primitive(Handler &h) const { switch (key.get_type().flags()) { - GENERATE_FOR_ALL_PROPERTYS( + GENERATE_FOR_ALL_PROPERTIES( GENERATE_CASE_CLAUSE_FOR_HANDLER_PRIMITIVE); default: assert(false); @@ -185,7 +185,7 @@ public: std::ostream &print(std::ostream &stream) const { switch (key.get_type().flags()) { - GENERATE_FOR_ALL_PROPERTYS(GENERATE_CASE_CLAUSE_FOR_PRINT); + GENERATE_FOR_ALL_PROPERTIES(GENERATE_CASE_CLAUSE_FOR_PRINT); default: assert(false); } @@ -201,9 +201,10 @@ public: { if (key == other.key) { switch (key.get_type().flags()) { - GENERATE_FOR_ALL_PROPERTYS(GENERATE_CASE_CLAUSE_FOR_COMPARISON); + GENERATE_FOR_ALL_PROPERTIES(GENERATE_CASE_CLAUSE_FOR_COMPARISON); default: assert(false); + return false; } } else { return false; @@ -215,9 +216,10 @@ public: { if (key.get_type() == other.key.get_type()) { switch (key.get_type().flags()) { - GENERATE_FOR_ALL_PROPERTYS(GENERATE_CASE_CLAUSE_FOR_COMPARISON); + GENERATE_FOR_ALL_PROPERTIES(GENERATE_CASE_CLAUSE_FOR_COMPARISON); default: assert(false); + return false; } } else { return false; @@ -273,7 +275,7 @@ private: // Stored data. union { - GENERATE_FOR_ALL_PROPERTYS(GENERATE_UNION_FIELD); + GENERATE_FOR_ALL_PROPERTIES(GENERATE_UNION_FIELD); }; }; @@ -285,4 +287,4 @@ private: #undef GENERATE_CASE_CLAUSE_FOR_PRINT #undef GENERATE_CASE_CLAUSE_FOR_COMPARISON #undef GENERATE_UNION_FIELD -#undef GENERATE_FOR_ALL_PROPERTYS +#undef GENERATE_FOR_ALL_PROPERTIES diff --git a/include/storage/model/properties/stored_property.hpp b/include/storage/model/properties/stored_property.hpp index e5bf39a9d..002661c73 100644 --- a/include/storage/model/properties/stored_property.hpp +++ b/include/storage/model/properties/stored_property.hpp @@ -18,8 +18,7 @@ class StoredProperty : public PropertyHolder> public: // NOTE: Needed for properties to return reference on stored property when - // they - // don't cointain searched property. + // they don't cointain searched property. const static class StoredProperty null; using PropertyHolder>::PropertyHolder; diff --git a/include/storage/record_accessor.hpp b/include/storage/record_accessor.hpp index 379bbd02e..466ae97a6 100644 --- a/include/storage/record_accessor.hpp +++ b/include/storage/record_accessor.hpp @@ -88,6 +88,11 @@ public: } } + bool contains(property_key &key) const + { + return properties().contains(key); + } + const StoredProperty &at(PropertyFamily &key) const { return properties().at(key); diff --git a/include/storage/vertex_accessor.hpp b/include/storage/vertex_accessor.hpp index a42f5c8b3..60b6247bc 100644 --- a/include/storage/vertex_accessor.hpp +++ b/include/storage/vertex_accessor.hpp @@ -14,35 +14,41 @@ class VertexAccessor : public RecordAccessor public: using RecordAccessor::RecordAccessor; - typedef Vertex record_t; - typedef VertexRecord record_list_t; + + using record_t = Vertex; + using record_list_t = VertexRecord; // Removes self and all edges connected to it. void remove() const; + // Returns number of out edges. size_t out_degree() const; + // Returns number of in edges. size_t in_degree() const; + // Returns number of all edges. size_t degree() const; // True if vertex isn't connected to any other vertex. bool isolated() const; - // False if it already has labe. + // False if it already has the label. bool add_label(const Label &label); - // False if it doesn't have label. + // False if it doesn't have the label. bool remove_label(const Label &label); + // Checks if it has the label. bool has_label(const Label &label) const; + // Returns container with all labels. const std::vector &labels() const; auto out() const; auto in() const; - // True if there exists edge other->this + // True if there exists edge between other vertex and this vertex. bool in_contains(VertexAccessor const &other) const; }; diff --git a/include/utils/iterator/composable.hpp b/include/utils/iterator/composable.hpp index b5a23e6b8..d4beab834 100644 --- a/include/utils/iterator/composable.hpp +++ b/include/utils/iterator/composable.hpp @@ -148,7 +148,7 @@ public: // Filters out vertices which are connected. auto isolated() { - return filter([&](auto &ra) { return ra.isolated(); }); + return filter([&](auto &element) { return element.isolated(); }); } // For all items calls OP. diff --git a/include/utils/iterator/lambda_iterator.hpp b/include/utils/iterator/lambda_iterator.hpp index d1bd24f4a..9581e267c 100644 --- a/include/utils/iterator/lambda_iterator.hpp +++ b/include/utils/iterator/lambda_iterator.hpp @@ -52,4 +52,5 @@ auto make_iterator(F &&f, size_t count) // is T. return LambdaIterator(std::move(f), count); } + } diff --git a/include/utils/iterator/limited_map.hpp b/include/utils/iterator/limited_map.hpp index ccf64aec4..8c1a6c207 100644 --- a/include/utils/iterator/limited_map.hpp +++ b/include/utils/iterator/limited_map.hpp @@ -54,4 +54,5 @@ auto make_limited_map(I &&iter, OP &&op) return LimitedMap( std::move(iter), std::move(op)); } + } diff --git a/include/utils/iterator/map.hpp b/include/utils/iterator/map.hpp index df9f6b174..b38562d57 100644 --- a/include/utils/iterator/map.hpp +++ b/include/utils/iterator/map.hpp @@ -51,4 +51,5 @@ auto make_map(I &&iter, OP &&op) return Map(std::move(iter), std::move(op)); } + } diff --git a/include/utils/iterator/range_iterator.hpp b/include/utils/iterator/range_iterator.hpp index 923e9525c..6012840b9 100644 --- a/include/utils/iterator/range_iterator.hpp +++ b/include/utils/iterator/range_iterator.hpp @@ -5,7 +5,7 @@ namespace iter { -// Class which wraps iterator with next() into c++ iterator. +// Class which wraps iterator with next() into C++ iterator. // T - type of return value // I - iterator type template @@ -65,10 +65,10 @@ private: template auto make_range_iterator(I &&iter) { - // Because function isn't receving or in any way using type T from - // RangeIterator compiler can't deduce it thats way there is decltype in - // construction of RangeIterator. Resoulting type of iter.next().take() is - // T. + // Because this function isn't receving or in any way using type T from + // RangeIterator, compiler can't deduce it. That is the reason why + // there is decltype in construction of RangeIterator. + // declytype(iter.next().take()) is T. return RangeIterator(std::move(iter)); } } diff --git a/include/utils/iterator/virtual_iter.hpp b/include/utils/iterator/virtual_iter.hpp index 6bee1c73d..c56a83c4f 100644 --- a/include/utils/iterator/virtual_iter.hpp +++ b/include/utils/iterator/virtual_iter.hpp @@ -42,7 +42,7 @@ private: template auto make_virtual(I &&iter) { - // Compiler cant deduce type T. decltype is here to help with it. + // Compiler can't deduce type T. decltype is here to help with it. return Virtual(std::move(iter)); } } diff --git a/src/storage/model/properties/properties.cpp b/src/storage/model/properties/properties.cpp index f17e61a2b..51f6151b6 100644 --- a/src/storage/model/properties/properties.cpp +++ b/src/storage/model/properties/properties.cpp @@ -7,6 +7,20 @@ #include "storage/type_group_edge.hpp" #include "storage/type_group_vertex.hpp" +template +const bool Properties::contains(property_key &key) const +{ + for (auto &prop : props) + { + if (prop.key == key) + { + return true; + } + } + + return false; +} + template const StoredProperty &Properties::at(PropertyFamily &fam) const { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5e8a88c40..f5532198c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -98,18 +98,6 @@ target_link_libraries(index ${yaml_static_lib}) add_test(NAME index COMMAND index) set_property(TARGET index PROPERTY CXX_STANDARD 14) -# test query engine -add_executable(integration_query_engine integration/query_engine.cpp) -target_link_libraries(integration_query_engine Threads::Threads) -add_test(NAME integration_query_engine COMMAND integration_query_engine) -set_property(TARGET integration_query_engine PROPERTY CXX_STANDARD 14) - -# test memgraph with bolt protocol -add_executable(integration_memgraph_bolt integration/memgraph_bolt.cpp) -target_link_libraries(integration_memgraph_bolt Threads::Threads) -add_test(NAME integration_memgraph_bolt COMMAND integration_memgraph_bolt) -set_property(TARGET integration_memgraph_bolt PROPERTY CXX_STANDARD 14) - ## MANUAL TESTS # cypher_ast diff --git a/tests/integration/cleaning.cpp b/tests/integration/cleaning.cpp index 6f6cbd619..b8db0afff 100644 --- a/tests/integration/cleaning.cpp +++ b/tests/integration/cleaning.cpp @@ -33,7 +33,7 @@ int main(void) logging::init_async(); logging::log->pipe(std::make_unique()); - size_t cvl_n = 1000; + size_t entities_number = 1000; Db db("cleaning"); @@ -57,14 +57,14 @@ int main(void) // clean vertices // delete vertices a // clean vertices - run(cvl_n, create_vertex_label, stripper, query_functions); - assert(db.graph.vertices.access().size() == cvl_n); + run(entities_number, create_vertex_label, stripper, query_functions); + assert(db.graph.vertices.access().size() == entities_number); clean_vertex(db); - assert(db.graph.vertices.access().size() == cvl_n); + assert(db.graph.vertices.access().size() == entities_number); run(1, delete_label_vertices, stripper, query_functions); - assert(db.graph.vertices.access().size() == cvl_n); + assert(db.graph.vertices.access().size() == entities_number); clean_vertex(db); assert(db.graph.vertices.access().size() == 0); @@ -76,23 +76,23 @@ int main(void) // delete vertices a // clean vertices // delete vertices all - run(cvl_n, create_vertex_label, stripper, query_functions); - assert(db.graph.vertices.access().size() == cvl_n); + run(entities_number, create_vertex_label, stripper, query_functions); + assert(db.graph.vertices.access().size() == entities_number); - run(cvl_n, create_vertex_other, stripper, query_functions); - assert(db.graph.vertices.access().size() == cvl_n * 2); + run(entities_number, create_vertex_other, stripper, query_functions); + assert(db.graph.vertices.access().size() == entities_number * 2); clean_vertex(db); - assert(db.graph.vertices.access().size() == cvl_n * 2); + assert(db.graph.vertices.access().size() == entities_number * 2); run(1, delete_label_vertices, stripper, query_functions); - assert(db.graph.vertices.access().size() == cvl_n * 2); + assert(db.graph.vertices.access().size() == entities_number * 2); clean_vertex(db); - assert(db.graph.vertices.access().size() == cvl_n); + assert(db.graph.vertices.access().size() == entities_number); run(1, delete_all_vertices, stripper, query_functions); - assert(db.graph.vertices.access().size() == cvl_n); + assert(db.graph.vertices.access().size() == entities_number); clean_vertex(db); assert(db.graph.vertices.access().size() == 0); diff --git a/tests/integration/memgraph_bolt.cpp b/tests/integration/memgraph_bolt.cpp deleted file mode 100644 index fd95d0ff1..000000000 --- a/tests/integration/memgraph_bolt.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/assert.hpp" - -auto main() -> int -{ - permanent_assert(false, "TODO: implement memgraph bolt integration test"); - return 0; -} diff --git a/tests/integration/queries.cpp b/tests/integration/queries.cpp index 5dcf19c2b..9baedde8f 100644 --- a/tests/integration/queries.cpp +++ b/tests/integration/queries.cpp @@ -32,14 +32,20 @@ int main(void) // TODO: put all queries into a file std::vector queries = { - "CREATE (n:LABEL {name: \"TEST1\"}) RETURN n", + + // CREATE and MATCH by label and property + "CREATE (n:LABEL {name: \"TEST01\"}) RETURN n", + "CREATE (n:LABEL {name: \"TEST02\"}) RETURN n", + "MATCH (n:LABEL {name: \"TEST01\"}) RETURN n", + "CREATE (n:LABEL {name: \"TEST2\"}) RETURN n", "CREATE (n:LABEL {name: \"TEST3\"}) RETURN n", "CREATE (n:OTHER {name: \"TEST4\"}) RETURN n" - "CREATE (n:ACCOUNT {id: 2322, name: \"TEST\", country: \"Croatia\", " - "created_at: 2352352}) RETURN n", - "MATCH (n {id: 0}) RETURN n", "MATCH (n {id: 1}) RETURN n", - "MATCH (n {id: 2}) RETURN n", "MATCH (n {id: 3}) RETURN n", + "CREATE (n:ACCOUNT {id: 2322, name: \"TEST\", country: \"Croatia\", created_at: 2352352}) RETURN n", + "MATCH (n {id: 0}) RETURN n", + "MATCH (n {id: 1}) RETURN n", + "MATCH (n {id: 2}) RETURN n", + "MATCH (n {id: 3}) RETURN n", "MATCH (a {id:0}), (p {id: 1}) CREATE (a)-[r:IS]->(p) RETURN r", "MATCH (a {id:1}), (p {id: 2}) CREATE (a)-[r:IS]->(p) RETURN r", "MATCH ()-[r]-() WHERE ID(r)=0 RETURN r", @@ -47,9 +53,8 @@ int main(void) "MATCH (n: {id: 0}) SET n.name = \"TEST100\" RETURN n", "MATCH (n: {id: 1}) SET n.name = \"TEST101\" RETURN n", "MATCH (n: {id: 0}) SET n.name = \"TEST102\" RETURN n", - "MATCH (n:LABEL) RETURN n", "MATCH (n1), (n2) WHERE ID(n1)=0 AND " - "ID(n2)=1 CREATE (n1)<-[r:IS {age: " - "25,weight: 70}]-(n2) RETURN r", + "MATCH (n:LABEL) RETURN n", + "MATCH (n1), (n2) WHERE ID(n1)=0 AND ID(n2)=1 CREATE (n1)<-[r:IS {age: 25,weight: 70}]-(n2) RETURN r", "MATCH (n) RETURN n", "MATCH (n:LABEL) RETURN n", "MATCH (n) DELETE n ", "MATCH (n:LABEL) DELETE n", "MATCH (n) WHERE ID(n) = 0 DELETE n", "MATCH ()-[r]-() WHERE ID(r) = 0 DELETE r", "MATCH ()-[r]-() DELETE r", @@ -57,7 +62,12 @@ int main(void) "MATCH (n)-[:TYPE]->(m) WHERE ID(n) = 0 RETURN m", "MATCH (n)-[:TYPE]->(m) WHERE n.name = \"kruno\" RETURN m", "MATCH (n)-[:TYPE]->(m) WHERE n.name = \"kruno\" RETURN n,m", - "MATCH (n:LABEL)-[:TYPE]->(m) RETURN n"}; + "MATCH (n:LABEL)-[:TYPE]->(m) RETURN n", + + // CREATE and MATCH multiple labels and properties + "CREATE (n:LABEL1:LABEL2 {name: \"TEST01\", age: 20}) RETURN n", + "MATCH (n:LABEL1:LABEL2 {name: \"TEST01\", age: 20}) RETURN n" + }; for (auto &query : queries) { auto stripped = stripper.strip(query); diff --git a/tests/integration/query_engine.cpp b/tests/integration/query_engine.cpp deleted file mode 100644 index 5a42433c6..000000000 --- a/tests/integration/query_engine.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/assert.hpp" - -auto main() -> int -{ - permanent_assert(false, "TODO: implement query engine integration test"); - return 0; -} diff --git a/tests/manual/queries.cpp b/tests/manual/queries.cpp index 540bfe1ea..698cac25b 100644 --- a/tests/manual/queries.cpp +++ b/tests/manual/queries.cpp @@ -6,6 +6,8 @@ #include "barrier/barrier.cpp" #endif +#include "logging/default.hpp" +#include "logging/streams/stdout.hpp" #include "communication/bolt/v1/serialization/bolt_serializer.hpp" #include "database/db.hpp" #include "query_engine/query_stripper.hpp" @@ -18,6 +20,9 @@ using namespace std; int main(int argc, char **argv) { + logging::init_async(); + logging::log->pipe(std::make_unique()); + Db db; #ifdef BARRIER auto queries = load_queries(barrier::trans(db)); @@ -25,17 +30,7 @@ int main(int argc, char **argv) auto queries = load_queries(db); #endif - // auto arguments = all_arguments(argc, argv); - // auto input_query = extract_query(arguments); auto stripper = make_query_stripper(TK_LONG, TK_FLOAT, TK_STR, TK_BOOL); - // auto stripped = stripper.strip(input_query); - // - // auto time = timer([&stripped, &queries]() { - // for (int i = 0; i < 1000000; ++i) { - // queries[stripped.hash](stripped.arguments); - // } - // }); - // std::cout << time << std::endl; vector history; string command; diff --git a/tests/try/iterator/main.cpp b/tests/try/iterator/main.cpp new file mode 100644 index 000000000..550e4fa23 --- /dev/null +++ b/tests/try/iterator/main.cpp @@ -0,0 +1,15 @@ +#include +#include + +#include "utils/iterator/map.hpp" + +int main(void) +{ + std::vector test{1,2,3}; + + for (auto item : test) { + std::cout << item << std::endl; + } + + return 0; +}