From 1d112e1141e6dc455705b4365d4197c166312838 Mon Sep 17 00:00:00 2001 From: florijan Date: Wed, 9 Aug 2017 15:36:01 +0200 Subject: [PATCH] GraphDbAccessor - style change Summary: Not strictly neccessary, but it's been itching me. It took an hour. Reviewers: buda, mislav.bradac Reviewed By: mislav.bradac Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D648 --- .../bolt/v1/encoder/base_encoder.hpp | 8 +- src/communication/bolt/v1/session.hpp | 8 +- .../bolt/v1/states/idle_result.hpp | 2 +- src/database/graph_db_accessor.cpp | 117 +++++-- src/database/graph_db_accessor.hpp | 130 +++---- src/durability/recovery.cpp | 20 +- src/durability/snapshooter.cpp | 4 +- src/query/console.cpp | 2 +- .../frontend/ast/cypher_main_visitor.cpp | 8 +- .../interpret/awesome_memgraph_functions.cpp | 9 +- src/query/interpret/eval.hpp | 5 +- src/query/plan/cost_estimator.cpp | 14 +- src/query/plan/operator.cpp | 26 +- src/query/plan/rule_based_planner.cpp | 10 +- src/storage/edge_accessor.cpp | 6 +- src/storage/edge_accessor.hpp | 2 +- src/storage/record_accessor.cpp | 4 +- src/storage/vertex_accessor.cpp | 6 +- src/utils/random_graph_generator.hpp | 26 +- tests/integration/hardcoded_query/clique.hpp | 24 +- .../create_full_profile_conceals_return.cpp | 10 +- .../create_full_profile_return.cpp | 8 +- .../create_full_profile_reveals_return.cpp | 10 +- .../hardcoded_query/create_garment.cpp | 8 +- .../create_garment_conceals.cpp | 10 +- .../create_garment_reveals.cpp | 10 +- .../hardcoded_query/delete_all.cpp | 5 +- .../hardcoded_query/match_garment.cpp | 6 +- .../match_garment_default_outfit.cpp | 16 +- ...match_garment_set_label_general_return.hpp | 8 +- .../hardcoded_query/match_profile.cpp | 8 +- .../match_profile_garment_score.cpp | 10 +- .../match_profile_garment_set_score.cpp | 18 +- .../match_profile_garment_update_score.cpp | 12 +- tests/property_based/random_graph.cpp | 15 +- tests/unit/bolt_encoder.cpp | 6 +- tests/unit/cypher_main_visitor.cpp | 40 +-- tests/unit/database_key_index.cpp | 80 ++--- tests/unit/database_label_property_index.cpp | 22 +- tests/unit/dbms_recovery.cpp | 16 +- tests/unit/graph_db_accessor.cpp | 302 ++++++++--------- tests/unit/graph_db_accessor_index_api.cpp | 152 ++++----- tests/unit/query_common.hpp | 6 +- tests/unit/query_cost_estimator.cpp | 8 +- tests/unit/query_expression_evaluator.cpp | 116 +++---- .../unit/query_plan_accumulate_aggregate.cpp | 79 +++-- tests/unit/query_plan_bag_semantics.cpp | 80 ++--- .../query_plan_create_set_remove_delete.cpp | 318 +++++++++--------- tests/unit/query_plan_edge_cases.cpp | 6 +- tests/unit/query_plan_match_filter_return.cpp | 301 +++++++++-------- tests/unit/query_planner.cpp | 107 +++--- tests/unit/query_semantic.cpp | 52 +-- tests/unit/query_variable_start_planner.cpp | 50 +-- tests/unit/record_edge_vertex_accessor.cpp | 90 ++--- tests/unit/recovery.cpp | 70 ++-- 55 files changed, 1245 insertions(+), 1241 deletions(-) diff --git a/src/communication/bolt/v1/encoder/base_encoder.hpp b/src/communication/bolt/v1/encoder/base_encoder.hpp index 056205aaa..dee9663fd 100644 --- a/src/communication/bolt/v1/encoder/base_encoder.hpp +++ b/src/communication/bolt/v1/encoder/base_encoder.hpp @@ -116,13 +116,13 @@ class BaseEncoder { const auto &labels = vertex.labels(); WriteTypeSize(labels.size(), MarkerList); for (const auto &label : labels) - WriteString(vertex.db_accessor().label_name(label)); + WriteString(vertex.db_accessor().LabelName(label)); // write properties const auto &props = vertex.Properties(); WriteTypeSize(props.size(), MarkerMap); for (const auto &prop : props) { - WriteString(vertex.db_accessor().property_name(prop.first)); + WriteString(vertex.db_accessor().PropertyName(prop.first)); WriteTypedValue(prop.second); } } @@ -136,13 +136,13 @@ class BaseEncoder { WriteUInt(edge.to().temporary_id()); // write type - WriteString(edge.db_accessor().edge_type_name(edge.edge_type())); + WriteString(edge.db_accessor().EdgeTypeName(edge.EdgeType())); // write properties const auto &props = edge.Properties(); WriteTypeSize(props.size(), MarkerMap); for (const auto &prop : props) { - WriteString(edge.db_accessor().property_name(prop.first)); + WriteString(edge.db_accessor().PropertyName(prop.first)); WriteTypedValue(prop.second); } } diff --git a/src/communication/bolt/v1/session.hpp b/src/communication/bolt/v1/session.hpp index 7e813ed6c..8926a05ec 100644 --- a/src/communication/bolt/v1/session.hpp +++ b/src/communication/bolt/v1/session.hpp @@ -53,7 +53,9 @@ class Session { public: Session(Socket &&socket, SessionData &data) - : socket_(std::move(socket)), dbms_(data.dbms), query_engine_(data.query_engine) { + : socket_(std::move(socket)), + dbms_(data.dbms), + query_engine_(data.query_engine) { event_.data.ptr = this; } @@ -168,7 +170,7 @@ class Session { */ void Commit() { debug_assert(db_accessor_, "Commit called and there is no transaction"); - db_accessor_->commit(); + db_accessor_->Commit(); db_accessor_ = nullptr; } @@ -177,7 +179,7 @@ class Session { */ void Abort() { debug_assert(db_accessor_, "Abort called and there is no transaction"); - db_accessor_->abort(); + db_accessor_->Abort(); db_accessor_ = nullptr; } diff --git a/src/communication/bolt/v1/states/idle_result.hpp b/src/communication/bolt/v1/states/idle_result.hpp index d1ec0662a..bfeb7cd47 100644 --- a/src/communication/bolt/v1/states/idle_result.hpp +++ b/src/communication/bolt/v1/states/idle_result.hpp @@ -106,7 +106,7 @@ State HandleRun(Session &session, State state, Marker marker) { session.encoder_.MessageSuccess({}, false); return State::Result; } - session.db_accessor_->advance_command(); + session.db_accessor_->AdvanceCommand(); } try { diff --git a/src/database/graph_db_accessor.cpp b/src/database/graph_db_accessor.cpp index 2749458d4..322734428 100644 --- a/src/database/graph_db_accessor.cpp +++ b/src/database/graph_db_accessor.cpp @@ -1,5 +1,5 @@ -#include "database/creation_exception.hpp" #include "database/graph_db_accessor.hpp" +#include "database/creation_exception.hpp" #include "storage/edge.hpp" #include "storage/edge_accessor.hpp" @@ -12,25 +12,25 @@ GraphDbAccessor::GraphDbAccessor(GraphDb &db) GraphDbAccessor::~GraphDbAccessor() { if (!commited_ && !aborted_) { - this->abort(); + this->Abort(); } } const std::string &GraphDbAccessor::name() const { return db_.name_; } -void GraphDbAccessor::advance_command() { +void GraphDbAccessor::AdvanceCommand() { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); transaction_->engine_.Advance(transaction_->id_); } -void GraphDbAccessor::commit() { +void GraphDbAccessor::Commit() { debug_assert(!commited_ && !aborted_, "Already aborted or commited transaction."); transaction_->Commit(); commited_ = true; } -void GraphDbAccessor::abort() { +void GraphDbAccessor::Abort() { debug_assert(!commited_ && !aborted_, "Already aborted or commited transaction."); transaction_->Abort(); @@ -42,7 +42,7 @@ bool GraphDbAccessor::should_abort() const { return transaction_->should_abort(); } -VertexAccessor GraphDbAccessor::insert_vertex() { +VertexAccessor GraphDbAccessor::InsertVertex() { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); // create a vertex @@ -53,16 +53,60 @@ VertexAccessor GraphDbAccessor::insert_vertex() { throw CreationException("Unable to create a Vertex."); } -void GraphDbAccessor::update_label_indices( - const GraphDbTypes::Label &label, const VertexAccessor &vertex_accessor, - const Vertex *const vertex) { +void GraphDbAccessor::BuildIndex(const GraphDbTypes::Label &label, + const GraphDbTypes::Property &property) { + debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); + + const LabelPropertyIndex::Key key(label, property); + if (db_.label_property_index_.CreateIndex(key) == false) { + throw IndexExistsException( + "Index is either being created by another transaction or already " + "exists."); + } + // Everything that happens after the line above ended will be added to the + // index automatically, but we still have to add to index everything that + // happened earlier. We have to first wait for every transaction that + // happend before, or a bit later than CreateIndex to end. + { + auto wait_transaction = db_.tx_engine_.Begin(); + for (auto id : wait_transaction->snapshot()) { + if (id == transaction_->id_) continue; + while (wait_transaction->engine_.clog().is_active(id)) + // TODO reconsider this constant, currently rule-of-thumb chosen + std::this_thread::sleep_for(std::chrono::microseconds(100)); + } + wait_transaction->Commit(); + } + + // This transaction surely sees everything that happened before CreateIndex. + auto transaction = db_.tx_engine_.Begin(); + + for (auto vertex_vlist : db_.vertices_.access()) { + auto vertex_record = vertex_vlist->find(*transaction); + // Check if visible record exists, if it exists apply function on it. + if (vertex_record == nullptr) continue; + db_.label_property_index_.UpdateOnLabelProperty(vertex_vlist, + vertex_record); + } + // Commit transaction as we finished applying method on newest visible + // records. + transaction->Commit(); + // After these two operations we are certain that everything is contained in + // the index under the assumption that this transaction contained no + // vertex/edge insert/update before this method was invoked. + db_.label_property_index_.IndexFinishedBuilding(key); +} + +void GraphDbAccessor::UpdateLabelIndices(const GraphDbTypes::Label &label, + const VertexAccessor &vertex_accessor, + const Vertex *const vertex) { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); this->db_.labels_index_.Update(label, vertex_accessor.vlist_, vertex); this->db_.label_property_index_.UpdateOnLabel(label, vertex_accessor.vlist_, vertex); } -void GraphDbAccessor::update_property_index( +void GraphDbAccessor::UpdatePropertyIndex( const GraphDbTypes::Property &property, const RecordAccessor &record_accessor, const Vertex *const vertex) { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); @@ -70,18 +114,17 @@ void GraphDbAccessor::update_property_index( property, record_accessor.vlist_, vertex); } -int64_t GraphDbAccessor::vertices_count() const { +int64_t GraphDbAccessor::VerticesCount() const { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); return db_.vertices_.access().size(); } -int64_t GraphDbAccessor::vertices_count( - const GraphDbTypes::Label &label) const { +int64_t GraphDbAccessor::VerticesCount(const GraphDbTypes::Label &label) const { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); return db_.labels_index_.Count(label); } -int64_t GraphDbAccessor::vertices_count( +int64_t GraphDbAccessor::VerticesCount( const GraphDbTypes::Label &label, const GraphDbTypes::Property &property) const { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); @@ -91,9 +134,9 @@ int64_t GraphDbAccessor::vertices_count( return db_.label_property_index_.Count(key); } -int64_t GraphDbAccessor::vertices_count(const GraphDbTypes::Label &label, - const GraphDbTypes::Property &property, - const PropertyValue &value) const { +int64_t GraphDbAccessor::VerticesCount(const GraphDbTypes::Label &label, + const GraphDbTypes::Property &property, + const PropertyValue &value) const { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); const LabelPropertyIndex::Key key(label, property); debug_assert(db_.label_property_index_.IndexExists(key), @@ -101,7 +144,7 @@ int64_t GraphDbAccessor::vertices_count(const GraphDbTypes::Label &label, return db_.label_property_index_.PositionAndCount(key, value).second; } -int64_t GraphDbAccessor::vertices_count( +int64_t GraphDbAccessor::VerticesCount( const GraphDbTypes::Label &label, const GraphDbTypes::Property &property, const std::experimental::optional> lower, const std::experimental::optional> upper) @@ -144,7 +187,7 @@ int64_t GraphDbAccessor::vertices_count( } } -bool GraphDbAccessor::remove_vertex(VertexAccessor &vertex_accessor) { +bool GraphDbAccessor::RemoveVertex(VertexAccessor &vertex_accessor) { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); vertex_accessor.SwitchNew(); // it's possible the vertex was removed already in this transaction @@ -158,19 +201,19 @@ bool GraphDbAccessor::remove_vertex(VertexAccessor &vertex_accessor) { return true; } -void GraphDbAccessor::detach_remove_vertex(VertexAccessor &vertex_accessor) { +void GraphDbAccessor::DetachRemoveVertex(VertexAccessor &vertex_accessor) { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); vertex_accessor.SwitchNew(); - for (auto edge_accessor : vertex_accessor.in()) remove_edge(edge_accessor); + for (auto edge_accessor : vertex_accessor.in()) RemoveEdge(edge_accessor); vertex_accessor.SwitchNew(); - for (auto edge_accessor : vertex_accessor.out()) remove_edge(edge_accessor); - if (!remove_vertex(vertex_accessor)) + for (auto edge_accessor : vertex_accessor.out()) RemoveEdge(edge_accessor); + if (!RemoveVertex(vertex_accessor)) permanent_fail("Unable to remove vertex after all edges detached"); } -EdgeAccessor GraphDbAccessor::insert_edge(VertexAccessor &from, - VertexAccessor &to, - GraphDbTypes::EdgeType edge_type) { +EdgeAccessor GraphDbAccessor::InsertEdge(VertexAccessor &from, + VertexAccessor &to, + GraphDbTypes::EdgeType edge_type) { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); // create an edge auto edge_vlist = new mvcc::VersionList(*transaction_, *from.vlist_, @@ -190,26 +233,26 @@ EdgeAccessor GraphDbAccessor::insert_edge(VertexAccessor &from, if (success) { // This has to be here because there is no additional method for setting // edge type. - update_edge_type_index(edge_type, edge_accessor, &edge_accessor.current()); + UpdateEdgeTypeIndex(edge_type, edge_accessor, &edge_accessor.current()); return edge_accessor; } throw CreationException("Unable to create an Edge."); } -void GraphDbAccessor::update_edge_type_index( +void GraphDbAccessor::UpdateEdgeTypeIndex( const GraphDbTypes::EdgeType &edge_type, const EdgeAccessor &edge_accessor, const Edge *const edge) { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); this->db_.edge_types_index_.Update(edge_type, edge_accessor.vlist_, edge); } -int64_t GraphDbAccessor::edges_count() const { +int64_t GraphDbAccessor::EdgesCount() const { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); return db_.edges_.access().size(); } -int64_t GraphDbAccessor::edges_count( +int64_t GraphDbAccessor::EdgesCount( const GraphDbTypes::EdgeType &edge_type) const { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); return db_.edge_types_index_.Count(edge_type); @@ -227,7 +270,7 @@ void swap_out_edge(std::vector *> &edges, edges.pop_back(); } -void GraphDbAccessor::remove_edge(EdgeAccessor &edge_accessor) { +void GraphDbAccessor::RemoveEdge(EdgeAccessor &edge_accessor) { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); // it's possible the edge was removed already in this transaction // due to it getting matched multiple times by some patterns @@ -239,36 +282,36 @@ void GraphDbAccessor::remove_edge(EdgeAccessor &edge_accessor) { edge_accessor.vlist_->remove(edge_accessor.current_, *transaction_); } -GraphDbTypes::Label GraphDbAccessor::label(const std::string &label_name) { +GraphDbTypes::Label GraphDbAccessor::Label(const std::string &label_name) { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); return &(*db_.labels_.access().insert(label_name).first); } -const std::string &GraphDbAccessor::label_name( +const std::string &GraphDbAccessor::LabelName( const GraphDbTypes::Label label) const { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); return *label; } -GraphDbTypes::EdgeType GraphDbAccessor::edge_type( +GraphDbTypes::EdgeType GraphDbAccessor::EdgeType( const std::string &edge_type_name) { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); return &(*db_.edge_types_.access().insert(edge_type_name).first); } -const std::string &GraphDbAccessor::edge_type_name( +const std::string &GraphDbAccessor::EdgeTypeName( const GraphDbTypes::EdgeType edge_type) const { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); return *edge_type; } -GraphDbTypes::Property GraphDbAccessor::property( +GraphDbTypes::Property GraphDbAccessor::Property( const std::string &property_name) { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); return &(*db_.properties_.access().insert(property_name).first); } -const std::string &GraphDbAccessor::property_name( +const std::string &GraphDbAccessor::PropertyName( const GraphDbTypes::Property property) const { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); return *property; diff --git a/src/database/graph_db_accessor.hpp b/src/database/graph_db_accessor.hpp index c31a7220a..168c8e38a 100644 --- a/src/database/graph_db_accessor.hpp +++ b/src/database/graph_db_accessor.hpp @@ -66,11 +66,11 @@ class GraphDbAccessor { * * @return See above. */ - VertexAccessor insert_vertex(); + VertexAccessor InsertVertex(); /** * Removes the vertex of the given accessor. If the vertex has any outgoing - * or incoming edges, it is not deleted. See `detach_remove_vertex` if you + * or incoming edges, it is not deleted. See `DetachRemoveVertex` if you * want to remove a vertex regardless of connectivity. * * If the vertex has already been deleted by the current transaction+command, @@ -79,7 +79,7 @@ class GraphDbAccessor { * @param vertex_accessor Accessor to vertex. * @return If or not the vertex was deleted. */ - bool remove_vertex(VertexAccessor &vertex_accessor); + bool RemoveVertex(VertexAccessor &vertex_accessor); /** * Removes the vertex of the given accessor along with all it's outgoing @@ -87,7 +87,7 @@ class GraphDbAccessor { * * @param vertex_accessor Accessor to a vertex. */ - void detach_remove_vertex(VertexAccessor &vertex_accessor); + void DetachRemoveVertex(VertexAccessor &vertex_accessor); /** * Returns iterable over accessors to all the vertices in the graph @@ -98,7 +98,7 @@ class GraphDbAccessor { * deletions performed in the current transaction+command are not * ignored). */ - auto vertices(bool current_state) { + auto Vertices(bool current_state) { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); // wrap version lists into accessors, which will look for visible versions auto accessors = @@ -127,7 +127,7 @@ class GraphDbAccessor { * ignored). * @return iterable collection */ - auto vertices(const GraphDbTypes::Label &label, bool current_state) { + auto Vertices(const GraphDbTypes::Label &label, bool current_state) { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); return iter::imap( [this, current_state](auto vlist) { @@ -147,7 +147,7 @@ class GraphDbAccessor { * ignored). * @return iterable collection */ - auto vertices(const GraphDbTypes::Label &label, + auto Vertices(const GraphDbTypes::Label &label, const GraphDbTypes::Property &property, bool current_state) { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); debug_assert(db_.label_property_index_.IndexExists( @@ -173,7 +173,7 @@ class GraphDbAccessor { * ignored). * @return iterable collection */ - auto vertices(const GraphDbTypes::Label &label, + auto Vertices(const GraphDbTypes::Label &label, const GraphDbTypes::Property &property, const PropertyValue &value, bool current_state) { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); @@ -216,7 +216,7 @@ class GraphDbAccessor { * @return iterable collection of record accessors * satisfy the bounds and are visible to the current transaction. */ - auto vertices( + auto Vertices( const GraphDbTypes::Label &label, const GraphDbTypes::Property &property, const std::experimental::optional> lower, const std::experimental::optional> upper, @@ -240,15 +240,15 @@ class GraphDbAccessor { * @param type Edge type. * @return An accessor to the edge. */ - EdgeAccessor insert_edge(VertexAccessor &from, VertexAccessor &to, - GraphDbTypes::EdgeType type); + EdgeAccessor InsertEdge(VertexAccessor &from, VertexAccessor &to, + GraphDbTypes::EdgeType type); /** * Removes an edge from the graph. * * @param edge_accessor The accessor to an edge. */ - void remove_edge(EdgeAccessor &edge_accessor); + void RemoveEdge(EdgeAccessor &edge_accessor); /** * Returns iterable over accessors to all the edges in the graph @@ -259,7 +259,7 @@ class GraphDbAccessor { * deletions performed in the current transaction+command are not * ignored). */ - auto edges(bool current_state) { + auto Edges(bool current_state) { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); // wrap version lists into accessors, which will look for visible versions @@ -289,7 +289,7 @@ class GraphDbAccessor { * ignored). * @return iterable collection */ - auto edges(const GraphDbTypes::EdgeType &edge_type, bool current_state) { + auto Edges(const GraphDbTypes::EdgeType &edge_type, bool current_state) { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); return iter::imap([this, current_state]( auto vlist) { return EdgeAccessor(*vlist, *this); }, @@ -342,48 +342,7 @@ class GraphDbAccessor { * @param property - property to build for */ void BuildIndex(const GraphDbTypes::Label &label, - const GraphDbTypes::Property &property) { - debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); - - const LabelPropertyIndex::Key key(label, property); - if (db_.label_property_index_.CreateIndex(key) == false) { - throw IndexExistsException( - "Index is either being created by another transaction or already " - "exists."); - } - // Everything that happens after the line above ended will be added to the - // index automatically, but we still have to add to index everything that - // happened earlier. We have to first wait for every transaction that - // happend before, or a bit later than CreateIndex to end. - { - auto wait_transaction = db_.tx_engine_.Begin(); - for (auto id : wait_transaction->snapshot()) { - if (id == transaction_->id_) continue; - while (wait_transaction->engine_.clog().is_active(id)) - // TODO reconsider this constant, currently rule-of-thumb chosen - std::this_thread::sleep_for(std::chrono::microseconds(100)); - } - wait_transaction->Commit(); - } - - // This transaction surely sees everything that happened before CreateIndex. - auto transaction = db_.tx_engine_.Begin(); - - for (auto vertex_vlist : db_.vertices_.access()) { - auto vertex_record = vertex_vlist->find(*transaction); - // Check if visible record exists, if it exists apply function on it. - if (vertex_record == nullptr) continue; - db_.label_property_index_.UpdateOnLabelProperty(vertex_vlist, - vertex_record); - } - // Commit transaction as we finished applying method on newest visible - // records. - transaction->Commit(); - // After these two operations we are certain that everything is contained in - // the index under the assumption that this transaction contained no - // vertex/edge insert/update before this method was invoked. - db_.label_property_index_.IndexFinishedBuilding(key); - } + const GraphDbTypes::Property &property); /** * @brief - Returns true if the given label+property index already exists and @@ -408,13 +367,13 @@ class GraphDbAccessor { * Return approximate number of all vertices in the database. * Note that this is always an over-estimate and never an under-estimate. */ - int64_t vertices_count() const; + int64_t VerticesCount() const; /* * Return approximate number of all edges in the database. * Note that this is always an over-estimate and never an under-estimate. */ - int64_t edges_count() const; + int64_t EdgesCount() const; /** * Return approximate number of vertices under indexes with the given label. @@ -422,7 +381,7 @@ class GraphDbAccessor { * @param label - label to check for * @return number of vertices with the given label */ - int64_t vertices_count(const GraphDbTypes::Label &label) const; + int64_t VerticesCount(const GraphDbTypes::Label &label) const; /** * Return approximate number of vertices under indexes with the given label @@ -433,8 +392,8 @@ class GraphDbAccessor { * @return number of vertices with the given label, fails if no such * label+property index exists. */ - int64_t vertices_count(const GraphDbTypes::Label &label, - const GraphDbTypes::Property &property) const; + int64_t VerticesCount(const GraphDbTypes::Label &label, + const GraphDbTypes::Property &property) const; /** * Returns approximate number of vertices that have the given label @@ -442,9 +401,9 @@ class GraphDbAccessor { * * Assumes that an index for that (label, property) exists. */ - int64_t vertices_count(const GraphDbTypes::Label &label, - const GraphDbTypes::Property &property, - const PropertyValue &value) const; + int64_t VerticesCount(const GraphDbTypes::Label &label, + const GraphDbTypes::Property &property, + const PropertyValue &value) const; /** * Returns approximate number of vertices that have the given label @@ -455,7 +414,7 @@ class GraphDbAccessor { * * Assumes that an index for that (label, property) exists. */ - int64_t vertices_count( + int64_t VerticesCount( const GraphDbTypes::Label &label, const GraphDbTypes::Property &property, const std::experimental::optional> lower, const std::experimental::optional> upper) @@ -467,13 +426,13 @@ class GraphDbAccessor { * @param edge_type - edge_type to check for * @return number of edges with the given edge_type */ - int64_t edges_count(const GraphDbTypes::EdgeType &edge_type) const; + int64_t EdgesCount(const GraphDbTypes::EdgeType &edge_type) const; /** * Obtains the Label for the label's name. * @return See above. */ - GraphDbTypes::Label label(const std::string &label_name); + GraphDbTypes::Label Label(const std::string &label_name); /** * Obtains the label name (a string) for the given label. @@ -481,13 +440,13 @@ class GraphDbAccessor { * @param label a Label. * @return See above. */ - const std::string &label_name(const GraphDbTypes::Label label) const; + const std::string &LabelName(const GraphDbTypes::Label label) const; /** * Obtains the EdgeType for it's name. * @return See above. */ - GraphDbTypes::EdgeType edge_type(const std::string &edge_type_name); + GraphDbTypes::EdgeType EdgeType(const std::string &edge_type_name); /** * Obtains the edge type name (a string) for the given edge type. @@ -495,14 +454,13 @@ class GraphDbAccessor { * @param edge_type an EdgeType. * @return See above. */ - const std::string &edge_type_name( - const GraphDbTypes::EdgeType edge_type) const; + const std::string &EdgeTypeName(const GraphDbTypes::EdgeType edge_type) const; /** * Obtains the Property for it's name. * @return See above. */ - GraphDbTypes::Property property(const std::string &property_name); + GraphDbTypes::Property Property(const std::string &property_name); /** * Obtains the property name (a string) for the given property. @@ -510,22 +468,22 @@ class GraphDbAccessor { * @param property a Property. * @return See above. */ - const std::string &property_name(const GraphDbTypes::Property property) const; + const std::string &PropertyName(const GraphDbTypes::Property property) const; /** * Advances transaction's command id by 1. */ - void advance_command(); + void AdvanceCommand(); /** * Commit transaction. */ - void commit(); + void Commit(); /** * Abort transaction. */ - void abort(); + void Abort(); /** * Return true if transaction is hinted to abort. @@ -566,7 +524,7 @@ class GraphDbAccessor { * @args accessor whose record to update if possible. */ template - void update(RecordAccessor &accessor) { + void Update(RecordAccessor &accessor) { debug_assert(!commited_ && !aborted_, "Accessor committed or aborted"); // can't update a deleted record if: // - we only have old_ and it hasn't been deleted @@ -592,9 +550,9 @@ class GraphDbAccessor { * @param vertex_accessor - vertex_accessor to insert * @param vertex - vertex record to insert */ - void update_label_indices(const GraphDbTypes::Label &label, - const VertexAccessor &vertex_accessor, - const Vertex *const vertex); + void UpdateLabelIndices(const GraphDbTypes::Label &label, + const VertexAccessor &vertex_accessor, + const Vertex *const vertex); /** * Insert this edge into corresponding edge_type index. @@ -602,9 +560,9 @@ class GraphDbAccessor { * @param edge_accessor - edge_accessor to insert * @param edge - edge record to insert */ - void update_edge_type_index(const GraphDbTypes::EdgeType &edge_type, - const EdgeAccessor &edge_accessor, - const Edge *const edge); + void UpdateEdgeTypeIndex(const GraphDbTypes::EdgeType &edge_type, + const EdgeAccessor &edge_accessor, + const Edge *const edge); /** * Insert this vertex into corresponding any label + 'property' index. @@ -613,9 +571,9 @@ class GraphDbAccessor { * @param record_accessor - record_accessor to insert * @param vertex - vertex to insert */ - void update_property_index(const GraphDbTypes::Property &property, - const RecordAccessor &record_accessor, - const Vertex *const vertex); + void UpdatePropertyIndex(const GraphDbTypes::Property &property, + const RecordAccessor &record_accessor, + const Vertex *const vertex); GraphDb &db_; /** The current transaction */ diff --git a/src/durability/recovery.cpp b/src/durability/recovery.cpp index aba5d3113..b32ad15fa 100644 --- a/src/durability/recovery.cpp +++ b/src/durability/recovery.cpp @@ -6,10 +6,10 @@ bool Recovery::Recover(const fs::path &snapshot_file, GraphDbAccessor &db_accessor) { if (!fs::exists(snapshot_file)) return false; if (!Decode(snapshot_file, db_accessor)) { - db_accessor.abort(); + db_accessor.Abort(); return false; } - db_accessor.commit(); + db_accessor.Commit(); return true; } @@ -34,8 +34,8 @@ bool Recovery::Decode(const fs::path &snapshot_file, for (int i = 0; i < label_property_vector.size(); i += 2) { auto label = label_property_vector[i].Value(); auto property = label_property_vector[i + 1].Value(); - db_accessor.BuildIndex(db_accessor.label(label), - db_accessor.property(property)); + db_accessor.BuildIndex(db_accessor.Label(label), + db_accessor.Property(property)); } for (int64_t i = 0; i < summary.vertex_num_; ++i) { @@ -44,12 +44,12 @@ bool Recovery::Decode(const fs::path &snapshot_file, buffer.Close(); return false; } - auto vertex_accessor = db_accessor.insert_vertex(); + auto vertex_accessor = db_accessor.InsertVertex(); for (const auto &label : vertex.labels) { - vertex_accessor.add_label(db_accessor.label(label)); + vertex_accessor.add_label(db_accessor.Label(label)); } for (const auto &property_pair : vertex.properties) { - vertex_accessor.PropsSet(db_accessor.property(property_pair.first), + vertex_accessor.PropsSet(db_accessor.Property(property_pair.first), property_pair.second); } vertices.insert({vertex.id, vertex_accessor}); @@ -66,11 +66,11 @@ bool Recovery::Decode(const fs::path &snapshot_file, buffer.Close(); return false; } - auto edge_accessor = db_accessor.insert_edge( - it_from->second, it_to->second, db_accessor.edge_type(edge.type)); + auto edge_accessor = db_accessor.InsertEdge( + it_from->second, it_to->second, db_accessor.EdgeType(edge.type)); for (const auto &property_pair : edge.properties) - edge_accessor.PropsSet(db_accessor.property(property_pair.first), + edge_accessor.PropsSet(db_accessor.Property(property_pair.first), property_pair.second); } diff --git a/src/durability/snapshooter.cpp b/src/durability/snapshooter.cpp index 26a41dd97..5fcca944b 100644 --- a/src/durability/snapshooter.cpp +++ b/src/durability/snapshooter.cpp @@ -44,11 +44,11 @@ bool Snapshooter::Encode(const fs::path &snapshot_file, } encoder.WriteList(label_property_vector); - for (const auto &vertex : db_accessor_.vertices(false)) { + for (const auto &vertex : db_accessor_.Vertices(false)) { encoder.WriteVertex(vertex); vertex_num++; } - for (const auto &edge : db_accessor_.edges(false)) { + for (const auto &edge : db_accessor_.Edges(false)) { encoder.WriteEdge(edge); edge_num++; } diff --git a/src/query/console.cpp b/src/query/console.cpp index ef2f837bc..20d40168f 100644 --- a/src/query/console.cpp +++ b/src/query/console.cpp @@ -142,7 +142,7 @@ void query::Repl(Dbms &dbms) { ResultStreamFaker results; interpeter.Interpret(command, *dba, results, {}); PrintResults(results); - dba->commit(); + dba->Commit(); } catch (const query::SyntaxException &e) { std::cout << "SYNTAX EXCEPTION: " << e.what() << std::endl; } catch (const query::LexingException &e) { diff --git a/src/query/frontend/ast/cypher_main_visitor.cpp b/src/query/frontend/ast/cypher_main_visitor.cpp index a1861568d..2439290a0 100644 --- a/src/query/frontend/ast/cypher_main_visitor.cpp +++ b/src/query/frontend/ast/cypher_main_visitor.cpp @@ -180,7 +180,7 @@ antlrcpp::Any CypherMainVisitor::visitCreateIndex( std::pair key = ctx->propertyKeyName()->accept(this); return storage_.Create( - ctx_.db_accessor_.label(ctx->labelName()->accept(this)), key.second); + ctx_.db_accessor_.Label(ctx->labelName()->accept(this)), key.second); } antlrcpp::Any CypherMainVisitor::visitCypherReturn( @@ -285,7 +285,7 @@ antlrcpp::Any CypherMainVisitor::visitNodeLabels( CypherParser::NodeLabelsContext *ctx) { std::vector labels; for (auto *node_label : ctx->nodeLabel()) { - labels.push_back(ctx_.db_accessor_.label(node_label->accept(this))); + labels.push_back(ctx_.db_accessor_.Label(node_label->accept(this))); } return labels; } @@ -328,7 +328,7 @@ antlrcpp::Any CypherMainVisitor::visitListLiteral( antlrcpp::Any CypherMainVisitor::visitPropertyKeyName( CypherParser::PropertyKeyNameContext *ctx) { const std::string key_name = visitChildren(ctx); - return std::make_pair(key_name, ctx_.db_accessor_.property(key_name)); + return std::make_pair(key_name, ctx_.db_accessor_.Property(key_name)); } antlrcpp::Any CypherMainVisitor::visitSymbolicName( @@ -499,7 +499,7 @@ antlrcpp::Any CypherMainVisitor::visitRelationshipTypes( CypherParser::RelationshipTypesContext *ctx) { std::vector types; for (auto *edge_type : ctx->relTypeName()) { - types.push_back(ctx_.db_accessor_.edge_type(edge_type->accept(this))); + types.push_back(ctx_.db_accessor_.EdgeType(edge_type->accept(this))); } return types; } diff --git a/src/query/interpret/awesome_memgraph_functions.cpp b/src/query/interpret/awesome_memgraph_functions.cpp index 6992afb24..cbc49f648 100644 --- a/src/query/interpret/awesome_memgraph_functions.cpp +++ b/src/query/interpret/awesome_memgraph_functions.cpp @@ -101,7 +101,7 @@ TypedValue Properties(const std::vector &args, auto get_properties = [&](const auto &record_accessor) { std::map properties; for (const auto &property : record_accessor.Properties()) { - properties[db_accessor.property_name(property.first)] = property.second; + properties[db_accessor.PropertyName(property.first)] = property.second; } return properties; }; @@ -247,8 +247,7 @@ TypedValue Type(const std::vector &args, case TypedValue::Type::Null: return TypedValue::Null; case TypedValue::Type::Edge: - return db_accessor.edge_type_name( - args[0].Value().edge_type()); + return db_accessor.EdgeTypeName(args[0].Value().EdgeType()); default: throw QueryRuntimeException("type called with incompatible type"); } @@ -262,7 +261,7 @@ TypedValue Keys(const std::vector &args, auto get_keys = [&](const auto &record_accessor) { std::vector keys; for (const auto &property : record_accessor.Properties()) { - keys.push_back(db_accessor.property_name(property.first)); + keys.push_back(db_accessor.PropertyName(property.first)); } return keys; }; @@ -289,7 +288,7 @@ TypedValue Labels(const std::vector &args, case TypedValue::Type::Vertex: { std::vector labels; for (const auto &label : args[0].Value().labels()) { - labels.push_back(db_accessor.label_name(label)); + labels.push_back(db_accessor.LabelName(label)); } return labels; } diff --git a/src/query/interpret/eval.hpp b/src/query/interpret/eval.hpp index f80f07f89..d4de2452d 100644 --- a/src/query/interpret/eval.hpp +++ b/src/query/interpret/eval.hpp @@ -250,7 +250,8 @@ class ExpressionEvaluator : public TreeVisitor { return expression_result.Value().PropsAt( property_lookup.property_); case TypedValue::Type::Map: { - auto &map = expression_result.Value>(); + auto &map = + expression_result.Value>(); auto found = map.find(property_lookup.property_name_); if (found == map.end()) return TypedValue::Null; return found->second; @@ -287,7 +288,7 @@ class ExpressionEvaluator : public TreeVisitor { return TypedValue::Null; case TypedValue::Type::Edge: { auto real_edge_type = - expression_result.Value().edge_type(); + expression_result.Value().EdgeType(); for (const auto edge_type : edge_type_test.edge_types_) { if (edge_type == real_edge_type) { return true; diff --git a/src/query/plan/cost_estimator.cpp b/src/query/plan/cost_estimator.cpp index d029b12f7..f86e10324 100644 --- a/src/query/plan/cost_estimator.cpp +++ b/src/query/plan/cost_estimator.cpp @@ -5,14 +5,14 @@ namespace query::plan { bool CostEstimator::PostVisit(ScanAll &) { - cardinality_ *= db_accessor_.vertices_count(); + cardinality_ *= db_accessor_.VerticesCount(); // ScanAll performs some work for every element that is produced IncrementCost(CostParam::kScanAll); return true; } bool CostEstimator::PostVisit(ScanAllByLabel &scan_all_by_label) { - cardinality_ *= db_accessor_.vertices_count(scan_all_by_label.label()); + cardinality_ *= db_accessor_.VerticesCount(scan_all_by_label.label()); // ScanAll performs some work for every element that is produced IncrementCost(CostParam::kScanAllByLabel); return true; @@ -32,12 +32,12 @@ bool CostEstimator::PostVisit(ScanAllByLabelPropertyValue &logical_op) { double factor = 1.0; if (property_value) // get the exact influence based on ScanAll(label, property, value) - factor = db_accessor_.vertices_count( + factor = db_accessor_.VerticesCount( logical_op.label(), logical_op.property(), property_value.value()); else // estimate the influence as ScanAll(label, property) * filtering factor = - db_accessor_.vertices_count(logical_op.label(), logical_op.property()) * + db_accessor_.VerticesCount(logical_op.label(), logical_op.property()) * CardParam::kFilter; cardinality_ *= factor; @@ -70,12 +70,12 @@ bool CostEstimator::PostVisit(ScanAllByLabelPropertyRange &logical_op) { int64_t factor = 1; if (upper || lower) // if we have either Bound, use the value index - factor = db_accessor_.vertices_count(logical_op.label(), - logical_op.property(), lower, upper); + factor = db_accessor_.VerticesCount(logical_op.label(), + logical_op.property(), lower, upper); else // no values, but we still have the label factor = - db_accessor_.vertices_count(logical_op.label(), logical_op.property()); + db_accessor_.VerticesCount(logical_op.label(), logical_op.property()); // if we failed to take either bound from the op into account, then apply // the filtering constant to the factor diff --git a/src/query/plan/operator.cpp b/src/query/plan/operator.cpp index ea94f93f5..256758bf8 100644 --- a/src/query/plan/operator.cpp +++ b/src/query/plan/operator.cpp @@ -87,7 +87,7 @@ void CreateNode::CreateNodeCursor::Reset() { input_cursor_->Reset(); } void CreateNode::CreateNodeCursor::Create(Frame &frame, const SymbolTable &symbol_table) { - auto new_node = db_.insert_vertex(); + auto new_node = db_.InsertVertex(); for (auto label : self_.node_atom_->labels_) new_node.add_label(label); // Evaluator should use the latest accessors, as modified in this query, when @@ -168,7 +168,7 @@ VertexAccessor &CreateExpand::CreateExpandCursor::OtherVertex( return dest_node_value.Value(); } else { // the node does not exist, it needs to be created - auto node = db_.insert_vertex(); + auto node = db_.InsertVertex(); for (auto label : self_.node_atom_->labels_) node.add_label(label); for (auto kv : self_.node_atom_->properties_) PropsSetChecked(node, kv.first.second, kv.second->Accept(evaluator)); @@ -182,7 +182,7 @@ void CreateExpand::CreateExpandCursor::CreateEdge( VertexAccessor &from, VertexAccessor &to, Frame &frame, const SymbolTable &symbol_table, ExpressionEvaluator &evaluator) { EdgeAccessor edge = - db_.insert_edge(from, to, self_.edge_atom_->edge_types_[0]); + db_.InsertEdge(from, to, self_.edge_atom_->edge_types_[0]); for (auto kv : self_.edge_atom_->properties_) PropsSetChecked(edge, kv.first.second, kv.second->Accept(evaluator)); frame[symbol_table.at(*self_.edge_atom_->identifier_)] = edge; @@ -246,7 +246,7 @@ ACCEPT_WITH_INPUT(ScanAll) std::unique_ptr ScanAll::MakeCursor(GraphDbAccessor &db) { auto vertices = [this, &db](Frame &, const SymbolTable &) { - return db.vertices(graph_view_ == GraphView::NEW); + return db.Vertices(graph_view_ == GraphView::NEW); }; return std::make_unique>( output_symbol_, input_->MakeCursor(db), std::move(vertices), db); @@ -261,7 +261,7 @@ ACCEPT_WITH_INPUT(ScanAllByLabel) std::unique_ptr ScanAllByLabel::MakeCursor(GraphDbAccessor &db) { auto vertices = [this, &db](Frame &, const SymbolTable &) { - return db.vertices(label_, graph_view_ == GraphView::NEW); + return db.Vertices(label_, graph_view_ == GraphView::NEW); }; return std::make_unique>( output_symbol_, input_->MakeCursor(db), std::move(vertices), db); @@ -304,7 +304,7 @@ std::unique_ptr ScanAllByLabelPropertyRange::MakeCursor( return std::experimental::make_optional(utils::Bound( bound.value().value()->Accept(evaluator), bound.value().type())); }; - return db.vertices(label_, property_, convert(lower_bound()), + return db.Vertices(label_, property_, convert(lower_bound()), convert(upper_bound()), graph_view_ == GraphView::NEW); }; return std::make_unique>( @@ -339,7 +339,7 @@ class ScanAllByLabelPropertyValueCursor : public Cursor { TypedValue value = self_.expression()->Accept(evaluator); if (value.IsNull()) return Pull(frame, symbol_table); try { - vertices_.emplace(db_.vertices(self_.label(), self_.property(), value, + vertices_.emplace(db_.Vertices(self_.label(), self_.property(), value, self_.graph_view() == GraphView::NEW)); } catch (const TypedValueException &) { throw QueryRuntimeException("'{}' cannot be used as a property value.", @@ -367,7 +367,7 @@ class ScanAllByLabelPropertyValueCursor : public Cursor { GraphDbAccessor &db_; const std::unique_ptr input_cursor_; std::experimental::optional + db_.Vertices(self_.label(), self_.property(), TypedValue::Null, false))> vertices_; std::experimental::optional vertices_it_; }; @@ -1112,7 +1112,7 @@ bool Delete::DeleteCursor::Pull(Frame &frame, const SymbolTable &symbol_table) { // delete edges first for (TypedValue &expression_result : expression_results) if (expression_result.type() == TypedValue::Type::Edge) - db_.remove_edge(expression_result.Value()); + db_.RemoveEdge(expression_result.Value()); // delete vertices for (TypedValue &expression_result : expression_results) @@ -1122,8 +1122,8 @@ bool Delete::DeleteCursor::Pull(Frame &frame, const SymbolTable &symbol_table) { va.SwitchNew(); // necessary because an edge deletion could have // updated if (self_.detach_) - db_.detach_remove_vertex(va); - else if (!db_.remove_vertex(va)) + db_.DetachRemoveVertex(va); + else if (!db_.RemoveVertex(va)) throw QueryRuntimeException( "Failed to remove vertex because of it's existing " "connections. Consider using DETACH DELETE."); @@ -1248,7 +1248,7 @@ void SetProperties::SetPropertiesCursor::Set(TRecordAccessor &record, break; case TypedValue::Type::Map: { for (const auto &kv : rhs.Value>()) - PropsSetChecked(record, db_.property(kv.first), kv.second); + PropsSetChecked(record, db_.Property(kv.first), kv.second); break; } default: @@ -1517,7 +1517,7 @@ bool Accumulate::AccumulateCursor::Pull(Frame &frame, cache_it_ = cache_.begin(); if (self_.advance_command_) { - db_.advance_command(); + db_.AdvanceCommand(); for (auto &row : cache_) for (auto &col : row) ReconstructTypedValue(col); } diff --git a/src/query/plan/rule_based_planner.cpp b/src/query/plan/rule_based_planner.cpp index 606dd77cc..636ba6050 100644 --- a/src/query/plan/rule_based_planner.cpp +++ b/src/query/plan/rule_based_planner.cpp @@ -713,8 +713,8 @@ const GraphDbTypes::Label &FindBestLabelIndex( "Trying to find the best label without any labels."); return *std::min_element(labels.begin(), labels.end(), [&db](const auto &label1, const auto &label2) { - return db.vertices_count(label1) < - db.vertices_count(label2); + return db.VerticesCount(label1) < + db.VerticesCount(label2); }); } @@ -744,8 +744,8 @@ bool FindBestLabelPropertyIndex( for (const auto &prop_pair : property_filters) { const auto &property = prop_pair.first; if (db.LabelPropertyIndexExists(label, property)) { - auto vertices_count = db.vertices_count(label, property); - if (vertices_count < min_count) { + auto VerticesCount = db.VerticesCount(label, property); + if (VerticesCount < min_count) { for (const auto &prop_filter : prop_pair.second) { if (prop_filter.used_symbols.find(symbol) != prop_filter.used_symbols.end()) { @@ -759,7 +759,7 @@ bool FindBestLabelPropertyIndex( // Take the first property filter which uses bound symbols. best_label = label; best_property = {property, prop_filter}; - min_count = vertices_count; + min_count = VerticesCount; found = true; break; } diff --git a/src/storage/edge_accessor.cpp b/src/storage/edge_accessor.cpp index 0d2a74c45..227b06de2 100644 --- a/src/storage/edge_accessor.cpp +++ b/src/storage/edge_accessor.cpp @@ -4,7 +4,7 @@ #include "storage/vertex_accessor.hpp" #include "utils/algorithm.hpp" -GraphDbTypes::EdgeType EdgeAccessor::edge_type() const { +GraphDbTypes::EdgeType EdgeAccessor::EdgeType() const { return current().edge_type_; } @@ -20,10 +20,10 @@ bool EdgeAccessor::is_cycle() const { } std::ostream &operator<<(std::ostream &os, const EdgeAccessor &ea) { - os << "E[" << ea.db_accessor().edge_type_name(ea.edge_type()); + os << "E[" << ea.db_accessor().EdgeTypeName(ea.EdgeType()); os << " {"; PrintIterable(os, ea.Properties(), ", ", [&](auto &stream, const auto &pair) { - stream << ea.db_accessor().property_name(pair.first) << ": " << pair.second; + stream << ea.db_accessor().PropertyName(pair.first) << ": " << pair.second; }); return os << "}]"; } diff --git a/src/storage/edge_accessor.hpp b/src/storage/edge_accessor.hpp index 353f4649e..f01adcc3b 100644 --- a/src/storage/edge_accessor.hpp +++ b/src/storage/edge_accessor.hpp @@ -24,7 +24,7 @@ class EdgeAccessor : public RecordAccessor { * Returns the edge type. * @return */ - GraphDbTypes::EdgeType edge_type() const; + GraphDbTypes::EdgeType EdgeType() const; /** * Returns an accessor to the originating Vertex of this edge. diff --git a/src/storage/record_accessor.cpp b/src/storage/record_accessor.cpp index 6572b45b0..beddc5154 100644 --- a/src/storage/record_accessor.cpp +++ b/src/storage/record_accessor.cpp @@ -80,7 +80,7 @@ bool RecordAccessor::Reconstruct() { template TRecord &RecordAccessor::update() { - db_accessor().update(*this); + db_accessor().Update(*this); debug_assert(new_ != nullptr, "RecordAccessor.new_ is null after update"); return *new_; } @@ -97,7 +97,7 @@ void RecordAccessor::PropsSet(GraphDbTypes::Property key, PropertyValue value) { Vertex &vertex = update(); vertex.properties_.set(key, value); - this->db_accessor().update_property_index(key, *this, &vertex); + this->db_accessor().UpdatePropertyIndex(key, *this, &vertex); } template <> void RecordAccessor::PropsSet(GraphDbTypes::Property key, diff --git a/src/storage/vertex_accessor.cpp b/src/storage/vertex_accessor.cpp index bc6f2933d..55a96172f 100644 --- a/src/storage/vertex_accessor.cpp +++ b/src/storage/vertex_accessor.cpp @@ -18,7 +18,7 @@ bool VertexAccessor::add_label(GraphDbTypes::Label label) { // not a duplicate label, add it Vertex &vertex = update(); vertex.labels_.emplace_back(label); - this->db_accessor().update_label_indices(label, *this, &vertex); + this->db_accessor().UpdateLabelIndices(label, *this, &vertex); return true; } @@ -44,11 +44,11 @@ const std::vector &VertexAccessor::labels() const { std::ostream &operator<<(std::ostream &os, const VertexAccessor &va) { os << "V("; PrintIterable(os, va.labels(), ":", [&](auto &stream, auto label) { - stream << va.db_accessor().label_name(label); + stream << va.db_accessor().LabelName(label); }); os << " {"; PrintIterable(os, va.Properties(), ", ", [&](auto &stream, const auto &pair) { - stream << va.db_accessor().property_name(pair.first) << ": " << pair.second; + stream << va.db_accessor().PropertyName(pair.first) << ": " << pair.second; }); return os << "})"; } diff --git a/src/utils/random_graph_generator.hpp b/src/utils/random_graph_generator.hpp index 9e8fe83a9..57c9b57c7 100644 --- a/src/utils/random_graph_generator.hpp +++ b/src/utils/random_graph_generator.hpp @@ -69,11 +69,11 @@ class RandomGraphGenerator { auto dba = dbms_.active(); std::vector labels; for (const auto &label_name : label_names) - labels.push_back(dba->label(label_name)); + labels.push_back(dba->Label(label_name)); Map( [&labels, this](GraphDbAccessor &dba) { - auto vertex = dba.insert_vertex(); + auto vertex = dba.InsertVertex(); for (auto label : labels) vertex.add_label(label); NotifyProgressListeners(); }, @@ -84,7 +84,7 @@ class RandomGraphGenerator { * Returns the number of vertices created by this generator, * regardless of their labels. */ - int64_t VertexCount() const { return dbms_.active()->vertices_count(); } + int64_t VertexCount() const { return dbms_.active()->VerticesCount(); } /** * Adds the given number of edges to the graph. @@ -108,11 +108,11 @@ class RandomGraphGenerator { auto vertices_to = FilterVertices(to_filter); auto dba = dbms_.active(); - auto edge_type = dba->edge_type(edge_type_name); + auto edge_type = dba->EdgeType(edge_type_name); // for small vertex counts reduce the batch size - batch_size = std::min(batch_size, - static_cast(dba->vertices_count() / 1000 + 1)); + batch_size = + std::min(batch_size, static_cast(dba->VerticesCount() / 1000 + 1)); Map( [&vertices_from, &vertices_to, edge_type, this](GraphDbAccessor &dba) { @@ -121,7 +121,7 @@ class RandomGraphGenerator { auto to = dba.Transfer(vertices_to[rand() % vertices_to.size()]); debug_assert(from, "From not visible in current GraphDbAccessor"); debug_assert(to, "From not visible in current GraphDbAccessor"); - dba.insert_edge(from.value(), to.value(), edge_type); + dba.InsertEdge(from.value(), to.value(), edge_type); NotifyProgressListeners(); }, count, thread_count, batch_size); @@ -131,7 +131,7 @@ class RandomGraphGenerator { * Returns the number of edges created by this generator, * regardless of their types and origin/destination labels. */ - int64_t EdgeCount() const { return dbms_.active()->edges_count(); } + int64_t EdgeCount() const { return dbms_.active()->EdgesCount(); } /** * Sets a generated property on a random vertex. @@ -148,10 +148,10 @@ class RandomGraphGenerator { std::function predicate = {}) { if (!predicate) predicate = [](VertexAccessor &) { return true; }; auto dba = dbms_.active(); - auto property = dba->property(prop_name); - for (VertexAccessor va : dba->vertices(false)) + auto property = dba->Property(prop_name); + for (VertexAccessor va : dba->Vertices(false)) if (predicate(va)) va.PropsSet(property, value_generator()); - dba->commit(); + dba->Commit(); } private: @@ -177,7 +177,7 @@ class RandomGraphGenerator { if (!predicate) predicate = [](VertexAccessor &) { return true; }; std::vector r_val; auto dba = dbms_.active(); - for (VertexAccessor &item : dba->vertices(false)) + for (VertexAccessor &item : dba->Vertices(false)) if (predicate(item)) r_val.emplace_back(item); return r_val; @@ -218,7 +218,7 @@ class RandomGraphGenerator { } if (i == (count_per_thread - 1) || (i >= 0 && i % elements_per_commit == 0)) { - dba->commit(); + dba->Commit(); auto dba2 = dbms_.active(); dba.swap(dba2); } diff --git a/tests/integration/hardcoded_query/clique.hpp b/tests/integration/hardcoded_query/clique.hpp index faefe3c3a..d1e8a5f7b 100644 --- a/tests/integration/hardcoded_query/clique.hpp +++ b/tests/integration/hardcoded_query/clique.hpp @@ -39,8 +39,8 @@ bool run_general_query(GraphDbAccessor &db_accessor, const Parameters &args, // TODO dgleich: this code is very inefficient as it first makes a copy // of all the vertices/edges, and filters aftwarwards. I warned about this // happening in code review!!! - auto vertices_iterator = db_accessor.vertices(false); - auto edge_iterator = db_accessor.edges(false); + auto vertices_iterator = db_accessor.Vertices(false); + auto edge_iterator = db_accessor.Edges(false); std::vector vertices(vertices_iterator.begin(), vertices_iterator.end()); std::vector edges(edge_iterator.begin(), edge_iterator.end()); @@ -50,15 +50,15 @@ bool run_general_query(GraphDbAccessor &db_accessor, const Parameters &args, int profile_index = -1; for (int i = 0; i < (int)vertices.size(); ++i) { - if (vertices[i].has_label(db_accessor.label("garment"))) + if (vertices[i].has_label(db_accessor.Label("garment"))) vertices_indexed.push_back(&vertices[i]); if (query_type == CliqueQuery::SCORE_AND_LIMIT && - vertices[i].has_label(db_accessor.label("profile"))) { - auto has_prop = vertices[i].PropsAt(db_accessor.property("profile_id")) == + vertices[i].has_label(db_accessor.Label("profile"))) { + auto has_prop = vertices[i].PropsAt(db_accessor.Property("profile_id")) == args.At(0).second; if (has_prop.type() == query::TypedValue::Type::Null) continue; if (has_prop.Value() == false) continue; - has_prop = vertices[i].PropsAt(db_accessor.property("partner_id")) == + has_prop = vertices[i].PropsAt(db_accessor.Property("partner_id")) == args.At(1).second; if (has_prop.type() == query::TypedValue::Type::Null) continue; if (has_prop.Value() == false) continue; @@ -66,8 +66,8 @@ bool run_general_query(GraphDbAccessor &db_accessor, const Parameters &args, } } for (int i = 0; i < (int)edges.size(); ++i) { - if (edges[i].edge_type() == db_accessor.edge_type("default_outfit") || - edges[i].edge_type() == db_accessor.edge_type("score")) + if (edges[i].EdgeType() == db_accessor.EdgeType("default_outfit") || + edges[i].EdgeType() == db_accessor.EdgeType("score")) edges_indexed.push_back(&edges[i]); } const int n = vertices_indexed.size(); @@ -99,7 +99,7 @@ bool run_general_query(GraphDbAccessor &db_accessor, const Parameters &args, */ auto update = [&db_accessor, &query](Bitset &bitset, auto &&edges) { for (auto e : edges) { - if (e.edge_type() != db_accessor.edge_type("default_outfit")) continue; + if (e.EdgeType() != db_accessor.EdgeType("default_outfit")) continue; const int from = query(e.from()); const int to = query(e.to()); if (from == -1 || to == -1) continue; @@ -120,7 +120,7 @@ bool run_general_query(GraphDbAccessor &db_accessor, const Parameters &args, for (int i = 0; i < n; ++i) { const VertexAccessor v = *vertices_indexed[i]; auto cmp_res = - v.PropsAt(db_accessor.property("garment_id")) == + v.PropsAt(db_accessor.Property("garment_id")) == args.At(query_type == CliqueQuery::SCORE_AND_LIMIT ? 8 : 0).second; if (cmp_res.type() != query::TypedValue::Type::Bool) continue; if (cmp_res.Value() != true) continue; @@ -188,7 +188,7 @@ bool run_general_query(GraphDbAccessor &db_accessor, const Parameters &args, auto edge = get_edge(vertices[profile_index], *vertices_indexed[x]); if (edge == nullptr) continue; auto prop = - query::TypedValue(edge->PropsAt(db_accessor.property("score"))); + query::TypedValue(edge->PropsAt(db_accessor.Property("score"))); if (prop.type() == query::TypedValue::Type::Int) res += prop.Value(); } @@ -209,7 +209,7 @@ bool run_general_query(GraphDbAccessor &db_accessor, const Parameters &args, std::vector result; for (auto x : results[i]) { result.push_back(vertices_indexed[x] - ->PropsAt(db_accessor.property("garment_id")) + ->PropsAt(db_accessor.Property("garment_id")) .Value()); } if (query_type == CliqueQuery::SCORE_AND_LIMIT) diff --git a/tests/integration/hardcoded_query/create_full_profile_conceals_return.cpp b/tests/integration/hardcoded_query/create_full_profile_conceals_return.cpp index f92c9e4c0..947859850 100644 --- a/tests/integration/hardcoded_query/create_full_profile_conceals_return.cpp +++ b/tests/integration/hardcoded_query/create_full_profile_conceals_return.cpp @@ -19,11 +19,11 @@ class CPUPlan : public PlanInterface { public: bool run(GraphDbAccessor &db_accessor, const Parameters &args, Stream &stream) { - auto v = db_accessor.insert_vertex(); - v.PropsSet(db_accessor.property("profile_id"), args.At(0).second); - v.PropsSet(db_accessor.property("partner_id"), args.At(1).second); - v.PropsSet(db_accessor.property("conceals"), args.At(2).second); - v.add_label(db_accessor.label("profile")); + auto v = db_accessor.InsertVertex(); + v.PropsSet(db_accessor.Property("profile_id"), args.At(0).second); + v.PropsSet(db_accessor.Property("partner_id"), args.At(1).second); + v.PropsSet(db_accessor.Property("conceals"), args.At(2).second); + v.add_label(db_accessor.Label("profile")); std::vector headers{std::string("p")}; stream.Header(headers); std::vector result{TypedValue(v)}; diff --git a/tests/integration/hardcoded_query/create_full_profile_return.cpp b/tests/integration/hardcoded_query/create_full_profile_return.cpp index 3409029c9..3f78e9118 100644 --- a/tests/integration/hardcoded_query/create_full_profile_return.cpp +++ b/tests/integration/hardcoded_query/create_full_profile_return.cpp @@ -18,10 +18,10 @@ class CPUPlan : public PlanInterface { public: bool run(GraphDbAccessor &db_accessor, const Parameters &args, Stream &stream) { - auto v = db_accessor.insert_vertex(); - v.PropsSet(db_accessor.property("profile_id"), args.At(0).second); - v.PropsSet(db_accessor.property("partner_id"), args.At(1).second); - v.add_label(db_accessor.label("profile")); + auto v = db_accessor.InsertVertex(); + v.PropsSet(db_accessor.Property("profile_id"), args.At(0).second); + v.PropsSet(db_accessor.Property("partner_id"), args.At(1).second); + v.add_label(db_accessor.Label("profile")); std::vector headers{std::string("p")}; stream.Header(headers); std::vector result{TypedValue(v)}; diff --git a/tests/integration/hardcoded_query/create_full_profile_reveals_return.cpp b/tests/integration/hardcoded_query/create_full_profile_reveals_return.cpp index 85672cd47..df89102c9 100644 --- a/tests/integration/hardcoded_query/create_full_profile_reveals_return.cpp +++ b/tests/integration/hardcoded_query/create_full_profile_reveals_return.cpp @@ -19,11 +19,11 @@ class CPUPlan : public PlanInterface { public: bool run(GraphDbAccessor &db_accessor, const Parameters &args, Stream &stream) { - auto v = db_accessor.insert_vertex(); - v.PropsSet(db_accessor.property("profile_id"), args.At(0).second); - v.PropsSet(db_accessor.property("partner_id"), args.At(1).second); - v.PropsSet(db_accessor.property("reveals"), args.At(2).second); - v.add_label(db_accessor.label("profile")); + auto v = db_accessor.InsertVertex(); + v.PropsSet(db_accessor.Property("profile_id"), args.At(0).second); + v.PropsSet(db_accessor.Property("partner_id"), args.At(1).second); + v.PropsSet(db_accessor.Property("reveals"), args.At(2).second); + v.add_label(db_accessor.Label("profile")); std::vector headers{std::string("p")}; stream.Header(headers); std::vector result{TypedValue(v)}; diff --git a/tests/integration/hardcoded_query/create_garment.cpp b/tests/integration/hardcoded_query/create_garment.cpp index a7b12e135..90107a419 100644 --- a/tests/integration/hardcoded_query/create_garment.cpp +++ b/tests/integration/hardcoded_query/create_garment.cpp @@ -18,10 +18,10 @@ class CPUPlan : public PlanInterface { public: bool run(GraphDbAccessor &db_accessor, const Parameters &args, Stream &stream) { - auto v = db_accessor.insert_vertex(); - v.add_label(db_accessor.label("garment")); - v.PropsSet(db_accessor.property("garment_id"), args.At(0).second); - v.PropsSet(db_accessor.property("garment_category_id"), args.At(1).second); + auto v = db_accessor.InsertVertex(); + v.add_label(db_accessor.Label("garment")); + v.PropsSet(db_accessor.Property("garment_id"), args.At(0).second); + v.PropsSet(db_accessor.Property("garment_category_id"), args.At(1).second); std::vector headers{std::string("g")}; stream.Header(headers); std::vector result{TypedValue(v)}; diff --git a/tests/integration/hardcoded_query/create_garment_conceals.cpp b/tests/integration/hardcoded_query/create_garment_conceals.cpp index a8fe8c532..5ef98ce5d 100644 --- a/tests/integration/hardcoded_query/create_garment_conceals.cpp +++ b/tests/integration/hardcoded_query/create_garment_conceals.cpp @@ -19,11 +19,11 @@ class CPUPlan : public PlanInterface { public: bool run(GraphDbAccessor &db_accessor, const Parameters &args, Stream &stream) { - auto v = db_accessor.insert_vertex(); - v.add_label(db_accessor.label("garment")); - v.PropsSet(db_accessor.property("garment_id"), args.At(0).second); - v.PropsSet(db_accessor.property("garment_category_id"), args.At(1).second); - v.PropsSet(db_accessor.property("conceals"), args.At(2).second); + auto v = db_accessor.InsertVertex(); + v.add_label(db_accessor.Label("garment")); + v.PropsSet(db_accessor.Property("garment_id"), args.At(0).second); + v.PropsSet(db_accessor.Property("garment_category_id"), args.At(1).second); + v.PropsSet(db_accessor.Property("conceals"), args.At(2).second); std::vector headers{std::string("g")}; stream.Header(headers); std::vector result{TypedValue(v)}; diff --git a/tests/integration/hardcoded_query/create_garment_reveals.cpp b/tests/integration/hardcoded_query/create_garment_reveals.cpp index 1700ff622..30c8e30ff 100644 --- a/tests/integration/hardcoded_query/create_garment_reveals.cpp +++ b/tests/integration/hardcoded_query/create_garment_reveals.cpp @@ -19,11 +19,11 @@ class CPUPlan : public PlanInterface { public: bool run(GraphDbAccessor &db_accessor, const Parameters &args, Stream &stream) { - auto v = db_accessor.insert_vertex(); - v.add_label(db_accessor.label("garment")); - v.PropsSet(db_accessor.property("garment_id"), args.At(0).second); - v.PropsSet(db_accessor.property("garment_category_id"), args.At(1).second); - v.PropsSet(db_accessor.property("reveals"), args.At(2).second); + auto v = db_accessor.InsertVertex(); + v.add_label(db_accessor.Label("garment")); + v.PropsSet(db_accessor.Property("garment_id"), args.At(0).second); + v.PropsSet(db_accessor.Property("garment_category_id"), args.At(1).second); + v.PropsSet(db_accessor.Property("reveals"), args.At(2).second); std::vector headers{std::string("g")}; stream.Header(headers); std::vector result{TypedValue(v)}; diff --git a/tests/integration/hardcoded_query/delete_all.cpp b/tests/integration/hardcoded_query/delete_all.cpp index dbce8994f..27ff4ff86 100644 --- a/tests/integration/hardcoded_query/delete_all.cpp +++ b/tests/integration/hardcoded_query/delete_all.cpp @@ -1,9 +1,9 @@ #include #include +#include "query/frontend/stripped.hpp" #include "query/parameters.hpp" #include "query/plan_interface.hpp" -#include "query/frontend/stripped.hpp" #include "query/typed_value.hpp" #include "using.hpp" @@ -17,7 +17,8 @@ class CPUPlan : public PlanInterface { public: bool run(GraphDbAccessor &db_accessor, const Parameters &args, Stream &stream) { - for (auto v : db_accessor.vertices(false)) db_accessor.detach_remove_vertex(v); + for (auto v : db_accessor.Vertices(false)) + db_accessor.DetachRemoveVertex(v); std::vector headers; stream.Header(headers); return true; diff --git a/tests/integration/hardcoded_query/match_garment.cpp b/tests/integration/hardcoded_query/match_garment.cpp index 004d42a85..2b21a0b28 100644 --- a/tests/integration/hardcoded_query/match_garment.cpp +++ b/tests/integration/hardcoded_query/match_garment.cpp @@ -20,9 +20,9 @@ class CPUPlan : public PlanInterface { Stream &stream) { std::vector headers{std::string("g")}; stream.Header(headers); - for (auto vertex : db_accessor.vertices(false)) { - if (vertex.has_label(db_accessor.label("garment"))) { - TypedValue prop = vertex.PropsAt(db_accessor.property("garment_id")); + for (auto vertex : db_accessor.Vertices(false)) { + if (vertex.has_label(db_accessor.Label("garment"))) { + TypedValue prop = vertex.PropsAt(db_accessor.Property("garment_id")); if (prop.type() == TypedValue::Type::Null) continue; auto cmp = prop == args.At(0).second; if (cmp.type() != TypedValue::Type::Bool) continue; diff --git a/tests/integration/hardcoded_query/match_garment_default_outfit.cpp b/tests/integration/hardcoded_query/match_garment_default_outfit.cpp index 0e228f271..4349c3cc9 100644 --- a/tests/integration/hardcoded_query/match_garment_default_outfit.cpp +++ b/tests/integration/hardcoded_query/match_garment_default_outfit.cpp @@ -22,9 +22,9 @@ class CPUPlan : public PlanInterface { std::vector headers{std::string("r")}; stream.Header(headers); std::vector g1_set, g2_set; - for (auto g1 : db_accessor.vertices(false)) { - if (g1.has_label(db_accessor.label("garment"))) { - TypedValue prop = g1.PropsAt(db_accessor.property("garment_id")); + for (auto g1 : db_accessor.Vertices(false)) { + if (g1.has_label(db_accessor.Label("garment"))) { + TypedValue prop = g1.PropsAt(db_accessor.Property("garment_id")); if (prop.type() == TypedValue::Type::Null) continue; auto cmp = prop == args.At(0).second; if (cmp.type() != TypedValue::Type::Bool) continue; @@ -32,9 +32,9 @@ class CPUPlan : public PlanInterface { g1_set.push_back(g1); } } - for (auto g2 : db_accessor.vertices(false)) { - if (g2.has_label(db_accessor.label("garment"))) { - auto prop = g2.PropsAt(db_accessor.property("garment_id")); + for (auto g2 : db_accessor.Vertices(false)) { + if (g2.has_label(db_accessor.Label("garment"))) { + auto prop = g2.PropsAt(db_accessor.Property("garment_id")); if (prop.type() == PropertyValue::Type::Null) continue; auto cmp = prop == args.At(1).second; if (cmp.type() != TypedValue::Type::Bool) continue; @@ -44,8 +44,8 @@ class CPUPlan : public PlanInterface { } for (auto g1 : g1_set) for (auto g2 : g2_set) { - EdgeAccessor e = db_accessor.insert_edge( - g1, g2, db_accessor.edge_type("default_outfit")); + EdgeAccessor e = db_accessor.InsertEdge( + g1, g2, db_accessor.EdgeType("default_outfit")); std::vector result{TypedValue(e)}; stream.Result(result); } diff --git a/tests/integration/hardcoded_query/match_garment_set_label_general_return.hpp b/tests/integration/hardcoded_query/match_garment_set_label_general_return.hpp index bef5966e4..a47c038f2 100644 --- a/tests/integration/hardcoded_query/match_garment_set_label_general_return.hpp +++ b/tests/integration/hardcoded_query/match_garment_set_label_general_return.hpp @@ -18,15 +18,15 @@ bool run_general_query(GraphDbAccessor &db_accessor, const Parameters &args, Stream &stream, const std::string &general_label) { std::vector headers{std::string("g")}; stream.Header(headers); - for (auto vertex : db_accessor.vertices(false)) { - if (vertex.has_label(db_accessor.label("garment"))) { + for (auto vertex : db_accessor.Vertices(false)) { + if (vertex.has_label(db_accessor.Label("garment"))) { query::TypedValue prop = - vertex.PropsAt(db_accessor.property("garment_id")); + vertex.PropsAt(db_accessor.Property("garment_id")); if (prop.type() == query::TypedValue::Type::Null) continue; query::TypedValue cmp = prop == args.At(0).second; if (cmp.type() != query::TypedValue::Type::Bool) continue; if (cmp.Value() != true) continue; - vertex.add_label(db_accessor.label(general_label)); + vertex.add_label(db_accessor.Label(general_label)); std::vector result{query::TypedValue(vertex)}; stream.Result(result); } diff --git a/tests/integration/hardcoded_query/match_profile.cpp b/tests/integration/hardcoded_query/match_profile.cpp index 2251ac1f7..330a12422 100644 --- a/tests/integration/hardcoded_query/match_profile.cpp +++ b/tests/integration/hardcoded_query/match_profile.cpp @@ -20,15 +20,15 @@ class CPUPlan : public PlanInterface { Stream &stream) { std::vector headers{std::string("p")}; stream.Header(headers); - for (auto vertex : db_accessor.vertices(false)) { - if (vertex.has_label(db_accessor.label("profile"))) { - TypedValue prop = vertex.PropsAt(db_accessor.property("profile_id")); + for (auto vertex : db_accessor.Vertices(false)) { + if (vertex.has_label(db_accessor.Label("profile"))) { + TypedValue prop = vertex.PropsAt(db_accessor.Property("profile_id")); if (prop.type() == TypedValue::Type::Null) continue; auto cmp = prop == args.At(0).second; if (cmp.type() != TypedValue::Type::Bool) continue; if (cmp.Value() != true) continue; - TypedValue prop2 = vertex.PropsAt(db_accessor.property("partner_id")); + TypedValue prop2 = vertex.PropsAt(db_accessor.Property("partner_id")); if (prop2.type() == TypedValue::Type::Null) continue; auto cmp2 = prop2 == args.At(1).second; if (cmp2.type() != TypedValue::Type::Bool) continue; diff --git a/tests/integration/hardcoded_query/match_profile_garment_score.cpp b/tests/integration/hardcoded_query/match_profile_garment_score.cpp index 870fed5c7..3565f7045 100644 --- a/tests/integration/hardcoded_query/match_profile_garment_score.cpp +++ b/tests/integration/hardcoded_query/match_profile_garment_score.cpp @@ -24,29 +24,29 @@ class CPUPlan : public PlanInterface { std::vector headers{std::string("s")}; stream.Header(headers); auto profile = [&db_accessor, &args](const VertexAccessor &v) -> bool { - TypedValue prop = v.PropsAt(db_accessor.property("profile_id")); + TypedValue prop = v.PropsAt(db_accessor.Property("profile_id")); if (prop.type() == TypedValue::Type::Null) return false; auto cmp = prop == args.At(0).second; if (cmp.type() != TypedValue::Type::Bool) return false; if (cmp.Value() != true) return false; - TypedValue prop2 = v.PropsAt(db_accessor.property("partner_id")); + TypedValue prop2 = v.PropsAt(db_accessor.Property("partner_id")); if (prop2.type() == TypedValue::Type::Null) return false; auto cmp2 = prop2 == args.At(1).second; if (cmp2.type() != TypedValue::Type::Bool) return false; return cmp2.Value(); }; auto garment = [&db_accessor, &args](const VertexAccessor &v) -> bool { - TypedValue prop = v.PropsAt(db_accessor.property("garment_id")); + TypedValue prop = v.PropsAt(db_accessor.Property("garment_id")); if (prop.type() == TypedValue::Type::Null) return false; auto cmp = prop == args.At(2).second; if (cmp.type() != TypedValue::Type::Bool) return false; return cmp.Value(); }; - for (auto edge : db_accessor.edges(false)) { + for (auto edge : db_accessor.Edges(false)) { auto from = edge.from(); auto to = edge.to(); - if (edge.edge_type() != db_accessor.edge_type("score")) continue; + if (edge.EdgeType() != db_accessor.EdgeType("score")) continue; if ((profile(from) && garment(to)) || (profile(to) && garment(from))) { std::vector result{TypedValue(edge)}; stream.Result(result); diff --git a/tests/integration/hardcoded_query/match_profile_garment_set_score.cpp b/tests/integration/hardcoded_query/match_profile_garment_set_score.cpp index aade3dad9..c71d25866 100644 --- a/tests/integration/hardcoded_query/match_profile_garment_set_score.cpp +++ b/tests/integration/hardcoded_query/match_profile_garment_set_score.cpp @@ -22,15 +22,15 @@ class CPUPlan : public PlanInterface { std::vector headers{std::string("r")}; stream.Header(headers); std::vector g1_set, g2_set; - for (auto g1 : db_accessor.vertices(false)) { - if (g1.has_label(db_accessor.label("profile"))) { - auto prop = TypedValue(g1.PropsAt(db_accessor.property("profile_id"))); + for (auto g1 : db_accessor.Vertices(false)) { + if (g1.has_label(db_accessor.Label("profile"))) { + auto prop = TypedValue(g1.PropsAt(db_accessor.Property("profile_id"))); if (prop.type() == TypedValue::Type::Null) continue; auto cmp = prop == args.At(0).second; if (cmp.type() != TypedValue::Type::Bool) continue; if (cmp.Value() != true) continue; - auto prop2 = TypedValue(g1.PropsAt(db_accessor.property("partner_id"))); + auto prop2 = TypedValue(g1.PropsAt(db_accessor.Property("partner_id"))); if (prop2.type() == TypedValue::Type::Null) continue; auto cmp2 = prop2 == args.At(1).second; if (cmp2.type() != TypedValue::Type::Bool) continue; @@ -38,9 +38,9 @@ class CPUPlan : public PlanInterface { g1_set.push_back(g1); } } - for (auto g2 : db_accessor.vertices(false)) { - if (g2.has_label(db_accessor.label("garment"))) { - auto prop = TypedValue(g2.PropsAt(db_accessor.property("garment_id"))); + for (auto g2 : db_accessor.Vertices(false)) { + if (g2.has_label(db_accessor.Label("garment"))) { + auto prop = TypedValue(g2.PropsAt(db_accessor.Property("garment_id"))); if (prop.type() == TypedValue::Type::Null) continue; auto cmp = prop == args.At(2).second; if (cmp.type() != TypedValue::Type::Bool) continue; @@ -51,8 +51,8 @@ class CPUPlan : public PlanInterface { for (auto g1 : g1_set) for (auto g2 : g2_set) { EdgeAccessor e = - db_accessor.insert_edge(g1, g2, db_accessor.edge_type("score")); - e.PropsSet(db_accessor.property("score"), args.At(3).second); + db_accessor.InsertEdge(g1, g2, db_accessor.EdgeType("score")); + e.PropsSet(db_accessor.Property("score"), args.At(3).second); std::vector result{TypedValue(e)}; stream.Result(result); } diff --git a/tests/integration/hardcoded_query/match_profile_garment_update_score.cpp b/tests/integration/hardcoded_query/match_profile_garment_update_score.cpp index 719a2ce4a..f0caf6979 100644 --- a/tests/integration/hardcoded_query/match_profile_garment_update_score.cpp +++ b/tests/integration/hardcoded_query/match_profile_garment_update_score.cpp @@ -23,31 +23,31 @@ class CPUPlan : public PlanInterface { std::vector headers{std::string("s")}; stream.Header(headers); auto profile = [&db_accessor, &args](const VertexAccessor &v) -> bool { - TypedValue prop = v.PropsAt(db_accessor.property("profile_id")); + TypedValue prop = v.PropsAt(db_accessor.Property("profile_id")); if (prop.type() == TypedValue::Type::Null) return false; auto cmp = prop == args.At(0).second; if (cmp.type() != TypedValue::Type::Bool) return false; if (cmp.Value() != true) return false; - TypedValue prop2 = v.PropsAt(db_accessor.property("partner_id")); + TypedValue prop2 = v.PropsAt(db_accessor.Property("partner_id")); if (prop2.type() == TypedValue::Type::Null) return false; auto cmp2 = prop2 == args.At(1).second; if (cmp2.type() != TypedValue::Type::Bool) return false; return cmp2.Value(); }; auto garment = [&db_accessor, &args](const VertexAccessor &v) -> bool { - TypedValue prop = v.PropsAt(db_accessor.property("garment_id")); + TypedValue prop = v.PropsAt(db_accessor.Property("garment_id")); if (prop.type() == TypedValue::Type::Null) return false; auto cmp = prop == args.At(2).second; if (cmp.type() != TypedValue::Type::Bool) return false; return cmp.Value(); }; - for (auto edge : db_accessor.edges(false)) { + for (auto edge : db_accessor.Edges(false)) { auto from = edge.from(); auto to = edge.to(); - if (edge.edge_type() != db_accessor.edge_type("score")) continue; + if (edge.EdgeType() != db_accessor.EdgeType("score")) continue; if ((profile(from) && garment(to)) || (profile(to) && garment(from))) { - edge.PropsSet(db_accessor.property("score"), args.At(3).second); + edge.PropsSet(db_accessor.Property("score"), args.At(3).second); edge.SwitchNew(); std::vector result{TypedValue(edge)}; stream.Result(result); diff --git a/tests/property_based/random_graph.cpp b/tests/property_based/random_graph.cpp index 6cf18585a..271f4b0a7 100644 --- a/tests/property_based/random_graph.cpp +++ b/tests/property_based/random_graph.cpp @@ -10,7 +10,6 @@ #include "gtest/gtest.h" #include - /** * It is possible to run test with custom seed with: * RC_PARAMS="seed=1" ./random_graph @@ -31,8 +30,8 @@ RC_GTEST_PROP(RandomGraph, RandomGraph, (std::vector vertex_labels, auto dba = dbms.active(); for (auto label : vertex_labels) { - auto vertex_accessor = dba->insert_vertex(); - vertex_accessor.add_label(dba->label(label)); + auto vertex_accessor = dba->InsertVertex(); + vertex_accessor.add_label(dba->Label(label)); vertex_label_map.insert({vertex_accessor, label}); vertices.push_back(vertex_accessor); } @@ -40,23 +39,23 @@ RC_GTEST_PROP(RandomGraph, RandomGraph, (std::vector vertex_labels, for (auto type : edge_types) { auto from = vertices[*rc::gen::inRange(0, vertices_num)]; auto to = vertices[*rc::gen::inRange(0, vertices_num)]; - auto edge_accessor = dba->insert_edge(from, to, dba->edge_type(type)); + auto edge_accessor = dba->InsertEdge(from, to, dba->EdgeType(type)); edge_type_map.insert({edge_accessor, type}); } - dba->advance_command(); + dba->AdvanceCommand(); int edges_num_check = 0; int vertices_num_check = 0; - for (const auto &vertex : dba->vertices(false)) { + for (const auto &vertex : dba->Vertices(false)) { auto label = vertex_label_map.at(vertex); RC_ASSERT(vertex.labels().size() == 1); RC_ASSERT(*vertex.labels()[0] == label); vertices_num_check++; } - for (const auto &edge : dba->edges(false)) { + for (const auto &edge : dba->Edges(false)) { auto type = edge_type_map.at(edge); - RC_ASSERT(*edge.edge_type() == type); + RC_ASSERT(*edge.EdgeType() == type); edges_num_check++; } RC_ASSERT(vertices_num_check == vertices_num); diff --git a/tests/unit/bolt_encoder.cpp b/tests/unit/bolt_encoder.cpp index 03f365585..604c54db5 100644 --- a/tests/unit/bolt_encoder.cpp +++ b/tests/unit/bolt_encoder.cpp @@ -167,8 +167,8 @@ TEST(BoltEncoder, VertexAndEdge) { // create vertex Dbms dbms; auto db_accessor = dbms.active(); - auto va1 = db_accessor->insert_vertex(); - auto va2 = db_accessor->insert_vertex(); + auto va1 = db_accessor->InsertVertex(); + auto va2 = db_accessor->InsertVertex(); std::string l1("label1"), l2("label2"); va1.add_label(&l1); va1.add_label(&l2); @@ -179,7 +179,7 @@ TEST(BoltEncoder, VertexAndEdge) { // create edge std::string et("edgetype"); - auto ea = db_accessor->insert_edge(va1, va2, &et); + auto ea = db_accessor->InsertEdge(va1, va2, &et); std::string p3("prop3"), p4("prop4"); PropertyValue pv3(42), pv4(1234); ea.PropsSet(&p3, pv3); diff --git a/tests/unit/cypher_main_visitor.cpp b/tests/unit/cypher_main_visitor.cpp index 0fb1c0090..f8a1db10e 100644 --- a/tests/unit/cypher_main_visitor.cpp +++ b/tests/unit/cypher_main_visitor.cpp @@ -35,7 +35,7 @@ class Base { std::string query_string_; auto Prop(const std::string &prop_name) { - return db_accessor_->property(prop_name); + return db_accessor_->Property(prop_name); } auto PropPair(const std::string &prop_name) { @@ -133,7 +133,7 @@ TYPED_TEST(CypherMainVisitorTest, PropertyLookup) { ASSERT_TRUE(identifier); ASSERT_EQ(identifier->name_, "n"); ASSERT_EQ(property_lookup->property_, - ast_generator.db_accessor_->property("x")); + ast_generator.db_accessor_->Property("x")); } TYPED_TEST(CypherMainVisitorTest, LabelsTest) { @@ -148,8 +148,8 @@ TYPED_TEST(CypherMainVisitorTest, LabelsTest) { ASSERT_TRUE(identifier); ASSERT_EQ(identifier->name_, "n"); ASSERT_THAT(labels_test->labels_, - ElementsAre(ast_generator.db_accessor_->label("x"), - ast_generator.db_accessor_->label("y"))); + ElementsAre(ast_generator.db_accessor_->Label("x"), + ast_generator.db_accessor_->Label("y"))); } TYPED_TEST(CypherMainVisitorTest, EscapedLabel) { @@ -162,7 +162,7 @@ TYPED_TEST(CypherMainVisitorTest, EscapedLabel) { auto identifier = dynamic_cast(labels_test->expression_); ASSERT_EQ(identifier->name_, "n"); ASSERT_THAT(labels_test->labels_, - ElementsAre(ast_generator.db_accessor_->label("l-$\"'ab`e``l"))); + ElementsAre(ast_generator.db_accessor_->Label("l-$\"'ab`e``l"))); } TYPED_TEST(CypherMainVisitorTest, KeywordLabel) { @@ -179,7 +179,7 @@ TYPED_TEST(CypherMainVisitorTest, HexLetterLabel) { auto identifier = dynamic_cast(labels_test->expression_); EXPECT_EQ(identifier->name_, "n"); ASSERT_THAT(labels_test->labels_, - ElementsAre(ast_generator.db_accessor_->label("a"))); + ElementsAre(ast_generator.db_accessor_->Label("a"))); } TYPED_TEST(CypherMainVisitorTest, ReturnNoDistinctNoBagSemantics) { @@ -779,9 +779,9 @@ TYPED_TEST(CypherMainVisitorTest, NodePattern) { CypherMainVisitor::kAnonPrefix + std::to_string(1)); EXPECT_FALSE(node->identifier_->user_declared_); EXPECT_THAT(node->labels_, UnorderedElementsAre( - ast_generator.db_accessor_->label("label1"), - ast_generator.db_accessor_->label("label2"), - ast_generator.db_accessor_->label("label3"))); + ast_generator.db_accessor_->Label("label1"), + ast_generator.db_accessor_->Label("label2"), + ast_generator.db_accessor_->Label("label3"))); std::map, int64_t> properties; for (auto x : node->properties_) { auto *literal = dynamic_cast(x.second); @@ -873,8 +873,8 @@ TYPED_TEST(CypherMainVisitorTest, RelationshipPatternDetails) { EXPECT_EQ(edge->direction_, EdgeAtom::Direction::IN); EXPECT_THAT( edge->edge_types_, - UnorderedElementsAre(ast_generator.db_accessor_->edge_type("type1"), - ast_generator.db_accessor_->edge_type("type2"))); + UnorderedElementsAre(ast_generator.db_accessor_->EdgeType("type1"), + ast_generator.db_accessor_->EdgeType("type2"))); std::map, int64_t> properties; for (auto x : edge->properties_) { auto *literal = dynamic_cast(x.second); @@ -1031,7 +1031,7 @@ TYPED_TEST(CypherMainVisitorTest, edge->properties_[ast_generator.PropPair("prop")]); EXPECT_EQ(prop_literal->value_.Value(), 42); ASSERT_EQ(edge->edge_types_.size(), 1U); - auto edge_type = ast_generator.db_accessor_->edge_type("edge_type"); + auto edge_type = ast_generator.db_accessor_->EdgeType("edge_type"); EXPECT_EQ(edge->edge_types_[0], edge_type); } @@ -1155,7 +1155,7 @@ TYPED_TEST(CypherMainVisitorTest, Set) { ASSERT_TRUE(identifier1); ASSERT_EQ(identifier1->name_, "a"); ASSERT_EQ(set_property->property_lookup_->property_, - ast_generator.db_accessor_->property("x")); + ast_generator.db_accessor_->Property("x")); auto *identifier2 = dynamic_cast(set_property->expression_); ASSERT_EQ(identifier2->name_, "b"); } @@ -1190,8 +1190,8 @@ TYPED_TEST(CypherMainVisitorTest, Set) { ASSERT_TRUE(set_labels->identifier_); ASSERT_EQ(set_labels->identifier_->name_, "g"); ASSERT_THAT(set_labels->labels_, - UnorderedElementsAre(ast_generator.db_accessor_->label("h"), - ast_generator.db_accessor_->label("i"))); + UnorderedElementsAre(ast_generator.db_accessor_->Label("h"), + ast_generator.db_accessor_->Label("i"))); } } @@ -1209,7 +1209,7 @@ TYPED_TEST(CypherMainVisitorTest, Remove) { ASSERT_TRUE(identifier1); ASSERT_EQ(identifier1->name_, "a"); ASSERT_EQ(remove_property->property_lookup_->property_, - ast_generator.db_accessor_->property("x")); + ast_generator.db_accessor_->Property("x")); } { auto *remove_labels = dynamic_cast(query->clauses_[1]); @@ -1217,8 +1217,8 @@ TYPED_TEST(CypherMainVisitorTest, Remove) { ASSERT_TRUE(remove_labels->identifier_); ASSERT_EQ(remove_labels->identifier_->name_, "g"); ASSERT_THAT(remove_labels->labels_, - UnorderedElementsAre(ast_generator.db_accessor_->label("h"), - ast_generator.db_accessor_->label("i"))); + UnorderedElementsAre(ast_generator.db_accessor_->Label("h"), + ast_generator.db_accessor_->Label("i"))); } } @@ -1395,9 +1395,9 @@ TYPED_TEST(CypherMainVisitorTest, CreateIndex) { ASSERT_EQ(query->clauses_.size(), 1U); auto *create_index = dynamic_cast(query->clauses_[0]); ASSERT_TRUE(create_index); - ASSERT_EQ(create_index->label_, ast_generator.db_accessor_->label("mirko")); + ASSERT_EQ(create_index->label_, ast_generator.db_accessor_->Label("mirko")); ASSERT_EQ(create_index->property_, - ast_generator.db_accessor_->property("slavko")); + ast_generator.db_accessor_->Property("slavko")); } TYPED_TEST(CypherMainVisitorTest, ReturnAll) { diff --git a/tests/unit/database_key_index.cpp b/tests/unit/database_key_index.cpp index 3399de068..9c3297723 100644 --- a/tests/unit/database_key_index.cpp +++ b/tests/unit/database_key_index.cpp @@ -1,9 +1,9 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" +#include "database/dbms.hpp" #include "database/graph_db_accessor.hpp" #include "database/graph_db_datatypes.hpp" -#include "database/dbms.hpp" #include "storage/vertex.hpp" #include "mvcc_gc_common.hpp" @@ -21,21 +21,21 @@ TEST(LabelsIndex, UniqueInsert) { t1->Commit(); auto t2 = engine.Begin(); - vlist.find(*t2)->labels_.push_back(dba->label("1")); - index.Update(dba->label("1"), &vlist, vlist.find(*t2)); + vlist.find(*t2)->labels_.push_back(dba->Label("1")); + index.Update(dba->Label("1"), &vlist, vlist.find(*t2)); // Try multiple inserts - index.Update(dba->label("1"), &vlist, vlist.find(*t2)); + index.Update(dba->Label("1"), &vlist, vlist.find(*t2)); - vlist.find(*t2)->labels_.push_back(dba->label("2")); - index.Update(dba->label("2"), &vlist, vlist.find(*t2)); + vlist.find(*t2)->labels_.push_back(dba->Label("2")); + index.Update(dba->Label("2"), &vlist, vlist.find(*t2)); - vlist.find(*t2)->labels_.push_back(dba->label("3")); - index.Update(dba->label("3"), &vlist, vlist.find(*t2)); + vlist.find(*t2)->labels_.push_back(dba->Label("3")); + index.Update(dba->Label("3"), &vlist, vlist.find(*t2)); t2->Commit(); - EXPECT_EQ(index.Count(dba->label("1")), 1); - EXPECT_EQ(index.Count(dba->label("2")), 1); - EXPECT_EQ(index.Count(dba->label("3")), 1); + EXPECT_EQ(index.Count(dba->Label("1")), 1); + EXPECT_EQ(index.Count(dba->Label("2")), 1); + EXPECT_EQ(index.Count(dba->Label("3")), 1); } // Check if index filters duplicates. @@ -53,7 +53,7 @@ TEST(LabelsIndex, UniqueFilter) { auto r1v2 = vlist2.find(*t1); EXPECT_NE(vlist1.find(*t1), nullptr); - auto label1 = dba->label("1"); + auto label1 = dba->Label("1"); vlist1.find(*t1)->labels_.push_back(label1); vlist2.find(*t1)->labels_.push_back(label1); index.Update(label1, &vlist1, r1v1); @@ -96,7 +96,7 @@ TEST(LabelsIndex, Refresh) { EXPECT_NE(v1r1, nullptr); EXPECT_NE(v2r1, nullptr); - auto label = access->label("label"); + auto label = access->Label("label"); v1r1->labels_.push_back(label); v2r1->labels_.push_back(label); index.Update(label, &vlist1, v1r1); @@ -122,9 +122,9 @@ TEST(LabelsIndex, Refresh) { TEST(LabelsIndexDb, AddGetZeroLabels) { Dbms dbms; auto dba = dbms.active(); - auto vertex = dba->insert_vertex(); - vertex.add_label(dba->label("test")); - auto collection = dba->vertices(dba->label("test"), false); + auto vertex = dba->InsertVertex(); + vertex.add_label(dba->Label("test")); + auto collection = dba->Vertices(dba->Label("test"), false); std::vector collection_vector(collection.begin(), collection.end()); EXPECT_EQ(collection_vector.size(), (size_t)0); @@ -137,59 +137,59 @@ TEST(LabelsIndexDb, AddGetRemoveLabel) { { auto dba = dbms.active(); - auto vertex1 = dba->insert_vertex(); - vertex1.add_label(dba->label("test")); + auto vertex1 = dba->InsertVertex(); + vertex1.add_label(dba->Label("test")); - auto vertex2 = dba->insert_vertex(); - vertex2.add_label(dba->label("test2")); + auto vertex2 = dba->InsertVertex(); + vertex2.add_label(dba->Label("test2")); - auto vertex3 = dba->insert_vertex(); - vertex3.add_label(dba->label("test")); + auto vertex3 = dba->InsertVertex(); + vertex3.add_label(dba->Label("test")); - dba->commit(); + dba->Commit(); } // Finish transaction. { auto dba = dbms.active(); - auto filtered = dba->vertices(dba->label("test"), false); + auto filtered = dba->Vertices(dba->Label("test"), false); std::vector collection(filtered.begin(), filtered.end()); - auto vertices = dba->vertices(false); + auto vertices = dba->Vertices(false); std::vector expected_collection; for (auto vertex : vertices) { - if (vertex.has_label(dba->label("test"))) { + if (vertex.has_label(dba->Label("test"))) { expected_collection.push_back(vertex); } else { - EXPECT_TRUE(vertex.has_label(dba->label("test2"))); + EXPECT_TRUE(vertex.has_label(dba->Label("test2"))); } } EXPECT_EQ(expected_collection.size(), collection.size()); - EXPECT_TRUE(collection[0].has_label(dba->label("test"))); - EXPECT_TRUE(collection[1].has_label(dba->label("test"))); - EXPECT_FALSE(collection[0].has_label(dba->label("test2"))); - EXPECT_FALSE(collection[1].has_label(dba->label("test2"))); - dba->remove_vertex(collection[0]); // Remove from database and test if - // index won't return it. + EXPECT_TRUE(collection[0].has_label(dba->Label("test"))); + EXPECT_TRUE(collection[1].has_label(dba->Label("test"))); + EXPECT_FALSE(collection[0].has_label(dba->Label("test2"))); + EXPECT_FALSE(collection[1].has_label(dba->Label("test2"))); + dba->RemoveVertex(collection[0]); // Remove from database and test if + // index won't return it. // Remove label from the vertex and add new label. - collection[1].remove_label(dba->label("test")); - collection[1].add_label(dba->label("test2")); - dba->commit(); + collection[1].remove_label(dba->Label("test")); + collection[1].add_label(dba->Label("test2")); + dba->Commit(); } { auto dba = dbms.active(); - auto filtered = dba->vertices(dba->label("test"), false); + auto filtered = dba->Vertices(dba->Label("test"), false); std::vector collection(filtered.begin(), filtered.end()); - auto vertices = dba->vertices(false); + auto vertices = dba->Vertices(false); std::vector expected_collection; for (auto vertex : vertices) { - if (vertex.has_label(dba->label("test"))) { + if (vertex.has_label(dba->Label("test"))) { expected_collection.push_back(vertex); } else { - EXPECT_TRUE(vertex.has_label(dba->label("test2"))); + EXPECT_TRUE(vertex.has_label(dba->Label("test2"))); } } diff --git a/tests/unit/database_label_property_index.cpp b/tests/unit/database_label_property_index.cpp index f6e707918..a9c10d4e6 100644 --- a/tests/unit/database_label_property_index.cpp +++ b/tests/unit/database_label_property_index.cpp @@ -1,9 +1,9 @@ #include "gtest/gtest.h" +#include "database/dbms.hpp" #include "database/graph_db.hpp" #include "database/graph_db_datatypes.hpp" #include "database/indexes/label_property_index.hpp" -#include "database/dbms.hpp" #include "mvcc_gc_common.hpp" @@ -12,10 +12,10 @@ class LabelPropertyIndexComplexTest : public ::testing::Test { virtual void SetUp() { auto accessor = dbms.active(); - label = accessor->label("label"); - property = accessor->property("property"); - label2 = accessor->label("label2"); - property2 = accessor->property("property2"); + label = accessor->Label("label"); + property = accessor->Property("property"); + label2 = accessor->Label("label2"); + property2 = accessor->Property("property2"); key = new LabelPropertyIndex::Key(label, property); EXPECT_EQ(index.CreateIndex(*key), true); @@ -58,8 +58,8 @@ class LabelPropertyIndexComplexTest : public ::testing::Test { TEST(LabelPropertyIndex, CreateIndex) { Dbms dbms; auto accessor = dbms.active(); - LabelPropertyIndex::Key key(accessor->label("test"), - accessor->property("test2")); + LabelPropertyIndex::Key key(accessor->Label("test"), + accessor->Property("test2")); LabelPropertyIndex index; EXPECT_EQ(index.CreateIndex(key), true); EXPECT_EQ(index.CreateIndex(key), false); @@ -68,8 +68,8 @@ TEST(LabelPropertyIndex, CreateIndex) { TEST(LabelPropertyIndex, IndexExistance) { Dbms dbms; auto accessor = dbms.active(); - LabelPropertyIndex::Key key(accessor->label("test"), - accessor->property("test2")); + LabelPropertyIndex::Key key(accessor->Label("test"), + accessor->Property("test2")); LabelPropertyIndex index; EXPECT_EQ(index.CreateIndex(key), true); // Index doesn't exist - and can't be used untill it's been notified as built. @@ -81,8 +81,8 @@ TEST(LabelPropertyIndex, IndexExistance) { TEST(LabelPropertyIndex, Count) { Dbms dbms; auto accessor = dbms.active(); - auto label = accessor->label("label"); - auto property = accessor->property("property"); + auto label = accessor->Label("label"); + auto property = accessor->Property("property"); LabelPropertyIndex::Key key(label, property); LabelPropertyIndex index; ::testing::FLAGS_gtest_death_test_style = "threadsafe"; diff --git a/tests/unit/dbms_recovery.cpp b/tests/unit/dbms_recovery.cpp index dc8187e5f..bb7f1b62e 100644 --- a/tests/unit/dbms_recovery.cpp +++ b/tests/unit/dbms_recovery.cpp @@ -48,12 +48,12 @@ void CreateSnapshot() { auto dba = dbms.active(); // setup (v1) - [:likes] -> (v2) <- [:hates] - (v3) - auto va1 = dba->insert_vertex(); - auto va2 = dba->insert_vertex(); - dba->insert_edge(va1, va2, dba->edge_type("likes")); - auto va3 = dba->insert_vertex(); - dba->insert_edge(va3, va2, dba->edge_type("hates")); - dba->advance_command(); + auto va1 = dba->InsertVertex(); + auto va2 = dba->InsertVertex(); + dba->InsertEdge(va1, va2, dba->EdgeType("likes")); + auto va3 = dba->InsertVertex(); + dba->InsertEdge(va3, va2, dba->EdgeType("hates")); + dba->AdvanceCommand(); Snapshooter snapshooter; EXPECT_EQ(snapshooter.MakeSnapshot(*dba.get(), @@ -70,14 +70,14 @@ void RecoverDbms() { std::vector edges; int vertex_count = 0; - for (auto const &vertex : dba->vertices(false)) { + for (auto const &vertex : dba->Vertices(false)) { vertices.push_back(vertex); vertex_count++; } EXPECT_EQ(vertex_count, 3); int edge_count = 0; - for (auto const &edge : dba->edges(false)) { + for (auto const &edge : dba->Edges(false)) { EXPECT_NE(vertices.end(), std::find(vertices.begin(), vertices.end(), edge.to())); EXPECT_NE(vertices.end(), diff --git a/tests/unit/graph_db_accessor.cpp b/tests/unit/graph_db_accessor.cpp index 016f9cbad..b99084761 100644 --- a/tests/unit/graph_db_accessor.cpp +++ b/tests/unit/graph_db_accessor.cpp @@ -1,9 +1,9 @@ #include #include "gtest/gtest.h" +#include "database/dbms.hpp" #include "database/graph_db.hpp" #include "database/graph_db_accessor.hpp" -#include "database/dbms.hpp" #include "storage/edge_accessor.hpp" #include "storage/vertex_accessor.hpp" @@ -23,37 +23,37 @@ TEST(GraphDbAccessorTest, InsertVertex) { Dbms dbms; auto accessor = dbms.active(); - EXPECT_EQ(Count(accessor->vertices(false)), 0); + EXPECT_EQ(Count(accessor->Vertices(false)), 0); - accessor->insert_vertex(); - EXPECT_EQ(Count(accessor->vertices(false)), 0); - EXPECT_EQ(Count(accessor->vertices(true)), 1); - accessor->advance_command(); - EXPECT_EQ(Count(accessor->vertices(false)), 1); + accessor->InsertVertex(); + EXPECT_EQ(Count(accessor->Vertices(false)), 0); + EXPECT_EQ(Count(accessor->Vertices(true)), 1); + accessor->AdvanceCommand(); + EXPECT_EQ(Count(accessor->Vertices(false)), 1); - accessor->insert_vertex(); - EXPECT_EQ(Count(accessor->vertices(false)), 1); - EXPECT_EQ(Count(accessor->vertices(true)), 2); - accessor->advance_command(); - EXPECT_EQ(Count(accessor->vertices(false)), 2); + accessor->InsertVertex(); + EXPECT_EQ(Count(accessor->Vertices(false)), 1); + EXPECT_EQ(Count(accessor->Vertices(true)), 2); + accessor->AdvanceCommand(); + EXPECT_EQ(Count(accessor->Vertices(false)), 2); } TEST(GraphDbAccessorTest, RemoveVertexSameTransaction) { Dbms dbms; auto accessor = dbms.active(); - EXPECT_EQ(Count(accessor->vertices(false)), 0); + EXPECT_EQ(Count(accessor->Vertices(false)), 0); - auto va1 = accessor->insert_vertex(); - accessor->advance_command(); - EXPECT_EQ(Count(accessor->vertices(false)), 1); + auto va1 = accessor->InsertVertex(); + accessor->AdvanceCommand(); + EXPECT_EQ(Count(accessor->Vertices(false)), 1); - EXPECT_TRUE(accessor->remove_vertex(va1)); - EXPECT_EQ(Count(accessor->vertices(false)), 1); - EXPECT_EQ(Count(accessor->vertices(true)), 0); - accessor->advance_command(); - EXPECT_EQ(Count(accessor->vertices(false)), 0); - EXPECT_EQ(Count(accessor->vertices(true)), 0); + EXPECT_TRUE(accessor->RemoveVertex(va1)); + EXPECT_EQ(Count(accessor->Vertices(false)), 1); + EXPECT_EQ(Count(accessor->Vertices(true)), 0); + accessor->AdvanceCommand(); + EXPECT_EQ(Count(accessor->Vertices(false)), 0); + EXPECT_EQ(Count(accessor->Vertices(true)), 0); } TEST(GraphDbAccessorTest, RemoveVertexDifferentTransaction) { @@ -61,42 +61,42 @@ TEST(GraphDbAccessorTest, RemoveVertexDifferentTransaction) { // first transaction creates a vertex auto accessor1 = dbms.active(); - accessor1->insert_vertex(); - accessor1->commit(); + accessor1->InsertVertex(); + accessor1->Commit(); // second transaction checks that it sees it, and deletes it auto accessor2 = dbms.active(); - EXPECT_EQ(Count(accessor2->vertices(false)), 1); - EXPECT_EQ(Count(accessor2->vertices(true)), 1); - for (auto vertex_accessor : accessor2->vertices(false)) - accessor2->remove_vertex(vertex_accessor); - accessor2->commit(); + EXPECT_EQ(Count(accessor2->Vertices(false)), 1); + EXPECT_EQ(Count(accessor2->Vertices(true)), 1); + for (auto vertex_accessor : accessor2->Vertices(false)) + accessor2->RemoveVertex(vertex_accessor); + accessor2->Commit(); // third transaction checks that it does not see the vertex auto accessor3 = dbms.active(); - EXPECT_EQ(Count(accessor3->vertices(false)), 0); - EXPECT_EQ(Count(accessor3->vertices(true)), 0); + EXPECT_EQ(Count(accessor3->Vertices(false)), 0); + EXPECT_EQ(Count(accessor3->Vertices(true)), 0); } TEST(GraphDbAccessorTest, InsertEdge) { Dbms dbms; auto dba = dbms.active(); - auto va1 = dba->insert_vertex(); - auto va2 = dba->insert_vertex(); - dba->advance_command(); + auto va1 = dba->InsertVertex(); + auto va2 = dba->InsertVertex(); + dba->AdvanceCommand(); EXPECT_EQ(va1.in_degree(), 0); EXPECT_EQ(va1.out_degree(), 0); EXPECT_EQ(va2.in_degree(), 0); EXPECT_EQ(va2.out_degree(), 0); // setup (v1) - [:likes] -> (v2) - dba->insert_edge(va1, va2, dba->edge_type("likes")); - EXPECT_EQ(Count(dba->edges(false)), 0); - EXPECT_EQ(Count(dba->edges(true)), 1); - dba->advance_command(); - EXPECT_EQ(Count(dba->edges(false)), 1); - EXPECT_EQ(Count(dba->edges(true)), 1); + dba->InsertEdge(va1, va2, dba->EdgeType("likes")); + EXPECT_EQ(Count(dba->Edges(false)), 0); + EXPECT_EQ(Count(dba->Edges(true)), 1); + dba->AdvanceCommand(); + EXPECT_EQ(Count(dba->Edges(false)), 1); + EXPECT_EQ(Count(dba->Edges(true)), 1); EXPECT_EQ(va1.out().begin()->to(), va2); EXPECT_EQ(va2.in().begin()->from(), va1); EXPECT_EQ(va1.in_degree(), 0); @@ -105,12 +105,12 @@ TEST(GraphDbAccessorTest, InsertEdge) { EXPECT_EQ(va2.out_degree(), 0); // setup (v1) - [:likes] -> (v2) <- [:hates] - (v3) - auto va3 = dba->insert_vertex(); - dba->insert_edge(va3, va2, dba->edge_type("hates")); - EXPECT_EQ(Count(dba->edges(false)), 1); - EXPECT_EQ(Count(dba->edges(true)), 2); - dba->advance_command(); - EXPECT_EQ(Count(dba->edges(false)), 2); + auto va3 = dba->InsertVertex(); + dba->InsertEdge(va3, va2, dba->EdgeType("hates")); + EXPECT_EQ(Count(dba->Edges(false)), 1); + EXPECT_EQ(Count(dba->Edges(true)), 2); + dba->AdvanceCommand(); + EXPECT_EQ(Count(dba->Edges(false)), 2); EXPECT_EQ(va3.out().begin()->to(), va2); EXPECT_EQ(va1.in_degree(), 0); EXPECT_EQ(va1.out_degree(), 1); @@ -125,34 +125,34 @@ TEST(GraphDbAccessorTest, RemoveEdge) { auto dba = dbms.active(); // setup (v1) - [:likes] -> (v2) <- [:hates] - (v3) - auto va1 = dba->insert_vertex(); - auto va2 = dba->insert_vertex(); - auto va3 = dba->insert_vertex(); - dba->insert_edge(va1, va2, dba->edge_type("likes")); - dba->insert_edge(va3, va2, dba->edge_type("hates")); - dba->advance_command(); - EXPECT_EQ(Count(dba->edges(false)), 2); - EXPECT_EQ(Count(dba->edges(true)), 2); + auto va1 = dba->InsertVertex(); + auto va2 = dba->InsertVertex(); + auto va3 = dba->InsertVertex(); + dba->InsertEdge(va1, va2, dba->EdgeType("likes")); + dba->InsertEdge(va3, va2, dba->EdgeType("hates")); + dba->AdvanceCommand(); + EXPECT_EQ(Count(dba->Edges(false)), 2); + EXPECT_EQ(Count(dba->Edges(true)), 2); // remove all [:hates] edges - for (auto edge : dba->edges(false)) - if (edge.edge_type() == dba->edge_type("hates")) dba->remove_edge(edge); - EXPECT_EQ(Count(dba->edges(false)), 2); - EXPECT_EQ(Count(dba->edges(true)), 1); + for (auto edge : dba->Edges(false)) + if (edge.EdgeType() == dba->EdgeType("hates")) dba->RemoveEdge(edge); + EXPECT_EQ(Count(dba->Edges(false)), 2); + EXPECT_EQ(Count(dba->Edges(true)), 1); // current state: (v1) - [:likes] -> (v2), (v3) - dba->advance_command(); - EXPECT_EQ(Count(dba->edges(false)), 1); - EXPECT_EQ(Count(dba->edges(true)), 1); - EXPECT_EQ(Count(dba->vertices(false)), 3); - EXPECT_EQ(Count(dba->vertices(true)), 3); - for (auto edge : dba->edges(false)) { - EXPECT_EQ(edge.edge_type(), dba->edge_type("likes")); + dba->AdvanceCommand(); + EXPECT_EQ(Count(dba->Edges(false)), 1); + EXPECT_EQ(Count(dba->Edges(true)), 1); + EXPECT_EQ(Count(dba->Vertices(false)), 3); + EXPECT_EQ(Count(dba->Vertices(true)), 3); + for (auto edge : dba->Edges(false)) { + EXPECT_EQ(edge.EdgeType(), dba->EdgeType("likes")); auto v1 = edge.from(); auto v2 = edge.to(); // ensure correct connectivity for all the vertices - for (auto vertex : dba->vertices(false)) { + for (auto vertex : dba->Vertices(false)) { if (vertex == v1) { EXPECT_EQ(vertex.in_degree(), 0); EXPECT_EQ(vertex.out_degree(), 1); @@ -173,69 +173,69 @@ TEST(GraphDbAccessorTest, DetachRemoveVertex) { // setup (v0)- []->(v1)<-[]-(v2)<-[]-(v3) std::vector vertices; - for (int i = 0; i < 4; ++i) vertices.emplace_back(dba->insert_vertex()); + for (int i = 0; i < 4; ++i) vertices.emplace_back(dba->InsertVertex()); - auto edge_type = dba->edge_type("type"); - dba->insert_edge(vertices[0], vertices[1], edge_type); - dba->insert_edge(vertices[2], vertices[1], edge_type); - dba->insert_edge(vertices[3], vertices[2], edge_type); + auto edge_type = dba->EdgeType("type"); + dba->InsertEdge(vertices[0], vertices[1], edge_type); + dba->InsertEdge(vertices[2], vertices[1], edge_type); + dba->InsertEdge(vertices[3], vertices[2], edge_type); - dba->advance_command(); + dba->AdvanceCommand(); for (auto &vertex : vertices) vertex.Reconstruct(); // ensure that plain remove does NOT work - EXPECT_EQ(Count(dba->vertices(false)), 4); - EXPECT_EQ(Count(dba->edges(false)), 3); - EXPECT_FALSE(dba->remove_vertex(vertices[0])); - EXPECT_FALSE(dba->remove_vertex(vertices[1])); - EXPECT_FALSE(dba->remove_vertex(vertices[2])); - EXPECT_EQ(Count(dba->vertices(false)), 4); - EXPECT_EQ(Count(dba->edges(false)), 3); + EXPECT_EQ(Count(dba->Vertices(false)), 4); + EXPECT_EQ(Count(dba->Edges(false)), 3); + EXPECT_FALSE(dba->RemoveVertex(vertices[0])); + EXPECT_FALSE(dba->RemoveVertex(vertices[1])); + EXPECT_FALSE(dba->RemoveVertex(vertices[2])); + EXPECT_EQ(Count(dba->Vertices(false)), 4); + EXPECT_EQ(Count(dba->Edges(false)), 3); - dba->detach_remove_vertex(vertices[2]); - EXPECT_EQ(Count(dba->vertices(false)), 4); - EXPECT_EQ(Count(dba->vertices(true)), 3); - EXPECT_EQ(Count(dba->edges(false)), 3); - EXPECT_EQ(Count(dba->edges(true)), 1); - dba->advance_command(); + dba->DetachRemoveVertex(vertices[2]); + EXPECT_EQ(Count(dba->Vertices(false)), 4); + EXPECT_EQ(Count(dba->Vertices(true)), 3); + EXPECT_EQ(Count(dba->Edges(false)), 3); + EXPECT_EQ(Count(dba->Edges(true)), 1); + dba->AdvanceCommand(); for (auto &vertex : vertices) vertex.Reconstruct(); - EXPECT_EQ(Count(dba->vertices(false)), 3); - EXPECT_EQ(Count(dba->edges(false)), 1); - EXPECT_TRUE(dba->remove_vertex(vertices[3])); - EXPECT_EQ(Count(dba->vertices(true)), 2); - EXPECT_EQ(Count(dba->vertices(false)), 3); - dba->advance_command(); + EXPECT_EQ(Count(dba->Vertices(false)), 3); + EXPECT_EQ(Count(dba->Edges(false)), 1); + EXPECT_TRUE(dba->RemoveVertex(vertices[3])); + EXPECT_EQ(Count(dba->Vertices(true)), 2); + EXPECT_EQ(Count(dba->Vertices(false)), 3); + dba->AdvanceCommand(); for (auto &vertex : vertices) vertex.Reconstruct(); - EXPECT_EQ(Count(dba->vertices(false)), 2); - EXPECT_EQ(Count(dba->edges(false)), 1); - for (auto va : dba->vertices(false)) EXPECT_FALSE(dba->remove_vertex(va)); - dba->advance_command(); + EXPECT_EQ(Count(dba->Vertices(false)), 2); + EXPECT_EQ(Count(dba->Edges(false)), 1); + for (auto va : dba->Vertices(false)) EXPECT_FALSE(dba->RemoveVertex(va)); + dba->AdvanceCommand(); for (auto &vertex : vertices) vertex.Reconstruct(); - EXPECT_EQ(Count(dba->vertices(false)), 2); - EXPECT_EQ(Count(dba->edges(false)), 1); - for (auto va : dba->vertices(false)) { - EXPECT_FALSE(dba->remove_vertex(va)); - dba->detach_remove_vertex(va); + EXPECT_EQ(Count(dba->Vertices(false)), 2); + EXPECT_EQ(Count(dba->Edges(false)), 1); + for (auto va : dba->Vertices(false)) { + EXPECT_FALSE(dba->RemoveVertex(va)); + dba->DetachRemoveVertex(va); break; } - EXPECT_EQ(Count(dba->vertices(true)), 1); - EXPECT_EQ(Count(dba->vertices(false)), 2); - dba->advance_command(); + EXPECT_EQ(Count(dba->Vertices(true)), 1); + EXPECT_EQ(Count(dba->Vertices(false)), 2); + dba->AdvanceCommand(); for (auto &vertex : vertices) vertex.Reconstruct(); - EXPECT_EQ(Count(dba->vertices(false)), 1); - EXPECT_EQ(Count(dba->edges(false)), 0); + EXPECT_EQ(Count(dba->Vertices(false)), 1); + EXPECT_EQ(Count(dba->Edges(false)), 0); // remove the last vertex, it has no connections // so that should work - for (auto va : dba->vertices(false)) EXPECT_TRUE(dba->remove_vertex(va)); - dba->advance_command(); + for (auto va : dba->Vertices(false)) EXPECT_TRUE(dba->RemoveVertex(va)); + dba->AdvanceCommand(); - EXPECT_EQ(Count(dba->vertices(false)), 0); - EXPECT_EQ(Count(dba->edges(false)), 0); + EXPECT_EQ(Count(dba->Vertices(false)), 0); + EXPECT_EQ(Count(dba->Edges(false)), 0); } TEST(GraphDbAccessorTest, DetachRemoveVertexMultiple) { @@ -249,93 +249,93 @@ TEST(GraphDbAccessorTest, DetachRemoveVertexMultiple) { // with cycles too! int N = 7; std::vector vertices; - auto edge_type = dba->edge_type("edge"); - for (int i = 0; i < N; ++i) vertices.emplace_back(dba->insert_vertex()); + auto edge_type = dba->EdgeType("edge"); + for (int i = 0; i < N; ++i) vertices.emplace_back(dba->InsertVertex()); for (int j = 0; j < N; ++j) for (int k = 0; k < N; ++k) - dba->insert_edge(vertices[j], vertices[k], edge_type); + dba->InsertEdge(vertices[j], vertices[k], edge_type); - dba->advance_command(); + dba->AdvanceCommand(); for (auto &vertex : vertices) vertex.Reconstruct(); - EXPECT_EQ(Count(dba->vertices(false)), N); - EXPECT_EQ(Count(dba->edges(false)), N * N); + EXPECT_EQ(Count(dba->Vertices(false)), N); + EXPECT_EQ(Count(dba->Edges(false)), N * N); // detach delete one edge - dba->detach_remove_vertex(vertices[0]); - dba->advance_command(); + dba->DetachRemoveVertex(vertices[0]); + dba->AdvanceCommand(); for (auto &vertex : vertices) vertex.Reconstruct(); - EXPECT_EQ(Count(dba->vertices(false)), N - 1); - EXPECT_EQ(Count(dba->edges(false)), (N - 1) * (N - 1)); + EXPECT_EQ(Count(dba->Vertices(false)), N - 1); + EXPECT_EQ(Count(dba->Edges(false)), (N - 1) * (N - 1)); // detach delete two neighboring edges - dba->detach_remove_vertex(vertices[1]); - dba->detach_remove_vertex(vertices[2]); - dba->advance_command(); + dba->DetachRemoveVertex(vertices[1]); + dba->DetachRemoveVertex(vertices[2]); + dba->AdvanceCommand(); for (auto &vertex : vertices) vertex.Reconstruct(); - EXPECT_EQ(Count(dba->vertices(false)), N - 3); - EXPECT_EQ(Count(dba->edges(false)), (N - 3) * (N - 3)); + EXPECT_EQ(Count(dba->Vertices(false)), N - 3); + EXPECT_EQ(Count(dba->Edges(false)), (N - 3) * (N - 3)); // detach delete everything, buwahahahaha - for (int l = 3; l < N; ++l) dba->detach_remove_vertex(vertices[l]); - dba->advance_command(); + for (int l = 3; l < N; ++l) dba->DetachRemoveVertex(vertices[l]); + dba->AdvanceCommand(); for (auto &vertex : vertices) vertex.Reconstruct(); - EXPECT_EQ(Count(dba->vertices(false)), 0); - EXPECT_EQ(Count(dba->edges(false)), 0); + EXPECT_EQ(Count(dba->Vertices(false)), 0); + EXPECT_EQ(Count(dba->Edges(false)), 0); } TEST(GraphDbAccessorTest, Labels) { Dbms dbms; auto dba1 = dbms.active(); - GraphDbTypes::Label label_friend = dba1->label("friend"); - EXPECT_EQ(label_friend, dba1->label("friend")); - EXPECT_NE(label_friend, dba1->label("friend2")); - EXPECT_EQ(dba1->label_name(label_friend), "friend"); + GraphDbTypes::Label label_friend = dba1->Label("friend"); + EXPECT_EQ(label_friend, dba1->Label("friend")); + EXPECT_NE(label_friend, dba1->Label("friend2")); + EXPECT_EQ(dba1->LabelName(label_friend), "friend"); // test that getting labels through a different accessor works - EXPECT_EQ(label_friend, dbms.active()->label("friend")); - EXPECT_NE(label_friend, dbms.active()->label("friend2")); + EXPECT_EQ(label_friend, dbms.active()->Label("friend")); + EXPECT_NE(label_friend, dbms.active()->Label("friend2")); } TEST(GraphDbAccessorTest, EdgeTypes) { Dbms dbms; auto dba1 = dbms.active(); - GraphDbTypes::EdgeType edge_type = dba1->edge_type("likes"); - EXPECT_EQ(edge_type, dba1->edge_type("likes")); - EXPECT_NE(edge_type, dba1->edge_type("hates")); - EXPECT_EQ(dba1->edge_type_name(edge_type), "likes"); + GraphDbTypes::EdgeType edge_type = dba1->EdgeType("likes"); + EXPECT_EQ(edge_type, dba1->EdgeType("likes")); + EXPECT_NE(edge_type, dba1->EdgeType("hates")); + EXPECT_EQ(dba1->EdgeTypeName(edge_type), "likes"); // test that getting labels through a different accessor works - EXPECT_EQ(edge_type, dbms.active()->edge_type("likes")); - EXPECT_NE(edge_type, dbms.active()->edge_type("hates")); + EXPECT_EQ(edge_type, dbms.active()->EdgeType("likes")); + EXPECT_NE(edge_type, dbms.active()->EdgeType("hates")); } TEST(GraphDbAccessorTest, Properties) { Dbms dbms; auto dba1 = dbms.active(); - GraphDbTypes::EdgeType prop = dba1->property("name"); - EXPECT_EQ(prop, dba1->property("name")); - EXPECT_NE(prop, dba1->property("surname")); - EXPECT_EQ(dba1->property_name(prop), "name"); + GraphDbTypes::EdgeType prop = dba1->Property("name"); + EXPECT_EQ(prop, dba1->Property("name")); + EXPECT_NE(prop, dba1->Property("surname")); + EXPECT_EQ(dba1->PropertyName(prop), "name"); // test that getting labels through a different accessor works - EXPECT_EQ(prop, dbms.active()->property("name")); - EXPECT_NE(prop, dbms.active()->property("surname")); + EXPECT_EQ(prop, dbms.active()->Property("name")); + EXPECT_NE(prop, dbms.active()->Property("surname")); } TEST(GraphDbAccessorTest, Transfer) { Dbms dbms; auto dba1 = dbms.active(); - auto prop = dba1->property("property"); - VertexAccessor v1 = dba1->insert_vertex(); + auto prop = dba1->Property("property"); + VertexAccessor v1 = dba1->InsertVertex(); v1.PropsSet(prop, 1); - VertexAccessor v2 = dba1->insert_vertex(); + VertexAccessor v2 = dba1->InsertVertex(); v2.PropsSet(prop, 2); - EdgeAccessor e12 = dba1->insert_edge(v1, v2, dba1->edge_type("et")); + EdgeAccessor e12 = dba1->InsertEdge(v1, v2, dba1->EdgeType("et")); e12.PropsSet(prop, 12); // make dba2 that has dba1 in it's snapshot, so data isn't visible @@ -344,7 +344,7 @@ TEST(GraphDbAccessorTest, Transfer) { EXPECT_EQ(dba2->Transfer(e12), std::experimental::nullopt); // make dba3 that does not have dba1 in it's snapshot - dba1->commit(); + dba1->Commit(); auto dba3 = dbms.active(); // we can transfer accessors even though the GraphDbAccessor they // belong to is not alive anymore diff --git a/tests/unit/graph_db_accessor_index_api.cpp b/tests/unit/graph_db_accessor_index_api.cpp index 8f1bc595a..81e542138 100644 --- a/tests/unit/graph_db_accessor_index_api.cpp +++ b/tests/unit/graph_db_accessor_index_api.cpp @@ -23,18 +23,18 @@ class GraphDbAccessorIndex : public testing::Test { protected: Dbms dbms; std::unique_ptr dba = dbms.active(); - GraphDbTypes::Property property = dba->property("property"); - GraphDbTypes::Label label = dba->label("label"); - GraphDbTypes::EdgeType edge_type = dba->edge_type("edge_type"); + GraphDbTypes::Property property = dba->Property("property"); + GraphDbTypes::Label label = dba->Label("label"); + GraphDbTypes::EdgeType edge_type = dba->EdgeType("edge_type"); auto AddVertex() { - auto vertex = dba->insert_vertex(); + auto vertex = dba->InsertVertex(); vertex.add_label(label); return vertex; } auto AddVertex(int property_value) { - auto vertex = dba->insert_vertex(); + auto vertex = dba->InsertVertex(); vertex.add_label(label); vertex.PropsSet(property, property_value); return vertex; @@ -42,63 +42,63 @@ class GraphDbAccessorIndex : public testing::Test { // commits the current dba, and replaces it with a new one void Commit() { - dba->commit(); + dba->Commit(); auto dba2 = dbms.active(); dba.swap(dba2); } }; TEST_F(GraphDbAccessorIndex, LabelIndexCount) { - auto label2 = dba->label("label2"); - EXPECT_EQ(dba->vertices_count(label), 0); - EXPECT_EQ(dba->vertices_count(label2), 0); - EXPECT_EQ(dba->vertices_count(), 0); - for (int i = 0; i < 11; ++i) dba->insert_vertex().add_label(label); - for (int i = 0; i < 17; ++i) dba->insert_vertex().add_label(label2); + auto label2 = dba->Label("label2"); + EXPECT_EQ(dba->VerticesCount(label), 0); + EXPECT_EQ(dba->VerticesCount(label2), 0); + EXPECT_EQ(dba->VerticesCount(), 0); + for (int i = 0; i < 11; ++i) dba->InsertVertex().add_label(label); + for (int i = 0; i < 17; ++i) dba->InsertVertex().add_label(label2); // even though xxx_count functions in GraphDbAccessor can over-estaimate // in this situation they should be exact (nothing was ever deleted) - EXPECT_EQ(dba->vertices_count(label), 11); - EXPECT_EQ(dba->vertices_count(label2), 17); - EXPECT_EQ(dba->vertices_count(), 28); + EXPECT_EQ(dba->VerticesCount(label), 11); + EXPECT_EQ(dba->VerticesCount(label2), 17); + EXPECT_EQ(dba->VerticesCount(), 28); } TEST_F(GraphDbAccessorIndex, LabelIndexIteration) { // add 10 vertices, check visibility for (int i = 0; i < 10; i++) AddVertex(); - EXPECT_EQ(Count(dba->vertices(label, false)), 0); - EXPECT_EQ(Count(dba->vertices(label, true)), 10); + EXPECT_EQ(Count(dba->Vertices(label, false)), 0); + EXPECT_EQ(Count(dba->Vertices(label, true)), 10); Commit(); - EXPECT_EQ(Count(dba->vertices(label, false)), 10); - EXPECT_EQ(Count(dba->vertices(label, true)), 10); + EXPECT_EQ(Count(dba->Vertices(label, false)), 10); + EXPECT_EQ(Count(dba->Vertices(label, true)), 10); // remove 3 vertices, check visibility int deleted = 0; - for (auto vertex : dba->vertices(false)) { - dba->remove_vertex(vertex); + for (auto vertex : dba->Vertices(false)) { + dba->RemoveVertex(vertex); if (++deleted >= 3) break; } - EXPECT_EQ(Count(dba->vertices(label, false)), 10); - EXPECT_EQ(Count(dba->vertices(label, true)), 7); + EXPECT_EQ(Count(dba->Vertices(label, false)), 10); + EXPECT_EQ(Count(dba->Vertices(label, true)), 7); Commit(); - EXPECT_EQ(Count(dba->vertices(label, false)), 7); - EXPECT_EQ(Count(dba->vertices(label, true)), 7); + EXPECT_EQ(Count(dba->Vertices(label, false)), 7); + EXPECT_EQ(Count(dba->Vertices(label, true)), 7); } TEST_F(GraphDbAccessorIndex, EdgeTypeCount) { - auto edge_type2 = dba->edge_type("edge_type2"); - EXPECT_EQ(dba->edges_count(edge_type), 0); - EXPECT_EQ(dba->edges_count(edge_type2), 0); - EXPECT_EQ(dba->edges_count(), 0); + auto edge_type2 = dba->EdgeType("edge_type2"); + EXPECT_EQ(dba->EdgesCount(edge_type), 0); + EXPECT_EQ(dba->EdgesCount(edge_type2), 0); + EXPECT_EQ(dba->EdgesCount(), 0); auto v1 = AddVertex(); auto v2 = AddVertex(); - for (int i = 0; i < 11; ++i) dba->insert_edge(v1, v2, edge_type); - for (int i = 0; i < 17; ++i) dba->insert_edge(v1, v2, edge_type2); + for (int i = 0; i < 11; ++i) dba->InsertEdge(v1, v2, edge_type); + for (int i = 0; i < 17; ++i) dba->InsertEdge(v1, v2, edge_type2); // even though xxx_count functions in GraphDbAccessor can over-estaimate // in this situation they should be exact (nothing was ever deleted) - EXPECT_EQ(dba->edges_count(edge_type), 11); - EXPECT_EQ(dba->edges_count(edge_type2), 17); - EXPECT_EQ(dba->edges_count(), 28); + EXPECT_EQ(dba->EdgesCount(edge_type), 11); + EXPECT_EQ(dba->EdgesCount(edge_type2), 17); + EXPECT_EQ(dba->EdgesCount(), 28); } TEST_F(GraphDbAccessorIndex, LabelPropertyIndexBuild) { @@ -108,18 +108,18 @@ TEST_F(GraphDbAccessorIndex, LabelPropertyIndexBuild) { dba->BuildIndex(label, property); Commit(); - EXPECT_EQ(dba->vertices_count(label, property), 1); + EXPECT_EQ(dba->VerticesCount(label, property), 1); // confirm there is a differentiation of indexes based on (label, property) - auto label2 = dba->label("label2"); - auto property2 = dba->property("property2"); + auto label2 = dba->Label("label2"); + auto property2 = dba->Property("property2"); dba->BuildIndex(label2, property); dba->BuildIndex(label, property2); Commit(); - EXPECT_EQ(dba->vertices_count(label, property), 1); - EXPECT_EQ(dba->vertices_count(label2, property), 0); - EXPECT_EQ(dba->vertices_count(label, property2), 0); + EXPECT_EQ(dba->VerticesCount(label, property), 1); + EXPECT_EQ(dba->VerticesCount(label2, property), 0); + EXPECT_EQ(dba->VerticesCount(label, property2), 0); } TEST_F(GraphDbAccessorIndex, LabelPropertyIndexBuildTwice) { @@ -129,11 +129,11 @@ TEST_F(GraphDbAccessorIndex, LabelPropertyIndexBuildTwice) { TEST_F(GraphDbAccessorIndex, LabelPropertyIndexCount) { dba->BuildIndex(label, property); - EXPECT_EQ(dba->vertices_count(label, property), 0); - EXPECT_EQ(Count(dba->vertices(label, property)), 0); + EXPECT_EQ(dba->VerticesCount(label, property), 0); + EXPECT_EQ(Count(dba->Vertices(label, property)), 0); for (int i = 0; i < 14; ++i) AddVertex(0); - EXPECT_EQ(dba->vertices_count(label, property), 14); - EXPECT_EQ(Count(dba->vertices(label, property)), 14); + EXPECT_EQ(dba->VerticesCount(label, property), 14); + EXPECT_EQ(Count(dba->Vertices(label, property)), 14); } #define EXPECT_WITH_MARGIN(x, center) \ @@ -152,11 +152,11 @@ TEST_F(GraphDbAccessorIndex, LabelPropertyValueCount) { for (int i = 0; i < 1000; i++) AddVertex(30 + i / 100); // test estimates for exact value count - EXPECT_WITH_MARGIN(dba->vertices_count(label, property, 10), 10); - EXPECT_WITH_MARGIN(dba->vertices_count(label, property, 14), 10); - EXPECT_WITH_MARGIN(dba->vertices_count(label, property, 30), 100); - EXPECT_WITH_MARGIN(dba->vertices_count(label, property, 39), 100); - EXPECT_EQ(dba->vertices_count(label, property, 40), 0); + EXPECT_WITH_MARGIN(dba->VerticesCount(label, property, 10), 10); + EXPECT_WITH_MARGIN(dba->VerticesCount(label, property, 14), 10); + EXPECT_WITH_MARGIN(dba->VerticesCount(label, property, 30), 100); + EXPECT_WITH_MARGIN(dba->VerticesCount(label, property, 39), 100); + EXPECT_EQ(dba->VerticesCount(label, property, 40), 0); // helper functions auto Inclusive = [](int64_t value) { @@ -167,21 +167,21 @@ TEST_F(GraphDbAccessorIndex, LabelPropertyValueCount) { return std::experimental::make_optional( utils::MakeBoundExclusive(PropertyValue(value))); }; - auto vertices_count = [this](auto lower, auto upper) { - return dba->vertices_count(label, property, lower, upper); + auto VerticesCount = [this](auto lower, auto upper) { + return dba->VerticesCount(label, property, lower, upper); }; using std::experimental::nullopt; ::testing::FLAGS_gtest_death_test_style = "threadsafe"; - EXPECT_DEATH(vertices_count(nullopt, nullopt), "bound must be provided"); - EXPECT_WITH_MARGIN(vertices_count(nullopt, Exclusive(4)), 40); - EXPECT_WITH_MARGIN(vertices_count(nullopt, Inclusive(4)), 50); - EXPECT_WITH_MARGIN(vertices_count(Exclusive(13), nullopt), 160 + 1000); - EXPECT_WITH_MARGIN(vertices_count(Inclusive(13), nullopt), 170 + 1000); - EXPECT_WITH_MARGIN(vertices_count(Inclusive(13), Exclusive(14)), 10); - EXPECT_WITH_MARGIN(vertices_count(Exclusive(13), Inclusive(14)), 10); - EXPECT_WITH_MARGIN(vertices_count(Exclusive(13), Exclusive(13)), 0); - EXPECT_WITH_MARGIN(vertices_count(Inclusive(20), Exclusive(13)), 0); + EXPECT_DEATH(VerticesCount(nullopt, nullopt), "bound must be provided"); + EXPECT_WITH_MARGIN(VerticesCount(nullopt, Exclusive(4)), 40); + EXPECT_WITH_MARGIN(VerticesCount(nullopt, Inclusive(4)), 50); + EXPECT_WITH_MARGIN(VerticesCount(Exclusive(13), nullopt), 160 + 1000); + EXPECT_WITH_MARGIN(VerticesCount(Inclusive(13), nullopt), 170 + 1000); + EXPECT_WITH_MARGIN(VerticesCount(Inclusive(13), Exclusive(14)), 10); + EXPECT_WITH_MARGIN(VerticesCount(Exclusive(13), Inclusive(14)), 10); + EXPECT_WITH_MARGIN(VerticesCount(Exclusive(13), Exclusive(13)), 0); + EXPECT_WITH_MARGIN(VerticesCount(Inclusive(20), Exclusive(13)), 0); } #undef EXPECT_WITH_MARGIN @@ -192,11 +192,11 @@ TEST_F(GraphDbAccessorIndex, LabelPropertyValueIteration) { // insert 10 verties and and check visibility for (int i = 0; i < 10; i++) AddVertex(12); - EXPECT_EQ(Count(dba->vertices(label, property, 12, false)), 0); - EXPECT_EQ(Count(dba->vertices(label, property, 12, true)), 10); + EXPECT_EQ(Count(dba->Vertices(label, property, 12, false)), 0); + EXPECT_EQ(Count(dba->Vertices(label, property, 12, true)), 10); Commit(); - EXPECT_EQ(Count(dba->vertices(label, property, 12, false)), 10); - EXPECT_EQ(Count(dba->vertices(label, property, 12, true)), 10); + EXPECT_EQ(Count(dba->Vertices(label, property, 12, false)), 10); + EXPECT_EQ(Count(dba->Vertices(label, property, 12, true)), 10); } TEST_F(GraphDbAccessorIndex, LabelPropertyValueSorting) { @@ -207,7 +207,7 @@ TEST_F(GraphDbAccessorIndex, LabelPropertyValueSorting) { // strings for (int i = 0; i < 10; ++i) { - auto vertex_accessor = dba->insert_vertex(); + auto vertex_accessor = dba->InsertVertex(); vertex_accessor.add_label(label); vertex_accessor.PropsSet(property, static_cast(std::to_string(i))); @@ -215,7 +215,7 @@ TEST_F(GraphDbAccessorIndex, LabelPropertyValueSorting) { } // bools - insert in reverse to check for comparison between values. for (int i = 9; i >= 0; --i) { - auto vertex_accessor = dba->insert_vertex(); + auto vertex_accessor = dba->InsertVertex(); vertex_accessor.add_label(label); vertex_accessor.PropsSet(property, static_cast(i / 5)); expected_property_value[10 + i] = vertex_accessor.PropsAt(property); @@ -223,14 +223,14 @@ TEST_F(GraphDbAccessorIndex, LabelPropertyValueSorting) { // integers for (int i = 0; i < 10; ++i) { - auto vertex_accessor = dba->insert_vertex(); + auto vertex_accessor = dba->InsertVertex(); vertex_accessor.add_label(label); vertex_accessor.PropsSet(property, i); expected_property_value[20 + 2 * i] = vertex_accessor.PropsAt(property); } // doubles for (int i = 0; i < 10; ++i) { - auto vertex_accessor = dba->insert_vertex(); + auto vertex_accessor = dba->InsertVertex(); vertex_accessor.add_label(label); vertex_accessor.PropsSet(property, static_cast(i + 0.5)); expected_property_value[20 + 2 * i + 1] = vertex_accessor.PropsAt(property); @@ -239,7 +239,7 @@ TEST_F(GraphDbAccessorIndex, LabelPropertyValueSorting) { // lists of ints - insert in reverse to check for comparision between // lists. for (int i = 9; i >= 0; --i) { - auto vertex_accessor = dba->insert_vertex(); + auto vertex_accessor = dba->InsertVertex(); vertex_accessor.add_label(label); std::vector value; value.push_back(PropertyValue(i)); @@ -247,11 +247,11 @@ TEST_F(GraphDbAccessorIndex, LabelPropertyValueSorting) { expected_property_value[40 + i] = vertex_accessor.PropsAt(property); } - EXPECT_EQ(Count(dba->vertices(label, property, false)), 0); - EXPECT_EQ(Count(dba->vertices(label, property, true)), 50); + EXPECT_EQ(Count(dba->Vertices(label, property, false)), 0); + EXPECT_EQ(Count(dba->Vertices(label, property, true)), 50); int cnt = 0; - for (auto vertex : dba->vertices(label, property, true)) { + for (auto vertex : dba->Vertices(label, property, true)) { const PropertyValue &property_value = vertex.PropsAt(property); EXPECT_EQ(property_value.type(), expected_property_value[cnt].type()); switch (property_value.type()) { @@ -300,16 +300,16 @@ class GraphDbAccesssorIndexRange : public GraphDbAccessorIndex { dba->BuildIndex(label, property); for (int i = 0; i < 100; i++) AddVertex(i / 10); - ASSERT_EQ(Count(dba->vertices(false)), 0); - ASSERT_EQ(Count(dba->vertices(true)), 100); + ASSERT_EQ(Count(dba->Vertices(false)), 0); + ASSERT_EQ(Count(dba->Vertices(true)), 100); Commit(); - ASSERT_EQ(Count(dba->vertices(false)), 100); + ASSERT_EQ(Count(dba->Vertices(false)), 100); } auto Vertices(std::experimental::optional> lower, std::experimental::optional> upper, bool current_state = false) { - return dba->vertices(label, property, lower, upper, current_state); + return dba->Vertices(label, property, lower, upper, current_state); } auto Inclusive(PropertyValue value) { diff --git a/tests/unit/query_common.hpp b/tests/unit/query_common.hpp index 6fc3b31a6..2152ad6b7 100644 --- a/tests/unit/query_common.hpp +++ b/tests/unit/query_common.hpp @@ -102,12 +102,12 @@ auto GetPropertyLookup(AstTreeStorage &storage, const std::string &name, GraphDbTypes::Property property) { return storage.Create(storage.Create(name), - dba->property_name(property), property); + dba->PropertyName(property), property); } auto GetPropertyLookup(AstTreeStorage &storage, std::unique_ptr &dba, Expression *expr, GraphDbTypes::Property property) { - return storage.Create(expr, dba->property_name(property), + return storage.Create(expr, dba->PropertyName(property), property); } auto GetPropertyLookup( @@ -449,7 +449,7 @@ auto GetMerge(AstTreeStorage &storage, Pattern *pattern, OnMatch on_match, std::map, \ query::Expression *>{__VA_ARGS__}) #define PROPERTY_PAIR(property_name) \ - std::make_pair(property_name, dba->property(property_name)) + std::make_pair(property_name, dba->Property(property_name)) #define PROPERTY_LOOKUP(...) \ query::test_common::GetPropertyLookup(storage, dba, __VA_ARGS__) #define NEXPR(name, expr) storage.Create((name), (expr)) diff --git a/tests/unit/query_cost_estimator.cpp b/tests/unit/query_cost_estimator.cpp index 00e90c82e..16f1d7e86 100644 --- a/tests/unit/query_cost_estimator.cpp +++ b/tests/unit/query_cost_estimator.cpp @@ -24,8 +24,8 @@ class QueryCostEstimator : public ::testing::Test { protected: Dbms dbms; std::unique_ptr dba = dbms.active(); - GraphDbTypes::Label label = dba->label("label"); - GraphDbTypes::Property property = dba->property("property"); + GraphDbTypes::Label label = dba->Label("label"); + GraphDbTypes::Property property = dba->Property("property"); // we incrementally build the logical operator plan // start it off with Once @@ -52,12 +52,12 @@ class QueryCostEstimator : public ::testing::Test { void AddVertices(int vertex_count, int labeled_count, int property_count = 0) { for (int i = 0; i < vertex_count; i++) { - auto vertex = dba->insert_vertex(); + auto vertex = dba->InsertVertex(); if (i < labeled_count) vertex.add_label(label); if (i < property_count) vertex.PropsSet(property, i); } - dba->advance_command(); + dba->AdvanceCommand(); } auto Cost() { diff --git a/tests/unit/query_expression_evaluator.cpp b/tests/unit/query_expression_evaluator.cpp index 801bebff0..9b7a71612 100644 --- a/tests/unit/query_expression_evaluator.cpp +++ b/tests/unit/query_expression_evaluator.cpp @@ -521,7 +521,7 @@ class ExpressionEvaluatorPropertyLookup : public testing::Test { }; TEST_F(ExpressionEvaluatorPropertyLookup, Vertex) { - auto v1 = dba->insert_vertex(); + auto v1 = dba->InsertVertex(); v1.PropsSet(prop_age.second, 10); eval.frame[symbol] = v1; EXPECT_EQ(Value(prop_age).Value(), 10); @@ -529,9 +529,9 @@ TEST_F(ExpressionEvaluatorPropertyLookup, Vertex) { } TEST_F(ExpressionEvaluatorPropertyLookup, Edge) { - auto v1 = dba->insert_vertex(); - auto v2 = dba->insert_vertex(); - auto e12 = dba->insert_edge(v1, v2, dba->edge_type("edge_type")); + auto v1 = dba->InsertVertex(); + auto v2 = dba->InsertVertex(); + auto e12 = dba->InsertEdge(v1, v2, dba->EdgeType("edge_type")); e12.PropsSet(prop_age.second, 10); eval.frame[symbol] = e12; EXPECT_EQ(Value(prop_age).Value(), 10); @@ -554,18 +554,18 @@ TEST(ExpressionEvaluator, LabelsTest) { NoContextExpressionEvaluator eval; Dbms dbms; auto dba = dbms.active(); - auto v1 = dba->insert_vertex(); - v1.add_label(dba->label("ANIMAL")); - v1.add_label(dba->label("DOG")); - v1.add_label(dba->label("NICE_DOG")); + auto v1 = dba->InsertVertex(); + v1.add_label(dba->Label("ANIMAL")); + v1.add_label(dba->Label("DOG")); + v1.add_label(dba->Label("NICE_DOG")); auto *identifier = storage.Create("n"); auto node_symbol = eval.symbol_table.CreateSymbol("n", true); eval.symbol_table[*identifier] = node_symbol; eval.frame[node_symbol] = v1; { auto *op = storage.Create( - identifier, std::vector{dba->label("DOG"), - dba->label("ANIMAL")}); + identifier, std::vector{dba->Label("DOG"), + dba->Label("ANIMAL")}); auto value = op->Accept(eval.eval); EXPECT_EQ(value.Value(), true); } @@ -573,7 +573,7 @@ TEST(ExpressionEvaluator, LabelsTest) { auto *op = storage.Create( identifier, std::vector{ - dba->label("DOG"), dba->label("BAD_DOG"), dba->label("ANIMAL")}); + dba->Label("DOG"), dba->Label("BAD_DOG"), dba->Label("ANIMAL")}); auto value = op->Accept(eval.eval); EXPECT_EQ(value.Value(), false); } @@ -582,7 +582,7 @@ TEST(ExpressionEvaluator, LabelsTest) { auto *op = storage.Create( identifier, std::vector{ - dba->label("DOG"), dba->label("BAD_DOG"), dba->label("ANIMAL")}); + dba->Label("DOG"), dba->Label("BAD_DOG"), dba->Label("ANIMAL")}); auto value = op->Accept(eval.eval); EXPECT_TRUE(value.IsNull()); } @@ -593,9 +593,9 @@ TEST(ExpressionEvaluator, EdgeTypeTest) { NoContextExpressionEvaluator eval; Dbms dbms; auto dba = dbms.active(); - auto v1 = dba->insert_vertex(); - auto v2 = dba->insert_vertex(); - auto e = dba->insert_edge(v1, v2, dba->edge_type("TYPE1")); + auto v1 = dba->InsertVertex(); + auto v2 = dba->InsertVertex(); + auto e = dba->InsertEdge(v1, v2, dba->EdgeType("TYPE1")); auto *identifier = storage.Create("e"); auto edge_symbol = eval.symbol_table.CreateSymbol("e", true); eval.symbol_table[*identifier] = edge_symbol; @@ -603,15 +603,15 @@ TEST(ExpressionEvaluator, EdgeTypeTest) { { auto *op = storage.Create( identifier, std::vector{ - dba->edge_type("TYPE0"), dba->edge_type("TYPE1"), - dba->edge_type("TYPE2")}); + dba->EdgeType("TYPE0"), dba->EdgeType("TYPE1"), + dba->EdgeType("TYPE2")}); auto value = op->Accept(eval.eval); EXPECT_EQ(value.Value(), true); } { auto *op = storage.Create( identifier, std::vector{ - dba->edge_type("TYPE0"), dba->edge_type("TYPE2")}); + dba->EdgeType("TYPE0"), dba->EdgeType("TYPE2")}); auto value = op->Accept(eval.eval); EXPECT_EQ(value.Value(), false); } @@ -619,7 +619,7 @@ TEST(ExpressionEvaluator, EdgeTypeTest) { eval.frame[edge_symbol] = TypedValue::Null; auto *op = storage.Create( identifier, std::vector{ - dba->edge_type("TYPE0"), dba->edge_type("TYPE2")}); + dba->EdgeType("TYPE0"), dba->EdgeType("TYPE2")}); auto value = op->Accept(eval.eval); EXPECT_TRUE(value.IsNull()); } @@ -673,14 +673,14 @@ TEST(ExpressionEvaluator, FunctionEndNode) { TypedValue::Type::Null); Dbms dbms; auto dba = dbms.active(); - auto v1 = dba->insert_vertex(); - v1.add_label(dba->label("label1")); - auto v2 = dba->insert_vertex(); - v2.add_label(dba->label("label2")); - auto e = dba->insert_edge(v1, v2, dba->edge_type("t")); + auto v1 = dba->InsertVertex(); + v1.add_label(dba->Label("label1")); + auto v2 = dba->InsertVertex(); + v2.add_label(dba->Label("label2")); + auto e = dba->InsertEdge(v1, v2, dba->EdgeType("t")); ASSERT_TRUE(EvaluateFunction("ENDNODE", {e}) .Value() - .has_label(dba->label("label2"))); + .has_label(dba->Label("label2"))); ASSERT_THROW(EvaluateFunction("ENDNODE", {2}), QueryRuntimeException); } @@ -702,13 +702,13 @@ TEST(ExpressionEvaluator, FunctionProperties) { TypedValue::Type::Null); Dbms dbms; auto dba = dbms.active(); - auto v1 = dba->insert_vertex(); - v1.PropsSet(dba->property("height"), 5); - v1.PropsSet(dba->property("age"), 10); - auto v2 = dba->insert_vertex(); - auto e = dba->insert_edge(v1, v2, dba->edge_type("type1")); - e.PropsSet(dba->property("height"), 3); - e.PropsSet(dba->property("age"), 15); + auto v1 = dba->InsertVertex(); + v1.PropsSet(dba->Property("height"), 5); + v1.PropsSet(dba->Property("age"), 10); + auto v2 = dba->InsertVertex(); + auto e = dba->InsertEdge(v1, v2, dba->EdgeType("type1")); + e.PropsSet(dba->Property("height"), 3); + e.PropsSet(dba->Property("age"), 15); auto prop_values_to_int = [](TypedValue t) { std::unordered_map properties; @@ -757,14 +757,14 @@ TEST(ExpressionEvaluator, FunctionStartNode) { TypedValue::Type::Null); Dbms dbms; auto dba = dbms.active(); - auto v1 = dba->insert_vertex(); - v1.add_label(dba->label("label1")); - auto v2 = dba->insert_vertex(); - v2.add_label(dba->label("label2")); - auto e = dba->insert_edge(v1, v2, dba->edge_type("t")); + auto v1 = dba->InsertVertex(); + v1.add_label(dba->Label("label1")); + auto v2 = dba->InsertVertex(); + v2.add_label(dba->Label("label2")); + auto e = dba->InsertEdge(v1, v2, dba->EdgeType("t")); ASSERT_TRUE(EvaluateFunction("STARTNODE", {e}) .Value() - .has_label(dba->label("label1"))); + .has_label(dba->Label("label1"))); ASSERT_THROW(EvaluateFunction("STARTNODE", {2}), QueryRuntimeException); } @@ -774,11 +774,11 @@ TEST(ExpressionEvaluator, FunctionDegree) { TypedValue::Type::Null); Dbms dbms; auto dba = dbms.active(); - auto v1 = dba->insert_vertex(); - auto v2 = dba->insert_vertex(); - auto v3 = dba->insert_vertex(); - auto e12 = dba->insert_edge(v1, v2, dba->edge_type("t")); - dba->insert_edge(v3, v2, dba->edge_type("t")); + auto v1 = dba->InsertVertex(); + auto v2 = dba->InsertVertex(); + auto v3 = dba->InsertVertex(); + auto e12 = dba->InsertEdge(v1, v2, dba->EdgeType("t")); + dba->InsertEdge(v3, v2, dba->EdgeType("t")); ASSERT_EQ(EvaluateFunction("DEGREE", {v1}).Value(), 1); ASSERT_EQ(EvaluateFunction("DEGREE", {v2}).Value(), 2); ASSERT_EQ(EvaluateFunction("DEGREE", {v3}).Value(), 1); @@ -831,11 +831,11 @@ TEST(ExpressionEvaluator, FunctionType) { TypedValue::Type::Null); Dbms dbms; auto dba = dbms.active(); - auto v1 = dba->insert_vertex(); - v1.add_label(dba->label("label1")); - auto v2 = dba->insert_vertex(); - v2.add_label(dba->label("label2")); - auto e = dba->insert_edge(v1, v2, dba->edge_type("type1")); + auto v1 = dba->InsertVertex(); + v1.add_label(dba->Label("label1")); + auto v2 = dba->InsertVertex(); + v2.add_label(dba->Label("label2")); + auto e = dba->InsertEdge(v1, v2, dba->EdgeType("type1")); ASSERT_EQ(EvaluateFunction("TYPE", {e}).Value(), "type1"); ASSERT_THROW(EvaluateFunction("TYPE", {2}), QueryRuntimeException); } @@ -846,9 +846,9 @@ TEST(ExpressionEvaluator, FunctionLabels) { TypedValue::Type::Null); Dbms dbms; auto dba = dbms.active(); - auto v = dba->insert_vertex(); - v.add_label(dba->label("label1")); - v.add_label(dba->label("label2")); + auto v = dba->InsertVertex(); + v.add_label(dba->Label("label1")); + v.add_label(dba->Label("label2")); std::vector labels; auto _labels = EvaluateFunction("LABELS", {v}).Value>(); @@ -890,13 +890,13 @@ TEST(ExpressionEvaluator, FunctionKeys) { TypedValue::Type::Null); Dbms dbms; auto dba = dbms.active(); - auto v1 = dba->insert_vertex(); - v1.PropsSet(dba->property("height"), 5); - v1.PropsSet(dba->property("age"), 10); - auto v2 = dba->insert_vertex(); - auto e = dba->insert_edge(v1, v2, dba->edge_type("type1")); - e.PropsSet(dba->property("width"), 3); - e.PropsSet(dba->property("age"), 15); + auto v1 = dba->InsertVertex(); + v1.PropsSet(dba->Property("height"), 5); + v1.PropsSet(dba->Property("age"), 10); + auto v2 = dba->InsertVertex(); + auto e = dba->InsertEdge(v1, v2, dba->EdgeType("type1")); + e.PropsSet(dba->Property("width"), 3); + e.PropsSet(dba->Property("age"), 15); auto prop_keys_to_string = [](TypedValue t) { std::vector keys; diff --git a/tests/unit/query_plan_accumulate_aggregate.cpp b/tests/unit/query_plan_accumulate_aggregate.cpp index 6d3d23278..73dd1ca1c 100644 --- a/tests/unit/query_plan_accumulate_aggregate.cpp +++ b/tests/unit/query_plan_accumulate_aggregate.cpp @@ -34,14 +34,14 @@ TEST(QueryPlan, Accumulate) { auto check = [&](bool accumulate) { Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("x"); + auto prop = dba->Property("x"); - auto v1 = dba->insert_vertex(); + auto v1 = dba->InsertVertex(); v1.PropsSet(prop, 0); - auto v2 = dba->insert_vertex(); + auto v2 = dba->InsertVertex(); v2.PropsSet(prop, 0); - dba->insert_edge(v1, v2, dba->edge_type("T")); - dba->advance_command(); + dba->InsertEdge(v1, v2, dba->EdgeType("T")); + dba->AdvanceCommand(); AstTreeStorage storage; SymbolTable symbol_table; @@ -151,7 +151,7 @@ class QueryPlanAggregateOps : public ::testing::Test { protected: Dbms dbms; std::unique_ptr dba = dbms.active(); - GraphDbTypes::Property prop = dba->property("prop"); + GraphDbTypes::Property prop = dba->Property("prop"); AstTreeStorage storage; SymbolTable symbol_table; @@ -160,13 +160,13 @@ class QueryPlanAggregateOps : public ::testing::Test { // setup is several nodes most of which have an int property set // we will take the sum, avg, min, max and count // we won't group by anything - dba->insert_vertex().PropsSet(prop, 5); - dba->insert_vertex().PropsSet(prop, 7); - dba->insert_vertex().PropsSet(prop, 12); + dba->InsertVertex().PropsSet(prop, 5); + dba->InsertVertex().PropsSet(prop, 7); + dba->InsertVertex().PropsSet(prop, 12); // a missing property (null) gets ignored by all aggregations except // COUNT(*) - dba->insert_vertex(); - dba->advance_command(); + dba->InsertVertex(); + dba->AdvanceCommand(); } auto AggregationResults(bool with_group_by, @@ -301,11 +301,10 @@ TEST(QueryPlan, AggregateGroupByValues) { group_by_vals.emplace_back(std::vector{1, 2.0}); // generate a lot of vertices and set props on them - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); for (int i = 0; i < 1000; ++i) - dba->insert_vertex().PropsSet(prop, - group_by_vals[i % group_by_vals.size()]); - dba->advance_command(); + dba->InsertVertex().PropsSet(prop, group_by_vals[i % group_by_vals.size()]); + dba->AdvanceCommand(); AstTreeStorage storage; SymbolTable symbol_table; @@ -339,16 +338,16 @@ TEST(QueryPlan, AggregateMultipleGroupBy) { Dbms dbms; auto dba = dbms.active(); - auto prop1 = dba->property("prop1"); - auto prop2 = dba->property("prop2"); - auto prop3 = dba->property("prop3"); + auto prop1 = dba->Property("prop1"); + auto prop2 = dba->Property("prop2"); + auto prop3 = dba->Property("prop3"); for (int i = 0; i < 2 * 3 * 5; ++i) { - auto v = dba->insert_vertex(); + auto v = dba->InsertVertex(); v.PropsSet(prop1, (bool)(i % 2)); v.PropsSet(prop2, i % 3); v.PropsSet(prop3, "value" + std::to_string(i % 5)); } - dba->advance_command(); + dba->AdvanceCommand(); AstTreeStorage storage; SymbolTable symbol_table; @@ -400,7 +399,7 @@ TEST(QueryPlan, AggregateCountEdgeCases) { Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); AstTreeStorage storage; SymbolTable symbol_table; @@ -426,23 +425,23 @@ TEST(QueryPlan, AggregateCountEdgeCases) { EXPECT_EQ(0, count()); // one vertex, no property set - dba->insert_vertex(); - dba->advance_command(); + dba->InsertVertex(); + dba->AdvanceCommand(); EXPECT_EQ(0, count()); // one vertex, property set - for (VertexAccessor va : dba->vertices(false)) va.PropsSet(prop, 42); - dba->advance_command(); + for (VertexAccessor va : dba->Vertices(false)) va.PropsSet(prop, 42); + dba->AdvanceCommand(); EXPECT_EQ(1, count()); // two vertices, one with property set - dba->insert_vertex(); - dba->advance_command(); + dba->InsertVertex(); + dba->AdvanceCommand(); EXPECT_EQ(1, count()); // two vertices, both with property set - for (VertexAccessor va : dba->vertices(false)) va.PropsSet(prop, 42); - dba->advance_command(); + for (VertexAccessor va : dba->Vertices(false)) va.PropsSet(prop, 42); + dba->AdvanceCommand(); EXPECT_EQ(2, count()); } @@ -453,12 +452,12 @@ TEST(QueryPlan, AggregateFirstValueTypes) { Dbms dbms; auto dba = dbms.active(); - auto v1 = dba->insert_vertex(); - auto prop_string = dba->property("string"); + auto v1 = dba->InsertVertex(); + auto prop_string = dba->Property("string"); v1.PropsSet(prop_string, "johhny"); - auto prop_int = dba->property("int"); + auto prop_int = dba->Property("int"); v1.PropsSet(prop_int, 12); - dba->advance_command(); + dba->AdvanceCommand(); AstTreeStorage storage; SymbolTable symbol_table; @@ -508,13 +507,13 @@ TEST(QueryPlan, AggregateTypes) { Dbms dbms; auto dba = dbms.active(); - auto p1 = dba->property("p1"); // has only string props - dba->insert_vertex().PropsSet(p1, "string"); - dba->insert_vertex().PropsSet(p1, "str2"); - auto p2 = dba->property("p2"); // combines int and bool - dba->insert_vertex().PropsSet(p2, 42); - dba->insert_vertex().PropsSet(p2, true); - dba->advance_command(); + auto p1 = dba->Property("p1"); // has only string props + dba->InsertVertex().PropsSet(p1, "string"); + dba->InsertVertex().PropsSet(p1, "str2"); + auto p2 = dba->Property("p2"); // combines int and bool + dba->InsertVertex().PropsSet(p2, 42); + dba->InsertVertex().PropsSet(p2, true); + dba->AdvanceCommand(); AstTreeStorage storage; SymbolTable symbol_table; diff --git a/tests/unit/query_plan_bag_semantics.cpp b/tests/unit/query_plan_bag_semantics.cpp index a71c98110..a2224170e 100644 --- a/tests/unit/query_plan_bag_semantics.cpp +++ b/tests/unit/query_plan_bag_semantics.cpp @@ -34,20 +34,20 @@ TEST(QueryPlan, Skip) { EXPECT_EQ(0, PullAll(skip, *dba, symbol_table)); - dba->insert_vertex(); - dba->advance_command(); + dba->InsertVertex(); + dba->AdvanceCommand(); EXPECT_EQ(0, PullAll(skip, *dba, symbol_table)); - dba->insert_vertex(); - dba->advance_command(); + dba->InsertVertex(); + dba->AdvanceCommand(); EXPECT_EQ(0, PullAll(skip, *dba, symbol_table)); - dba->insert_vertex(); - dba->advance_command(); + dba->InsertVertex(); + dba->AdvanceCommand(); EXPECT_EQ(1, PullAll(skip, *dba, symbol_table)); - for (int i = 0; i < 10; ++i) dba->insert_vertex(); - dba->advance_command(); + for (int i = 0; i < 10; ++i) dba->InsertVertex(); + dba->AdvanceCommand(); EXPECT_EQ(11, PullAll(skip, *dba, symbol_table)); } @@ -63,20 +63,20 @@ TEST(QueryPlan, Limit) { EXPECT_EQ(0, PullAll(skip, *dba, symbol_table)); - dba->insert_vertex(); - dba->advance_command(); + dba->InsertVertex(); + dba->AdvanceCommand(); EXPECT_EQ(1, PullAll(skip, *dba, symbol_table)); - dba->insert_vertex(); - dba->advance_command(); + dba->InsertVertex(); + dba->AdvanceCommand(); EXPECT_EQ(2, PullAll(skip, *dba, symbol_table)); - dba->insert_vertex(); - dba->advance_command(); + dba->InsertVertex(); + dba->AdvanceCommand(); EXPECT_EQ(2, PullAll(skip, *dba, symbol_table)); - for (int i = 0; i < 10; ++i) dba->insert_vertex(); - dba->advance_command(); + for (int i = 0; i < 10; ++i) dba->InsertVertex(); + dba->AdvanceCommand(); EXPECT_EQ(2, PullAll(skip, *dba, symbol_table)); } @@ -86,9 +86,9 @@ TEST(QueryPlan, CreateLimit) { // in the end we need to have 3 vertices in the db Dbms dbms; auto dba = dbms.active(); - dba->insert_vertex(); - dba->insert_vertex(); - dba->advance_command(); + dba->InsertVertex(); + dba->InsertVertex(); + dba->AdvanceCommand(); AstTreeStorage storage; SymbolTable symbol_table; @@ -100,8 +100,8 @@ TEST(QueryPlan, CreateLimit) { auto skip = std::make_shared(c, LITERAL(1)); EXPECT_EQ(1, PullAll(skip, *dba, symbol_table)); - dba->advance_command(); - EXPECT_EQ(3, CountIterable(dba->vertices(false))); + dba->AdvanceCommand(); + EXPECT_EQ(3, CountIterable(dba->Vertices(false))); } TEST(QueryPlan, OrderBy) { @@ -109,7 +109,7 @@ TEST(QueryPlan, OrderBy) { auto dba = dbms.active(); AstTreeStorage storage; SymbolTable symbol_table; - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); // contains a series of tests // each test defines the ordering a vector of values in the desired order @@ -125,9 +125,9 @@ TEST(QueryPlan, OrderBy) { for (const auto &order_value_pair : orderable) { const auto &values = order_value_pair.second; // empty database - for (auto &vertex : dba->vertices(false)) dba->detach_remove_vertex(vertex); - dba->advance_command(); - ASSERT_EQ(0, CountIterable(dba->vertices(false))); + for (auto &vertex : dba->Vertices(false)) dba->DetachRemoveVertex(vertex); + dba->AdvanceCommand(); + ASSERT_EQ(0, CountIterable(dba->Vertices(false))); // take some effort to shuffle the values // because we are testing that something not ordered gets ordered @@ -144,8 +144,8 @@ TEST(QueryPlan, OrderBy) { // create the vertices for (const auto &value : shuffled) - dba->insert_vertex().PropsSet(prop, value); - dba->advance_command(); + dba->InsertVertex().PropsSet(prop, value); + dba->AdvanceCommand(); // order by and collect results auto n = MakeScanAll(storage, symbol_table, "n"); @@ -172,8 +172,8 @@ TEST(QueryPlan, OrderByMultiple) { AstTreeStorage storage; SymbolTable symbol_table; - auto p1 = dba->property("p1"); - auto p2 = dba->property("p2"); + auto p1 = dba->Property("p1"); + auto p2 = dba->Property("p2"); // create a bunch of vertices that in two properties // have all the variations (with repetition) of N values. @@ -184,11 +184,11 @@ TEST(QueryPlan, OrderByMultiple) { for (int i = 0; i < N * N; ++i) prop_values.emplace_back(i % N, i / N); std::random_shuffle(prop_values.begin(), prop_values.end()); for (const auto &pair : prop_values) { - auto v = dba->insert_vertex(); + auto v = dba->InsertVertex(); v.PropsSet(p1, pair.first); v.PropsSet(p2, pair.second); } - dba->advance_command(); + dba->AdvanceCommand(); // order by and collect results auto n = MakeScanAll(storage, symbol_table, "n"); @@ -227,7 +227,7 @@ TEST(QueryPlan, OrderByExceptions) { auto dba = dbms.active(); AstTreeStorage storage; SymbolTable symbol_table; - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); // a vector of pairs of typed values that should result // in an exception when trying to order on them @@ -243,16 +243,16 @@ TEST(QueryPlan, OrderByExceptions) { for (const auto &pair : exception_pairs) { // empty database - for (auto &vertex : dba->vertices(false)) dba->detach_remove_vertex(vertex); - dba->advance_command(); - ASSERT_EQ(0, CountIterable(dba->vertices(false))); + for (auto &vertex : dba->Vertices(false)) dba->DetachRemoveVertex(vertex); + dba->AdvanceCommand(); + ASSERT_EQ(0, CountIterable(dba->Vertices(false))); // make two vertices, and set values - dba->insert_vertex().PropsSet(prop, pair.first); - dba->insert_vertex().PropsSet(prop, pair.second); - dba->advance_command(); - ASSERT_EQ(2, CountIterable(dba->vertices(false))); - for (const auto &va : dba->vertices(false)) + dba->InsertVertex().PropsSet(prop, pair.first); + dba->InsertVertex().PropsSet(prop, pair.second); + dba->AdvanceCommand(); + ASSERT_EQ(2, CountIterable(dba->Vertices(false))); + for (const auto &va : dba->Vertices(false)) ASSERT_NE(va.PropsAt(prop).type(), PropertyValue::Type::Null); // order by and expect an exception diff --git a/tests/unit/query_plan_create_set_remove_delete.cpp b/tests/unit/query_plan_create_set_remove_delete.cpp index 92bbc264f..eefb1ed48 100644 --- a/tests/unit/query_plan_create_set_remove_delete.cpp +++ b/tests/unit/query_plan_create_set_remove_delete.cpp @@ -26,7 +26,7 @@ TEST(QueryPlan, CreateNodeWithAttributes) { Dbms dbms; auto dba = dbms.active(); - GraphDbTypes::Label label = dba->label("Person"); + GraphDbTypes::Label label = dba->Label("Person"); auto property = PROPERTY_PAIR("prop"); AstTreeStorage storage; @@ -39,11 +39,11 @@ TEST(QueryPlan, CreateNodeWithAttributes) { auto create = std::make_shared(node, nullptr); PullAll(create, *dba, symbol_table); - dba->advance_command(); + dba->AdvanceCommand(); // count the number of vertices int vertex_count = 0; - for (VertexAccessor vertex : dba->vertices(false)) { + for (VertexAccessor vertex : dba->Vertices(false)) { vertex_count++; EXPECT_EQ(vertex.labels().size(), 1); EXPECT_EQ(*vertex.labels().begin(), label); @@ -60,7 +60,7 @@ TEST(QueryPlan, CreateReturn) { Dbms dbms; auto dba = dbms.active(); - GraphDbTypes::Label label = dba->label("Person"); + GraphDbTypes::Label label = dba->Label("Person"); auto property = PROPERTY_PAIR("property"); AstTreeStorage storage; @@ -93,26 +93,26 @@ TEST(QueryPlan, CreateReturn) { EXPECT_EQ(TypedValue::Type::Int, results[0][1].type()); EXPECT_EQ(42, results[0][1].Value()); - dba->advance_command(); - EXPECT_EQ(1, CountIterable(dba->vertices(false))); + dba->AdvanceCommand(); + EXPECT_EQ(1, CountIterable(dba->Vertices(false))); } TEST(QueryPlan, CreateExpand) { Dbms dbms; auto dba = dbms.active(); - GraphDbTypes::Label label_node_1 = dba->label("Node1"); - GraphDbTypes::Label label_node_2 = dba->label("Node2"); + GraphDbTypes::Label label_node_1 = dba->Label("Node1"); + GraphDbTypes::Label label_node_2 = dba->Label("Node2"); auto property = PROPERTY_PAIR("property"); - GraphDbTypes::EdgeType edge_type = dba->label("edge_type"); + GraphDbTypes::EdgeType edge_type = dba->Label("edge_type"); SymbolTable symbol_table; AstTreeStorage storage; auto test_create_path = [&](bool cycle, int expected_nodes_created, int expected_edges_created) { - int before_v = CountIterable(dba->vertices(false)); - int before_e = CountIterable(dba->edges(false)); + int before_v = CountIterable(dba->Vertices(false)); + int before_e = CountIterable(dba->Edges(false)); // data for the first node auto n = NODE("n"); @@ -139,18 +139,18 @@ TEST(QueryPlan, CreateExpand) { auto create_expand = std::make_shared(m, r, create_op, n_sym, cycle); PullAll(create_expand, *dba, symbol_table); - dba->advance_command(); + dba->AdvanceCommand(); - EXPECT_EQ(CountIterable(dba->vertices(false)) - before_v, + EXPECT_EQ(CountIterable(dba->Vertices(false)) - before_v, expected_nodes_created); - EXPECT_EQ(CountIterable(dba->edges(false)) - before_e, + EXPECT_EQ(CountIterable(dba->Edges(false)) - before_e, expected_edges_created); }; test_create_path(false, 2, 1); test_create_path(true, 1, 1); - for (VertexAccessor vertex : dba->vertices(false)) { + for (VertexAccessor vertex : dba->Vertices(false)) { EXPECT_EQ(vertex.labels().size(), 1); GraphDbTypes::Label label = vertex.labels()[0]; if (label == label_node_1) { @@ -164,8 +164,8 @@ TEST(QueryPlan, CreateExpand) { FAIL(); } - for (EdgeAccessor edge : dba->edges(false)) { - EXPECT_EQ(edge.edge_type(), edge_type); + for (EdgeAccessor edge : dba->Edges(false)) { + EXPECT_EQ(edge.EdgeType(), edge_type); EXPECT_EQ(edge.PropsAt(property.second).Value(), 3); } } @@ -176,10 +176,10 @@ TEST(QueryPlan, MatchCreateNode) { auto dba = dbms.active(); // add three nodes we'll match and expand-create from - dba->insert_vertex(); - dba->insert_vertex(); - dba->insert_vertex(); - dba->advance_command(); + dba->InsertVertex(); + dba->InsertVertex(); + dba->InsertVertex(); + dba->AdvanceCommand(); SymbolTable symbol_table; AstTreeStorage storage; @@ -192,10 +192,10 @@ TEST(QueryPlan, MatchCreateNode) { // creation op auto create_node = std::make_shared(m, n_scan_all.op_); - EXPECT_EQ(CountIterable(dba->vertices(false)), 3); + EXPECT_EQ(CountIterable(dba->Vertices(false)), 3); PullAll(create_node, *dba, symbol_table); - dba->advance_command(); - EXPECT_EQ(CountIterable(dba->vertices(false)), 6); + dba->AdvanceCommand(); + EXPECT_EQ(CountIterable(dba->Vertices(false)), 6); } TEST(QueryPlan, MatchCreateExpand) { @@ -203,23 +203,23 @@ TEST(QueryPlan, MatchCreateExpand) { auto dba = dbms.active(); // add three nodes we'll match and expand-create from - dba->insert_vertex(); - dba->insert_vertex(); - dba->insert_vertex(); - dba->advance_command(); + dba->InsertVertex(); + dba->InsertVertex(); + dba->InsertVertex(); + dba->AdvanceCommand(); - // GraphDbTypes::Label label_node_1 = dba->label("Node1"); - // GraphDbTypes::Label label_node_2 = dba->label("Node2"); - // GraphDbTypes::Property property = dba->label("prop"); - GraphDbTypes::EdgeType edge_type = dba->label("edge_type"); + // GraphDbTypes::Label label_node_1 = dba->Label("Node1"); + // GraphDbTypes::Label label_node_2 = dba->Label("Node2"); + // GraphDbTypes::Property property = dba->Label("prop"); + GraphDbTypes::EdgeType edge_type = dba->Label("edge_type"); SymbolTable symbol_table; AstTreeStorage storage; auto test_create_path = [&](bool cycle, int expected_nodes_created, int expected_edges_created) { - int before_v = CountIterable(dba->vertices(false)); - int before_e = CountIterable(dba->edges(false)); + int before_v = CountIterable(dba->Vertices(false)); + int before_e = CountIterable(dba->Edges(false)); // data for the first node auto n_scan_all = MakeScanAll(storage, symbol_table, "n"); @@ -238,11 +238,11 @@ TEST(QueryPlan, MatchCreateExpand) { auto create_expand = std::make_shared(m, r, n_scan_all.op_, n_scan_all.sym_, cycle); PullAll(create_expand, *dba, symbol_table); - dba->advance_command(); + dba->AdvanceCommand(); - EXPECT_EQ(CountIterable(dba->vertices(false)) - before_v, + EXPECT_EQ(CountIterable(dba->Vertices(false)) - before_v, expected_nodes_created); - EXPECT_EQ(CountIterable(dba->edges(false)) - before_e, + EXPECT_EQ(CountIterable(dba->Edges(false)) - before_e, expected_edges_created); }; @@ -256,15 +256,15 @@ TEST(QueryPlan, Delete) { // make a fully-connected (one-direction, no cycles) with 4 nodes std::vector vertices; - for (int i = 0; i < 4; ++i) vertices.push_back(dba->insert_vertex()); - auto type = dba->edge_type("type"); + for (int i = 0; i < 4; ++i) vertices.push_back(dba->InsertVertex()); + auto type = dba->EdgeType("type"); for (int j = 0; j < 4; ++j) for (int k = j + 1; k < 4; ++k) - dba->insert_edge(vertices[j], vertices[k], type); + dba->InsertEdge(vertices[j], vertices[k], type); - dba->advance_command(); - EXPECT_EQ(4, CountIterable(dba->vertices(false))); - EXPECT_EQ(6, CountIterable(dba->edges(false))); + dba->AdvanceCommand(); + EXPECT_EQ(4, CountIterable(dba->Vertices(false))); + EXPECT_EQ(6, CountIterable(dba->Edges(false))); AstTreeStorage storage; SymbolTable symbol_table; @@ -277,9 +277,9 @@ TEST(QueryPlan, Delete) { auto delete_op = std::make_shared( n.op_, std::vector{n_get}, false); EXPECT_THROW(PullAll(delete_op, *dba, symbol_table), QueryRuntimeException); - dba->advance_command(); - EXPECT_EQ(4, CountIterable(dba->vertices(false))); - EXPECT_EQ(6, CountIterable(dba->edges(false))); + dba->AdvanceCommand(); + EXPECT_EQ(4, CountIterable(dba->Vertices(false))); + EXPECT_EQ(6, CountIterable(dba->Edges(false))); } // detach delete a single vertex @@ -291,9 +291,9 @@ TEST(QueryPlan, Delete) { n.op_, std::vector{n_get}, true); Frame frame(symbol_table.max_position()); delete_op->MakeCursor(*dba)->Pull(frame, symbol_table); - dba->advance_command(); - EXPECT_EQ(3, CountIterable(dba->vertices(false))); - EXPECT_EQ(3, CountIterable(dba->edges(false))); + dba->AdvanceCommand(); + EXPECT_EQ(3, CountIterable(dba->Vertices(false))); + EXPECT_EQ(3, CountIterable(dba->Edges(false))); } // delete all remaining edges @@ -306,9 +306,9 @@ TEST(QueryPlan, Delete) { auto delete_op = std::make_shared( r_m.op_, std::vector{r_get}, false); PullAll(delete_op, *dba, symbol_table); - dba->advance_command(); - EXPECT_EQ(3, CountIterable(dba->vertices(false))); - EXPECT_EQ(0, CountIterable(dba->edges(false))); + dba->AdvanceCommand(); + EXPECT_EQ(3, CountIterable(dba->Vertices(false))); + EXPECT_EQ(0, CountIterable(dba->Edges(false))); } // delete all remaining vertices @@ -319,9 +319,9 @@ TEST(QueryPlan, Delete) { auto delete_op = std::make_shared( n.op_, std::vector{n_get}, false); PullAll(delete_op, *dba, symbol_table); - dba->advance_command(); - EXPECT_EQ(0, CountIterable(dba->vertices(false))); - EXPECT_EQ(0, CountIterable(dba->edges(false))); + dba->AdvanceCommand(); + EXPECT_EQ(0, CountIterable(dba->Vertices(false))); + EXPECT_EQ(0, CountIterable(dba->Edges(false))); } } @@ -341,12 +341,12 @@ TEST(QueryPlan, DeleteTwiceDeleteBlockingEdge) { Dbms dbms; auto dba = dbms.active(); - auto v1 = dba->insert_vertex(); - auto v2 = dba->insert_vertex(); - dba->insert_edge(v1, v2, dba->edge_type("T")); - dba->advance_command(); - EXPECT_EQ(2, CountIterable(dba->vertices(false))); - EXPECT_EQ(1, CountIterable(dba->edges(false))); + auto v1 = dba->InsertVertex(); + auto v2 = dba->InsertVertex(); + dba->InsertEdge(v1, v2, dba->EdgeType("T")); + dba->AdvanceCommand(); + EXPECT_EQ(2, CountIterable(dba->Vertices(false))); + EXPECT_EQ(1, CountIterable(dba->Edges(false))); AstTreeStorage storage; SymbolTable symbol_table; @@ -366,9 +366,9 @@ TEST(QueryPlan, DeleteTwiceDeleteBlockingEdge) { auto delete_op = std::make_shared( r_m.op_, std::vector{n_get, r_get, m_get}, detach); EXPECT_EQ(2, PullAll(delete_op, *dba, symbol_table)); - dba->advance_command(); - EXPECT_EQ(0, CountIterable(dba->vertices(false))); - EXPECT_EQ(0, CountIterable(dba->edges(false))); + dba->AdvanceCommand(); + EXPECT_EQ(0, CountIterable(dba->Vertices(false))); + EXPECT_EQ(0, CountIterable(dba->Edges(false))); }; test_delete(true); @@ -382,13 +382,13 @@ TEST(QueryPlan, DeleteReturn) { // make a fully-connected (one-direction, no cycles) with 4 nodes auto prop = PROPERTY_PAIR("property"); for (int i = 0; i < 4; ++i) { - auto va = dba->insert_vertex(); + auto va = dba->InsertVertex(); va.PropsSet(prop.second, 42); } - dba->advance_command(); - EXPECT_EQ(4, CountIterable(dba->vertices(false))); - EXPECT_EQ(0, CountIterable(dba->edges(false))); + dba->AdvanceCommand(); + EXPECT_EQ(4, CountIterable(dba->Vertices(false))); + EXPECT_EQ(0, CountIterable(dba->Edges(false))); AstTreeStorage storage; SymbolTable symbol_table; @@ -409,8 +409,8 @@ TEST(QueryPlan, DeleteReturn) { auto results = CollectProduce(produce.get(), symbol_table, *dba); EXPECT_EQ(4, results.size()); - dba->advance_command(); - EXPECT_EQ(0, CountIterable(dba->vertices(false))); + dba->AdvanceCommand(); + EXPECT_EQ(0, CountIterable(dba->Vertices(false))); } TEST(QueryPlan, DeleteNull) { @@ -438,8 +438,8 @@ TEST(QueryPlan, DeleteAdvance) { // we are not yet compatible with that Dbms dbms; auto dba = dbms.active(); - dba->insert_vertex(); - dba->advance_command(); + dba->InsertVertex(); + dba->AdvanceCommand(); AstTreeStorage storage; SymbolTable symbol_table; @@ -461,14 +461,14 @@ TEST(QueryPlan, SetProperty) { // graph with 4 vertices in connected pairs // the origin vertex in each par and both edges // have a property set - auto v1 = dba->insert_vertex(); - auto v2 = dba->insert_vertex(); - auto v3 = dba->insert_vertex(); - auto v4 = dba->insert_vertex(); - auto edge_type = dba->edge_type("edge_type"); - dba->insert_edge(v1, v3, edge_type); - dba->insert_edge(v2, v4, edge_type); - dba->advance_command(); + auto v1 = dba->InsertVertex(); + auto v2 = dba->InsertVertex(); + auto v3 = dba->InsertVertex(); + auto v4 = dba->InsertVertex(); + auto edge_type = dba->EdgeType("edge_type"); + dba->InsertEdge(v1, v3, edge_type); + dba->InsertEdge(v2, v4, edge_type); + dba->AdvanceCommand(); AstTreeStorage storage; SymbolTable symbol_table; @@ -479,7 +479,7 @@ TEST(QueryPlan, SetProperty) { EdgeAtom::Direction::OUT, false, "m", false); // set prop1 to 42 on n and r - auto prop1 = dba->property("prop1"); + auto prop1 = dba->Property("prop1"); auto literal = LITERAL(42); auto n_p = PROPERTY_LOOKUP("n", prop1); @@ -490,10 +490,10 @@ TEST(QueryPlan, SetProperty) { symbol_table[*r_p->expression_] = r_m.edge_sym_; auto set_r_p = std::make_shared(set_n_p, r_p, literal); EXPECT_EQ(2, PullAll(set_r_p, *dba, symbol_table)); - dba->advance_command(); + dba->AdvanceCommand(); - EXPECT_EQ(CountIterable(dba->edges(false)), 2); - for (EdgeAccessor edge : dba->edges(false)) { + EXPECT_EQ(CountIterable(dba->Edges(false)), 2); + for (EdgeAccessor edge : dba->Edges(false)) { ASSERT_EQ(edge.PropsAt(prop1).type(), PropertyValue::Type::Int); EXPECT_EQ(edge.PropsAt(prop1).Value(), 42); VertexAccessor from = edge.from(); @@ -510,16 +510,16 @@ TEST(QueryPlan, SetProperties) { auto dba = dbms.active(); // graph: ({a: 0})-[:R {b:1}]->({c:2}) - auto prop_a = dba->property("a"); - auto prop_b = dba->property("b"); - auto prop_c = dba->property("c"); - auto v1 = dba->insert_vertex(); - auto v2 = dba->insert_vertex(); - auto e = dba->insert_edge(v1, v2, dba->edge_type("R")); + auto prop_a = dba->Property("a"); + auto prop_b = dba->Property("b"); + auto prop_c = dba->Property("c"); + auto v1 = dba->InsertVertex(); + auto v2 = dba->InsertVertex(); + auto e = dba->InsertEdge(v1, v2, dba->EdgeType("R")); v1.PropsSet(prop_a, 0); e.PropsSet(prop_b, 1); v2.PropsSet(prop_c, 2); - dba->advance_command(); + dba->AdvanceCommand(); AstTreeStorage storage; SymbolTable symbol_table; @@ -542,10 +542,10 @@ TEST(QueryPlan, SetProperties) { auto set_m_to_r = std::make_shared( set_r_to_n, r_m.edge_sym_, m_ident, op); EXPECT_EQ(1, PullAll(set_m_to_r, *dba, symbol_table)); - dba->advance_command(); + dba->AdvanceCommand(); - EXPECT_EQ(CountIterable(dba->edges(false)), 1); - for (EdgeAccessor edge : dba->edges(false)) { + EXPECT_EQ(CountIterable(dba->Edges(false)), 1); + for (EdgeAccessor edge : dba->Edges(false)) { VertexAccessor from = edge.from(); EXPECT_EQ(from.Properties().size(), update ? 2 : 1); if (update) { @@ -578,12 +578,12 @@ TEST(QueryPlan, SetLabels) { Dbms dbms; auto dba = dbms.active(); - auto label1 = dba->label("label1"); - auto label2 = dba->label("label2"); - auto label3 = dba->label("label3"); - dba->insert_vertex().add_label(label1); - dba->insert_vertex().add_label(label1); - dba->advance_command(); + auto label1 = dba->Label("label1"); + auto label2 = dba->Label("label2"); + auto label3 = dba->Label("label3"); + dba->InsertVertex().add_label(label1); + dba->InsertVertex().add_label(label1); + dba->AdvanceCommand(); AstTreeStorage storage; SymbolTable symbol_table; @@ -593,7 +593,7 @@ TEST(QueryPlan, SetLabels) { n.op_, n.sym_, std::vector{label2, label3}); EXPECT_EQ(2, PullAll(label_set, *dba, symbol_table)); - for (VertexAccessor vertex : dba->vertices(false)) { + for (VertexAccessor vertex : dba->Vertices(false)) { vertex.SwitchNew(); EXPECT_EQ(3, vertex.labels().size()); EXPECT_TRUE(vertex.has_label(label2)); @@ -608,21 +608,21 @@ TEST(QueryPlan, RemoveProperty) { // graph with 4 vertices in connected pairs // the origin vertex in each par and both edges // have a property set - auto prop1 = dba->property("prop1"); - auto v1 = dba->insert_vertex(); - auto v2 = dba->insert_vertex(); - auto v3 = dba->insert_vertex(); - auto v4 = dba->insert_vertex(); - auto edge_type = dba->edge_type("edge_type"); - dba->insert_edge(v1, v3, edge_type).PropsSet(prop1, 42); - dba->insert_edge(v2, v4, edge_type); + auto prop1 = dba->Property("prop1"); + auto v1 = dba->InsertVertex(); + auto v2 = dba->InsertVertex(); + auto v3 = dba->InsertVertex(); + auto v4 = dba->InsertVertex(); + auto edge_type = dba->EdgeType("edge_type"); + dba->InsertEdge(v1, v3, edge_type).PropsSet(prop1, 42); + dba->InsertEdge(v2, v4, edge_type); v2.PropsSet(prop1, 42); v3.PropsSet(prop1, 42); v4.PropsSet(prop1, 42); - auto prop2 = dba->property("prop2"); + auto prop2 = dba->Property("prop2"); v1.PropsSet(prop2, 0); v2.PropsSet(prop2, 0); - dba->advance_command(); + dba->AdvanceCommand(); AstTreeStorage storage; SymbolTable symbol_table; @@ -640,10 +640,10 @@ TEST(QueryPlan, RemoveProperty) { symbol_table[*r_p->expression_] = r_m.edge_sym_; auto set_r_p = std::make_shared(set_n_p, r_p); EXPECT_EQ(2, PullAll(set_r_p, *dba, symbol_table)); - dba->advance_command(); + dba->AdvanceCommand(); - EXPECT_EQ(CountIterable(dba->edges(false)), 2); - for (EdgeAccessor edge : dba->edges(false)) { + EXPECT_EQ(CountIterable(dba->Edges(false)), 2); + for (EdgeAccessor edge : dba->Edges(false)) { EXPECT_EQ(edge.PropsAt(prop1).type(), PropertyValue::Type::Null); VertexAccessor from = edge.from(); VertexAccessor to = edge.to(); @@ -657,17 +657,17 @@ TEST(QueryPlan, RemoveLabels) { Dbms dbms; auto dba = dbms.active(); - auto label1 = dba->label("label1"); - auto label2 = dba->label("label2"); - auto label3 = dba->label("label3"); - auto v1 = dba->insert_vertex(); + auto label1 = dba->Label("label1"); + auto label2 = dba->Label("label2"); + auto label3 = dba->Label("label3"); + auto v1 = dba->InsertVertex(); v1.add_label(label1); v1.add_label(label2); v1.add_label(label3); - auto v2 = dba->insert_vertex(); + auto v2 = dba->InsertVertex(); v2.add_label(label1); v2.add_label(label3); - dba->advance_command(); + dba->AdvanceCommand(); AstTreeStorage storage; SymbolTable symbol_table; @@ -677,7 +677,7 @@ TEST(QueryPlan, RemoveLabels) { n.op_, n.sym_, std::vector{label1, label2}); EXPECT_EQ(2, PullAll(label_remove, *dba, symbol_table)); - for (VertexAccessor vertex : dba->vertices(false)) { + for (VertexAccessor vertex : dba->Vertices(false)) { vertex.SwitchNew(); EXPECT_EQ(1, vertex.labels().size()); EXPECT_FALSE(vertex.has_label(label1)); @@ -689,15 +689,15 @@ TEST(QueryPlan, NodeFilterSet) { Dbms dbms; auto dba = dbms.active(); // Create a graph such that (v1 {prop: 42}) is connected to v2 and v3. - auto v1 = dba->insert_vertex(); + auto v1 = dba->InsertVertex(); auto prop = PROPERTY_PAIR("property"); v1.PropsSet(prop.second, 42); - auto v2 = dba->insert_vertex(); - auto v3 = dba->insert_vertex(); - auto edge_type = dba->edge_type("Edge"); - dba->insert_edge(v1, v2, edge_type); - dba->insert_edge(v1, v3, edge_type); - dba->advance_command(); + auto v2 = dba->InsertVertex(); + auto v3 = dba->InsertVertex(); + auto edge_type = dba->EdgeType("Edge"); + dba->InsertEdge(v1, v2, edge_type); + dba->InsertEdge(v1, v3, edge_type); + dba->AdvanceCommand(); // Create operations which match (v1 {prop: 42}) -- (v) and increment the // v1.prop. The expected result is two incremenentations, since v1 is matched // twice for 2 edges it has. @@ -718,7 +718,7 @@ TEST(QueryPlan, NodeFilterSet) { auto add = ADD(set_prop, LITERAL(1)); auto set = std::make_shared(node_filter, set_prop, add); EXPECT_EQ(2, PullAll(set, *dba, symbol_table)); - dba->advance_command(); + dba->AdvanceCommand(); v1.Reconstruct(); auto prop_eq = v1.PropsAt(prop.second) == TypedValue(42 + 2); ASSERT_EQ(prop_eq.type(), TypedValue::Type::Bool); @@ -729,15 +729,15 @@ TEST(QueryPlan, FilterRemove) { Dbms dbms; auto dba = dbms.active(); // Create a graph such that (v1 {prop: 42}) is connected to v2 and v3. - auto v1 = dba->insert_vertex(); + auto v1 = dba->InsertVertex(); auto prop = PROPERTY_PAIR("property"); v1.PropsSet(prop.second, 42); - auto v2 = dba->insert_vertex(); - auto v3 = dba->insert_vertex(); - auto edge_type = dba->edge_type("Edge"); - dba->insert_edge(v1, v2, edge_type); - dba->insert_edge(v1, v3, edge_type); - dba->advance_command(); + auto v2 = dba->InsertVertex(); + auto v3 = dba->InsertVertex(); + auto edge_type = dba->EdgeType("Edge"); + dba->InsertEdge(v1, v2, edge_type); + dba->InsertEdge(v1, v3, edge_type); + dba->AdvanceCommand(); // Create operations which match (v1 {prop: 42}) -- (v) and remove v1.prop. // The expected result is two matches, for each edge of v1. AstTreeStorage storage; @@ -756,7 +756,7 @@ TEST(QueryPlan, FilterRemove) { symbol_table[*rem_prop->expression_] = scan_all.sym_; auto rem = std::make_shared(filter, rem_prop); EXPECT_EQ(2, PullAll(rem, *dba, symbol_table)); - dba->advance_command(); + dba->AdvanceCommand(); v1.Reconstruct(); EXPECT_EQ(v1.PropsAt(prop.second).type(), PropertyValue::Type::Null); } @@ -764,10 +764,10 @@ TEST(QueryPlan, FilterRemove) { TEST(QueryPlan, SetRemove) { Dbms dbms; auto dba = dbms.active(); - auto v = dba->insert_vertex(); - auto label1 = dba->label("label1"); - auto label2 = dba->label("label2"); - dba->advance_command(); + auto v = dba->InsertVertex(); + auto label1 = dba->Label("label1"); + auto label2 = dba->Label("label2"); + dba->AdvanceCommand(); // Create operations which match (v) and set and remove v :label. // The expected result is single (v) as it was at the start. AstTreeStorage storage; @@ -780,7 +780,7 @@ TEST(QueryPlan, SetRemove) { auto rem = std::make_shared( set, scan_all.sym_, std::vector{label1, label2}); EXPECT_EQ(1, PullAll(rem, *dba, symbol_table)); - dba->advance_command(); + dba->AdvanceCommand(); v.Reconstruct(); EXPECT_FALSE(v.has_label(label1)); EXPECT_FALSE(v.has_label(label2)); @@ -795,11 +795,11 @@ TEST(QueryPlan, Merge) { // - merge_create branch just sets some other property Dbms dbms; auto dba = dbms.active(); - auto v1 = dba->insert_vertex(); - auto v2 = dba->insert_vertex(); - dba->insert_edge(v1, v2, dba->edge_type("Type")); - auto v3 = dba->insert_vertex(); - dba->advance_command(); + auto v1 = dba->InsertVertex(); + auto v2 = dba->InsertVertex(); + dba->InsertEdge(v1, v2, dba->EdgeType("Type")); + auto v3 = dba->InsertVertex(); + dba->AdvanceCommand(); AstTreeStorage storage; SymbolTable symbol_table; @@ -822,7 +822,7 @@ TEST(QueryPlan, Merge) { auto merge = std::make_shared(n.op_, m_set, n_set); ASSERT_EQ(3, PullAll(merge, *dba, symbol_table)); - dba->advance_command(); + dba->AdvanceCommand(); v1.Reconstruct(); v2.Reconstruct(); v3.Reconstruct(); @@ -849,10 +849,10 @@ TEST(QueryPlan, MergeNoInput) { auto create = std::make_shared(node, nullptr); auto merge = std::make_shared(nullptr, create, create); - EXPECT_EQ(0, CountIterable(dba->vertices(false))); + EXPECT_EQ(0, CountIterable(dba->Vertices(false))); EXPECT_EQ(1, PullAll(merge, *dba, symbol_table)); - dba->advance_command(); - EXPECT_EQ(1, CountIterable(dba->vertices(false))); + dba->AdvanceCommand(); + EXPECT_EQ(1, CountIterable(dba->Vertices(false))); } TEST(QueryPlan, SetPropertyOnNull) { @@ -883,7 +883,7 @@ TEST(QueryPlan, SetPropertiesOnNull) { std::vector{n.sym_}); auto set_op = std::make_shared( optional, n.sym_, n_ident, plan::SetProperties::Op::REPLACE); - EXPECT_EQ(0, CountIterable(dba->vertices(false))); + EXPECT_EQ(0, CountIterable(dba->Vertices(false))); EXPECT_EQ(1, PullAll(set_op, *dba, symbol_table)); } @@ -891,7 +891,7 @@ TEST(QueryPlan, SetLabelsOnNull) { // OPTIONAL MATCH (n) SET n :label Dbms dbms; auto dba = dbms.active(); - auto label = dba->label("label"); + auto label = dba->Label("label"); AstTreeStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n"); @@ -901,7 +901,7 @@ TEST(QueryPlan, SetLabelsOnNull) { std::vector{n.sym_}); auto set_op = std::make_shared( optional, n.sym_, std::vector{label}); - EXPECT_EQ(0, CountIterable(dba->vertices(false))); + EXPECT_EQ(0, CountIterable(dba->Vertices(false))); EXPECT_EQ(1, PullAll(set_op, *dba, symbol_table)); } @@ -923,7 +923,7 @@ TEST(QueryPlan, RemoveLabelsOnNull) { // OPTIONAL MATCH (n) REMOVE n :label Dbms dbms; auto dba = dbms.active(); - auto label = dba->label("label"); + auto label = dba->Label("label"); AstTreeStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n"); @@ -933,16 +933,16 @@ TEST(QueryPlan, RemoveLabelsOnNull) { std::vector{n.sym_}); auto remove_op = std::make_shared( optional, n.sym_, std::vector{label}); - EXPECT_EQ(0, CountIterable(dba->vertices(false))); + EXPECT_EQ(0, CountIterable(dba->Vertices(false))); EXPECT_EQ(1, PullAll(remove_op, *dba, symbol_table)); } TEST(QueryPlan, CreateIndex) { - // CREATE INDEX ON :label(property) + // CREATE INDEX ON :Label(property) Dbms dbms; auto dba = dbms.active(); - auto label = dba->label("label"); - auto property = dba->property("property"); + auto label = dba->Label("label"); + auto property = dba->Property("property"); EXPECT_FALSE(dba->LabelPropertyIndexExists(label, property)); auto create_index = std::make_shared(label, property); SymbolTable symbol_table; diff --git a/tests/unit/query_plan_edge_cases.cpp b/tests/unit/query_plan_edge_cases.cpp index b11754fd6..fe0dc4da6 100644 --- a/tests/unit/query_plan_edge_cases.cpp +++ b/tests/unit/query_plan_edge_cases.cpp @@ -17,7 +17,7 @@ class QueryExecution : public testing::Test { /** Commits the current transaction and refreshes the db_ * variable to hold a new accessor with a new transaction */ void Commit() { - db_->commit(); + db_->Commit(); auto next_db = dbms_.active(); db_.swap(next_db); } @@ -47,7 +47,9 @@ TEST_F(QueryExecution, MissingOptionalIntoExpand) { return Execute(std::string("MATCH (p:Person) WITH p ORDER BY p.id ") + (desc ? "DESC " : "") + "OPTIONAL MATCH (p)-->(d:Dog) WITH p, d " - "MATCH (d)-" + (variable ? "[*1]" : "") + "->(f:Food) " + "MATCH (d)-" + + (variable ? "[*1]" : "") + + "->(f:Food) " "RETURN p, d, f") .size(); }; diff --git a/tests/unit/query_plan_match_filter_return.cpp b/tests/unit/query_plan_match_filter_return.cpp index 33484845b..d19b455a8 100644 --- a/tests/unit/query_plan_match_filter_return.cpp +++ b/tests/unit/query_plan_match_filter_return.cpp @@ -30,9 +30,9 @@ TEST(QueryPlan, MatchReturn) { auto dba = dbms.active(); // add a few nodes to the database - dba->insert_vertex(); - dba->insert_vertex(); - dba->advance_command(); + dba->InsertVertex(); + dba->InsertVertex(); + dba->AdvanceCommand(); AstTreeStorage storage; SymbolTable symbol_table; @@ -50,10 +50,10 @@ TEST(QueryPlan, MatchReturn) { EXPECT_EQ(2, test_pull_count(GraphView::NEW)); EXPECT_EQ(2, test_pull_count(GraphView::OLD)); - dba->insert_vertex(); + dba->InsertVertex(); EXPECT_EQ(3, test_pull_count(GraphView::NEW)); EXPECT_EQ(2, test_pull_count(GraphView::OLD)); - dba->advance_command(); + dba->AdvanceCommand(); EXPECT_EQ(3, test_pull_count(GraphView::OLD)); } @@ -61,9 +61,9 @@ TEST(QueryPlan, MatchReturnCartesian) { Dbms dbms; auto dba = dbms.active(); - dba->insert_vertex().add_label(dba->label("l1")); - dba->insert_vertex().add_label(dba->label("l2")); - dba->advance_command(); + dba->InsertVertex().add_label(dba->Label("l1")); + dba->InsertVertex().add_label(dba->Label("l2")); + dba->AdvanceCommand(); AstTreeStorage storage; SymbolTable symbol_table; @@ -95,9 +95,9 @@ TEST(QueryPlan, StandaloneReturn) { auto dba = dbms.active(); // add a few nodes to the database - dba->insert_vertex(); - dba->insert_vertex(); - dba->advance_command(); + dba->InsertVertex(); + dba->InsertVertex(); + dba->AdvanceCommand(); AstTreeStorage storage; SymbolTable symbol_table; @@ -117,14 +117,14 @@ TEST(QueryPlan, NodeFilterLabelsAndProperties) { auto dba = dbms.active(); // add a few nodes to the database - GraphDbTypes::Label label = dba->label("Label"); + GraphDbTypes::Label label = dba->Label("Label"); auto property = PROPERTY_PAIR("Property"); - auto v1 = dba->insert_vertex(); - auto v2 = dba->insert_vertex(); - auto v3 = dba->insert_vertex(); - auto v4 = dba->insert_vertex(); - auto v5 = dba->insert_vertex(); - dba->insert_vertex(); + auto v1 = dba->InsertVertex(); + auto v2 = dba->InsertVertex(); + auto v3 = dba->InsertVertex(); + auto v4 = dba->InsertVertex(); + auto v5 = dba->InsertVertex(); + dba->InsertVertex(); // test all combination of (label | no_label) * (no_prop | wrong_prop | // right_prop) // only v1-v3 will have the right labels @@ -136,7 +136,7 @@ TEST(QueryPlan, NodeFilterLabelsAndProperties) { v2.PropsSet(property.second, 1); v4.PropsSet(property.second, 42); v5.PropsSet(property.second, 1); - dba->advance_command(); + dba->AdvanceCommand(); AstTreeStorage storage; SymbolTable symbol_table; @@ -164,7 +164,7 @@ TEST(QueryPlan, NodeFilterLabelsAndProperties) { v4.Reconstruct(); v4.add_label(label); EXPECT_EQ(1, PullAll(produce, *dba, symbol_table)); - dba->advance_command(); + dba->AdvanceCommand(); EXPECT_EQ(2, PullAll(produce, *dba, symbol_table)); } @@ -173,25 +173,25 @@ TEST(QueryPlan, NodeFilterMultipleLabels) { auto dba = dbms.active(); // add a few nodes to the database - GraphDbTypes::Label label1 = dba->label("label1"); - GraphDbTypes::Label label2 = dba->label("label2"); - GraphDbTypes::Label label3 = dba->label("label3"); + GraphDbTypes::Label label1 = dba->Label("label1"); + GraphDbTypes::Label label2 = dba->Label("label2"); + GraphDbTypes::Label label3 = dba->Label("label3"); // the test will look for nodes that have label1 and label2 - dba->insert_vertex(); // NOT accepted - dba->insert_vertex().add_label(label1); // NOT accepted - dba->insert_vertex().add_label(label2); // NOT accepted - dba->insert_vertex().add_label(label3); // NOT accepted - auto v1 = dba->insert_vertex(); // YES accepted + dba->InsertVertex(); // NOT accepted + dba->InsertVertex().add_label(label1); // NOT accepted + dba->InsertVertex().add_label(label2); // NOT accepted + dba->InsertVertex().add_label(label3); // NOT accepted + auto v1 = dba->InsertVertex(); // YES accepted v1.add_label(label1); v1.add_label(label2); - auto v2 = dba->insert_vertex(); // NOT accepted + auto v2 = dba->InsertVertex(); // NOT accepted v2.add_label(label1); v2.add_label(label3); - auto v3 = dba->insert_vertex(); // YES accepted + auto v3 = dba->InsertVertex(); // YES accepted v3.add_label(label1); v3.add_label(label2); v3.add_label(label3); - dba->advance_command(); + dba->AdvanceCommand(); AstTreeStorage storage; SymbolTable symbol_table; @@ -223,16 +223,16 @@ TEST(QueryPlan, Expand) { auto dba = dbms.active(); // make a V-graph (v3)<-[r2]-(v1)-[r1]->(v2) - auto v1 = dba->insert_vertex(); + auto v1 = dba->InsertVertex(); v1.add_label((GraphDbTypes::Label)1); - auto v2 = dba->insert_vertex(); + auto v2 = dba->InsertVertex(); v2.add_label((GraphDbTypes::Label)2); - auto v3 = dba->insert_vertex(); + auto v3 = dba->InsertVertex(); v3.add_label((GraphDbTypes::Label)3); - auto edge_type = dba->edge_type("Edge"); - dba->insert_edge(v1, v2, edge_type); - dba->insert_edge(v1, v3, edge_type); - dba->advance_command(); + auto edge_type = dba->EdgeType("Edge"); + dba->InsertEdge(v1, v2, edge_type); + dba->InsertEdge(v1, v3, edge_type); + dba->AdvanceCommand(); AstTreeStorage storage; SymbolTable symbol_table; @@ -260,15 +260,15 @@ TEST(QueryPlan, Expand) { v1.Reconstruct(); v2.Reconstruct(); v3.Reconstruct(); - dba->insert_edge(v1, v2, edge_type); - dba->insert_edge(v1, v3, edge_type); + dba->InsertEdge(v1, v2, edge_type); + dba->InsertEdge(v1, v3, edge_type); EXPECT_EQ(2, test_expand(EdgeAtom::Direction::OUT, GraphView::OLD)); EXPECT_EQ(2, test_expand(EdgeAtom::Direction::IN, GraphView::OLD)); EXPECT_EQ(4, test_expand(EdgeAtom::Direction::BOTH, GraphView::OLD)); EXPECT_EQ(4, test_expand(EdgeAtom::Direction::OUT, GraphView::NEW)); EXPECT_EQ(4, test_expand(EdgeAtom::Direction::IN, GraphView::NEW)); EXPECT_EQ(8, test_expand(EdgeAtom::Direction::BOTH, GraphView::NEW)); - dba->advance_command(); + dba->AdvanceCommand(); EXPECT_EQ(4, test_expand(EdgeAtom::Direction::OUT, GraphView::OLD)); EXPECT_EQ(4, test_expand(EdgeAtom::Direction::IN, GraphView::OLD)); EXPECT_EQ(8, test_expand(EdgeAtom::Direction::BOTH, GraphView::OLD)); @@ -309,27 +309,26 @@ class QueryPlanExpandVariable : public testing::Test { std::vector layer; for (int from_layer_ind = -1; from_layer_ind < chain_length - 1; from_layer_ind++) { - std::vector new_layer{dba->insert_vertex(), - dba->insert_vertex()}; - auto label = dba->label(std::to_string(from_layer_ind + 1)); + std::vector new_layer{dba->InsertVertex(), + dba->InsertVertex()}; + auto label = dba->Label(std::to_string(from_layer_ind + 1)); labels.push_back(label); for (size_t v_to_ind = 0; v_to_ind < new_layer.size(); v_to_ind++) { auto &v_to = new_layer[v_to_ind]; v_to.add_label(label); for (size_t v_from_ind = 0; v_from_ind < layer.size(); v_from_ind++) { auto &v_from = layer[v_from_ind]; - auto edge = - dba->insert_edge(v_from, v_to, dba->edge_type("edge_type")); - edge.PropsSet(dba->property("p"), + auto edge = dba->InsertEdge(v_from, v_to, dba->EdgeType("edge_type")); + edge.PropsSet(dba->Property("p"), fmt::format("V{}{}->V{}{}", from_layer_ind, v_from_ind, from_layer_ind + 1, v_to_ind)); } } layer = new_layer; } - dba->advance_command(); - ASSERT_EQ(CountIterable(dba->vertices(false)), 2 * chain_length); - ASSERT_EQ(CountIterable(dba->edges(false)), 4 * (chain_length - 1)); + dba->AdvanceCommand(); + ASSERT_EQ(CountIterable(dba->Vertices(false)), 2 * chain_length); + ASSERT_EQ(CountIterable(dba->Edges(false)), 4 * (chain_length - 1)); } /** @@ -563,17 +562,17 @@ TEST_F(QueryPlanExpandVariable, GraphState) { EXPECT_EQ(test_expand(GraphView::OLD), (map_int{{2, 8}})); // add two vertices branching out from the second layer - for (VertexAccessor &vertex : dba->vertices(true)) + for (VertexAccessor &vertex : dba->Vertices(true)) if (vertex.has_label(labels[1])) { - auto new_vertex = dba->insert_vertex(); - dba->insert_edge(vertex, new_vertex, dba->edge_type("some_type")); + auto new_vertex = dba->InsertVertex(); + dba->InsertEdge(vertex, new_vertex, dba->EdgeType("some_type")); } - ASSERT_EQ(CountIterable(dba->vertices(false)), 6); - ASSERT_EQ(CountIterable(dba->vertices(true)), 8); + ASSERT_EQ(CountIterable(dba->Vertices(false)), 6); + ASSERT_EQ(CountIterable(dba->Vertices(true)), 8); EXPECT_EQ(test_expand(GraphView::OLD), (map_int{{2, 8}})); EXPECT_EQ(test_expand(GraphView::NEW), (map_int{{2, 12}})); - dba->advance_command(); + dba->AdvanceCommand(); EXPECT_EQ(test_expand(GraphView::OLD), (map_int{{2, 12}})); EXPECT_EQ(test_expand(GraphView::NEW), (map_int{{2, 12}})); } @@ -598,7 +597,7 @@ class QueryPlanExpandBreadthFirst : public testing::Test { std::unique_ptr dba = dbms_.active(); std::pair prop = PROPERTY_PAIR("property"); - GraphDbTypes::EdgeType edge_type = dba->edge_type("edge_type"); + GraphDbTypes::EdgeType edge_type = dba->EdgeType("edge_type"); // make 4 vertices because we'll need to compare against them exactly // v[0] has `prop` with the value 0 @@ -617,12 +616,12 @@ class QueryPlanExpandBreadthFirst : public testing::Test { void SetUp() { for (int i = 0; i < 4; i++) { - v.push_back(dba->insert_vertex()); + v.push_back(dba->InsertVertex()); v.back().PropsSet(prop.second, i); } auto add_edge = [&](int from, int to) { - EdgeAccessor edge = dba->insert_edge(v[from], v[to], edge_type); + EdgeAccessor edge = dba->InsertEdge(v[from], v[to], edge_type); edge.PropsSet(prop.second, from * 10 + to); e.emplace(std::make_pair(from, to), edge); }; @@ -634,7 +633,7 @@ class QueryPlanExpandBreadthFirst : public testing::Test { add_edge(3, 2); add_edge(2, 2); - dba->advance_command(); + dba->AdvanceCommand(); for (auto &vertex : v) vertex.Reconstruct(); for (auto &edge : e) edge.second.Reconstruct(); } @@ -760,14 +759,14 @@ TEST_F(QueryPlanExpandBreadthFirst, GraphState) { }; EXPECT_EQ(ExpandSize(GraphView::OLD), 3); EXPECT_EQ(ExpandSize(GraphView::NEW), 3); - auto new_vertex = dba->insert_vertex(); + auto new_vertex = dba->InsertVertex(); new_vertex.PropsSet(prop.second, 4); - dba->insert_edge(v[3], new_vertex, edge_type); - EXPECT_EQ(CountIterable(dba->vertices(false)), 4); - EXPECT_EQ(CountIterable(dba->vertices(true)), 5); + dba->InsertEdge(v[3], new_vertex, edge_type); + EXPECT_EQ(CountIterable(dba->Vertices(false)), 4); + EXPECT_EQ(CountIterable(dba->Vertices(true)), 5); EXPECT_EQ(ExpandSize(GraphView::OLD), 3); EXPECT_EQ(ExpandSize(GraphView::NEW), 4); - dba->advance_command(); + dba->AdvanceCommand(); EXPECT_EQ(ExpandSize(GraphView::OLD), 4); EXPECT_EQ(ExpandSize(GraphView::NEW), 4); } @@ -816,17 +815,17 @@ TEST(QueryPlan, ExpandOptional) { SymbolTable symbol_table; // graph (v2 {p: 2})<-[:T]-(v1 {p: 1})-[:T]->(v3 {p: 2}) - auto prop = dba->property("p"); - auto edge_type = dba->edge_type("T"); - auto v1 = dba->insert_vertex(); + auto prop = dba->Property("p"); + auto edge_type = dba->EdgeType("T"); + auto v1 = dba->InsertVertex(); v1.PropsSet(prop, 1); - auto v2 = dba->insert_vertex(); + auto v2 = dba->InsertVertex(); v2.PropsSet(prop, 2); - dba->insert_edge(v1, v2, edge_type); - auto v3 = dba->insert_vertex(); + dba->InsertEdge(v1, v2, edge_type); + auto v3 = dba->InsertVertex(); v3.PropsSet(prop, 2); - dba->insert_edge(v1, v3, edge_type); - dba->advance_command(); + dba->InsertEdge(v1, v3, edge_type); + dba->AdvanceCommand(); // MATCH (n) OPTIONAL MATCH (n)-[r]->(m) auto n = MakeScanAll(storage, symbol_table, "n"); @@ -920,18 +919,18 @@ TEST(QueryPlan, OptionalMatchThenExpandToMissingNode) { Dbms dbms; auto dba = dbms.active(); // Make a graph with 2 connected, unlabeled nodes. - auto v1 = dba->insert_vertex(); - auto v2 = dba->insert_vertex(); - auto edge_type = dba->edge_type("edge_type"); - dba->insert_edge(v1, v2, edge_type); - dba->advance_command(); - EXPECT_EQ(2, CountIterable(dba->vertices(false))); - EXPECT_EQ(1, CountIterable(dba->edges(false))); + auto v1 = dba->InsertVertex(); + auto v2 = dba->InsertVertex(); + auto edge_type = dba->EdgeType("edge_type"); + dba->InsertEdge(v1, v2, edge_type); + dba->AdvanceCommand(); + EXPECT_EQ(2, CountIterable(dba->Vertices(false))); + EXPECT_EQ(1, CountIterable(dba->Edges(false))); AstTreeStorage storage; SymbolTable symbol_table; // OPTIONAL MATCH (n :missing) auto n = MakeScanAll(storage, symbol_table, "n"); - auto label_missing = dba->label("missing"); + auto label_missing = dba->Label("missing"); n.node_->labels_.emplace_back(label_missing); auto *filter_expr = @@ -968,18 +967,18 @@ TEST(QueryPlan, OptionalMatchThenExpandToMissingEdge) { Dbms dbms; auto dba = dbms.active(); // Make a graph with 2 connected, unlabeled nodes. - auto v1 = dba->insert_vertex(); - auto v2 = dba->insert_vertex(); - auto edge_type = dba->edge_type("edge_type"); - dba->insert_edge(v1, v2, edge_type); - dba->advance_command(); - EXPECT_EQ(2, CountIterable(dba->vertices(false))); - EXPECT_EQ(1, CountIterable(dba->edges(false))); + auto v1 = dba->InsertVertex(); + auto v2 = dba->InsertVertex(); + auto edge_type = dba->EdgeType("edge_type"); + dba->InsertEdge(v1, v2, edge_type); + dba->AdvanceCommand(); + EXPECT_EQ(2, CountIterable(dba->Vertices(false))); + EXPECT_EQ(1, CountIterable(dba->Edges(false))); AstTreeStorage storage; SymbolTable symbol_table; // OPTIONAL MATCH (n :missing) -[r]- (m) auto n = MakeScanAll(storage, symbol_table, "n"); - auto label_missing = dba->label("missing"); + auto label_missing = dba->Label("missing"); n.node_->labels_.emplace_back(label_missing); auto *filter_expr = storage.Create(n.node_->identifier_, n.node_->labels_); @@ -1020,12 +1019,12 @@ TEST(QueryPlan, ExpandExistingNode) { // make a graph (v1)->(v2) that // has a recursive edge (v1)->(v1) - auto v1 = dba->insert_vertex(); - auto v2 = dba->insert_vertex(); - auto edge_type = dba->edge_type("Edge"); - dba->insert_edge(v1, v1, edge_type); - dba->insert_edge(v1, v2, edge_type); - dba->advance_command(); + auto v1 = dba->InsertVertex(); + auto v2 = dba->InsertVertex(); + auto edge_type = dba->EdgeType("Edge"); + dba->InsertEdge(v1, v1, edge_type); + dba->InsertEdge(v1, v2, edge_type); + dba->AdvanceCommand(); AstTreeStorage storage; SymbolTable symbol_table; @@ -1059,16 +1058,16 @@ TEST(QueryPlan, ExpandExistingEdge) { auto dba = dbms.active(); // make a V-graph (v3)<-[r2]-(v1)-[r1]->(v2) - auto v1 = dba->insert_vertex(); + auto v1 = dba->InsertVertex(); v1.add_label((GraphDbTypes::Label)1); - auto v2 = dba->insert_vertex(); + auto v2 = dba->InsertVertex(); v2.add_label((GraphDbTypes::Label)2); - auto v3 = dba->insert_vertex(); + auto v3 = dba->InsertVertex(); v3.add_label((GraphDbTypes::Label)3); - auto edge_type = dba->edge_type("Edge"); - dba->insert_edge(v1, v2, edge_type); - dba->insert_edge(v1, v3, edge_type); - dba->advance_command(); + auto edge_type = dba->EdgeType("Edge"); + dba->InsertEdge(v1, v2, edge_type); + dba->InsertEdge(v1, v3, edge_type); + dba->AdvanceCommand(); AstTreeStorage storage; SymbolTable symbol_table; @@ -1106,9 +1105,9 @@ TEST(QueryPlan, ExpandBothCycleEdgeCase) { Dbms dbms; auto dba = dbms.active(); - auto v = dba->insert_vertex(); - dba->insert_edge(v, v, dba->edge_type("et")); - dba->advance_command(); + auto v = dba->InsertVertex(); + dba->InsertEdge(v, v, dba->EdgeType("et")); + dba->AdvanceCommand(); AstTreeStorage storage; SymbolTable symbol_table; @@ -1129,14 +1128,14 @@ TEST(QueryPlan, EdgeFilter) { // (edge_type yes|no) * (property yes|absent|no) std::vector edge_types; for (int j = 0; j < 2; ++j) - edge_types.push_back(dba->edge_type("et" + std::to_string(j))); + edge_types.push_back(dba->EdgeType("et" + std::to_string(j))); std::vector vertices; - for (int i = 0; i < 7; ++i) vertices.push_back(dba->insert_vertex()); + for (int i = 0; i < 7; ++i) vertices.push_back(dba->InsertVertex()); auto prop = PROPERTY_PAIR("property"); std::vector edges; for (int i = 0; i < 6; ++i) { edges.push_back( - dba->insert_edge(vertices[0], vertices[i + 1], edge_types[i % 2])); + dba->InsertEdge(vertices[0], vertices[i + 1], edge_types[i % 2])); switch (i % 3) { case 0: edges.back().PropsSet(prop.second, 42); @@ -1148,7 +1147,7 @@ TEST(QueryPlan, EdgeFilter) { break; } } - dba->advance_command(); + dba->AdvanceCommand(); for (auto &vertex : vertices) vertex.Reconstruct(); for (auto &edge : edges) edge.Reconstruct(); @@ -1184,7 +1183,7 @@ TEST(QueryPlan, EdgeFilter) { // test that edge filtering always filters on old state for (auto &edge : edges) edge.PropsSet(prop.second, 42); EXPECT_EQ(1, test_filter()); - dba->advance_command(); + dba->AdvanceCommand(); EXPECT_EQ(3, test_filter()); } @@ -1192,15 +1191,15 @@ TEST(QueryPlan, EdgeFilterMultipleTypes) { Dbms dbms; auto dba = dbms.active(); - auto v1 = dba->insert_vertex(); - auto v2 = dba->insert_vertex(); - auto type_1 = dba->edge_type("type_1"); - auto type_2 = dba->edge_type("type_2"); - auto type_3 = dba->edge_type("type_3"); - dba->insert_edge(v1, v2, type_1); - dba->insert_edge(v1, v2, type_2); - dba->insert_edge(v1, v2, type_3); - dba->advance_command(); + auto v1 = dba->InsertVertex(); + auto v2 = dba->InsertVertex(); + auto type_1 = dba->EdgeType("type_1"); + auto type_2 = dba->EdgeType("type_2"); + auto type_3 = dba->EdgeType("type_3"); + dba->InsertEdge(v1, v2, type_1); + dba->InsertEdge(v1, v2, type_2); + dba->InsertEdge(v1, v2, type_3); + dba->AdvanceCommand(); AstTreeStorage storage; SymbolTable symbol_table; @@ -1235,9 +1234,9 @@ TEST(QueryPlan, Filter) { // add a 6 nodes with property 'prop', 2 have true as value auto property = PROPERTY_PAIR("property"); for (int i = 0; i < 6; ++i) - dba->insert_vertex().PropsSet(property.second, i % 3 == 0); - dba->insert_vertex(); // prop not set, gives NULL - dba->advance_command(); + dba->InsertVertex().PropsSet(property.second, i % 3 == 0); + dba->InsertVertex(); // prop not set, gives NULL + dba->AdvanceCommand(); AstTreeStorage storage; SymbolTable symbol_table; @@ -1262,12 +1261,12 @@ TEST(QueryPlan, ExpandUniquenessFilter) { auto dba = dbms.active(); // make a graph that has (v1)->(v2) and a recursive edge (v1)->(v1) - auto v1 = dba->insert_vertex(); - auto v2 = dba->insert_vertex(); - auto edge_type = dba->edge_type("edge_type"); - dba->insert_edge(v1, v2, edge_type); - dba->insert_edge(v1, v1, edge_type); - dba->advance_command(); + auto v1 = dba->InsertVertex(); + auto v2 = dba->InsertVertex(); + auto edge_type = dba->EdgeType("edge_type"); + dba->InsertEdge(v1, v2, edge_type); + dba->InsertEdge(v1, v1, edge_type); + dba->AdvanceCommand(); auto check_expand_results = [&](bool vertex_uniqueness, bool edge_uniqueness) { @@ -1350,12 +1349,12 @@ TEST(QueryPlan, ScanAllByLabel) { Dbms dbms; auto dba = dbms.active(); // Add a vertex with a label and one without. - auto label = dba->label("label"); - auto labeled_vertex = dba->insert_vertex(); + auto label = dba->Label("label"); + auto labeled_vertex = dba->InsertVertex(); labeled_vertex.add_label(label); - dba->insert_vertex(); - dba->advance_command(); - EXPECT_EQ(2, CountIterable(dba->vertices(false))); + dba->InsertVertex(); + dba->AdvanceCommand(); + EXPECT_EQ(2, CountIterable(dba->Vertices(false))); // MATCH (n :label) AstTreeStorage storage; SymbolTable symbol_table; @@ -1377,8 +1376,8 @@ TEST(QueryPlan, ScanAllByLabelProperty) { Dbms dbms; auto dba = dbms.active(); // Add 5 vertices with same label, but with different property values. - auto label = dba->label("label"); - auto prop = dba->property("prop"); + auto label = dba->Label("label"); + auto prop = dba->Property("prop"); // vertex property values that will be stored into the DB // clang-format off @@ -1389,16 +1388,16 @@ TEST(QueryPlan, ScanAllByLabelProperty) { // clang-format on for (const auto &value : values) { - auto vertex = dba->insert_vertex(); + auto vertex = dba->InsertVertex(); vertex.add_label(label); vertex.PropsSet(prop, value); } - dba->commit(); + dba->Commit(); dba = dbms.active(); dba->BuildIndex(label, prop); - dba->commit(); + dba->Commit(); dba = dbms.active(); - ASSERT_EQ(14, CountIterable(dba->vertices(false))); + ASSERT_EQ(14, CountIterable(dba->Vertices(false))); auto check = [&dba, label, prop](TypedValue lower, Bound::Type lower_type, TypedValue upper, Bound::Type upper_type, @@ -1450,19 +1449,19 @@ TEST(QueryPlan, ScanAllByLabelPropertyEqualityNoError) { auto dba = dbms.active(); // Add 2 vertices with same label, but with property values that cannot be // compared. On the other hand, equality works fine. - auto label = dba->label("label"); - auto prop = dba->property("prop"); - auto number_vertex = dba->insert_vertex(); + auto label = dba->Label("label"); + auto prop = dba->Property("prop"); + auto number_vertex = dba->InsertVertex(); number_vertex.add_label(label); number_vertex.PropsSet(prop, 42); - auto string_vertex = dba->insert_vertex(); + auto string_vertex = dba->InsertVertex(); string_vertex.add_label(label); string_vertex.PropsSet(prop, "string"); - dba->commit(); + dba->Commit(); dba = dbms.active(); dba->BuildIndex(label, prop); dba = dbms.active(); - EXPECT_EQ(2, CountIterable(dba->vertices(false))); + EXPECT_EQ(2, CountIterable(dba->Vertices(false))); // MATCH (n :label {prop: 42}) AstTreeStorage storage; SymbolTable symbol_table; @@ -1490,18 +1489,18 @@ TEST(QueryPlan, ScanAllByLabelPropertyEqualNull) { // the // other does not. Checking if the value is equal to null, should yield no // results. - auto label = dba->label("label"); - auto prop = dba->property("prop"); - auto vertex = dba->insert_vertex(); + auto label = dba->Label("label"); + auto prop = dba->Property("prop"); + auto vertex = dba->InsertVertex(); vertex.add_label(label); - auto vertex_with_prop = dba->insert_vertex(); + auto vertex_with_prop = dba->InsertVertex(); vertex_with_prop.add_label(label); vertex_with_prop.PropsSet(prop, 42); - dba->commit(); + dba->Commit(); dba = dbms.active(); dba->BuildIndex(label, prop); dba = dbms.active(); - EXPECT_EQ(2, CountIterable(dba->vertices(false))); + EXPECT_EQ(2, CountIterable(dba->Vertices(false))); // MATCH (n :label {prop: 42}) AstTreeStorage storage; SymbolTable symbol_table; diff --git a/tests/unit/query_planner.cpp b/tests/unit/query_planner.cpp index 274faaf81..e491ed160 100644 --- a/tests/unit/query_planner.cpp +++ b/tests/unit/query_planner.cpp @@ -337,7 +337,7 @@ TEST(TestLogicalPlanner, CreateExpand) { AstTreeStorage storage; Dbms dbms; auto dba = dbms.active(); - auto relationship = dba->edge_type("relationship"); + auto relationship = dba->EdgeType("relationship"); QUERY(CREATE( PATTERN(NODE("n"), EDGE("r", relationship, Direction::OUT), NODE("m")))); CheckPlan(storage, ExpectCreateNode(), ExpectCreateExpand()); @@ -355,7 +355,7 @@ TEST(TestLogicalPlanner, CreateNodeExpandNode) { AstTreeStorage storage; Dbms dbms; auto dba = dbms.active(); - auto relationship = dba->edge_type("rel"); + auto relationship = dba->EdgeType("rel"); QUERY(CREATE( PATTERN(NODE("n"), EDGE("r", relationship, Direction::OUT), NODE("m")), PATTERN(NODE("l")))); @@ -368,7 +368,7 @@ TEST(TestLogicalPlanner, MatchCreateExpand) { AstTreeStorage storage; Dbms dbms; auto dba = dbms.active(); - auto relationship = dba->edge_type("relationship"); + auto relationship = dba->EdgeType("relationship"); QUERY(MATCH(PATTERN(NODE("n"))), CREATE(PATTERN(NODE("n"), EDGE("r", relationship, Direction::OUT), NODE("m")))); @@ -380,7 +380,7 @@ TEST(TestLogicalPlanner, MatchLabeledNodes) { AstTreeStorage storage; Dbms dbms; auto dba = dbms.active(); - auto label = dba->label("label"); + auto label = dba->Label("label"); QUERY(MATCH(PATTERN(NODE("n", label))), RETURN("n")); CheckPlan(storage, ExpectScanAllByLabel(), ExpectFilter(), ExpectProduce()); } @@ -390,7 +390,7 @@ TEST(TestLogicalPlanner, MatchPathReturn) { AstTreeStorage storage; Dbms dbms; auto dba = dbms.active(); - auto relationship = dba->edge_type("relationship"); + auto relationship = dba->EdgeType("relationship"); QUERY(MATCH(PATTERN(NODE("n"), EDGE("r", relationship), NODE("m"))), RETURN("n")); CheckPlan(storage, ExpectScanAll(), ExpectExpand(), ExpectFilter(), @@ -402,7 +402,7 @@ TEST(TestLogicalPlanner, MatchWhereReturn) { AstTreeStorage storage; Dbms dbms; auto dba = dbms.active(); - auto property = dba->property("property"); + auto property = dba->Property("property"); QUERY(MATCH(PATTERN(NODE("n"))), WHERE(LESS(PROPERTY_LOOKUP("n", property), LITERAL(42))), RETURN("n")); CheckPlan(storage, ExpectScanAll(), ExpectFilter(), ExpectProduce()); @@ -420,8 +420,8 @@ TEST(TestLogicalPlanner, MatchNodeSet) { AstTreeStorage storage; Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); - auto label = dba->label("label"); + auto prop = dba->Property("prop"); + auto label = dba->Label("label"); QUERY(MATCH(PATTERN(NODE("n"))), SET(PROPERTY_LOOKUP("n", prop), LITERAL(42)), SET("n", IDENT("n")), SET("n", {label})); CheckPlan(storage, ExpectScanAll(), ExpectSetProperty(), @@ -433,8 +433,8 @@ TEST(TestLogicalPlanner, MatchRemove) { AstTreeStorage storage; Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); - auto label = dba->label("label"); + auto prop = dba->Property("prop"); + auto label = dba->Label("label"); QUERY(MATCH(PATTERN(NODE("n"))), REMOVE(PROPERTY_LOOKUP("n", prop)), REMOVE("n", {label})); CheckPlan(storage, ExpectScanAll(), ExpectRemoveProperty(), @@ -534,7 +534,7 @@ TEST(TestLogicalPlanner, MatchWithWhereReturn) { // Test MATCH (old) WITH old AS new WHERE new.prop < 42 RETURN new Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); AstTreeStorage storage; QUERY(MATCH(PATTERN(NODE("old"))), WITH("old", AS("new")), WHERE(LESS(PROPERTY_LOOKUP("new", prop), LITERAL(42))), RETURN("new")); @@ -547,8 +547,8 @@ TEST(TestLogicalPlanner, CreateMultiExpand) { // Test CREATE (n) -[r :r]-> (m), (n) - [p :p]-> (l) Dbms dbms; auto dba = dbms.active(); - auto r = dba->edge_type("r"); - auto p = dba->edge_type("p"); + auto r = dba->EdgeType("r"); + auto p = dba->EdgeType("p"); AstTreeStorage storage; QUERY(CREATE(PATTERN(NODE("n"), EDGE("r", r, Direction::OUT), NODE("m")), PATTERN(NODE("n"), EDGE("p", p, Direction::OUT), NODE("l")))); @@ -561,7 +561,7 @@ TEST(TestLogicalPlanner, MatchWithSumWhereReturn) { // RETURN sum AS result Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); AstTreeStorage storage; auto sum = SUM(PROPERTY_LOOKUP("n", prop)); auto literal = LITERAL(42); @@ -576,8 +576,8 @@ TEST(TestLogicalPlanner, MatchReturnSum) { // Test MATCH (n) RETURN SUM(n.prop1) AS sum, n.prop2 AS group Dbms dbms; auto dba = dbms.active(); - auto prop1 = dba->property("prop1"); - auto prop2 = dba->property("prop2"); + auto prop1 = dba->Property("prop1"); + auto prop2 = dba->Property("prop2"); AstTreeStorage storage; auto sum = SUM(PROPERTY_LOOKUP("n", prop1)); auto n_prop2 = PROPERTY_LOOKUP("n", prop2); @@ -591,7 +591,7 @@ TEST(TestLogicalPlanner, CreateWithSum) { // Test CREATE (n) WITH SUM(n.prop) AS sum Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); AstTreeStorage storage; auto n_prop = PROPERTY_LOOKUP("n", prop); auto sum = SUM(n_prop); @@ -610,7 +610,7 @@ TEST(TestLogicalPlanner, MatchWithCreate) { // Test MATCH (n) WITH n AS a CREATE (a) -[r :r]-> (b) Dbms dbms; auto dba = dbms.active(); - auto r_type = dba->edge_type("r"); + auto r_type = dba->EdgeType("r"); AstTreeStorage storage; QUERY( MATCH(PATTERN(NODE("n"))), WITH("n", AS("a")), @@ -652,7 +652,7 @@ TEST(TestLogicalPlanner, CreateReturnSumSkipLimit) { // Test CREATE (n) RETURN SUM(n.prop) AS s SKIP 2 LIMIT 1 Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); AstTreeStorage storage; auto n_prop = PROPERTY_LOOKUP("n", prop); auto sum = SUM(n_prop); @@ -670,7 +670,7 @@ TEST(TestLogicalPlanner, MatchReturnOrderBy) { // Test MATCH (n) RETURN n ORDER BY n.prop Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); AstTreeStorage storage; auto ret = RETURN("n", ORDER_BY(PROPERTY_LOOKUP("n", prop))); QUERY(MATCH(PATTERN(NODE("n"))), ret); @@ -682,8 +682,8 @@ TEST(TestLogicalPlanner, CreateWithOrderByWhere) { // WITH n AS new ORDER BY new.prop, r.prop WHERE m.prop < 42 Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); - auto r_type = dba->edge_type("r"); + auto prop = dba->Property("prop"); + auto r_type = dba->EdgeType("r"); AstTreeStorage storage; auto ident_n = IDENT("n"); auto new_prop = PROPERTY_LOOKUP("new", prop); @@ -721,8 +721,8 @@ TEST(TestLogicalPlanner, MatchMerge) { // RETURN n AS n Dbms dbms; auto dba = dbms.active(); - auto r_type = dba->edge_type("r"); - auto prop = dba->property("prop"); + auto r_type = dba->EdgeType("r"); + auto prop = dba->Property("prop"); AstTreeStorage storage; auto ident_n = IDENT("n"); auto query = @@ -751,7 +751,7 @@ TEST(TestLogicalPlanner, MatchOptionalMatchWhereReturn) { // Test MATCH (n) OPTIONAL MATCH (n) -[r]- (m) WHERE m.prop < 42 RETURN r Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); AstTreeStorage storage; QUERY(MATCH(PATTERN(NODE("n"))), OPTIONAL_MATCH(PATTERN(NODE("n"), EDGE("r"), NODE("m"))), @@ -784,7 +784,7 @@ TEST(TestLogicalPlanner, CreateWithDistinctSumWhereReturn) { // Test CREATE (n) WITH DISTINCT SUM(n.prop) AS s WHERE s < 42 RETURN s Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); AstTreeStorage storage; auto node_n = NODE("n"); auto sum = SUM(PROPERTY_LOOKUP("n", prop)); @@ -821,7 +821,7 @@ TEST(TestLogicalPlanner, MatchWhereBeforeExpand) { // Test MATCH (n) -[r]- (m) WHERE n.prop < 42 RETURN n Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); AstTreeStorage storage; QUERY(MATCH(PATTERN(NODE("n"), EDGE("r"), NODE("m"))), WHERE(LESS(PROPERTY_LOOKUP("n", prop), LITERAL(42))), RETURN("n")); @@ -834,7 +834,7 @@ TEST(TestLogicalPlanner, MultiMatchWhere) { // Test MATCH (n) -[r]- (m) MATCH (l) WHERE n.prop < 42 RETURN n Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); AstTreeStorage storage; QUERY(MATCH(PATTERN(NODE("n"), EDGE("r"), NODE("m"))), MATCH(PATTERN(NODE("l"))), @@ -849,7 +849,7 @@ TEST(TestLogicalPlanner, MatchOptionalMatchWhere) { // Test MATCH (n) -[r]- (m) OPTIONAL MATCH (l) WHERE n.prop < 42 RETURN n Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); AstTreeStorage storage; QUERY(MATCH(PATTERN(NODE("n"), EDGE("r"), NODE("m"))), OPTIONAL_MATCH(PATTERN(NODE("l"))), @@ -866,7 +866,7 @@ TEST(TestLogicalPlanner, MatchReturnAsterisk) { // Test MATCH (n) -[e]- (m) RETURN *, m.prop Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); AstTreeStorage storage; auto ret = RETURN(PROPERTY_LOOKUP("m", prop), AS("m.prop")); ret->body_.all_identifiers = true; @@ -887,7 +887,7 @@ TEST(TestLogicalPlanner, MatchReturnAsteriskSum) { // Test MATCH (n) RETURN *, SUM(n.prop) AS s Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); AstTreeStorage storage; auto sum = SUM(PROPERTY_LOOKUP("n", prop)); auto ret = RETURN(sum, AS("s")); @@ -967,7 +967,8 @@ TEST(TestLogicalPlanner, ListLiteralAggregationReturn) { TEST(TestLogicalPlanner, MapLiteralAggregationReturn) { // Test RETURN {sum: SUM(2)} AS result, 42 AS group_by - AstTreeStorage storage; Dbms dbms; + AstTreeStorage storage; + Dbms dbms; auto dba = dbms.active(); auto sum = SUM(LITERAL(2)); auto group_by_literal = LITERAL(42); @@ -1007,11 +1008,11 @@ TEST(TestLogicalPlanner, ListSliceAggregationReturn) { } TEST(TestLogicalPlanner, CreateIndex) { - // Test CREATE INDEX ON :label(property) + // Test CREATE INDEX ON :Label(property) Dbms dbms; auto dba = dbms.active(); - auto label = dba->label("label"); - auto property = dba->property("property"); + auto label = dba->Label("label"); + auto property = dba->Property("property"); AstTreeStorage storage; QUERY(CREATE_INDEX_ON(label, property)); CheckPlan(storage, ExpectCreateIndex(label, property)); @@ -1022,13 +1023,13 @@ TEST(TestLogicalPlanner, AtomIndexedLabelProperty) { AstTreeStorage storage; Dbms dbms; auto dba = dbms.active(); - auto label = dba->label("label"); + auto label = dba->Label("label"); auto property = PROPERTY_PAIR("property"); auto not_indexed = PROPERTY_PAIR("not_indexed"); - auto vertex = dba->insert_vertex(); + auto vertex = dba->InsertVertex(); vertex.add_label(label); vertex.PropsSet(property.second, 42); - dba->commit(); + dba->Commit(); dba = dbms.active(); dba->BuildIndex(label, property.second); dba = dbms.active(); @@ -1049,7 +1050,7 @@ TEST(TestLogicalPlanner, AtomPropertyWhereLabelIndexing) { AstTreeStorage storage; Dbms dbms; auto dba = dbms.active(); - auto label = dba->label("label"); + auto label = dba->Label("label"); auto property = PROPERTY_PAIR("property"); auto not_indexed = PROPERTY_PAIR("not_indexed"); dba->BuildIndex(label, property.second); @@ -1074,7 +1075,7 @@ TEST(TestLogicalPlanner, WhereIndexedLabelProperty) { AstTreeStorage storage; Dbms dbms; auto dba = dbms.active(); - auto label = dba->label("label"); + auto label = dba->Label("label"); auto property = PROPERTY_PAIR("property"); dba->BuildIndex(label, property.second); dba = dbms.active(); @@ -1093,22 +1094,22 @@ TEST(TestLogicalPlanner, BestPropertyIndexed) { AstTreeStorage storage; Dbms dbms; auto dba = dbms.active(); - auto label = dba->label("label"); - auto property = dba->property("property"); + auto label = dba->Label("label"); + auto property = dba->Property("property"); dba->BuildIndex(label, property); dba = dbms.active(); // Add a vertex with :label+property combination, so that the best // :label+better remains empty and thus better choice. - auto vertex = dba->insert_vertex(); + auto vertex = dba->InsertVertex(); vertex.add_label(label); vertex.PropsSet(property, 1); - dba->commit(); + dba->Commit(); dba = dbms.active(); - ASSERT_EQ(dba->vertices_count(label, property), 1); + ASSERT_EQ(dba->VerticesCount(label, property), 1); auto better = PROPERTY_PAIR("better"); dba->BuildIndex(label, better.second); dba = dbms.active(); - ASSERT_EQ(dba->vertices_count(label, better.second), 0); + ASSERT_EQ(dba->VerticesCount(label, better.second), 0); auto lit_42 = LITERAL(42); QUERY(MATCH(PATTERN(NODE("n", label))), WHERE(AND(EQ(PROPERTY_LOOKUP("n", property), LITERAL(1)), @@ -1126,8 +1127,8 @@ TEST(TestLogicalPlanner, MultiPropertyIndexScan) { // RETURN n, m Dbms dbms; auto dba = dbms.active(); - auto label1 = dba->label("label1"); - auto label2 = dba->label("label2"); + auto label1 = dba->Label("label1"); + auto label2 = dba->Label("label2"); auto prop1 = PROPERTY_PAIR("prop1"); auto prop2 = PROPERTY_PAIR("prop2"); dba->BuildIndex(label1, prop1.second); @@ -1155,8 +1156,8 @@ TEST(TestLogicalPlanner, WhereIndexedLabelPropertyRange) { // REL_OP is one of: `<`, `<=`, `>`, `>=` Dbms dbms; auto dba = dbms.active(); - auto label = dba->label("label"); - auto property = dba->property("property"); + auto label = dba->Label("label"); + auto property = dba->Property("property"); dba->BuildIndex(label, property); dba = dbms.active(); AstTreeStorage storage; @@ -1204,8 +1205,8 @@ TEST(TestLogicalPlanner, UnableToUsePropertyIndex) { // Test MATCH (n: label) WHERE n.property = n.property RETURN n Dbms dbms; auto dba = dbms.active(); - auto label = dba->label("label"); - auto property = dba->property("property"); + auto label = dba->Label("label"); + auto property = dba->Property("property"); dba->BuildIndex(label, property); dba = dbms.active(); AstTreeStorage storage; @@ -1254,7 +1255,7 @@ TEST(TestLogicalPlanner, MatchExpandVariableFiltered) { // Test MATCH (n) -[r :type * {prop: 42}]-> (m) RETURN r Dbms dbms; auto dba = dbms.active(); - auto type = dba->edge_type("type"); + auto type = dba->EdgeType("type"); auto prop = PROPERTY_PAIR("prop"); AstTreeStorage storage; auto edge = EDGE("r", type); diff --git a/tests/unit/query_semantic.cpp b/tests/unit/query_semantic.cpp index 7f6e4fe41..6292f8404 100644 --- a/tests/unit/query_semantic.cpp +++ b/tests/unit/query_semantic.cpp @@ -172,7 +172,7 @@ TEST(TestSymbolGenerator, MatchCreateRedeclareEdge) { // MATCH (n) -[r]- (m) CREATE (n) -[r :relationship]-> (l) Dbms dbms; auto dba = dbms.active(); - auto relationship = dba->edge_type("relationship"); + auto relationship = dba->EdgeType("relationship"); auto query = QUERY(MATCH(PATTERN(NODE("n"), EDGE("r"), NODE("m"))), CREATE(PATTERN(NODE("n"), EDGE("r", relationship, EdgeAtom::Direction::OUT), @@ -210,8 +210,8 @@ TEST(TestSymbolGenerator, CreateMultipleEdgeType) { // CREATE (n) -[r :rel1 | :rel2]-> (m) Dbms dbms; auto dba = dbms.active(); - auto rel1 = dba->edge_type("rel1"); - auto rel2 = dba->edge_type("rel2"); + auto rel1 = dba->EdgeType("rel1"); + auto rel2 = dba->EdgeType("rel2"); auto edge = EDGE("r", rel1, EdgeAtom::Direction::OUT); edge->edge_types_.emplace_back(rel2); auto query = QUERY(CREATE(PATTERN(NODE("n"), edge, NODE("m")))); @@ -226,7 +226,7 @@ TEST(TestSymbolGenerator, CreateBidirectionalEdge) { // CREATE (n) -[r :rel1]- (m) Dbms dbms; auto dba = dbms.active(); - auto rel1 = dba->edge_type("rel1"); + auto rel1 = dba->EdgeType("rel1"); auto query = QUERY(CREATE(PATTERN(NODE("n"), EDGE("r", rel1), NODE("m")))); SymbolTable symbol_table; SymbolGenerator symbol_generator(symbol_table); @@ -307,7 +307,7 @@ TEST(TestSymbolGenerator, MatchWithWhere) { // Test MATCH (old) WITH old AS n WHERE n.prop < 42 Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); AstTreeStorage storage; auto node = NODE("old"); auto old_ident = IDENT("old"); @@ -332,7 +332,7 @@ TEST(TestSymbolGenerator, MatchWithWhereUnbound) { // Test MATCH (old) WITH COUNT(old) AS c WHERE old.prop < 42 Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); AstTreeStorage storage; auto query = QUERY(MATCH(PATTERN(NODE("old"))), WITH(COUNT(IDENT("old")), AS("c")), @@ -346,8 +346,8 @@ TEST(TestSymbolGenerator, CreateMultiExpand) { // Test CREATE (n) -[r :r]-> (m), (n) - [p :p]-> (l) Dbms dbms; auto dba = dbms.active(); - auto r_type = dba->edge_type("r"); - auto p_type = dba->edge_type("p"); + auto r_type = dba->EdgeType("r"); + auto p_type = dba->EdgeType("p"); AstTreeStorage storage; auto node_n1 = NODE("n"); auto edge_r = EDGE("r", r_type, EdgeAtom::Direction::OUT); @@ -383,8 +383,8 @@ TEST(TestSymbolGenerator, MatchCreateExpandLabel) { // Test MATCH (n) CREATE (m) -[r :r]-> (n:label) Dbms dbms; auto dba = dbms.active(); - auto r_type = dba->edge_type("r"); - auto label = dba->label("label"); + auto r_type = dba->EdgeType("r"); + auto label = dba->Label("label"); AstTreeStorage storage; auto query = QUERY( MATCH(PATTERN(NODE("n"))), @@ -399,7 +399,7 @@ TEST(TestSymbolGenerator, CreateExpandProperty) { // Test CREATE (n) -[r :r]-> (n {prop: 42}) Dbms dbms; auto dba = dbms.active(); - auto r_type = dba->edge_type("r"); + auto r_type = dba->EdgeType("r"); AstTreeStorage storage; auto n_prop = NODE("n"); n_prop->properties_[PROPERTY_PAIR("prop")] = LITERAL(42); @@ -414,7 +414,7 @@ TEST(TestSymbolGenerator, MatchReturnSum) { // Test MATCH (n) RETURN SUM(n.prop) + 42 AS result Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); AstTreeStorage storage; auto node = NODE("n"); auto sum = SUM(PROPERTY_LOOKUP("n", prop)); @@ -438,7 +438,7 @@ TEST(TestSymbolGenerator, NestedAggregation) { // Test MATCH (n) RETURN SUM(42 + SUM(n.prop)) AS s Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); AstTreeStorage storage; auto query = QUERY( MATCH(PATTERN(NODE("n"))), @@ -452,7 +452,7 @@ TEST(TestSymbolGenerator, WrongAggregationContext) { // Test MATCH (n) WITH n.prop AS prop WHERE SUM(prop) < 42 Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); AstTreeStorage storage; auto query = QUERY(MATCH(PATTERN(NODE("n"))), WITH(PROPERTY_LOOKUP("n", prop), AS("prop")), @@ -487,7 +487,7 @@ TEST(TestSymbolGenerator, CreateNodeEdge) { // Test CREATE (n), (n) -[r :r]-> (n) Dbms dbms; auto dba = dbms.active(); - auto r_type = dba->edge_type("r"); + auto r_type = dba->EdgeType("r"); AstTreeStorage storage; auto node_1 = NODE("n"); auto node_2 = NODE("n"); @@ -508,7 +508,7 @@ TEST(TestSymbolGenerator, MatchWithCreate) { // Test MATCH (n) WITH n AS m CREATE (m) -[r :r]-> (m) Dbms dbms; auto dba = dbms.active(); - auto r_type = dba->edge_type("r"); + auto r_type = dba->EdgeType("r"); AstTreeStorage storage; auto node_1 = NODE("n"); auto node_2 = NODE("m"); @@ -655,7 +655,7 @@ TEST(TestSymbolGenerator, MergeVariableError) { { Dbms dbms; auto dba = dbms.active(); - auto rel = dba->edge_type("rel"); + auto rel = dba->EdgeType("rel"); AstTreeStorage storage; auto query = QUERY(MATCH(PATTERN(NODE("n"), EDGE("r"), NODE("m"))), MERGE(PATTERN(NODE("a"), EDGE("r", rel), NODE("b")))); @@ -680,8 +680,8 @@ TEST(TestSymbolGenerator, MergeOnMatchOnCreate) { // ON CREATE SET m.prop = 42 RETURN r AS r Dbms dbms; auto dba = dbms.active(); - auto rel = dba->edge_type("rel"); - auto prop = dba->property("prop"); + auto rel = dba->EdgeType("rel"); + auto prop = dba->Property("prop"); AstTreeStorage storage; auto match_n = NODE("n"); auto merge_n = NODE("n"); @@ -786,7 +786,7 @@ TEST(TestSymbolGenerator, MatchWithAsteriskReturnAsterisk) { // MATCH (n) -[e]- (m) WITH * RETURN *, n.prop Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); AstTreeStorage storage; auto n_prop = PROPERTY_LOOKUP("n", prop); auto ret = RETURN(n_prop, AS("n.prop")); @@ -834,8 +834,8 @@ TEST(TestSymbolGenerator, MatchMergeExpandLabel) { // Test MATCH (n) MERGE (m) -[r :r]-> (n:label) Dbms dbms; auto dba = dbms.active(); - auto r_type = dba->edge_type("r"); - auto label = dba->label("label"); + auto r_type = dba->EdgeType("r"); + auto label = dba->Label("label"); AstTreeStorage storage; auto query = QUERY( MATCH(PATTERN(NODE("n"))), @@ -870,7 +870,7 @@ TEST(TestSymbolGenerator, MatchVariablePathUsingIdentifier) { // Test MATCH (n) -[r *..l.prop]- (m), (l) RETURN r Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); AstTreeStorage storage; auto edge = EDGE("r"); edge->has_range_ = true; @@ -894,7 +894,7 @@ TEST(TestSymbolGenerator, MatchVariablePathUsingUnboundIdentifier) { // Test MATCH (n) -[r *..l.prop]- (m) MATCH (l) RETURN r Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); AstTreeStorage storage; auto edge = EDGE("r"); edge->has_range_ = true; @@ -952,7 +952,7 @@ TEST(TestSymbolGenerator, VariablePathSameIdentifier) { // variable expansion itself. Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); AstTreeStorage storage; auto edge = EDGE("r", EdgeAtom::Direction::OUT); edge->has_range_ = true; @@ -1012,7 +1012,7 @@ TEST(TestSymbolGenerator, MatchBfsReturn) { // Test MATCH (n) -bfs[r](r, n | r.prop, n.prop)-> (m) RETURN r AS r Dbms dbms; auto dba = dbms.active(); - auto prop = dba->property("prop"); + auto prop = dba->Property("prop"); AstTreeStorage storage; auto *node_n = NODE("n"); auto *r_prop = PROPERTY_LOOKUP("r", prop); diff --git a/tests/unit/query_variable_start_planner.cpp b/tests/unit/query_variable_start_planner.cpp index 3a110163e..4a170ef63 100644 --- a/tests/unit/query_variable_start_planner.cpp +++ b/tests/unit/query_variable_start_planner.cpp @@ -82,10 +82,10 @@ TEST(TestVariableStartPlanner, MatchReturn) { Dbms dbms; auto dba = dbms.active(); // Make a graph (v1) -[:r]-> (v2) - auto v1 = dba->insert_vertex(); - auto v2 = dba->insert_vertex(); - dba->insert_edge(v1, v2, dba->edge_type("r")); - dba->advance_command(); + auto v1 = dba->InsertVertex(); + auto v2 = dba->InsertVertex(); + dba->InsertEdge(v1, v2, dba->EdgeType("r")); + dba->AdvanceCommand(); // Test MATCH (n) -[r]-> (m) RETURN n AstTreeStorage storage; QUERY( @@ -102,12 +102,12 @@ TEST(TestVariableStartPlanner, MatchTripletPatternReturn) { Dbms dbms; auto dba = dbms.active(); // Make a graph (v1) -[:r]-> (v2) -[:r]-> (v3) - auto v1 = dba->insert_vertex(); - auto v2 = dba->insert_vertex(); - auto v3 = dba->insert_vertex(); - dba->insert_edge(v1, v2, dba->edge_type("r")); - dba->insert_edge(v2, v3, dba->edge_type("r")); - dba->advance_command(); + auto v1 = dba->InsertVertex(); + auto v2 = dba->InsertVertex(); + auto v3 = dba->InsertVertex(); + dba->InsertEdge(v1, v2, dba->EdgeType("r")); + dba->InsertEdge(v2, v3, dba->EdgeType("r")); + dba->AdvanceCommand(); { // Test `MATCH (n) -[r]-> (m) -[e]-> (l) RETURN n` AstTreeStorage storage; @@ -139,12 +139,12 @@ TEST(TestVariableStartPlanner, MatchOptionalMatchReturn) { Dbms dbms; auto dba = dbms.active(); // Make a graph (v1) -[:r]-> (v2) -[:r]-> (v3) - auto v1 = dba->insert_vertex(); - auto v2 = dba->insert_vertex(); - auto v3 = dba->insert_vertex(); - dba->insert_edge(v1, v2, dba->edge_type("r")); - dba->insert_edge(v2, v3, dba->edge_type("r")); - dba->advance_command(); + auto v1 = dba->InsertVertex(); + auto v2 = dba->InsertVertex(); + auto v3 = dba->InsertVertex(); + dba->InsertEdge(v1, v2, dba->EdgeType("r")); + dba->InsertEdge(v2, v3, dba->EdgeType("r")); + dba->AdvanceCommand(); // Test MATCH (n) -[r]-> (m) OPTIONAL MATCH (m) -[e]-> (l) RETURN n, l AstTreeStorage storage; QUERY( @@ -166,11 +166,11 @@ TEST(TestVariableStartPlanner, MatchOptionalMatchMergeReturn) { Dbms dbms; auto dba = dbms.active(); // Graph (v1) -[:r]-> (v2) - auto v1 = dba->insert_vertex(); - auto v2 = dba->insert_vertex(); - auto r_type = dba->edge_type("r"); - dba->insert_edge(v1, v2, r_type); - dba->advance_command(); + auto v1 = dba->InsertVertex(); + auto v2 = dba->InsertVertex(); + auto r_type = dba->EdgeType("r"); + dba->InsertEdge(v1, v2, r_type); + dba->AdvanceCommand(); // Test MATCH (n) -[r]-> (m) OPTIONAL MATCH (m) -[e]-> (l) // MERGE (u) -[q:r]-> (v) RETURN n, m, l, u, v AstTreeStorage storage; @@ -192,10 +192,10 @@ TEST(TestVariableStartPlanner, MatchWithMatchReturn) { Dbms dbms; auto dba = dbms.active(); // Graph (v1) -[:r]-> (v2) - auto v1 = dba->insert_vertex(); - auto v2 = dba->insert_vertex(); - dba->insert_edge(v1, v2, dba->edge_type("r")); - dba->advance_command(); + auto v1 = dba->InsertVertex(); + auto v2 = dba->InsertVertex(); + dba->InsertEdge(v1, v2, dba->EdgeType("r")); + dba->AdvanceCommand(); // Test MATCH (n) -[r]-> (m) WITH n MATCH (m) -[r]-> (l) RETURN n, m, l AstTreeStorage storage; QUERY( diff --git a/tests/unit/record_edge_vertex_accessor.cpp b/tests/unit/record_edge_vertex_accessor.cpp index 87176e8ce..3818d4871 100644 --- a/tests/unit/record_edge_vertex_accessor.cpp +++ b/tests/unit/record_edge_vertex_accessor.cpp @@ -3,9 +3,9 @@ #include "gtest/gtest.h" +#include "database/dbms.hpp" #include "database/graph_db.hpp" #include "database/graph_db_accessor.hpp" -#include "database/dbms.hpp" #include "storage/edge_accessor.hpp" #include "storage/property_value.hpp" @@ -15,11 +15,11 @@ TEST(RecordAccessor, Properties) { Dbms dbms; auto dba = dbms.active(); - auto vertex = dba->insert_vertex(); + auto vertex = dba->InsertVertex(); auto &properties = vertex.Properties(); - auto property = dba->property("PropName"); - auto property_other = dba->property("Other"); + auto property = dba->Property("PropName"); + auto property_other = dba->Property("Other"); EXPECT_EQ(vertex.PropsAt(property).type(), PropertyValue::Type::Null); vertex.PropsSet(property, 42); @@ -37,7 +37,7 @@ TEST(RecordAccessor, DbAccessor) { Dbms dbms; auto dba = dbms.active(); - auto vertex = dba->insert_vertex(); + auto vertex = dba->InsertVertex(); const auto &const_vertex_dba = vertex.db_accessor(); EXPECT_EQ(dba.get(), &const_vertex_dba); auto &vertex_dba = vertex.db_accessor(); @@ -48,13 +48,13 @@ TEST(RecordAccessor, RecordEquality) { Dbms dbms; auto dba = dbms.active(); - auto v1 = dba->insert_vertex(); - auto v2 = dba->insert_vertex(); + auto v1 = dba->InsertVertex(); + auto v2 = dba->InsertVertex(); EXPECT_EQ(v1, v1); EXPECT_NE(v1, v2); - auto e1 = dba->insert_edge(v1, v2, dba->edge_type("type")); - auto e2 = dba->insert_edge(v1, v2, dba->edge_type("type")); + auto e1 = dba->InsertEdge(v1, v2, dba->EdgeType("type")); + auto e2 = dba->InsertEdge(v1, v2, dba->EdgeType("type")); EXPECT_EQ(e1, e1); EXPECT_NE(e1, e2); } @@ -63,14 +63,14 @@ TEST(RecordAccessor, RecordLessThan) { Dbms dbms; auto dba = dbms.active(); - auto v1 = dba->insert_vertex(); - auto v2 = dba->insert_vertex(); + auto v1 = dba->InsertVertex(); + auto v2 = dba->InsertVertex(); EXPECT_NE(v1, v2); EXPECT_TRUE(v1 < v2 || v2 < v1); EXPECT_FALSE(v1 < v1); EXPECT_FALSE(v2 < v2); - auto e1 = dba->insert_edge(v1, v2, dba->edge_type("type")); - auto e2 = dba->insert_edge(v1, v2, dba->edge_type("type")); + auto e1 = dba->InsertEdge(v1, v2, dba->EdgeType("type")); + auto e2 = dba->InsertEdge(v1, v2, dba->EdgeType("type")); EXPECT_NE(e1, e2); EXPECT_TRUE(e1 < e2 || e2 < e1); EXPECT_FALSE(e1 < e1); @@ -83,16 +83,16 @@ TEST(RecordAccessor, SwitchOldAndSwitchNewMemberFunctionTest) { // test both Switches work on new record { auto dba = dbms.active(); - auto v1 = dba->insert_vertex(); + auto v1 = dba->InsertVertex(); v1.SwitchOld(); v1.SwitchNew(); - dba->commit(); + dba->Commit(); } // test both Switches work on existing record { auto dba = dbms.active(); - auto v1 = *dba->vertices(false).begin(); + auto v1 = *dba->Vertices(false).begin(); v1.SwitchOld(); v1.SwitchNew(); } @@ -100,8 +100,8 @@ TEST(RecordAccessor, SwitchOldAndSwitchNewMemberFunctionTest) { // ensure switch exposes the right data { auto dba = dbms.active(); - auto label = dba->label("label"); - auto v1 = *dba->vertices(false).begin(); + auto label = dba->Label("label"); + auto v1 = *dba->Vertices(false).begin(); EXPECT_FALSE(v1.has_label(label)); // old record v1.add_label(label); // modifying data does not switch to new @@ -115,26 +115,26 @@ TEST(RecordAccessor, SwitchOldAndSwitchNewMemberFunctionTest) { TEST(RecordAccessor, Reconstruct) { Dbms dbms; - auto label = dbms.active()->label("label"); + auto label = dbms.active()->Label("label"); { // we must operate on an old vertex // because otherwise we only have new // so create a vertex and commit it auto dba = dbms.active(); - dba->insert_vertex(); - dba->commit(); + dba->InsertVertex(); + dba->Commit(); } // ensure we don't have label set auto dba = dbms.active(); - auto v1 = *dba->vertices(false).begin(); + auto v1 = *dba->Vertices(false).begin(); v1.SwitchNew(); EXPECT_FALSE(v1.has_label(label)); { // update the record through a different accessor - auto v1_other_accessor = *dba->vertices(false).begin(); + auto v1_other_accessor = *dba->Vertices(false).begin(); v1_other_accessor.add_label(label); EXPECT_FALSE(v1.has_label(label)); v1_other_accessor.SwitchNew(); @@ -150,13 +150,13 @@ TEST(RecordAccessor, Reconstruct) { TEST(RecordAccessor, VertexLabels) { Dbms dbms; auto dba = dbms.active(); - auto v1 = dba->insert_vertex(); + auto v1 = dba->InsertVertex(); auto &labels = v1.labels(); EXPECT_EQ(v1.labels().size(), 0); - GraphDbTypes::Label l1 = dba->label("label1"); - GraphDbTypes::Label l2 = dba->label("label2"); + GraphDbTypes::Label l1 = dba->Label("label1"); + GraphDbTypes::Label l2 = dba->Label("label2"); // adding labels EXPECT_FALSE(v1.has_label(l1)); @@ -176,7 +176,7 @@ TEST(RecordAccessor, VertexLabels) { EXPECT_EQ(labels.size(), 2); // removing labels - GraphDbTypes::Label l3 = dba->label("label3"); + GraphDbTypes::Label l3 = dba->Label("label3"); EXPECT_EQ(v1.remove_label(l3), 0); EXPECT_EQ(labels.size(), 2); @@ -191,37 +191,37 @@ TEST(RecordAccessor, VertexLabels) { TEST(RecordAccessor, EdgeType) { Dbms dbms; auto dba = dbms.active(); - auto v1 = dba->insert_vertex(); - auto v2 = dba->insert_vertex(); + auto v1 = dba->InsertVertex(); + auto v2 = dba->InsertVertex(); - GraphDbTypes::EdgeType likes = dba->edge_type("likes"); - GraphDbTypes::EdgeType hates = dba->edge_type("hates"); + GraphDbTypes::EdgeType likes = dba->EdgeType("likes"); + GraphDbTypes::EdgeType hates = dba->EdgeType("hates"); - auto edge = dba->insert_edge(v1, v2, likes); - EXPECT_EQ(edge.edge_type(), likes); - EXPECT_NE(edge.edge_type(), hates); + auto edge = dba->InsertEdge(v1, v2, likes); + EXPECT_EQ(edge.EdgeType(), likes); + EXPECT_NE(edge.EdgeType(), hates); } TEST(RecordAccessor, EdgeIsCycle) { Dbms dbms; auto dba = dbms.active(); - auto v1 = dba->insert_vertex(); - auto v2 = dba->insert_vertex(); - auto likes = dba->edge_type("edge_type"); + auto v1 = dba->InsertVertex(); + auto v2 = dba->InsertVertex(); + auto likes = dba->EdgeType("edge_type"); - EXPECT_TRUE(dba->insert_edge(v1, v1, likes).is_cycle()); - EXPECT_TRUE(dba->insert_edge(v2, v2, likes).is_cycle()); - EXPECT_FALSE(dba->insert_edge(v1, v2, likes).is_cycle()); - EXPECT_FALSE(dba->insert_edge(v2, v1, likes).is_cycle()); + EXPECT_TRUE(dba->InsertEdge(v1, v1, likes).is_cycle()); + EXPECT_TRUE(dba->InsertEdge(v2, v2, likes).is_cycle()); + EXPECT_FALSE(dba->InsertEdge(v1, v2, likes).is_cycle()); + EXPECT_FALSE(dba->InsertEdge(v2, v1, likes).is_cycle()); } TEST(RecordAccessor, VertexEdgeConnections) { Dbms dbms; auto dba = dbms.active(); - auto v1 = dba->insert_vertex(); - auto v2 = dba->insert_vertex(); - auto edge = dba->insert_edge(v1, v2, dba->edge_type("likes")); - dba->advance_command(); + auto v1 = dba->InsertVertex(); + auto v2 = dba->InsertVertex(); + auto edge = dba->InsertEdge(v1, v2, dba->EdgeType("likes")); + dba->AdvanceCommand(); EXPECT_EQ(edge.from(), v1); EXPECT_NE(edge.from(), v2); diff --git a/tests/unit/recovery.cpp b/tests/unit/recovery.cpp index ee1eb8705..10ae6dddf 100644 --- a/tests/unit/recovery.cpp +++ b/tests/unit/recovery.cpp @@ -51,12 +51,12 @@ void CreateSmallGraph(Dbms &dbms) { auto dba = dbms.active(); // setup (v1) - [:likes] -> (v2) <- [:hates] - (v3) - auto va1 = dba->insert_vertex(); - auto va2 = dba->insert_vertex(); - dba->insert_edge(va1, va2, dba->edge_type("likes")); - auto va3 = dba->insert_vertex(); - dba->insert_edge(va3, va2, dba->edge_type("hates")); - dba->commit(); + auto va1 = dba->InsertVertex(); + auto va2 = dba->InsertVertex(); + dba->InsertEdge(va1, va2, dba->EdgeType("likes")); + auto va3 = dba->InsertVertex(); + dba->InsertEdge(va3, va2, dba->EdgeType("hates")); + dba->Commit(); } void CreateBigGraph(Dbms &dbms) { @@ -65,17 +65,17 @@ void CreateBigGraph(Dbms &dbms) { // every vertex hash label "label" and property "prop" with value "prop" // every relationship has type "type" and property "prop" with value "prop" auto dba = dbms.active(); - auto va_middle = dba->insert_vertex(); - va_middle.add_label(dba->label("label")); - va_middle.PropsSet(dba->property("prop"), "prop"); + auto va_middle = dba->InsertVertex(); + va_middle.add_label(dba->Label("label")); + va_middle.PropsSet(dba->Property("prop"), "prop"); for (int i = 1; i < 1000; ++i) { - auto va = dba->insert_vertex(); - va.add_label(dba->label("label")); - va.PropsSet(dba->property("prop"), "prop"); - auto ea = dba->insert_edge(va, va_middle, dba->edge_type("type")); - ea.PropsSet(dba->property("prop"), "prop"); + auto va = dba->InsertVertex(); + va.add_label(dba->Label("label")); + va.PropsSet(dba->Property("prop"), "prop"); + auto ea = dba->InsertEdge(va, va_middle, dba->EdgeType("type")); + ea.PropsSet(dba->Property("prop"), "prop"); } - dba->commit(); + dba->Commit(); } void TakeSnapshot(Dbms &dbms, int max_retained_snapshots_) { @@ -166,14 +166,14 @@ TEST_F(RecoveryTest, TestEncodingAndDecoding) { auto dba = dbms_recover.active(); int64_t vertex_count = 0; - for (const auto &vertex : dba->vertices(false)) { + for (const auto &vertex : dba->Vertices(false)) { vertices.push_back(vertex); vertex_count++; } EXPECT_EQ(vertex_count, 3); int64_t edge_count = 0; - for (const auto &edge : dba->edges(false)) { + for (const auto &edge : dba->Edges(false)) { EXPECT_NE(vertices.end(), std::find(vertices.begin(), vertices.end(), edge.to())); EXPECT_NE(vertices.end(), @@ -206,11 +206,11 @@ TEST_F(RecoveryTest, TestEncodingAndRecovering) { auto dba_get = dbms_recover.active(); int64_t vertex_count = 0; - for (const auto &vertex : dba_get->vertices(false)) { + for (const auto &vertex : dba_get->Vertices(false)) { EXPECT_EQ(vertex.labels().size(), 1); - EXPECT_TRUE(vertex.has_label(dba_get->label("label"))); + EXPECT_TRUE(vertex.has_label(dba_get->Label("label"))); query::TypedValue prop = - query::TypedValue(vertex.PropsAt(dba_get->property("prop"))); + query::TypedValue(vertex.PropsAt(dba_get->Property("prop"))); query::TypedValue expected_prop = query::TypedValue(PropertyValue("prop")); EXPECT_TRUE((prop == expected_prop).Value()); vertex_count++; @@ -218,24 +218,24 @@ TEST_F(RecoveryTest, TestEncodingAndRecovering) { EXPECT_EQ(vertex_count, 1000); int64_t edge_count = 0; - for (const auto &edge : dba_get->edges(false)) { - EXPECT_EQ(edge.edge_type(), dba_get->edge_type("type")); + for (const auto &edge : dba_get->Edges(false)) { + EXPECT_EQ(edge.EdgeType(), dba_get->EdgeType("type")); query::TypedValue prop = - query::TypedValue(edge.PropsAt(dba_get->property("prop"))); + query::TypedValue(edge.PropsAt(dba_get->Property("prop"))); query::TypedValue expected_prop = query::TypedValue(PropertyValue("prop")); EXPECT_TRUE((prop == expected_prop).Value()); edge_count++; } EXPECT_EQ(edge_count, 999); - dba_get->commit(); + dba_get->Commit(); } TEST_F(RecoveryTest, TestLabelPropertyIndexRecovery) { // Creates snapshot of the graph with indices. Dbms dbms; auto dba = dbms.active(); - dba->BuildIndex(dba->label("label"), dba->property("prop")); - dba->commit(); + dba->BuildIndex(dba->Label("label"), dba->Property("prop")); + dba->Commit(); CreateBigGraph(dbms); TakeSnapshot(dbms, max_retained_snapshots_); std::string snapshot = GetLatestSnapshot(); @@ -248,15 +248,15 @@ TEST_F(RecoveryTest, TestLabelPropertyIndexRecovery) { auto dba_get = dbms_recover.active(); EXPECT_EQ(dba_get->GetIndicesKeys().size(), 1); - EXPECT_TRUE(dba_get->LabelPropertyIndexExists(dba_get->label("label"), - dba_get->property("prop"))); + EXPECT_TRUE(dba_get->LabelPropertyIndexExists(dba_get->Label("label"), + dba_get->Property("prop"))); int64_t vertex_count = 0; - for (const auto &vertex : dba_get->vertices(false)) { + for (const auto &vertex : dba_get->Vertices(false)) { EXPECT_EQ(vertex.labels().size(), 1); - EXPECT_TRUE(vertex.has_label(dba_get->label("label"))); + EXPECT_TRUE(vertex.has_label(dba_get->Label("label"))); query::TypedValue prop = - query::TypedValue(vertex.PropsAt(dba_get->property("prop"))); + query::TypedValue(vertex.PropsAt(dba_get->Property("prop"))); query::TypedValue expected_prop = query::TypedValue(PropertyValue("prop")); EXPECT_TRUE((prop == expected_prop).Value()); vertex_count++; @@ -264,16 +264,16 @@ TEST_F(RecoveryTest, TestLabelPropertyIndexRecovery) { EXPECT_EQ(vertex_count, 1000); int64_t edge_count = 0; - for (const auto &edge : dba_get->edges(false)) { - EXPECT_EQ(edge.edge_type(), dba_get->edge_type("type")); + for (const auto &edge : dba_get->Edges(false)) { + EXPECT_EQ(edge.EdgeType(), dba_get->EdgeType("type")); query::TypedValue prop = - query::TypedValue(edge.PropsAt(dba_get->property("prop"))); + query::TypedValue(edge.PropsAt(dba_get->Property("prop"))); query::TypedValue expected_prop = query::TypedValue(PropertyValue("prop")); EXPECT_TRUE((prop == expected_prop).Value()); edge_count++; } EXPECT_EQ(edge_count, 999); - dba_get->commit(); + dba_get->Commit(); } int main(int argc, char **argv) {