diff --git a/src/distributed/plan_consumer.hpp b/src/distributed/plan_consumer.hpp index 933e50a99..ee3792edb 100644 --- a/src/distributed/plan_consumer.hpp +++ b/src/distributed/plan_consumer.hpp @@ -16,14 +16,14 @@ class PlanConsumer { public: struct PlanPack { PlanPack(std::shared_ptr plan, - query::SymbolTable symbol_table, query::AstTreeStorage storage) + query::SymbolTable symbol_table, query::AstStorage storage) : plan(plan), symbol_table(std::move(symbol_table)), storage(std::move(storage)) {} std::shared_ptr plan; query::SymbolTable symbol_table; - const query::AstTreeStorage storage; + const query::AstStorage storage; }; explicit PlanConsumer(communication::rpc::Server &server); diff --git a/src/distributed/plan_rpc_messages.lcp b/src/distributed/plan_rpc_messages.lcp index b55227308..c0e16dc8d 100644 --- a/src/distributed/plan_rpc_messages.lcp +++ b/src/distributed/plan_rpc_messages.lcp @@ -46,7 +46,7 @@ cpp<# :capnp-type "Utils.SharedPtr(Plan.LogicalOperator)" :capnp-save #'save-plan :capnp-load #'load-plan) (symbol-table "query::SymbolTable" :capnp-type "Sem.SymbolTable") - (storage "query::AstTreeStorage" :initarg nil + (storage "query::AstStorage" :initarg nil :save-fun "" :load-fun "storage = std::move(ar.template get_helper(query::AstTreeStorage::kHelperId));" :capnp-save :dont-save))) diff --git a/src/query/frontend/ast/ast.cpp b/src/query/frontend/ast/ast.cpp index 99cd17095..d0cc1d4fd 100644 --- a/src/query/frontend/ast/ast.cpp +++ b/src/query/frontend/ast/ast.cpp @@ -14,23 +14,23 @@ namespace query { // isn't unique, then different instances (even across different types!) will // replace the previous helper. The documentation recommends to take an address // of a function, which should be unique in the produced binary. -// It might seem logical to take an address of a AstTreeStorage constructor, but +// It might seem logical to take an address of a AstStorage constructor, but // according to c++ standard, the constructor function need not have an address. // Additionally, pointers to member functions are not required to contain the // address of the function // (https://isocpp.org/wiki/faq/pointers-to-members#addr-of-memfn). So, to be // safe, use a regular top-level function. -void *const AstTreeStorage::kHelperId = (void *)CloneReturnBody; +void *const AstStorage::kHelperId = (void *)CloneReturnBody; -AstTreeStorage::AstTreeStorage() { +AstStorage::AstStorage() { storage_.emplace_back(new Query(next_uid_++)); } -Query *AstTreeStorage::query() const { +Query *AstStorage::query() const { return dynamic_cast(storage_[0].get()); } -ReturnBody CloneReturnBody(AstTreeStorage &storage, const ReturnBody &body) { +ReturnBody CloneReturnBody(AstStorage &storage, const ReturnBody &body) { ReturnBody new_body; new_body.distinct = body.distinct; new_body.all_identifiers = body.all_identifiers; @@ -47,7 +47,7 @@ ReturnBody CloneReturnBody(AstTreeStorage &storage, const ReturnBody &body) { // Capnproto serialization. -Tree *AstTreeStorage::Load(const capnp::Tree::Reader &tree, +Tree *AstStorage::Load(const capnp::Tree::Reader &tree, std::vector *loaded_uids) { auto uid = tree.getUid(); @@ -137,7 +137,7 @@ bool Tree::IsSaved(const std::vector &saved_uids) { return utils::Contains(saved_uids, uid_); } -void Tree::Load(const capnp::Tree::Reader &reader, AstTreeStorage *storage, +void Tree::Load(const capnp::Tree::Reader &reader, AstStorage *storage, std::vector *loaded_uids) { uid_ = reader.getUid(); } @@ -159,7 +159,7 @@ void Expression::Save(capnp::Tree::Builder *tree_builder, } Expression *Expression::Construct(const capnp::Expression::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { switch (reader.which()) { case capnp::Expression::BINARY_OPERATOR: { auto bop_reader = reader.getBinaryOperator(); @@ -225,7 +225,7 @@ void BaseLiteral::Save(capnp::Expression::Builder *expr_builder, } BaseLiteral *BaseLiteral::Construct(const capnp::BaseLiteral::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { switch (reader.which()) { case capnp::BaseLiteral::PRIMITIVE_LITERAL: { auto literal = reader.getPrimitiveLiteral(); @@ -253,7 +253,7 @@ void PrimitiveLiteral::Save(capnp::BaseLiteral::Builder *base_literal_builder, } void PrimitiveLiteral::Load(const capnp::Tree::Reader &reader, - AstTreeStorage *storage, + AstStorage *storage, std::vector *loaded_uids) { BaseLiteral::Load(reader, storage, loaded_uids); auto pl_reader = @@ -264,7 +264,7 @@ void PrimitiveLiteral::Load(const capnp::Tree::Reader &reader, } PrimitiveLiteral *PrimitiveLiteral::Construct( - const capnp::PrimitiveLiteral::Reader &reader, AstTreeStorage *storage) { + const capnp::PrimitiveLiteral::Reader &reader, AstStorage *storage) { return storage->Create(); } @@ -282,7 +282,7 @@ void ListLiteral::Save(capnp::BaseLiteral::Builder *base_literal_builder, } void ListLiteral::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, std::vector *loaded_uids) { + AstStorage *storage, std::vector *loaded_uids) { BaseLiteral::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getExpression().getBaseLiteral().getListLiteral(); for (const auto tree_reader : reader.getElements()) { @@ -292,7 +292,7 @@ void ListLiteral::Load(const capnp::Tree::Reader &base_reader, } ListLiteral *ListLiteral::Construct(const capnp::ListLiteral::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -317,7 +317,7 @@ void MapLiteral::Save(capnp::BaseLiteral::Builder *base_literal_builder, } void MapLiteral::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, std::vector *loaded_uids) { + AstStorage *storage, std::vector *loaded_uids) { BaseLiteral::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getExpression().getBaseLiteral().getMapLiteral(); for (auto entry_reader : reader.getElements()) { @@ -335,7 +335,7 @@ void MapLiteral::Load(const capnp::Tree::Reader &base_reader, } MapLiteral *MapLiteral::Construct(const capnp::MapLiteral::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -360,7 +360,7 @@ void BinaryOperator::Save(capnp::BinaryOperator::Builder *builder, } void BinaryOperator::Load(const capnp::Tree::Reader &reader, - AstTreeStorage *storage, + AstStorage *storage, std::vector *loaded_uids) { Expression::Load(reader, storage, loaded_uids); auto bop_reader = reader.getExpression().getBinaryOperator(); @@ -377,7 +377,7 @@ void BinaryOperator::Load(const capnp::Tree::Reader &reader, } BinaryOperator *BinaryOperator::Construct( - const capnp::BinaryOperator::Reader &reader, AstTreeStorage *storage) { + const capnp::BinaryOperator::Reader &reader, AstStorage *storage) { switch (reader.which()) { case capnp::BinaryOperator::ADDITION_OPERATOR: { auto literal = reader.getAdditionOperator(); @@ -457,7 +457,7 @@ void OrOperator::Save(capnp::BinaryOperator::Builder *builder, } OrOperator *OrOperator::Construct(const capnp::OrOperator::Reader &, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -468,7 +468,7 @@ void XorOperator::Save(capnp::BinaryOperator::Builder *builder, } XorOperator *XorOperator::Construct(const capnp::XorOperator::Reader &, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -479,7 +479,7 @@ void AndOperator::Save(capnp::BinaryOperator::Builder *builder, } AndOperator *AndOperator::Construct(const capnp::AndOperator::Reader &, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -490,7 +490,7 @@ void AdditionOperator::Save(capnp::BinaryOperator::Builder *builder, } AdditionOperator *AdditionOperator::Construct( - const capnp::AdditionOperator::Reader &, AstTreeStorage *storage) { + const capnp::AdditionOperator::Reader &, AstStorage *storage) { return storage->Create(); } @@ -501,7 +501,7 @@ void SubtractionOperator::Save(capnp::BinaryOperator::Builder *builder, } SubtractionOperator *SubtractionOperator::Construct( - capnp::SubtractionOperator::Reader &, AstTreeStorage *storage) { + capnp::SubtractionOperator::Reader &, AstStorage *storage) { return storage->Create(); } @@ -512,7 +512,7 @@ void MultiplicationOperator::Save(capnp::BinaryOperator::Builder *builder, } MultiplicationOperator *MultiplicationOperator::Construct( - capnp::MultiplicationOperator::Reader &, AstTreeStorage *storage) { + capnp::MultiplicationOperator::Reader &, AstStorage *storage) { return storage->Create(); } @@ -523,7 +523,7 @@ void DivisionOperator::Save(capnp::BinaryOperator::Builder *builder, } DivisionOperator *DivisionOperator::Construct( - const capnp::DivisionOperator::Reader &, AstTreeStorage *storage) { + const capnp::DivisionOperator::Reader &, AstStorage *storage) { return storage->Create(); } @@ -534,7 +534,7 @@ void ModOperator::Save(capnp::BinaryOperator::Builder *builder, } ModOperator *ModOperator::Construct(const capnp::ModOperator::Reader &, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -545,7 +545,7 @@ void NotEqualOperator::Save(capnp::BinaryOperator::Builder *builder, } NotEqualOperator *NotEqualOperator::Construct( - const capnp::NotEqualOperator::Reader &, AstTreeStorage *storage) { + const capnp::NotEqualOperator::Reader &, AstStorage *storage) { return storage->Create(); } @@ -556,7 +556,7 @@ void EqualOperator::Save(capnp::BinaryOperator::Builder *builder, } EqualOperator *EqualOperator::Construct(const capnp::EqualOperator::Reader &, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -567,7 +567,7 @@ void LessOperator::Save(capnp::BinaryOperator::Builder *builder, } LessOperator *LessOperator::Construct(const capnp::LessOperator::Reader &, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -578,7 +578,7 @@ void GreaterOperator::Save(capnp::BinaryOperator::Builder *builder, } GreaterOperator *GreaterOperator::Construct( - const capnp::GreaterOperator::Reader &, AstTreeStorage *storage) { + const capnp::GreaterOperator::Reader &, AstStorage *storage) { return storage->Create(); } @@ -589,7 +589,7 @@ void LessEqualOperator::Save(capnp::BinaryOperator::Builder *builder, } LessEqualOperator *LessEqualOperator::Construct( - const capnp::LessEqualOperator::Reader &, AstTreeStorage *storage) { + const capnp::LessEqualOperator::Reader &, AstStorage *storage) { return storage->Create(); } @@ -600,7 +600,7 @@ void GreaterEqualOperator::Save(capnp::BinaryOperator::Builder *builder, } GreaterEqualOperator *GreaterEqualOperator::Construct( - const capnp::GreaterEqualOperator::Reader &, AstTreeStorage *storage) { + const capnp::GreaterEqualOperator::Reader &, AstStorage *storage) { return storage->Create(); } @@ -611,7 +611,7 @@ void InListOperator::Save(capnp::BinaryOperator::Builder *builder, } InListOperator *InListOperator::Construct(const capnp::InListOperator::Reader &, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -622,7 +622,7 @@ void ListMapIndexingOperator::Save(capnp::BinaryOperator::Builder *builder, } ListMapIndexingOperator *ListMapIndexingOperator::Construct( - capnp::ListMapIndexingOperator::Reader &, AstTreeStorage *storage) { + capnp::ListMapIndexingOperator::Reader &, AstStorage *storage) { return storage->Create(); } @@ -656,7 +656,7 @@ void Aggregation::Save(capnp::BinaryOperator::Builder *builder, } Aggregation *Aggregation::Construct(const capnp::Aggregation::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { Op op; switch (reader.getOp()) { case capnp::Aggregation::Op::AVG: @@ -701,7 +701,7 @@ void UnaryOperator::Save(capnp::UnaryOperator::Builder *builder, } void UnaryOperator::Load(const capnp::Tree::Reader &reader, - AstTreeStorage *storage, + AstStorage *storage, std::vector *loaded_uids) { Expression::Load(reader, storage, loaded_uids); if (reader.hasExpression()) { @@ -713,7 +713,7 @@ void UnaryOperator::Load(const capnp::Tree::Reader &reader, } UnaryOperator *UnaryOperator::Construct( - const capnp::UnaryOperator::Reader &reader, AstTreeStorage *storage) { + const capnp::UnaryOperator::Reader &reader, AstStorage *storage) { switch (reader.which()) { case capnp::UnaryOperator::IS_NULL_OPERATOR: { auto op = reader.getIsNullOperator(); @@ -742,7 +742,7 @@ void IsNullOperator::Save(capnp::UnaryOperator::Builder *builder, } IsNullOperator *IsNullOperator::Construct(const capnp::IsNullOperator::Reader &, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -754,7 +754,7 @@ void NotOperator::Save(capnp::UnaryOperator::Builder *builder, } NotOperator *NotOperator::Construct(const capnp::NotOperator::Reader &, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -766,7 +766,7 @@ void UnaryPlusOperator::Save(capnp::UnaryOperator::Builder *builder, } UnaryPlusOperator *UnaryPlusOperator::Construct( - const capnp::UnaryPlusOperator::Reader &, AstTreeStorage *storage) { + const capnp::UnaryPlusOperator::Reader &, AstStorage *storage) { return storage->Create(); } @@ -778,7 +778,7 @@ void UnaryMinusOperator::Save(capnp::UnaryOperator::Builder *builder, } UnaryMinusOperator *UnaryMinusOperator::Construct( - capnp::UnaryMinusOperator::Reader &, AstTreeStorage *storage) { + capnp::UnaryMinusOperator::Reader &, AstStorage *storage) { return storage->Create(); } @@ -807,7 +807,7 @@ void ListSlicingOperator::Save(capnp::ListSlicingOperator::Builder *builder, } void ListSlicingOperator::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, + AstStorage *storage, std::vector *loaded_uids) { Expression::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getExpression().getListSlicingOperator(); @@ -828,7 +828,7 @@ void ListSlicingOperator::Load(const capnp::Tree::Reader &base_reader, } ListSlicingOperator *ListSlicingOperator::Construct( - const capnp::ListSlicingOperator::Reader &reader, AstTreeStorage *storage) { + const capnp::ListSlicingOperator::Reader &reader, AstStorage *storage) { return storage->Create(nullptr, nullptr, nullptr); } @@ -851,7 +851,7 @@ void IfOperator::Save(capnp::IfOperator::Builder *builder, } void IfOperator::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, std::vector *loaded_uids) { + AstStorage *storage, std::vector *loaded_uids) { Expression::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getExpression().getIfOperator(); const auto condition_reader = reader.getCondition(); @@ -866,7 +866,7 @@ void IfOperator::Load(const capnp::Tree::Reader &base_reader, } IfOperator *IfOperator::Construct(const capnp::IfOperator::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(nullptr, nullptr, nullptr); } @@ -887,7 +887,7 @@ void All::Save(capnp::All::Builder *builder, std::vector *saved_uids) { where_->Save(&where_builder, saved_uids); } -void All::Load(const capnp::Tree::Reader &base_reader, AstTreeStorage *storage, +void All::Load(const capnp::Tree::Reader &base_reader, AstStorage *storage, std::vector *loaded_uids) { Expression::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getExpression().getAll(); @@ -901,7 +901,7 @@ void All::Load(const capnp::Tree::Reader &base_reader, AstTreeStorage *storage, where_ = dynamic_cast(storage->Load(where_reader, loaded_uids)); } -All *All::Construct(const capnp::All::Reader &reader, AstTreeStorage *storage) { +All *All::Construct(const capnp::All::Reader &reader, AstStorage *storage) { return storage->Create(nullptr, nullptr, nullptr); } @@ -925,7 +925,7 @@ void Function::Save(capnp::Function::Builder *builder, } void Function::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, std::vector *loaded_uids) { + AstStorage *storage, std::vector *loaded_uids) { Expression::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getExpression().getFunction(); function_name_ = reader.getFunctionName().cStr(); @@ -937,7 +937,7 @@ void Function::Load(const capnp::Tree::Reader &base_reader, } Function *Function::Construct(const capnp::Function::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -956,7 +956,7 @@ void Identifier::Save(capnp::Identifier::Builder *builder, } Identifier *Identifier::Construct(const capnp::Identifier::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { auto name = reader.getName().cStr(); auto user_declared = reader.getUserDeclared(); return storage->Create(name, user_declared); @@ -984,7 +984,7 @@ void LabelsTest::Save(capnp::LabelsTest::Builder *builder, } void LabelsTest::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, std::vector *loaded_uids) { + AstStorage *storage, std::vector *loaded_uids) { Expression::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getExpression().getLabelsTest(); if (reader.hasExpression()) { @@ -1000,7 +1000,7 @@ void LabelsTest::Load(const capnp::Tree::Reader &base_reader, } LabelsTest *LabelsTest::Construct(const capnp::LabelsTest::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(nullptr, std::vector()); } @@ -1018,7 +1018,7 @@ void ParameterLookup::Save(capnp::ParameterLookup::Builder *builder, } ParameterLookup *ParameterLookup::Construct( - const capnp::ParameterLookup::Reader &reader, AstTreeStorage *storage) { + const capnp::ParameterLookup::Reader &reader, AstStorage *storage) { auto token_position = reader.getTokenPosition(); return storage->Create(token_position); } @@ -1043,7 +1043,7 @@ void PropertyLookup::Save(capnp::PropertyLookup::Builder *builder, } void PropertyLookup::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, + AstStorage *storage, std::vector *loaded_uids) { Expression::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getExpression().getPropertyLookup(); @@ -1058,7 +1058,7 @@ void PropertyLookup::Load(const capnp::Tree::Reader &base_reader, } PropertyLookup *PropertyLookup::Construct( - const capnp::PropertyLookup::Reader &reader, AstTreeStorage *storage) { + const capnp::PropertyLookup::Reader &reader, AstStorage *storage) { return storage->Create(nullptr, "", storage::Property()); } @@ -1085,7 +1085,7 @@ void Reduce::Save(capnp::Reduce::Builder *builder, } void Reduce::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, std::vector *loaded_uids) { + AstStorage *storage, std::vector *loaded_uids) { Expression::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getExpression().getReduce(); const auto acc_reader = reader.getAccumulator(); @@ -1105,7 +1105,7 @@ void Reduce::Load(const capnp::Tree::Reader &base_reader, } Reduce *Reduce::Construct(const capnp::Reduce::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(nullptr, nullptr, nullptr, nullptr, nullptr); } @@ -1128,7 +1128,7 @@ void Single::Save(capnp::Single::Builder *builder, } void Single::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, std::vector *loaded_uids) { + AstStorage *storage, std::vector *loaded_uids) { Expression::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getExpression().getSingle(); const auto id_reader = reader.getIdentifier(); @@ -1142,7 +1142,7 @@ void Single::Load(const capnp::Tree::Reader &base_reader, } Single *Single::Construct(const capnp::Single::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(nullptr, nullptr, nullptr); } @@ -1166,7 +1166,7 @@ void Where::Save(capnp::Where::Builder *builder, std::vector *saved_uids) { } void Where::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, std::vector *loaded_uids) { + AstStorage *storage, std::vector *loaded_uids) { Tree::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getWhere(); if (reader.hasExpression()) { @@ -1177,7 +1177,7 @@ void Where::Load(const capnp::Tree::Reader &base_reader, } Where *Where::Construct(const capnp::Where::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -1194,7 +1194,7 @@ void Clause::Save(capnp::Tree::Builder *tree_builder, } Clause *Clause::Construct(const capnp::Clause::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { switch (reader.which()) { case capnp::Clause::CREATE: { auto create_reader = reader.getCreate(); @@ -1271,7 +1271,7 @@ void Create::Save(capnp::Create::Builder *builder, } void Create::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, std::vector *loaded_uids) { + AstStorage *storage, std::vector *loaded_uids) { Clause::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getClause().getCreate(); for (const auto pattern_reader : reader.getPatterns()) { @@ -1281,7 +1281,7 @@ void Create::Load(const capnp::Tree::Reader &base_reader, } Create *Create::Construct(const capnp::Create::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -1302,7 +1302,7 @@ void CreateIndex::Save(capnp::CreateIndex::Builder *builder, } CreateIndex *CreateIndex::Construct(const capnp::CreateIndex::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { auto label_reader = reader.getLabel(); storage::Label label; label.Load(label_reader); @@ -1332,7 +1332,7 @@ void Delete::Save(capnp::Delete::Builder *builder, } void Delete::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, std::vector *loaded_uids) { + AstStorage *storage, std::vector *loaded_uids) { Clause::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getClause().getDelete(); for (const auto tree_reader : reader.getExpressions()) { @@ -1343,7 +1343,7 @@ void Delete::Load(const capnp::Tree::Reader &base_reader, } Delete *Delete::Construct(const capnp::Delete::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -1371,7 +1371,7 @@ void Match::Save(capnp::Match::Builder *builder, std::vector *saved_uids) { } void Match::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, std::vector *loaded_uids) { + AstStorage *storage, std::vector *loaded_uids) { Clause::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getClause().getMatch(); for (const auto tree_reader : reader.getPatterns()) { @@ -1386,7 +1386,7 @@ void Match::Load(const capnp::Tree::Reader &base_reader, } Match *Match::Construct(const capnp::Match::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -1420,7 +1420,7 @@ void Merge::Save(capnp::Merge::Builder *builder, std::vector *saved_uids) { } void Merge::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, std::vector *loaded_uids) { + AstStorage *storage, std::vector *loaded_uids) { Clause::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getClause().getMerge(); for (const auto tree_reader : reader.getOnMatch()) { @@ -1439,7 +1439,7 @@ void Merge::Load(const capnp::Tree::Reader &base_reader, } } Merge *Merge::Construct(const capnp::Merge::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -1465,7 +1465,7 @@ void RemoveLabels::Save(capnp::RemoveLabels::Builder *builder, } void RemoveLabels::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, + AstStorage *storage, std::vector *loaded_uids) { Clause::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getClause().getRemoveLabels(); @@ -1482,7 +1482,7 @@ void RemoveLabels::Load(const capnp::Tree::Reader &base_reader, } RemoveLabels *RemoveLabels::Construct(const capnp::RemoveLabels::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -1503,7 +1503,7 @@ void RemoveProperty::Save(capnp::RemoveProperty::Builder *builder, } void RemoveProperty::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, + AstStorage *storage, std::vector *loaded_uids) { Clause::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getClause().getRemoveProperty(); @@ -1515,7 +1515,7 @@ void RemoveProperty::Load(const capnp::Tree::Reader &base_reader, } RemoveProperty *RemoveProperty::Construct( - const capnp::RemoveProperty::Reader &reader, AstTreeStorage *storage) { + const capnp::RemoveProperty::Reader &reader, AstStorage *storage) { return storage->Create(); } @@ -1568,7 +1568,7 @@ void Return::Save(capnp::Return::Builder *builder, } void LoadReturnBody(capnp::ReturnBody::Reader &rb_reader, ReturnBody &body, - AstTreeStorage *storage, std::vector *loaded_uids) { + AstStorage *storage, std::vector *loaded_uids) { body.distinct = rb_reader.getDistinct(); body.all_identifiers = rb_reader.getAllIdentifiers(); @@ -1601,7 +1601,7 @@ void LoadReturnBody(capnp::ReturnBody::Reader &rb_reader, ReturnBody &body, } void Return::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, std::vector *loaded_uids) { + AstStorage *storage, std::vector *loaded_uids) { Clause::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getClause().getReturn(); auto rb_reader = reader.getReturnBody(); @@ -1609,7 +1609,7 @@ void Return::Load(const capnp::Tree::Reader &base_reader, } Return *Return::Construct(const capnp::Return::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -1635,7 +1635,7 @@ void SetLabels::Save(capnp::SetLabels::Builder *builder, } void SetLabels::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, std::vector *loaded_uids) { + AstStorage *storage, std::vector *loaded_uids) { Clause::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getClause().getSetLabels(); if (reader.hasIdentifier()) { @@ -1651,7 +1651,7 @@ void SetLabels::Load(const capnp::Tree::Reader &base_reader, } SetLabels *SetLabels::Construct(const capnp::SetLabels::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -1676,7 +1676,7 @@ void SetProperty::Save(capnp::SetProperty::Builder *builder, } void SetProperty::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, std::vector *loaded_uids) { + AstStorage *storage, std::vector *loaded_uids) { Clause::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getClause().getSetProperty(); if (reader.hasPropertyLookup()) { @@ -1692,7 +1692,7 @@ void SetProperty::Load(const capnp::Tree::Reader &base_reader, } SetProperty *SetProperty::Construct(const capnp::SetProperty::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -1718,7 +1718,7 @@ void SetProperties::Save(capnp::SetProperties::Builder *builder, } void SetProperties::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, + AstStorage *storage, std::vector *loaded_uids) { Clause::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getClause().getSetProperties(); @@ -1736,7 +1736,7 @@ void SetProperties::Load(const capnp::Tree::Reader &base_reader, } SetProperties *SetProperties::Construct( - const capnp::SetProperties::Reader &reader, AstTreeStorage *storage) { + const capnp::SetProperties::Reader &reader, AstStorage *storage) { return storage->Create(); } @@ -1757,7 +1757,7 @@ void Unwind::Save(capnp::Unwind::Builder *builder, } void Unwind::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, std::vector *loaded_uids) { + AstStorage *storage, std::vector *loaded_uids) { Clause::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getClause().getUnwind(); if (reader.hasNamedExpression()) { @@ -1768,7 +1768,7 @@ void Unwind::Load(const capnp::Tree::Reader &base_reader, } Unwind *Unwind::Construct(const capnp::Unwind::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -1789,7 +1789,7 @@ void With::Save(capnp::With::Builder *builder, std::vector *saved_uids) { SaveReturnBody(&rb_builder, body_, saved_uids); } -void With::Load(const capnp::Tree::Reader &base_reader, AstTreeStorage *storage, +void With::Load(const capnp::Tree::Reader &base_reader, AstStorage *storage, std::vector *loaded_uids) { Clause::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getClause().getWith(); @@ -1802,7 +1802,7 @@ void With::Load(const capnp::Tree::Reader &base_reader, AstTreeStorage *storage, } With *With::Construct(const capnp::With::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -1833,7 +1833,7 @@ void CypherUnion::Save(capnp::CypherUnion::Builder *builder, } void CypherUnion::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, std::vector *loaded_uids) { + AstStorage *storage, std::vector *loaded_uids) { Tree::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getCypherUnion(); if (reader.hasSingleQuery()) { @@ -1850,7 +1850,7 @@ void CypherUnion::Load(const capnp::Tree::Reader &base_reader, } CypherUnion *CypherUnion::Construct(const capnp::CypherUnion::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -1877,7 +1877,7 @@ void NamedExpression::Save(capnp::NamedExpression::Builder *builder, } void NamedExpression::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, + AstStorage *storage, std::vector *loaded_uids) { Tree::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getNamedExpression(); @@ -1891,7 +1891,7 @@ void NamedExpression::Load(const capnp::Tree::Reader &base_reader, } NamedExpression *NamedExpression::Construct( - const capnp::NamedExpression::Reader &reader, AstTreeStorage *storage) { + const capnp::NamedExpression::Reader &reader, AstStorage *storage) { return storage->Create(); } @@ -1922,7 +1922,7 @@ void Pattern::Save(capnp::Pattern::Builder *builder, } void Pattern::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, std::vector *loaded_uids) { + AstStorage *storage, std::vector *loaded_uids) { Tree::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getPattern(); if (reader.hasIdentifier()) { @@ -1937,7 +1937,7 @@ void Pattern::Load(const capnp::Tree::Reader &base_reader, } Pattern *Pattern::Construct(const capnp::Pattern::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -1962,7 +1962,7 @@ void PatternAtom::Save(capnp::PatternAtom::Builder *builder, } PatternAtom *PatternAtom::Construct(const capnp::PatternAtom::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { switch (reader.which()) { case capnp::PatternAtom::EDGE_ATOM: { auto edge_reader = reader.getEdgeAtom(); @@ -1976,7 +1976,7 @@ PatternAtom *PatternAtom::Construct(const capnp::PatternAtom::Reader &reader, } void PatternAtom::Load(const capnp::Tree::Reader &reader, - AstTreeStorage *storage, std::vector *loaded_uids) { + AstStorage *storage, std::vector *loaded_uids) { Tree::Load(reader, storage, loaded_uids); auto pa_reader = reader.getPatternAtom(); if (pa_reader.hasIdentifier()) { @@ -2017,7 +2017,7 @@ void NodeAtom::Save(capnp::NodeAtom::Builder *builder, } void NodeAtom::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, std::vector *loaded_uids) { + AstStorage *storage, std::vector *loaded_uids) { PatternAtom::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getPatternAtom().getNodeAtom(); for (auto entry_reader : reader.getProperties()) { @@ -2040,7 +2040,7 @@ void NodeAtom::Load(const capnp::Tree::Reader &base_reader, } NodeAtom *NodeAtom::Construct(const capnp::NodeAtom::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -2139,7 +2139,7 @@ void EdgeAtom::Save(capnp::EdgeAtom::Builder *builder, } void LoadLambda(capnp::EdgeAtom::Lambda::Reader &reader, - query::EdgeAtom::Lambda &lambda, AstTreeStorage *storage, + query::EdgeAtom::Lambda &lambda, AstStorage *storage, std::vector *loaded_uids) { if (reader.hasInnerEdge()) { const auto ie_reader = reader.getInnerEdge(); @@ -2159,7 +2159,7 @@ void LoadLambda(capnp::EdgeAtom::Lambda::Reader &reader, } void EdgeAtom::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, std::vector *loaded_uids) { + AstStorage *storage, std::vector *loaded_uids) { PatternAtom::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getPatternAtom().getEdgeAtom(); switch (reader.getType()) { @@ -2230,7 +2230,7 @@ void EdgeAtom::Load(const capnp::Tree::Reader &base_reader, } EdgeAtom *EdgeAtom::Construct(const capnp::EdgeAtom::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } @@ -2259,7 +2259,7 @@ void Query::Save(capnp::Query::Builder *builder, std::vector *saved_uids) { } } -void Query::Load(const capnp::Tree::Reader &reader, AstTreeStorage *storage, +void Query::Load(const capnp::Tree::Reader &reader, AstStorage *storage, std::vector *loaded_uids) { Tree::Load(reader, storage, loaded_uids); auto query_reader = reader.getQuery(); @@ -2297,7 +2297,7 @@ void SingleQuery::Save(capnp::SingleQuery::Builder *builder, } void SingleQuery::Load(const capnp::Tree::Reader &base_reader, - AstTreeStorage *storage, std::vector *loaded_uids) { + AstStorage *storage, std::vector *loaded_uids) { Tree::Load(base_reader, storage, loaded_uids); auto reader = base_reader.getSingleQuery(); for (const auto tree_reader : reader.getClauses()) { @@ -2307,7 +2307,7 @@ void SingleQuery::Load(const capnp::Tree::Reader &base_reader, } SingleQuery *SingleQuery::Construct(const capnp::SingleQuery::Reader &reader, - AstTreeStorage *storage) { + AstStorage *storage) { return storage->Create(); } } // namespace query diff --git a/src/query/frontend/ast/ast.hpp b/src/query/frontend/ast/ast.hpp index 122dc50dc..11444274b 100644 --- a/src/query/frontend/ast/ast.hpp +++ b/src/query/frontend/ast/ast.hpp @@ -41,14 +41,14 @@ class GraphDbAccessor; namespace query { #define CLONE_BINARY_EXPRESSION \ - auto Clone(AstTreeStorage &storage) const->std::remove_const< \ + auto Clone(AstStorage &storage) const->std::remove_const< \ std::remove_pointer::type>::type *override { \ return storage.Create< \ std::remove_cv::type>::type>( \ expression1_->Clone(storage), expression2_->Clone(storage)); \ } #define CLONE_UNARY_EXPRESSION \ - auto Clone(AstTreeStorage &storage) const->std::remove_const< \ + auto Clone(AstStorage &storage) const->std::remove_const< \ std::remove_pointer::type>::type *override { \ return storage.Create< \ std::remove_cv::type>::type>( \ @@ -66,13 +66,13 @@ class Tree; // It would be better to call this AstTree, but we already have a class Tree, // which could be renamed to Node or AstTreeNode, but we also have a class // called NodeAtom... -class AstTreeStorage { +class AstStorage { public: - AstTreeStorage(); - AstTreeStorage(const AstTreeStorage &) = delete; - AstTreeStorage &operator=(const AstTreeStorage &) = delete; - AstTreeStorage(AstTreeStorage &&) = default; - AstTreeStorage &operator=(AstTreeStorage &&) = default; + AstStorage(); + AstStorage(const AstStorage &) = delete; + AstStorage &operator=(const AstStorage &) = delete; + AstStorage(AstStorage &&) = default; + AstStorage &operator=(AstStorage &&) = default; template T *Create(Args &&... args) { @@ -85,13 +85,13 @@ class AstTreeStorage { Query *query() const; - /// Id for using get_helper in boost archives. + /// Id for using get_helper in boost archives. static void *const kHelperId; /// Load an Ast Node into this storage. template void Load(TArchive &ar, TNode &node) { - auto &tmp_ast = ar.template get_helper(kHelperId); + auto &tmp_ast = ar.template get_helper(kHelperId); std::swap(*this, tmp_ast); ar >> node; std::swap(*this, tmp_ast); @@ -123,7 +123,7 @@ void LoadPointer(TArchive &ar, TNode *&node) { ar >> node; if (node) { auto &ast_storage = - ar.template get_helper(AstTreeStorage::kHelperId); + ar.template get_helper(AstStorage::kHelperId); auto found = std::find_if(ast_storage.storage_.begin(), ast_storage.storage_.end(), [&](const auto &n) { return n->uid() == node->uid(); }); @@ -160,7 +160,7 @@ void LoadPointers(TArchive &ar, std::vector &nodes) { class Tree : public ::utils::Visitable, ::utils::Visitable> { - friend class AstTreeStorage; + friend class AstStorage; public: using ::utils::Visitable::Accept; @@ -168,14 +168,14 @@ class Tree : public ::utils::Visitable, int uid() const { return uid_; } - virtual Tree *Clone(AstTreeStorage &storage) const = 0; + virtual Tree *Clone(AstStorage &storage) const = 0; virtual void Save(capnp::Tree::Builder *builder, std::vector *saved_uids); protected: explicit Tree(int uid) : uid_(uid) {} - virtual void Load(const capnp::Tree::Reader &reader, AstTreeStorage *storage, + virtual void Load(const capnp::Tree::Reader &reader, AstStorage *storage, std::vector *loaded_uids); bool IsSaved(const std::vector &saved_uids); void AddToSaved(std::vector *saved_uids); @@ -194,12 +194,12 @@ class Tree : public ::utils::Visitable, // Expressions class Expression : public Tree { - friend class AstTreeStorage; + friend class AstStorage; public: - Expression *Clone(AstTreeStorage &storage) const override = 0; + Expression *Clone(AstStorage &storage) const override = 0; static Expression *Construct(const capnp::Expression::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); void Save(capnp::Tree::Builder *builder, std::vector *saved_uids) override; @@ -215,7 +215,7 @@ class Expression : public Tree { }; class Where : public Tree { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -226,12 +226,12 @@ class Where : public Tree { return visitor.PostVisit(*this); } - Where *Clone(AstTreeStorage &storage) const override { + Where *Clone(AstStorage &storage) const override { return storage.Create(expression_->Clone(storage)); } static Where *Construct(const capnp::Where::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); void Save(capnp::Tree::Builder *builder, std::vector *saved_uids) override; @@ -243,7 +243,7 @@ class Where : public Tree { Where(int uid, Expression *expression) : Tree(uid), expression_(expression) {} virtual void Save(capnp::Where::Builder *, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &tree_reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &tree_reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -269,15 +269,15 @@ class Where : public Tree { }; class BinaryOperator : public Expression { - friend class AstTreeStorage; + friend class AstStorage; public: Expression *expression1_ = nullptr; Expression *expression2_ = nullptr; - BinaryOperator *Clone(AstTreeStorage &storage) const override = 0; + BinaryOperator *Clone(AstStorage &storage) const override = 0; static BinaryOperator *Construct(const capnp::BinaryOperator::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); protected: explicit BinaryOperator(int uid) : Expression(uid) {} @@ -289,7 +289,7 @@ class BinaryOperator : public Expression { using Expression::Save; virtual void Save(capnp::BinaryOperator::Builder *builder, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -313,14 +313,14 @@ class BinaryOperator : public Expression { }; class UnaryOperator : public Expression { - friend class AstTreeStorage; + friend class AstStorage; public: Expression *expression_ = nullptr; - UnaryOperator *Clone(AstTreeStorage &storage) const override = 0; + UnaryOperator *Clone(AstStorage &storage) const override = 0; static UnaryOperator *Construct(const capnp::UnaryOperator::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); protected: explicit UnaryOperator(int uid) : Expression(uid) {} @@ -332,7 +332,7 @@ class UnaryOperator : public Expression { using Expression::Save; virtual void Save(capnp::UnaryOperator::Builder *builder, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -354,7 +354,7 @@ class UnaryOperator : public Expression { }; class OrOperator : public BinaryOperator { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -367,7 +367,7 @@ class OrOperator : public BinaryOperator { CLONE_BINARY_EXPRESSION; static OrOperator *Construct(const capnp::OrOperator::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); protected: using BinaryOperator::BinaryOperator; @@ -384,7 +384,7 @@ class OrOperator : public BinaryOperator { }; class XorOperator : public BinaryOperator { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -396,7 +396,7 @@ class XorOperator : public BinaryOperator { } CLONE_BINARY_EXPRESSION; static XorOperator *Construct(const capnp::XorOperator::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); protected: using BinaryOperator::BinaryOperator; @@ -413,7 +413,7 @@ class XorOperator : public BinaryOperator { }; class AndOperator : public BinaryOperator { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -425,7 +425,7 @@ class AndOperator : public BinaryOperator { } CLONE_BINARY_EXPRESSION; static AndOperator *Construct(const capnp::AndOperator::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); protected: using BinaryOperator::BinaryOperator; @@ -442,7 +442,7 @@ class AndOperator : public BinaryOperator { }; class AdditionOperator : public BinaryOperator { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -454,7 +454,7 @@ class AdditionOperator : public BinaryOperator { } CLONE_BINARY_EXPRESSION; static AdditionOperator *Construct( - const capnp::AdditionOperator::Reader &reader, AstTreeStorage *storage); + const capnp::AdditionOperator::Reader &reader, AstStorage *storage); protected: using BinaryOperator::BinaryOperator; @@ -471,7 +471,7 @@ class AdditionOperator : public BinaryOperator { }; class SubtractionOperator : public BinaryOperator { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -483,7 +483,7 @@ class SubtractionOperator : public BinaryOperator { } CLONE_BINARY_EXPRESSION; static SubtractionOperator *Construct( - capnp::SubtractionOperator::Reader &reader, AstTreeStorage *storage); + capnp::SubtractionOperator::Reader &reader, AstStorage *storage); protected: using BinaryOperator::BinaryOperator; @@ -500,7 +500,7 @@ class SubtractionOperator : public BinaryOperator { }; class MultiplicationOperator : public BinaryOperator { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -512,7 +512,7 @@ class MultiplicationOperator : public BinaryOperator { } CLONE_BINARY_EXPRESSION; static MultiplicationOperator *Construct( - capnp::MultiplicationOperator::Reader &reader, AstTreeStorage *storage); + capnp::MultiplicationOperator::Reader &reader, AstStorage *storage); protected: using BinaryOperator::BinaryOperator; @@ -528,7 +528,7 @@ class MultiplicationOperator : public BinaryOperator { }; class DivisionOperator : public BinaryOperator { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -540,7 +540,7 @@ class DivisionOperator : public BinaryOperator { } CLONE_BINARY_EXPRESSION; static DivisionOperator *Construct( - const capnp::DivisionOperator::Reader &reader, AstTreeStorage *storage); + const capnp::DivisionOperator::Reader &reader, AstStorage *storage); protected: using BinaryOperator::BinaryOperator; @@ -557,7 +557,7 @@ class DivisionOperator : public BinaryOperator { }; class ModOperator : public BinaryOperator { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -569,7 +569,7 @@ class ModOperator : public BinaryOperator { } CLONE_BINARY_EXPRESSION; static ModOperator *Construct(const capnp::ModOperator::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); protected: using BinaryOperator::BinaryOperator; @@ -586,7 +586,7 @@ class ModOperator : public BinaryOperator { }; class NotEqualOperator : public BinaryOperator { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -598,7 +598,7 @@ class NotEqualOperator : public BinaryOperator { } CLONE_BINARY_EXPRESSION; static NotEqualOperator *Construct( - const capnp::NotEqualOperator::Reader &reader, AstTreeStorage *storage); + const capnp::NotEqualOperator::Reader &reader, AstStorage *storage); protected: using BinaryOperator::BinaryOperator; @@ -615,7 +615,7 @@ class NotEqualOperator : public BinaryOperator { }; class EqualOperator : public BinaryOperator { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -627,7 +627,7 @@ class EqualOperator : public BinaryOperator { } CLONE_BINARY_EXPRESSION; static EqualOperator *Construct(const capnp::EqualOperator::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); protected: using BinaryOperator::BinaryOperator; @@ -644,7 +644,7 @@ class EqualOperator : public BinaryOperator { }; class LessOperator : public BinaryOperator { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -656,7 +656,7 @@ class LessOperator : public BinaryOperator { } CLONE_BINARY_EXPRESSION; static LessOperator *Construct(const capnp::LessOperator::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); protected: using BinaryOperator::BinaryOperator; @@ -673,7 +673,7 @@ class LessOperator : public BinaryOperator { }; class GreaterOperator : public BinaryOperator { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -685,7 +685,7 @@ class GreaterOperator : public BinaryOperator { } CLONE_BINARY_EXPRESSION; static GreaterOperator *Construct( - const capnp::GreaterOperator::Reader &reader, AstTreeStorage *storage); + const capnp::GreaterOperator::Reader &reader, AstStorage *storage); protected: using BinaryOperator::BinaryOperator; @@ -702,7 +702,7 @@ class GreaterOperator : public BinaryOperator { }; class LessEqualOperator : public BinaryOperator { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -714,7 +714,7 @@ class LessEqualOperator : public BinaryOperator { } CLONE_BINARY_EXPRESSION; static LessEqualOperator *Construct( - const capnp::LessEqualOperator::Reader &reader, AstTreeStorage *storage); + const capnp::LessEqualOperator::Reader &reader, AstStorage *storage); protected: using BinaryOperator::BinaryOperator; @@ -731,7 +731,7 @@ class LessEqualOperator : public BinaryOperator { }; class GreaterEqualOperator : public BinaryOperator { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -744,7 +744,7 @@ class GreaterEqualOperator : public BinaryOperator { CLONE_BINARY_EXPRESSION; static GreaterEqualOperator *Construct( const capnp::GreaterEqualOperator::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); protected: using BinaryOperator::BinaryOperator; @@ -761,7 +761,7 @@ class GreaterEqualOperator : public BinaryOperator { }; class InListOperator : public BinaryOperator { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -773,7 +773,7 @@ class InListOperator : public BinaryOperator { } CLONE_BINARY_EXPRESSION; static InListOperator *Construct(const capnp::InListOperator::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); protected: using BinaryOperator::BinaryOperator; @@ -790,7 +790,7 @@ class InListOperator : public BinaryOperator { }; class ListMapIndexingOperator : public BinaryOperator { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -802,7 +802,7 @@ class ListMapIndexingOperator : public BinaryOperator { } CLONE_BINARY_EXPRESSION; static ListMapIndexingOperator *Construct( - capnp::ListMapIndexingOperator::Reader &reader, AstTreeStorage *storage); + capnp::ListMapIndexingOperator::Reader &reader, AstStorage *storage); protected: using BinaryOperator::BinaryOperator; @@ -818,7 +818,7 @@ class ListMapIndexingOperator : public BinaryOperator { }; class ListSlicingOperator : public Expression { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -835,7 +835,7 @@ class ListSlicingOperator : public Expression { return visitor.PostVisit(*this); } - ListSlicingOperator *Clone(AstTreeStorage &storage) const override { + ListSlicingOperator *Clone(AstStorage &storage) const override { return storage.Create( list_->Clone(storage), lower_bound_ ? lower_bound_->Clone(storage) : nullptr, @@ -844,7 +844,7 @@ class ListSlicingOperator : public Expression { static ListSlicingOperator *Construct( const capnp::ListSlicingOperator::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); Expression *list_ = nullptr; Expression *lower_bound_ = nullptr; @@ -863,7 +863,7 @@ class ListSlicingOperator : public Expression { using Expression::Save; virtual void Save(capnp::ListSlicingOperator::Builder *builder, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -894,7 +894,7 @@ class ListSlicingOperator : public Expression { }; class IfOperator : public Expression { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -906,14 +906,14 @@ class IfOperator : public Expression { return visitor.PostVisit(*this); } - IfOperator *Clone(AstTreeStorage &storage) const override { + IfOperator *Clone(AstStorage &storage) const override { return storage.Create(condition_->Clone(storage), then_expression_->Clone(storage), else_expression_->Clone(storage)); } static IfOperator *Construct(const capnp::IfOperator::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); // None of the expressions should be nullptrs. If there is no else_expression // you probably want to make it NULL PrimitiveLiteral. Expression *condition_; @@ -933,7 +933,7 @@ class IfOperator : public Expression { using Expression::Save; virtual void Save(capnp::IfOperator::Builder *builder, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -964,7 +964,7 @@ class IfOperator : public Expression { }; class NotOperator : public UnaryOperator { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -976,7 +976,7 @@ class NotOperator : public UnaryOperator { } CLONE_UNARY_EXPRESSION; static NotOperator *Construct(const capnp::NotOperator::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); protected: using UnaryOperator::UnaryOperator; @@ -993,7 +993,7 @@ class NotOperator : public UnaryOperator { }; class UnaryPlusOperator : public UnaryOperator { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -1005,7 +1005,7 @@ class UnaryPlusOperator : public UnaryOperator { } CLONE_UNARY_EXPRESSION; static UnaryPlusOperator *Construct( - const capnp::UnaryPlusOperator::Reader &reader, AstTreeStorage *storage); + const capnp::UnaryPlusOperator::Reader &reader, AstStorage *storage); protected: using UnaryOperator::UnaryOperator; @@ -1022,7 +1022,7 @@ class UnaryPlusOperator : public UnaryOperator { }; class UnaryMinusOperator : public UnaryOperator { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -1034,7 +1034,7 @@ class UnaryMinusOperator : public UnaryOperator { } CLONE_UNARY_EXPRESSION; static UnaryMinusOperator *Construct( - capnp::UnaryMinusOperator::Reader &reader, AstTreeStorage *storage); + capnp::UnaryMinusOperator::Reader &reader, AstStorage *storage); protected: using UnaryOperator::UnaryOperator; @@ -1051,7 +1051,7 @@ class UnaryMinusOperator : public UnaryOperator { }; class IsNullOperator : public UnaryOperator { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -1063,7 +1063,7 @@ class IsNullOperator : public UnaryOperator { } CLONE_UNARY_EXPRESSION; static IsNullOperator *Construct(const capnp::IsNullOperator::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); protected: using UnaryOperator::UnaryOperator; @@ -1080,12 +1080,12 @@ class IsNullOperator : public UnaryOperator { }; class BaseLiteral : public Expression { - friend class AstTreeStorage; + friend class AstStorage; public: - BaseLiteral *Clone(AstTreeStorage &storage) const override = 0; + BaseLiteral *Clone(AstStorage &storage) const override = 0; static BaseLiteral *Construct(const capnp::BaseLiteral::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); protected: explicit BaseLiteral(int uid) : Expression(uid) {} @@ -1102,18 +1102,18 @@ class BaseLiteral : public Expression { }; class PrimitiveLiteral : public BaseLiteral { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); DEFVISITABLE(HierarchicalTreeVisitor); - PrimitiveLiteral *Clone(AstTreeStorage &storage) const override { + PrimitiveLiteral *Clone(AstStorage &storage) const override { return storage.Create(value_, token_position_); } static PrimitiveLiteral *Construct( - const capnp::PrimitiveLiteral::Reader &reader, AstTreeStorage *storage); + const capnp::PrimitiveLiteral::Reader &reader, AstStorage *storage); TypedValue value_; // This field contains token position of literal used to create @@ -1131,7 +1131,7 @@ class PrimitiveLiteral : public BaseLiteral { void Save(capnp::BaseLiteral::Builder *builder, std::vector *saved_uids) override; - void Load(const capnp::Tree::Reader &reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -1160,7 +1160,7 @@ class PrimitiveLiteral : public BaseLiteral { }; class ListLiteral : public BaseLiteral { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -1172,7 +1172,7 @@ class ListLiteral : public BaseLiteral { return visitor.PostVisit(*this); } - ListLiteral *Clone(AstTreeStorage &storage) const override { + ListLiteral *Clone(AstStorage &storage) const override { auto *list = storage.Create(); for (auto *element : elements_) { list->elements_.push_back(element->Clone(storage)); @@ -1181,7 +1181,7 @@ class ListLiteral : public BaseLiteral { } static ListLiteral *Construct(const capnp::ListLiteral::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); std::vector elements_; @@ -1192,7 +1192,7 @@ class ListLiteral : public BaseLiteral { void Save(capnp::BaseLiteral::Builder *builder, std::vector *saved_uids) override; - void Load(const capnp::Tree::Reader &reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -1219,7 +1219,7 @@ class ListLiteral : public BaseLiteral { }; class MapLiteral : public BaseLiteral { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -1231,7 +1231,7 @@ class MapLiteral : public BaseLiteral { return visitor.PostVisit(*this); } - MapLiteral *Clone(AstTreeStorage &storage) const override { + MapLiteral *Clone(AstStorage &storage) const override { auto *map = storage.Create(); for (auto pair : elements_) map->elements_.emplace(pair.first, pair.second->Clone(storage)); @@ -1239,7 +1239,7 @@ class MapLiteral : public BaseLiteral { } static MapLiteral *Construct(const capnp::MapLiteral::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); // maps (property_name, property) to expressions std::unordered_map, Expression *> @@ -1254,7 +1254,7 @@ class MapLiteral : public BaseLiteral { void Save(capnp::BaseLiteral::Builder *builder, std::vector *saved_uids) override; - void Load(const capnp::Tree::Reader &reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -1297,18 +1297,18 @@ class MapLiteral : public BaseLiteral { }; class Identifier : public Expression { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); DEFVISITABLE(HierarchicalTreeVisitor); - Identifier *Clone(AstTreeStorage &storage) const override { + Identifier *Clone(AstStorage &storage) const override { return storage.Create(name_, user_declared_); } static Identifier *Construct(const capnp::Identifier::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); using Expression::Save; std::string name_; @@ -1341,7 +1341,7 @@ class Identifier : public Expression { }; class PropertyLookup : public Expression { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -1352,13 +1352,13 @@ class PropertyLookup : public Expression { return visitor.PostVisit(*this); } - PropertyLookup *Clone(AstTreeStorage &storage) const override { + PropertyLookup *Clone(AstStorage &storage) const override { return storage.Create(expression_->Clone(storage), property_name_, property_); } static PropertyLookup *Construct(const capnp::PropertyLookup::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); using Expression::Save; Expression *expression_ = nullptr; @@ -1383,7 +1383,7 @@ class PropertyLookup : public Expression { std::vector *saved_uids) override; virtual void Save(capnp::PropertyLookup::Builder *builder, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -1414,7 +1414,7 @@ class PropertyLookup : public Expression { }; class LabelsTest : public Expression { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -1425,12 +1425,12 @@ class LabelsTest : public Expression { return visitor.PostVisit(*this); } - LabelsTest *Clone(AstTreeStorage &storage) const override { + LabelsTest *Clone(AstStorage &storage) const override { return storage.Create(expression_->Clone(storage), labels_); } static LabelsTest *Construct(const capnp::LabelsTest::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); using Expression::Save; Expression *expression_ = nullptr; @@ -1445,7 +1445,7 @@ class LabelsTest : public Expression { std::vector *saved_uids) override; virtual void Save(capnp::LabelsTest::Builder *builder, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &tree_reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &tree_reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -1474,7 +1474,7 @@ class LabelsTest : public Expression { }; class Function : public Expression { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -1487,7 +1487,7 @@ class Function : public Expression { return visitor.PostVisit(*this); } - Function *Clone(AstTreeStorage &storage) const override { + Function *Clone(AstStorage &storage) const override { std::vector arguments; for (auto *argument : arguments_) { arguments.push_back(argument->Clone(storage)); @@ -1496,7 +1496,7 @@ class Function : public Expression { } static Function *Construct(const capnp::Function::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); const auto &function() const { return function_; } const auto &function_name() const { return function_name_; } @@ -1518,7 +1518,7 @@ class Function : public Expression { using Expression::Save; virtual void Save(capnp::Function::Builder *builder, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &tree_reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &tree_reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -1553,7 +1553,7 @@ class Function : public Expression { }; class Aggregation : public BinaryOperator { - friend class AstTreeStorage; + friend class AstStorage; public: enum class Op { COUNT, MIN, MAX, SUM, AVG, COLLECT_LIST, COLLECT_MAP }; @@ -1579,7 +1579,7 @@ class Aggregation : public BinaryOperator { return visitor.PostVisit(*this); } - Aggregation *Clone(AstTreeStorage &storage) const override { + Aggregation *Clone(AstStorage &storage) const override { return storage.Create( expression1_ ? expression1_->Clone(storage) : nullptr, expression2_ ? expression2_->Clone(storage) : nullptr, op_); @@ -1587,7 +1587,7 @@ class Aggregation : public BinaryOperator { Op op_; static Aggregation *Construct(const capnp::Aggregation::Reader &, - AstTreeStorage *storage); + AstStorage *storage); protected: // Use only for serialization. @@ -1624,7 +1624,7 @@ class Aggregation : public BinaryOperator { }; class Reduce : public Expression { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -1637,7 +1637,7 @@ class Reduce : public Expression { return visitor.PostVisit(*this); } - Reduce *Clone(AstTreeStorage &storage) const override { + Reduce *Clone(AstStorage &storage) const override { return storage.Create( accumulator_->Clone(storage), initializer_->Clone(storage), identifier_->Clone(storage), list_->Clone(storage), @@ -1645,7 +1645,7 @@ class Reduce : public Expression { } static Reduce *Construct(const capnp::Reduce::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); using Expression::Save; // None of these should be nullptr after construction. @@ -1676,7 +1676,7 @@ class Reduce : public Expression { std::vector *saved_uids) override; virtual void Save(capnp::Reduce::Builder *builder, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &tree_reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &tree_reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -1711,7 +1711,7 @@ class Reduce : public Expression { // TODO: Think about representing All and Any as Reduce. class All : public Expression { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -1723,14 +1723,14 @@ class All : public Expression { return visitor.PostVisit(*this); } - All *Clone(AstTreeStorage &storage) const override { + All *Clone(AstStorage &storage) const override { return storage.Create(identifier_->Clone(storage), list_expression_->Clone(storage), where_->Clone(storage)); } static All *Construct(const capnp::All::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); // None of these should be nullptr after construction. Identifier *identifier_ = nullptr; @@ -1749,7 +1749,7 @@ class All : public Expression { std::vector *saved_uids) override; using Expression::Save; virtual void Save(capnp::All::Builder *builder, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &tree_reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &tree_reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -1782,7 +1782,7 @@ class All : public Expression { // All, Any and Single into something like a higher-order function call which // takes a list argument and a function which is applied on list elements. class Single : public Expression { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -1794,14 +1794,14 @@ class Single : public Expression { return visitor.PostVisit(*this); } - Single *Clone(AstTreeStorage &storage) const override { + Single *Clone(AstStorage &storage) const override { return storage.Create(identifier_->Clone(storage), list_expression_->Clone(storage), where_->Clone(storage)); } static Single *Construct(const capnp::Single::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); using Expression::Save; // None of these should be nullptr after construction. @@ -1821,7 +1821,7 @@ class Single : public Expression { std::vector *saved_uids) override; virtual void Save(capnp::Single::Builder *builder, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &tree_reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &tree_reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -1851,18 +1851,18 @@ class Single : public Expression { }; class ParameterLookup : public Expression { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); DEFVISITABLE(HierarchicalTreeVisitor); - ParameterLookup *Clone(AstTreeStorage &storage) const override { + ParameterLookup *Clone(AstStorage &storage) const override { return storage.Create(token_position_); } static ParameterLookup *Construct( - const capnp::ParameterLookup::Reader &reader, AstTreeStorage *storage); + const capnp::ParameterLookup::Reader &reader, AstStorage *storage); using Expression::Save; // This field contains token position of *literal* used to create @@ -1895,7 +1895,7 @@ class ParameterLookup : public Expression { }; class NamedExpression : public Tree { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -1906,13 +1906,13 @@ class NamedExpression : public Tree { return visitor.PostVisit(*this); } - NamedExpression *Clone(AstTreeStorage &storage) const override { + NamedExpression *Clone(AstStorage &storage) const override { return storage.Create(name_, expression_->Clone(storage), token_position_); } static NamedExpression *Construct( - const capnp::NamedExpression::Reader &reader, AstTreeStorage *storage); + const capnp::NamedExpression::Reader &reader, AstStorage *storage); void Save(capnp::Tree::Builder *builder, std::vector *saved_uids) override; @@ -1937,7 +1937,7 @@ class NamedExpression : public Tree { virtual void Save(capnp::NamedExpression::Builder *, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &base_reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &base_reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -1970,15 +1970,15 @@ class NamedExpression : public Tree { // Pattern atoms class PatternAtom : public Tree { - friend class AstTreeStorage; + friend class AstStorage; public: Identifier *identifier_ = nullptr; - PatternAtom *Clone(AstTreeStorage &storage) const override = 0; + PatternAtom *Clone(AstStorage &storage) const override = 0; static PatternAtom *Construct(const capnp::PatternAtom::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); void Save(capnp::Tree::Builder *builder, std::vector *saved_uids) override; @@ -1989,7 +1989,7 @@ class PatternAtom : public Tree { virtual void Save(capnp::PatternAtom::Builder *, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -2011,7 +2011,7 @@ class PatternAtom : public Tree { }; class NodeAtom : public PatternAtom { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -2027,7 +2027,7 @@ class NodeAtom : public PatternAtom { return visitor.PostVisit(*this); } - NodeAtom *Clone(AstTreeStorage &storage) const override { + NodeAtom *Clone(AstStorage &storage) const override { auto *node_atom = storage.Create(identifier_->Clone(storage)); node_atom->labels_ = labels_; for (auto property : properties_) { @@ -2037,7 +2037,7 @@ class NodeAtom : public PatternAtom { } static NodeAtom *Construct(const capnp::NodeAtom::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); using PatternAtom::Save; std::vector labels_; @@ -2052,7 +2052,7 @@ class NodeAtom : public PatternAtom { std::vector *saved_uids) override; virtual void Save(capnp::NodeAtom::Builder *builder, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &base_reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &base_reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -2096,10 +2096,10 @@ class NodeAtom : public PatternAtom { }; class EdgeAtom : public PatternAtom { - friend class AstTreeStorage; + friend class AstStorage; template - static TPtr *CloneOpt(TPtr *ptr, AstTreeStorage &storage) { + static TPtr *CloneOpt(TPtr *ptr, AstStorage &storage) { return ptr ? ptr->Clone(storage) : nullptr; } @@ -2145,7 +2145,7 @@ class EdgeAtom : public PatternAtom { return visitor.PostVisit(*this); } - EdgeAtom *Clone(AstTreeStorage &storage) const override { + EdgeAtom *Clone(AstStorage &storage) const override { auto *edge_atom = storage.Create(identifier_->Clone(storage)); edge_atom->direction_ = direction_; edge_atom->type_ = type_; @@ -2178,7 +2178,7 @@ class EdgeAtom : public PatternAtom { } static EdgeAtom *Construct(const capnp::EdgeAtom::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); using PatternAtom::Save; Type type_ = Type::SINGLE; @@ -2222,7 +2222,7 @@ class EdgeAtom : public PatternAtom { std::vector *saved_uids) override; virtual void Save(capnp::EdgeAtom::Builder *builder, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &base_reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &base_reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -2290,7 +2290,7 @@ class EdgeAtom : public PatternAtom { }; class Pattern : public Tree { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -2306,7 +2306,7 @@ class Pattern : public Tree { return visitor.PostVisit(*this); } - Pattern *Clone(AstTreeStorage &storage) const override { + Pattern *Clone(AstStorage &storage) const override { auto *pattern = storage.Create(); pattern->identifier_ = identifier_->Clone(storage); for (auto *atom : atoms_) { @@ -2316,7 +2316,7 @@ class Pattern : public Tree { } static Pattern *Construct(const capnp::Pattern::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); void Save(capnp::Tree::Builder *builder, std::vector *saved_uids) override; @@ -2327,7 +2327,7 @@ class Pattern : public Tree { explicit Pattern(int uid) : Tree(uid) {} virtual void Save(capnp::Pattern::Builder *, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &base_reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &base_reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -2357,15 +2357,15 @@ class Pattern : public Tree { // Clause class Clause : public Tree { - friend class AstTreeStorage; + friend class AstStorage; public: explicit Clause(int uid) : Tree(uid) {} - Clause *Clone(AstTreeStorage &storage) const override = 0; + Clause *Clone(AstStorage &storage) const override = 0; static Clause *Construct(const capnp::Clause::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); void Save(capnp::Tree::Builder *builder, std::vector *saved_uids) override; @@ -2381,7 +2381,7 @@ class Clause : public Tree { // SingleQuery class SingleQuery : public Tree { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -2394,7 +2394,7 @@ class SingleQuery : public Tree { return visitor.PostVisit(*this); } - SingleQuery *Clone(AstTreeStorage &storage) const override { + SingleQuery *Clone(AstStorage &storage) const override { auto *single_query = storage.Create(); for (auto *clause : clauses_) { single_query->clauses_.push_back(clause->Clone(storage)); @@ -2403,7 +2403,7 @@ class SingleQuery : public Tree { } static SingleQuery *Construct(const capnp::SingleQuery::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); void Save(capnp::Tree::Builder *builder, std::vector *saved_uids) override; @@ -2415,7 +2415,7 @@ class SingleQuery : public Tree { virtual void Save(capnp::SingleQuery::Builder *, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &base_reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &base_reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -2444,7 +2444,7 @@ class SingleQuery : public Tree { // CypherUnion class CypherUnion : public Tree { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -2455,7 +2455,7 @@ class CypherUnion : public Tree { return visitor.PostVisit(*this); } - CypherUnion *Clone(AstTreeStorage &storage) const override { + CypherUnion *Clone(AstStorage &storage) const override { auto cypher_union = storage.Create(distinct_); cypher_union->single_query_ = single_query_->Clone(storage); cypher_union->union_symbols_ = union_symbols_; @@ -2463,7 +2463,7 @@ class CypherUnion : public Tree { } static CypherUnion *Construct(const capnp::CypherUnion::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); void Save(capnp::Tree::Builder *builder, std::vector *saved_uids) override; @@ -2486,7 +2486,7 @@ class CypherUnion : public Tree { virtual void Save(capnp::CypherUnion::Builder *, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &base_reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &base_reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -2519,7 +2519,7 @@ class CypherUnion : public Tree { // Queries class Query : public Tree { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -2536,7 +2536,7 @@ class Query : public Tree { } // Creates deep copy of whole ast. - Query *Clone(AstTreeStorage &storage) const override { + Query *Clone(AstStorage &storage) const override { auto *query = storage.query(); query->single_query_ = single_query_->Clone(storage); for (auto *cypher_union : cypher_unions_) { @@ -2545,7 +2545,7 @@ class Query : public Tree { return query; } - void Load(const capnp::Tree::Reader &reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &reader, AstStorage *storage, std::vector *loaded_uids) override; void Save(capnp::Tree::Builder *builder, std::vector *saved_uids) override; @@ -2585,7 +2585,7 @@ class Query : public Tree { // Clauses class Create : public Clause { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -2598,7 +2598,7 @@ class Create : public Clause { return visitor.PostVisit(*this); } - Create *Clone(AstTreeStorage &storage) const override { + Create *Clone(AstStorage &storage) const override { auto *create = storage.Create(); for (auto *pattern : patterns_) { create->patterns_.push_back(pattern->Clone(storage)); @@ -2607,7 +2607,7 @@ class Create : public Clause { } static Create *Construct(const capnp::Create::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); using Clause::Save; std::vector patterns_; @@ -2621,7 +2621,7 @@ class Create : public Clause { std::vector *saved_uids) override; virtual void Save(capnp::Create::Builder *builder, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &tree_reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &tree_reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -2647,7 +2647,7 @@ class Create : public Clause { }; class Match : public Clause { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -2667,7 +2667,7 @@ class Match : public Clause { return visitor.PostVisit(*this); } - Match *Clone(AstTreeStorage &storage) const override { + Match *Clone(AstStorage &storage) const override { auto *match = storage.Create(optional_); for (auto *pattern : patterns_) { match->patterns_.push_back(pattern->Clone(storage)); @@ -2678,7 +2678,7 @@ class Match : public Clause { using Clause::Save; static Match *Construct(const capnp::Match::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); std::vector patterns_; Where *where_ = nullptr; @@ -2694,7 +2694,7 @@ class Match : public Clause { std::vector *saved_uids) override; virtual void Save(capnp::Match::Builder *builder, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &base_reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &base_reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -2745,7 +2745,7 @@ struct ReturnBody { // Deep copy ReturnBody. // TODO: Think about turning ReturnBody to class and making this // function class member. -ReturnBody CloneReturnBody(AstTreeStorage &storage, const ReturnBody &body); +ReturnBody CloneReturnBody(AstStorage &storage, const ReturnBody &body); template void serialize(TArchive &ar, ReturnBody &body, @@ -2786,7 +2786,7 @@ void load(TArchive &ar, ReturnBody &body, const unsigned int) { } class Return : public Clause { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -2813,7 +2813,7 @@ class Return : public Clause { return visitor.PostVisit(*this); } - Return *Clone(AstTreeStorage &storage) const override { + Return *Clone(AstStorage &storage) const override { auto *ret = storage.Create(); ret->body_ = CloneReturnBody(storage, body_); return ret; @@ -2821,7 +2821,7 @@ class Return : public Clause { using Clause::Save; static Return *Construct(const capnp::Return::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); ReturnBody body_; @@ -2833,7 +2833,7 @@ class Return : public Clause { std::vector *saved_uids) override; virtual void Save(capnp::Return::Builder *builder, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &base_reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &base_reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -2851,7 +2851,7 @@ class Return : public Clause { }; class With : public Clause { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -2879,7 +2879,7 @@ class With : public Clause { return visitor.PostVisit(*this); } - With *Clone(AstTreeStorage &storage) const override { + With *Clone(AstStorage &storage) const override { auto *with = storage.Create(); with->body_ = CloneReturnBody(storage, body_); with->where_ = where_ ? where_->Clone(storage) : nullptr; @@ -2888,7 +2888,7 @@ class With : public Clause { using Clause::Save; static With *Construct(const capnp::With::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); ReturnBody body_; Where *where_ = nullptr; @@ -2902,7 +2902,7 @@ class With : public Clause { std::vector *saved_uids) override; virtual void Save(capnp::With::Builder *builder, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &base_reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &base_reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -2930,7 +2930,7 @@ class With : public Clause { }; class Delete : public Clause { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -2943,7 +2943,7 @@ class Delete : public Clause { return visitor.PostVisit(*this); } - Delete *Clone(AstTreeStorage &storage) const override { + Delete *Clone(AstStorage &storage) const override { auto *del = storage.Create(); for (auto *expression : expressions_) { del->expressions_.push_back(expression->Clone(storage)); @@ -2954,7 +2954,7 @@ class Delete : public Clause { using Clause::Save; static Delete *Construct(const capnp::Delete::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); std::vector expressions_; @@ -2969,7 +2969,7 @@ class Delete : public Clause { std::vector *saved_uids) override; virtual void Save(capnp::Delete::Builder *builder, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &base_reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &base_reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -2997,7 +2997,7 @@ class Delete : public Clause { }; class SetProperty : public Clause { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -3008,14 +3008,14 @@ class SetProperty : public Clause { return visitor.PostVisit(*this); } - SetProperty *Clone(AstTreeStorage &storage) const override { + SetProperty *Clone(AstStorage &storage) const override { return storage.Create(property_lookup_->Clone(storage), expression_->Clone(storage)); } using Clause::Save; static SetProperty *Construct(const capnp::SetProperty::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); PropertyLookup *property_lookup_ = nullptr; Expression *expression_ = nullptr; @@ -3031,7 +3031,7 @@ class SetProperty : public Clause { std::vector *saved_uids) override; virtual void Save(capnp::SetProperty::Builder *builder, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &base_reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &base_reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -3060,7 +3060,7 @@ class SetProperty : public Clause { }; class SetProperties : public Clause { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -3071,14 +3071,14 @@ class SetProperties : public Clause { return visitor.PostVisit(*this); } - SetProperties *Clone(AstTreeStorage &storage) const override { + SetProperties *Clone(AstStorage &storage) const override { return storage.Create(identifier_->Clone(storage), expression_->Clone(storage), update_); } using Clause::Save; static SetProperties *Construct(const capnp::SetProperties::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); Identifier *identifier_ = nullptr; Expression *expression_ = nullptr; @@ -3097,7 +3097,7 @@ class SetProperties : public Clause { std::vector *saved_uids) override; virtual void Save(capnp::SetProperties::Builder *builder, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &base_reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &base_reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -3128,7 +3128,7 @@ class SetProperties : public Clause { }; class SetLabels : public Clause { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -3139,13 +3139,13 @@ class SetLabels : public Clause { return visitor.PostVisit(*this); } - SetLabels *Clone(AstTreeStorage &storage) const override { + SetLabels *Clone(AstStorage &storage) const override { return storage.Create(identifier_->Clone(storage), labels_); } using Clause::Save; static SetLabels *Construct(const capnp::SetLabels::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); Identifier *identifier_ = nullptr; std::vector labels_; @@ -3160,7 +3160,7 @@ class SetLabels : public Clause { std::vector *saved_uids) override; virtual void Save(capnp::SetLabels::Builder *builder, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &base_reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &base_reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -3188,7 +3188,7 @@ class SetLabels : public Clause { }; class RemoveProperty : public Clause { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -3199,13 +3199,13 @@ class RemoveProperty : public Clause { return visitor.PostVisit(*this); } - RemoveProperty *Clone(AstTreeStorage &storage) const override { + RemoveProperty *Clone(AstStorage &storage) const override { return storage.Create(property_lookup_->Clone(storage)); } using Clause::Save; static RemoveProperty *Construct(const capnp::RemoveProperty::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); PropertyLookup *property_lookup_ = nullptr; @@ -3218,7 +3218,7 @@ class RemoveProperty : public Clause { std::vector *saved_uids) override; virtual void Save(capnp::RemoveProperty::Builder *builder, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &base_reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &base_reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -3245,7 +3245,7 @@ class RemoveProperty : public Clause { }; class RemoveLabels : public Clause { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -3256,13 +3256,13 @@ class RemoveLabels : public Clause { return visitor.PostVisit(*this); } - RemoveLabels *Clone(AstTreeStorage &storage) const override { + RemoveLabels *Clone(AstStorage &storage) const override { return storage.Create(identifier_->Clone(storage), labels_); } using Clause::Save; static RemoveLabels *Construct(const capnp::RemoveLabels::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); Identifier *identifier_ = nullptr; std::vector labels_; @@ -3277,7 +3277,7 @@ class RemoveLabels : public Clause { std::vector *saved_uids) override; virtual void Save(capnp::RemoveLabels::Builder *builder, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &base_reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &base_reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -3306,7 +3306,7 @@ class RemoveLabels : public Clause { }; class Merge : public Clause { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -3333,7 +3333,7 @@ class Merge : public Clause { return visitor.PostVisit(*this); } - Merge *Clone(AstTreeStorage &storage) const override { + Merge *Clone(AstStorage &storage) const override { auto *merge = storage.Create(); merge->pattern_ = pattern_->Clone(storage); for (auto *on_match : on_match_) { @@ -3347,7 +3347,7 @@ class Merge : public Clause { using Clause::Save; static Merge *Construct(const capnp::Merge::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); Pattern *pattern_ = nullptr; std::vector on_match_; @@ -3366,7 +3366,7 @@ class Merge : public Clause { std::vector *saved_uids) override; virtual void Save(capnp::Merge::Builder *builder, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &base_reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &base_reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -3396,7 +3396,7 @@ class Merge : public Clause { }; class Unwind : public Clause { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); @@ -3407,13 +3407,13 @@ class Unwind : public Clause { return visitor.PostVisit(*this); } - Unwind *Clone(AstTreeStorage &storage) const override { + Unwind *Clone(AstStorage &storage) const override { return storage.Create(named_expression_->Clone(storage)); } using Clause::Save; static Unwind *Construct(const capnp::Unwind::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); NamedExpression *named_expression_ = nullptr; @@ -3430,7 +3430,7 @@ class Unwind : public Clause { std::vector *saved_uids) override; virtual void Save(capnp::Unwind::Builder *builder, std::vector *saved_uids); - void Load(const capnp::Tree::Reader &base_reader, AstTreeStorage *storage, + void Load(const capnp::Tree::Reader &base_reader, AstStorage *storage, std::vector *loaded_uids) override; private: @@ -3456,18 +3456,18 @@ class Unwind : public Clause { }; class CreateIndex : public Clause { - friend class AstTreeStorage; + friend class AstStorage; public: DEFVISITABLE(TreeVisitor); DEFVISITABLE(HierarchicalTreeVisitor); - CreateIndex *Clone(AstTreeStorage &storage) const override { + CreateIndex *Clone(AstStorage &storage) const override { return storage.Create(label_, property_); } static CreateIndex *Construct(const capnp::CreateIndex::Reader &reader, - AstTreeStorage *storage); + AstStorage *storage); using Clause::Save; storage::Label label_; diff --git a/src/query/frontend/ast/cypher_main_visitor.hpp b/src/query/frontend/ast/cypher_main_visitor.hpp index 2404b9efc..01f1b3bcd 100644 --- a/src/query/frontend/ast/cypher_main_visitor.hpp +++ b/src/query/frontend/ast/cypher_main_visitor.hpp @@ -573,7 +573,7 @@ class CypherMainVisitor : public antlropencypher::CypherBaseVisitor { public: Query *query() { return query_; } - AstTreeStorage &storage() { return storage_; } + AstStorage &storage() { return storage_; } const static std::string kAnonPrefix; private: @@ -582,7 +582,7 @@ class CypherMainVisitor : public antlropencypher::CypherBaseVisitor { std::unordered_set users_identifiers; // Identifiers that user didn't name. std::vector anonymous_identifiers; - AstTreeStorage storage_; + AstStorage storage_; Query *query_ = nullptr; // All return items which are not variables must be aliased in with. // We use this variable in visitReturnItem to check if we are in with or diff --git a/src/query/interpreter.cpp b/src/query/interpreter.cpp index 391541938..472107433 100644 --- a/src/query/interpreter.cpp +++ b/src/query/interpreter.cpp @@ -125,7 +125,7 @@ Interpreter::Results Interpreter::operator()( std::shared_ptr Interpreter::QueryToPlan( const StrippedQuery &stripped, Context &ctx) { - AstTreeStorage ast_storage = QueryToAst(stripped, ctx); + AstStorage ast_storage = QueryToAst(stripped, ctx); SymbolGenerator symbol_generator(ctx.symbol_table_); ast_storage.query()->Accept(symbol_generator); @@ -156,7 +156,7 @@ std::shared_ptr Interpreter::QueryToPlan( } } -AstTreeStorage Interpreter::QueryToAst(const StrippedQuery &stripped, +AstStorage Interpreter::QueryToAst(const StrippedQuery &stripped, Context &ctx) { if (!ctx.is_query_cached_) { // stripped query -> AST @@ -201,13 +201,13 @@ AstTreeStorage Interpreter::QueryToAst(const StrippedQuery &stripped, ast_cache_accessor.insert(stripped.hash(), std::move(visitor.storage())) .first; } - AstTreeStorage new_ast; + AstStorage new_ast; ast_it->second.query()->Clone(new_ast); return new_ast; } std::pair, double> -Interpreter::MakeLogicalPlan(AstTreeStorage &ast_storage, Context &context) { +Interpreter::MakeLogicalPlan(AstStorage &ast_storage, Context &context) { std::unique_ptr logical_plan; auto vertex_counts = plan::MakeVertexCountCache(context.db_accessor_); auto planning_context = plan::MakePlanningContext( diff --git a/src/query/interpreter.hpp b/src/query/interpreter.hpp index 2e6788a2f..fae3b95bb 100644 --- a/src/query/interpreter.hpp +++ b/src/query/interpreter.hpp @@ -164,7 +164,7 @@ class Interpreter { bool in_explicit_transaction); private: - ConcurrentMap ast_cache_; + ConcurrentMap ast_cache_; PlanCacheT plan_cache_; std::atomic next_plan_id_{0}; // Antlr has singleton instance that is shared between threads. It is @@ -182,12 +182,12 @@ class Interpreter { std::shared_ptr QueryToPlan(const StrippedQuery &stripped, Context &ctx); // stripped query -> high level tree - AstTreeStorage QueryToAst(const StrippedQuery &stripped, Context &ctx); + AstStorage QueryToAst(const StrippedQuery &stripped, Context &ctx); // high level tree -> (logical plan, plan cost) - // AstTreeStorage and SymbolTable may be modified during planning. + // AstStorage and SymbolTable may be modified during planning. std::pair, double> MakeLogicalPlan( - AstTreeStorage &, Context &); + AstStorage &, Context &); }; } // namespace query diff --git a/src/query/plan/distributed.cpp b/src/query/plan/distributed.cpp index 6d41c92b7..09964c750 100644 --- a/src/query/plan/distributed.cpp +++ b/src/query/plan/distributed.cpp @@ -16,7 +16,7 @@ namespace query::plan { namespace { -std::pair, AstTreeStorage> Clone( +std::pair, AstStorage> Clone( const LogicalOperator &original_plan) { // TODO: Add a proper Clone method to LogicalOperator std::stringstream stream; @@ -28,8 +28,8 @@ std::pair, AstTreeStorage> Clone( LogicalOperator *plan_copy = nullptr; in_archive >> plan_copy; return {std::unique_ptr(plan_copy), - std::move(in_archive.template get_helper( - AstTreeStorage::kHelperId))}; + std::move(in_archive.template get_helper( + AstStorage::kHelperId))}; } int64_t AddWorkerPlan(DistributedPlan &distributed_plan, diff --git a/src/query/plan/distributed.hpp b/src/query/plan/distributed.hpp index 00d9d96bc..828c4f268 100644 --- a/src/query/plan/distributed.hpp +++ b/src/query/plan/distributed.hpp @@ -17,7 +17,7 @@ struct DistributedPlan { std::vector>> worker_plans; /// Ast storage with newly added expressions. - AstTreeStorage ast_storage; + AstStorage ast_storage; /// Symbol table with newly added symbols. SymbolTable symbol_table; }; diff --git a/src/query/plan/operator.lcp b/src/query/plan/operator.lcp index b29bcef4a..dfb92cb17 100644 --- a/src/query/plan/operator.lcp +++ b/src/query/plan/operator.lcp @@ -226,7 +226,7 @@ can serve as inputs to others and thus a sequence of operations is formed.") }; struct LoadHelper { - AstTreeStorage ast_storage; + AstStorage ast_storage; std::vector loaded_ast_uids; std::vector>> loaded_ops; @@ -245,12 +245,12 @@ can serve as inputs to others and thus a sequence of operations is formed.") #>cpp template -std::pair, AstTreeStorage> LoadPlan( +std::pair, AstStorage> LoadPlan( TArchive &ar) { std::unique_ptr root; ar >> root; - return {std::move(root), std::move(ar.template get_helper( - AstTreeStorage::kHelperId))}; + return {std::move(root), std::move(ar.template get_helper( + AstStorage::kHelperId))}; } cpp<# diff --git a/src/query/plan/planner.hpp b/src/query/plan/planner.hpp index ba6384135..a3d9f651e 100644 --- a/src/query/plan/planner.hpp +++ b/src/query/plan/planner.hpp @@ -14,7 +14,7 @@ namespace query { -class AstTreeStorage; +class AstStorage; class SymbolTable; namespace plan { diff --git a/src/query/plan/preprocess.cpp b/src/query/plan/preprocess.cpp index 52cc5c84d..79156f7bb 100644 --- a/src/query/plan/preprocess.cpp +++ b/src/query/plan/preprocess.cpp @@ -82,7 +82,7 @@ std::vector NormalizePatterns( // will lift them out of a pattern and generate new expressions (just like they // were in a Where clause). void AddMatching(const std::vector &patterns, Where *where, - SymbolTable &symbol_table, AstTreeStorage &storage, + SymbolTable &symbol_table, AstStorage &storage, Matching &matching) { auto expansions = NormalizePatterns(symbol_table, patterns); std::unordered_set edge_symbols; @@ -125,7 +125,7 @@ void AddMatching(const std::vector &patterns, Where *where, } } void AddMatching(const Match &match, SymbolTable &symbol_table, - AstTreeStorage &storage, Matching &matching) { + AstStorage &storage, Matching &matching) { return AddMatching(match.patterns_, match.where_, symbol_table, storage, matching); } @@ -219,7 +219,7 @@ void Filters::EraseLabelFilter(const Symbol &symbol, storage::Label label) { } void Filters::CollectPatternFilters(Pattern &pattern, SymbolTable &symbol_table, - AstTreeStorage &storage) { + AstStorage &storage) { UsedSymbolsCollector collector(symbol_table); auto add_properties_variable = [&](EdgeAtom *atom) { const auto &symbol = symbol_table.at(*atom->identifier_); @@ -443,7 +443,7 @@ void Filters::AnalyzeAndStoreFilter(Expression *expr, // Converts a Query to multiple QueryParts. In the process new Ast nodes may be // created, e.g. filter expressions. std::vector CollectSingleQueryParts( - SymbolTable &symbol_table, AstTreeStorage &storage, + SymbolTable &symbol_table, AstStorage &storage, SingleQuery *single_query) { std::vector query_parts(1); auto *query_part = &query_parts.back(); @@ -478,7 +478,7 @@ std::vector CollectSingleQueryParts( } QueryParts CollectQueryParts(SymbolTable &symbol_table, - AstTreeStorage &storage) { + AstStorage &storage) { auto query = storage.query(); std::vector query_parts; bool distinct = false; diff --git a/src/query/plan/preprocess.hpp b/src/query/plan/preprocess.hpp index c21c7c6b8..dbbb94c6b 100644 --- a/src/query/plan/preprocess.hpp +++ b/src/query/plan/preprocess.hpp @@ -182,7 +182,7 @@ class Filters { /// Goes through all the atoms in a pattern and generates filter expressions /// for found labels, properties and edge types. The generated expressions are /// stored. - void CollectPatternFilters(Pattern &, SymbolTable &, AstTreeStorage &); + void CollectPatternFilters(Pattern &, SymbolTable &, AstStorage &); /// Collects filtering information from a where expression. /// /// Takes the where expression and stores it, then analyzes the expression for @@ -280,8 +280,8 @@ struct QueryParts { /// /// This function will normalize patterns inside @c Match and @c Merge clauses /// and do some other preprocessing in order to generate multiple @c QueryPart -/// structures. @c AstTreeStorage and @c SymbolTable may be used to create new +/// structures. @c AstStorage and @c SymbolTable may be used to create new /// AST nodes. -QueryParts CollectQueryParts(SymbolTable &, AstTreeStorage &); +QueryParts CollectQueryParts(SymbolTable &, AstStorage &); } // namespace query::plan diff --git a/src/query/plan/rule_based_planner.cpp b/src/query/plan/rule_based_planner.cpp index d0399cbf2..929daac48 100644 --- a/src/query/plan/rule_based_planner.cpp +++ b/src/query/plan/rule_based_planner.cpp @@ -98,7 +98,7 @@ class ReturnBodyContext : public HierarchicalTreeVisitor { public: ReturnBodyContext(const ReturnBody &body, SymbolTable &symbol_table, const std::unordered_set &bound_symbols, - AstTreeStorage &storage, Where *where = nullptr) + AstStorage &storage, Where *where = nullptr) : body_(body), symbol_table_(symbol_table), bound_symbols_(bound_symbols), @@ -449,7 +449,7 @@ class ReturnBodyContext : public HierarchicalTreeVisitor { const ReturnBody &body_; SymbolTable &symbol_table_; const std::unordered_set &bound_symbols_; - AstTreeStorage &storage_; + AstStorage &storage_; const Where *const where_ = nullptr; std::unordered_set used_symbols_; std::vector output_symbols_; @@ -523,7 +523,7 @@ std::unique_ptr GenReturnBody( namespace impl { Expression *ExtractFilters(const std::unordered_set &bound_symbols, - Filters &filters, AstTreeStorage &storage) { + Filters &filters, AstStorage &storage) { Expression *filter_expr = nullptr; for (auto filters_it = filters.begin(); filters_it != filters.end();) { if (HasBoundFilterSymbols(bound_symbols, *filters_it)) { @@ -540,7 +540,7 @@ Expression *ExtractFilters(const std::unordered_set &bound_symbols, std::unique_ptr GenFilters( std::unique_ptr last_op, const std::unordered_set &bound_symbols, Filters &filters, - AstTreeStorage &storage) { + AstStorage &storage) { auto *filter_expr = ExtractFilters(bound_symbols, filters, storage); if (filter_expr) { last_op = std::make_unique(std::move(last_op), filter_expr); @@ -576,7 +576,7 @@ std::unique_ptr GenNamedPaths( std::unique_ptr GenReturn( Return &ret, std::unique_ptr input_op, SymbolTable &symbol_table, bool is_write, - const std::unordered_set &bound_symbols, AstTreeStorage &storage) { + const std::unordered_set &bound_symbols, AstStorage &storage) { // Similar to WITH clause, but we want to accumulate when the query writes to // the database. This way we handle the case when we want to return // expressions with the latest updated results. For example, `MATCH (n) -- () @@ -672,7 +672,7 @@ std::unique_ptr HandleWriteClause( std::unique_ptr GenWith( With &with, std::unique_ptr input_op, SymbolTable &symbol_table, bool is_write, - std::unordered_set &bound_symbols, AstTreeStorage &storage) { + std::unordered_set &bound_symbols, AstStorage &storage) { // WITH clause is Accumulate/Aggregate (advance_command) + Produce and // optional Filter. In case of update and aggregation, we want to accumulate // first, so that when aggregating, we get the latest results. Similar to diff --git a/src/query/plan/rule_based_planner.hpp b/src/query/plan/rule_based_planner.hpp index a2b180a68..f6054dcdf 100644 --- a/src/query/plan/rule_based_planner.hpp +++ b/src/query/plan/rule_based_planner.hpp @@ -23,7 +23,7 @@ struct PlanningContext { SymbolTable &symbol_table; /// @brief The storage is used to traverse the AST as well as create new nodes /// for use in operators. - AstTreeStorage &ast_storage; + AstStorage &ast_storage; /// @brief TDbAccessor, which may be used to get some information from the /// database to generate better plans. The accessor is required only to live /// long enough for the plan generation to finish. @@ -38,7 +38,7 @@ struct PlanningContext { }; template -auto MakePlanningContext(AstTreeStorage &ast_storage, SymbolTable &symbol_table, +auto MakePlanningContext(AstStorage &ast_storage, SymbolTable &symbol_table, const TDbAccessor &db) { return PlanningContext{symbol_table, ast_storage, db}; } @@ -67,11 +67,11 @@ namespace impl { // `AndOperator` if symbols they use are bound.. All the joined filters are // removed from `Filters`. Expression *ExtractFilters(const std::unordered_set &, Filters &, - AstTreeStorage &); + AstStorage &); std::unique_ptr GenFilters(std::unique_ptr, const std::unordered_set &, - Filters &, AstTreeStorage &); + Filters &, AstStorage &); // For all given `named_paths` checks if all its symbols have been bound. // If so, it creates a logical operator for named path generation, binds its @@ -85,7 +85,7 @@ std::unique_ptr GenNamedPaths( std::unique_ptr GenReturn( Return &ret, std::unique_ptr input_op, SymbolTable &symbol_table, bool is_write, - const std::unordered_set &bound_symbols, AstTreeStorage &storage); + const std::unordered_set &bound_symbols, AstStorage &storage); std::unique_ptr GenCreateForPattern( Pattern &pattern, std::unique_ptr input_op, @@ -98,14 +98,14 @@ std::unique_ptr HandleWriteClause( std::unique_ptr GenWith( With &with, std::unique_ptr input_op, SymbolTable &symbol_table, bool is_write, - std::unordered_set &bound_symbols, AstTreeStorage &storage); + std::unordered_set &bound_symbols, AstStorage &storage); std::unique_ptr GenUnion( CypherUnion &cypher_union, std::shared_ptr left_op, std::shared_ptr right_op, SymbolTable &symbol_table); template -Expression *BoolJoin(AstTreeStorage &storage, Expression *expr1, +Expression *BoolJoin(AstStorage &storage, Expression *expr1, Expression *expr2) { if (expr1 && expr2) { return storage.Create(expr1, expr2); diff --git a/tests/benchmark/query/planner.cpp b/tests/benchmark/query/planner.cpp index 9b5fbeb40..8f578298d 100644 --- a/tests/benchmark/query/planner.cpp +++ b/tests/benchmark/query/planner.cpp @@ -9,7 +9,7 @@ #include "query/plan/vertex_count_cache.hpp" // Add chained MATCH (node1) -- (node2), MATCH (node2) -- (node3) ... clauses. -static void AddChainedMatches(int num_matches, query::AstTreeStorage &storage) { +static void AddChainedMatches(int num_matches, query::AstStorage &storage) { for (int i = 0; i < num_matches; ++i) { auto *match = storage.Create(); auto *pattern = storage.Create(); @@ -34,7 +34,7 @@ static void BM_PlanChainedMatches(benchmark::State &state) { database::GraphDbAccessor dba(db); while (state.KeepRunning()) { state.PauseTiming(); - query::AstTreeStorage storage; + query::AstStorage storage; int num_matches = state.range(0); AddChainedMatches(num_matches, storage); query::SymbolTable symbol_table; @@ -64,7 +64,7 @@ BENCHMARK(BM_PlanChainedMatches) static void AddIndexedMatches( int num_matches, storage::Label label, const std::pair &property, - query::AstTreeStorage &storage) { + query::AstStorage &storage) { for (int i = 0; i < num_matches; ++i) { auto *match = storage.Create(); auto *pattern = storage.Create(); @@ -110,7 +110,7 @@ static void BM_PlanAndEstimateIndexedMatching(benchmark::State &state) { Parameters parameters; while (state.KeepRunning()) { state.PauseTiming(); - query::AstTreeStorage storage; + query::AstStorage storage; AddIndexedMatches(index_count, label, std::make_pair("prop", prop), storage); query::SymbolTable symbol_table; @@ -144,7 +144,7 @@ static void BM_PlanAndEstimateIndexedMatchingWithCachedCounts( Parameters parameters; while (state.KeepRunning()) { state.PauseTiming(); - query::AstTreeStorage storage; + query::AstStorage storage; AddIndexedMatches(index_count, label, std::make_pair("prop", prop), storage); query::SymbolTable symbol_table; diff --git a/tests/manual/query_planner.cpp b/tests/manual/query_planner.cpp index a1851e8d5..1a04ff67c 100644 --- a/tests/manual/query_planner.cpp +++ b/tests/manual/query_planner.cpp @@ -725,7 +725,7 @@ void ExaminePlans( } } -query::AstTreeStorage MakeAst(const std::string &query, +query::AstStorage MakeAst(const std::string &query, database::GraphDbAccessor &dba) { query::Context ctx(dba); // query -> AST @@ -736,7 +736,7 @@ query::AstTreeStorage MakeAst(const std::string &query, return std::move(visitor.storage()); } -query::SymbolTable MakeSymbolTable(const query::AstTreeStorage &ast) { +query::SymbolTable MakeSymbolTable(const query::AstStorage &ast) { query::SymbolTable symbol_table; query::SymbolGenerator symbol_generator(symbol_table); ast.query()->Accept(symbol_generator); @@ -745,7 +745,7 @@ query::SymbolTable MakeSymbolTable(const query::AstTreeStorage &ast) { // Returns a list of pairs (plan, estimated cost), sorted in the ascending // order by cost. -auto MakeLogicalPlans(query::AstTreeStorage &ast, +auto MakeLogicalPlans(query::AstStorage &ast, query::SymbolTable &symbol_table, InteractiveDbAccessor &dba) { auto query_parts = query::plan::CollectQueryParts(symbol_table, ast); diff --git a/tests/unit/cypher_main_visitor.cpp b/tests/unit/cypher_main_visitor.cpp index 1e2abf72b..17791736a 100644 --- a/tests/unit/cypher_main_visitor.cpp +++ b/tests/unit/cypher_main_visitor.cpp @@ -68,7 +68,7 @@ class OriginalAfterCloningAstGenerator : public AstGenerator { public: explicit OriginalAfterCloningAstGenerator(const std::string &query) : AstGenerator(query) { - AstTreeStorage storage; + AstStorage storage; visitor_.query()->Clone(storage); } }; @@ -86,7 +86,7 @@ class ClonedAstGenerator : public Base { return visitor.query()->Clone(storage); }()) {} - AstTreeStorage storage; + AstStorage storage; Query *query_; }; @@ -103,13 +103,13 @@ class CachedAstGenerator : public Base { ::frontend::opencypher::Parser parser(stripped.query()); CypherMainVisitor visitor(context_); visitor.visit(parser.tree()); - AstTreeStorage new_ast; + AstStorage new_ast; visitor.storage().query()->Clone(new_ast); return new_ast; }()), query_(storage_.query()) {} - AstTreeStorage storage_; + AstStorage storage_; Query *query_; }; @@ -127,7 +127,7 @@ class SerializedAstGenerator : public Base { boost::archive::binary_oarchive out_archive(stream); out_archive << *visitor.query(); } - AstTreeStorage new_ast; + AstStorage new_ast; { boost::archive::binary_iarchive in_archive(stream); new_ast.Load(in_archive); @@ -136,7 +136,7 @@ class SerializedAstGenerator : public Base { }()), query_(storage_.query()) {} - AstTreeStorage storage_; + AstStorage storage_; Query *query_; }; @@ -157,7 +157,7 @@ class CapnpAstGenerator : public Base { visitor.query()->Save(&builder, &saved_uids); } - AstTreeStorage new_ast; + AstStorage new_ast; { const query::capnp::Tree::Reader reader = message.getRoot(); @@ -168,7 +168,7 @@ class CapnpAstGenerator : public Base { }()), query_(storage_.query()) {} - AstTreeStorage storage_; + AstStorage storage_; Query *query_; }; diff --git a/tests/unit/distributed_graph_db.cpp b/tests/unit/distributed_graph_db.cpp index 308b0157a..322fa7083 100644 --- a/tests/unit/distributed_graph_db.cpp +++ b/tests/unit/distributed_graph_db.cpp @@ -102,7 +102,7 @@ TEST_F(DistributedGraphDbTest, DispatchPlan) { auto kRPCWaitTime = 600ms; int64_t plan_id = 5; SymbolTable symbol_table; - AstTreeStorage storage; + AstStorage storage; auto scan_all = MakeScanAll(storage, symbol_table, "n"); diff --git a/tests/unit/distributed_query_plan.cpp b/tests/unit/distributed_query_plan.cpp index 88b8f00e2..f27f40394 100644 --- a/tests/unit/distributed_query_plan.cpp +++ b/tests/unit/distributed_query_plan.cpp @@ -35,7 +35,7 @@ TEST_F(DistributedGraphDbTest, PullProduceRpc) { GraphDbAccessor dba{master()}; Context ctx{dba}; SymbolGenerator symbol_generator{ctx.symbol_table_}; - AstTreeStorage storage; + AstStorage storage; // Query plan for: UNWIND [42, true, "bla", 1, 2] as x RETURN x using namespace query; @@ -122,7 +122,7 @@ TEST_F(DistributedGraphDbTest, PullProduceRpcWithGraphElements) { GraphDbAccessor dba{master()}; Context ctx{dba}; SymbolGenerator symbol_generator{ctx.symbol_table_}; - AstTreeStorage storage; + AstStorage storage; // Query plan for: MATCH p = (n)-[r]->(m) return [n, r], m, p // Use this query to test graph elements are transferred correctly in @@ -202,7 +202,7 @@ TEST_F(DistributedGraphDbTest, Synchronize) { GraphDbAccessor dba{db}; Context ctx{dba}; SymbolGenerator symbol_generator{ctx.symbol_table_}; - AstTreeStorage storage; + AstStorage storage; // MATCH auto n = MakeScanAll(storage, ctx.symbol_table_, "n"); auto r_m = @@ -250,7 +250,7 @@ TEST_F(DistributedGraphDbTest, Create) { GraphDbAccessor dba{db}; Context ctx{dba}; SymbolGenerator symbol_generator{ctx.symbol_table_}; - AstTreeStorage storage; + AstStorage storage; auto range = FN("range", LITERAL(0), LITERAL(1000)); auto x = ctx.symbol_table_.CreateSymbol("x", true); auto unwind = std::make_shared(nullptr, range, x); @@ -294,7 +294,7 @@ TEST_F(DistributedGraphDbTest, PullRemoteOrderBy) { GraphDbAccessor dba{db}; Context ctx{dba}; SymbolGenerator symbol_generator{ctx.symbol_table_}; - AstTreeStorage storage; + AstStorage storage; // Query plan for: MATCH (n) RETURN n.prop ORDER BY n.prop; auto n = MakeScanAll(storage, ctx.symbol_table_, "n"); @@ -336,7 +336,7 @@ TEST_F(DistributedTransactionTimeout, Timeout) { GraphDbAccessor dba{master()}; Context ctx{dba}; SymbolGenerator symbol_generator{ctx.symbol_table_}; - AstTreeStorage storage; + AstStorage storage; // Make distributed plan for MATCH (n) RETURN n auto scan_all = MakeScanAll(storage, ctx.symbol_table_, "n"); diff --git a/tests/unit/query_common.hpp b/tests/unit/query_common.hpp index 1cafb9e76..391ccb3fc 100644 --- a/tests/unit/query_common.hpp +++ b/tests/unit/query_common.hpp @@ -4,7 +4,7 @@ /// The usage of macros is very similar to how one would write openCypher. For /// example: /// -/// AstTreeStorage storage; // Macros rely on storage being in scope. +/// AstStorage storage; // Macros rely on storage being in scope. /// // PROPERTY_LOOKUP and PROPERTY_PAIR macros rely on database::SingleNode /// database::SingleNode db; /// @@ -109,26 +109,26 @@ auto GetOrderBy(T... exprs) { /// /// Name is used to create the Identifier which is used for property lookup. /// -auto GetPropertyLookup(AstTreeStorage &storage, database::GraphDb &db, +auto GetPropertyLookup(AstStorage &storage, database::GraphDb &db, const std::string &name, storage::Property property) { database::GraphDbAccessor dba(db); return storage.Create(storage.Create(name), dba.PropertyName(property), property); } -auto GetPropertyLookup(AstTreeStorage &storage, database::GraphDb &db, +auto GetPropertyLookup(AstStorage &storage, database::GraphDb &db, Expression *expr, storage::Property property) { database::GraphDbAccessor dba(db); return storage.Create(expr, dba.PropertyName(property), property); } auto GetPropertyLookup( - AstTreeStorage &storage, database::GraphDb &, const std::string &name, + AstStorage &storage, database::GraphDb &, const std::string &name, const std::pair &prop_pair) { return storage.Create(storage.Create(name), prop_pair.first, prop_pair.second); } auto GetPropertyLookup( - AstTreeStorage &storage, database::GraphDb &, Expression *expr, + AstStorage &storage, database::GraphDb &, Expression *expr, const std::pair &prop_pair) { return storage.Create(expr, prop_pair.first, prop_pair.second); @@ -139,7 +139,7 @@ auto GetPropertyLookup( /// /// Name is used to create the Identifier which is assigned to the edge. /// -auto GetEdge(AstTreeStorage &storage, const std::string &name, +auto GetEdge(AstStorage &storage, const std::string &name, EdgeAtom::Direction dir = EdgeAtom::Direction::BOTH, const std::vector &edge_types = {}) { return storage.Create(storage.Create(name), @@ -152,7 +152,7 @@ auto GetEdge(AstTreeStorage &storage, const std::string &name, /// /// Name is used to create the Identifier which is assigned to the edge. /// -auto GetEdgeVariable(AstTreeStorage &storage, const std::string &name, +auto GetEdgeVariable(AstStorage &storage, const std::string &name, EdgeAtom::Direction dir = EdgeAtom::Direction::BOTH, const std::vector &edge_types = {}, Identifier *inner_edge = nullptr, @@ -174,7 +174,7 @@ auto GetEdgeVariable(AstTreeStorage &storage, const std::string &name, /// /// Name is used to create the Identifier which is assigned to the node. /// -auto GetNode(AstTreeStorage &storage, const std::string &name, +auto GetNode(AstStorage &storage, const std::string &name, std::experimental::optional label = std::experimental::nullopt) { auto node = storage.Create(storage.Create(name)); @@ -185,7 +185,7 @@ auto GetNode(AstTreeStorage &storage, const std::string &name, /// /// Create a Pattern with given atoms. /// -auto GetPattern(AstTreeStorage &storage, std::vector atoms) { +auto GetPattern(AstStorage &storage, std::vector atoms) { auto pattern = storage.Create(); pattern->identifier_ = storage.Create(utils::RandomString(20), false); @@ -196,7 +196,7 @@ auto GetPattern(AstTreeStorage &storage, std::vector atoms) { /// /// Create a Pattern with given name and atoms. /// -auto GetPattern(AstTreeStorage &storage, const std::string &name, +auto GetPattern(AstStorage &storage, const std::string &name, std::vector atoms) { auto pattern = storage.Create(); pattern->identifier_ = storage.Create(name, true); @@ -261,81 +261,81 @@ auto GetCypherUnion(CypherUnion *cypher_union, SingleQuery *single_query) { return cypher_union; } -auto GetQuery(AstTreeStorage &storage, SingleQuery *single_query) { +auto GetQuery(AstStorage &storage, SingleQuery *single_query) { storage.query()->single_query_ = single_query; return storage.query(); } -auto GetQuery(AstTreeStorage &storage, SingleQuery *single_query, +auto GetQuery(AstStorage &storage, SingleQuery *single_query, CypherUnion *cypher_union) { storage.query()->cypher_unions_.emplace_back(cypher_union); return GetQuery(storage, single_query); } template -auto GetQuery(AstTreeStorage &storage, SingleQuery *single_query, +auto GetQuery(AstStorage &storage, SingleQuery *single_query, CypherUnion *cypher_union, T *... cypher_unions) { storage.query()->cypher_unions_.emplace_back(cypher_union); return GetQuery(storage, single_query, cypher_unions...); } // Helper functions for constructing RETURN and WITH clauses. -void FillReturnBody(AstTreeStorage &, ReturnBody &body, +void FillReturnBody(AstStorage &, ReturnBody &body, NamedExpression *named_expr) { body.named_expressions.emplace_back(named_expr); } -void FillReturnBody(AstTreeStorage &storage, ReturnBody &body, +void FillReturnBody(AstStorage &storage, ReturnBody &body, const std::string &name) { auto *ident = storage.Create(name); auto *named_expr = storage.Create(name, ident); body.named_expressions.emplace_back(named_expr); } -void FillReturnBody(AstTreeStorage &, ReturnBody &body, Limit limit) { +void FillReturnBody(AstStorage &, ReturnBody &body, Limit limit) { body.limit = limit.expression; } -void FillReturnBody(AstTreeStorage &, ReturnBody &body, Skip skip, +void FillReturnBody(AstStorage &, ReturnBody &body, Skip skip, Limit limit = Limit{}) { body.skip = skip.expression; body.limit = limit.expression; } -void FillReturnBody(AstTreeStorage &, ReturnBody &body, OrderBy order_by, +void FillReturnBody(AstStorage &, ReturnBody &body, OrderBy order_by, Limit limit = Limit{}) { body.order_by = order_by.expressions; body.limit = limit.expression; } -void FillReturnBody(AstTreeStorage &, ReturnBody &body, OrderBy order_by, +void FillReturnBody(AstStorage &, ReturnBody &body, OrderBy order_by, Skip skip, Limit limit = Limit{}) { body.order_by = order_by.expressions; body.skip = skip.expression; body.limit = limit.expression; } -void FillReturnBody(AstTreeStorage &, ReturnBody &body, Expression *expr, +void FillReturnBody(AstStorage &, ReturnBody &body, Expression *expr, NamedExpression *named_expr) { // This overload supports `RETURN(expr, AS(name))` construct, since // NamedExpression does not inherit Expression. named_expr->expression_ = expr; body.named_expressions.emplace_back(named_expr); } -void FillReturnBody(AstTreeStorage &storage, ReturnBody &body, +void FillReturnBody(AstStorage &storage, ReturnBody &body, const std::string &name, NamedExpression *named_expr) { named_expr->expression_ = storage.Create(name); body.named_expressions.emplace_back(named_expr); } template -void FillReturnBody(AstTreeStorage &storage, ReturnBody &body, Expression *expr, +void FillReturnBody(AstStorage &storage, ReturnBody &body, Expression *expr, NamedExpression *named_expr, T... rest) { named_expr->expression_ = expr; body.named_expressions.emplace_back(named_expr); FillReturnBody(storage, body, rest...); } template -void FillReturnBody(AstTreeStorage &storage, ReturnBody &body, +void FillReturnBody(AstStorage &storage, ReturnBody &body, NamedExpression *named_expr, T... rest) { body.named_expressions.emplace_back(named_expr); FillReturnBody(storage, body, rest...); } template -void FillReturnBody(AstTreeStorage &storage, ReturnBody &body, +void FillReturnBody(AstStorage &storage, ReturnBody &body, const std::string &name, NamedExpression *named_expr, T... rest) { named_expr->expression_ = storage.Create(name); @@ -343,7 +343,7 @@ void FillReturnBody(AstTreeStorage &storage, ReturnBody &body, FillReturnBody(storage, body, rest...); } template -void FillReturnBody(AstTreeStorage &storage, ReturnBody &body, +void FillReturnBody(AstStorage &storage, ReturnBody &body, const std::string &name, T... rest) { auto *ident = storage.Create(name); auto *named_expr = storage.Create(name, ident); @@ -366,7 +366,7 @@ void FillReturnBody(AstTreeStorage &storage, ReturnBody &body, /// /// @sa GetWith template -auto GetReturn(AstTreeStorage &storage, bool distinct, T... exprs) { +auto GetReturn(AstStorage &storage, bool distinct, T... exprs) { auto ret = storage.Create(); ret->body_.distinct = distinct; FillReturnBody(storage, ret->body_, exprs...); @@ -380,7 +380,7 @@ auto GetReturn(AstTreeStorage &storage, bool distinct, T... exprs) { /// /// @sa GetReturn template -auto GetWith(AstTreeStorage &storage, bool distinct, T... exprs) { +auto GetWith(AstStorage &storage, bool distinct, T... exprs) { auto with = storage.Create(); with->body_.distinct = distinct; FillReturnBody(storage, with->body_, exprs...); @@ -390,10 +390,10 @@ auto GetWith(AstTreeStorage &storage, bool distinct, T... exprs) { /// /// Create the UNWIND clause with given named expression. /// -auto GetUnwind(AstTreeStorage &storage, NamedExpression *named_expr) { +auto GetUnwind(AstStorage &storage, NamedExpression *named_expr) { return storage.Create(named_expr); } -auto GetUnwind(AstTreeStorage &storage, Expression *expr, NamedExpression *as) { +auto GetUnwind(AstStorage &storage, Expression *expr, NamedExpression *as) { as->expression_ = expr; return GetUnwind(storage, as); } @@ -401,7 +401,7 @@ auto GetUnwind(AstTreeStorage &storage, Expression *expr, NamedExpression *as) { /// /// Create the delete clause with given named expressions. /// -auto GetDelete(AstTreeStorage &storage, std::vector exprs, +auto GetDelete(AstStorage &storage, std::vector exprs, bool detach = false) { auto del = storage.Create(); del->expressions_.insert(del->expressions_.begin(), exprs.begin(), @@ -414,7 +414,7 @@ auto GetDelete(AstTreeStorage &storage, std::vector exprs, /// Create a set property clause for given property lookup and the right hand /// side expression. /// -auto GetSet(AstTreeStorage &storage, PropertyLookup *prop_lookup, +auto GetSet(AstStorage &storage, PropertyLookup *prop_lookup, Expression *expr) { return storage.Create(prop_lookup, expr); } @@ -423,7 +423,7 @@ auto GetSet(AstTreeStorage &storage, PropertyLookup *prop_lookup, /// Create a set properties clause for given identifier name and the right hand /// side expression. /// -auto GetSet(AstTreeStorage &storage, const std::string &name, Expression *expr, +auto GetSet(AstStorage &storage, const std::string &name, Expression *expr, bool update = false) { return storage.Create(storage.Create(name), expr, update); @@ -432,7 +432,7 @@ auto GetSet(AstTreeStorage &storage, const std::string &name, Expression *expr, /// /// Create a set labels clause for given identifier name and labels. /// -auto GetSet(AstTreeStorage &storage, const std::string &name, +auto GetSet(AstStorage &storage, const std::string &name, std::vector labels) { return storage.Create(storage.Create(name), labels); } @@ -440,14 +440,14 @@ auto GetSet(AstTreeStorage &storage, const std::string &name, /// /// Create a remove property clause for given property lookup /// -auto GetRemove(AstTreeStorage &storage, PropertyLookup *prop_lookup) { +auto GetRemove(AstStorage &storage, PropertyLookup *prop_lookup) { return storage.Create(prop_lookup); } /// /// Create a remove labels clause for given identifier name and labels. /// -auto GetRemove(AstTreeStorage &storage, const std::string &name, +auto GetRemove(AstStorage &storage, const std::string &name, std::vector labels) { return storage.Create(storage.Create(name), labels); } @@ -456,14 +456,14 @@ auto GetRemove(AstTreeStorage &storage, const std::string &name, /// Create a Merge clause for given Pattern with optional OnMatch and OnCreate /// parts. /// -auto GetMerge(AstTreeStorage &storage, Pattern *pattern, +auto GetMerge(AstStorage &storage, Pattern *pattern, OnCreate on_create = OnCreate{}) { auto *merge = storage.Create(); merge->pattern_ = pattern; merge->on_create_ = on_create.set; return merge; } -auto GetMerge(AstTreeStorage &storage, Pattern *pattern, OnMatch on_match, +auto GetMerge(AstStorage &storage, Pattern *pattern, OnMatch on_match, OnCreate on_create = OnCreate{}) { auto *merge = storage.Create(); merge->pattern_ = pattern; @@ -478,13 +478,13 @@ auto GetMerge(AstTreeStorage &storage, Pattern *pattern, OnMatch on_match, /// /// All the following macros implicitly pass `storage` variable to functions. -/// You need to have `AstTreeStorage storage;` somewhere in scope to use them. +/// You need to have `AstStorage storage;` somewhere in scope to use them. /// Refer to function documentation to see what the macro does. /// /// Example usage: /// /// // Create MATCH (n) -[r]- (m) RETURN m AS new_name -/// AstTreeStorage storage; +/// AstStorage storage; /// auto query = QUERY(MATCH(PATTERN(NODE("n"), EDGE("r"), NODE("m"))), /// RETURN(NEXPR("new_name"), IDENT("m"))); /// diff --git a/tests/unit/query_cost_estimator.cpp b/tests/unit/query_cost_estimator.cpp index 6f2d83a56..9f9ec657d 100644 --- a/tests/unit/query_cost_estimator.cpp +++ b/tests/unit/query_cost_estimator.cpp @@ -30,7 +30,7 @@ class QueryCostEstimator : public ::testing::Test { // start it off with Once std::shared_ptr last_op_ = std::make_shared(); - AstTreeStorage storage_; + AstStorage storage_; SymbolTable symbol_table_; Parameters parameters_; int symbol_count = 0; diff --git a/tests/unit/query_expression_evaluator.cpp b/tests/unit/query_expression_evaluator.cpp index 12074a61d..0cd4b59bb 100644 --- a/tests/unit/query_expression_evaluator.cpp +++ b/tests/unit/query_expression_evaluator.cpp @@ -44,7 +44,7 @@ struct NoContextExpressionEvaluator { TypedValue EvaluateFunction(const std::string &function_name, const std::vector &args, database::GraphDb &db) { - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; database::GraphDbAccessor dba(db); Frame frame{128}; @@ -67,7 +67,7 @@ TypedValue EvaluateFunction(const std::string &function_name, } TEST(ExpressionEvaluator, OrOperator) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; auto *op = storage.Create(storage.Create(true), @@ -81,7 +81,7 @@ TEST(ExpressionEvaluator, OrOperator) { } TEST(ExpressionEvaluator, XorOperator) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; auto *op = storage.Create(storage.Create(true), @@ -95,7 +95,7 @@ TEST(ExpressionEvaluator, XorOperator) { } TEST(ExpressionEvaluator, AndOperator) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; auto *op = storage.Create(storage.Create(true), @@ -109,7 +109,7 @@ TEST(ExpressionEvaluator, AndOperator) { } TEST(ExpressionEvaluator, AndOperatorShortCircuit) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; { auto *op = @@ -130,7 +130,7 @@ TEST(ExpressionEvaluator, AndOperatorShortCircuit) { } TEST(ExpressionEvaluator, AndOperatorNull) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; { // Null doesn't short circuit @@ -157,7 +157,7 @@ TEST(ExpressionEvaluator, AndOperatorNull) { } TEST(ExpressionEvaluator, AdditionOperator) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; auto *op = storage.Create( storage.Create(2), storage.Create(3)); @@ -166,7 +166,7 @@ TEST(ExpressionEvaluator, AdditionOperator) { } TEST(ExpressionEvaluator, SubtractionOperator) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; auto *op = storage.Create( storage.Create(2), storage.Create(3)); @@ -175,7 +175,7 @@ TEST(ExpressionEvaluator, SubtractionOperator) { } TEST(ExpressionEvaluator, MultiplicationOperator) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; auto *op = storage.Create( storage.Create(2), storage.Create(3)); @@ -184,7 +184,7 @@ TEST(ExpressionEvaluator, MultiplicationOperator) { } TEST(ExpressionEvaluator, DivisionOperator) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; auto *op = storage.Create(storage.Create(50), @@ -194,7 +194,7 @@ TEST(ExpressionEvaluator, DivisionOperator) { } TEST(ExpressionEvaluator, ModOperator) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; auto *op = storage.Create(storage.Create(65), storage.Create(10)); @@ -203,7 +203,7 @@ TEST(ExpressionEvaluator, ModOperator) { } TEST(ExpressionEvaluator, EqualOperator) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; auto *op = storage.Create(storage.Create(10), @@ -221,7 +221,7 @@ TEST(ExpressionEvaluator, EqualOperator) { } TEST(ExpressionEvaluator, NotEqualOperator) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; auto *op = storage.Create(storage.Create(10), @@ -239,7 +239,7 @@ TEST(ExpressionEvaluator, NotEqualOperator) { } TEST(ExpressionEvaluator, LessOperator) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; auto *op = storage.Create(storage.Create(10), storage.Create(15)); @@ -256,7 +256,7 @@ TEST(ExpressionEvaluator, LessOperator) { } TEST(ExpressionEvaluator, GreaterOperator) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; auto *op = storage.Create(storage.Create(10), @@ -274,7 +274,7 @@ TEST(ExpressionEvaluator, GreaterOperator) { } TEST(ExpressionEvaluator, LessEqualOperator) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; auto *op = storage.Create(storage.Create(10), @@ -292,7 +292,7 @@ TEST(ExpressionEvaluator, LessEqualOperator) { } TEST(ExpressionEvaluator, GreaterEqualOperator) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; auto *op = storage.Create( storage.Create(10), @@ -312,7 +312,7 @@ TEST(ExpressionEvaluator, GreaterEqualOperator) { } TEST(ExpressionEvaluator, InListOperator) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; auto *list_literal = storage.Create(std::vector{ storage.Create(1), storage.Create(2), @@ -368,7 +368,7 @@ TEST(ExpressionEvaluator, InListOperator) { } TEST(ExpressionEvaluator, ListMapIndexingOperator) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; auto *list_literal = storage.Create(std::vector{ storage.Create(1), storage.Create(2), @@ -420,7 +420,7 @@ TEST(ExpressionEvaluator, ListMapIndexingOperator) { } TEST(ExpressionEvaluator, MapIndexing) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; database::SingleNode db; database::GraphDbAccessor dba(db); @@ -460,7 +460,7 @@ TEST(ExpressionEvaluator, MapIndexing) { } TEST(ExpressionEvaluator, ListSlicingOperator) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; auto *list_literal = storage.Create(std::vector{ storage.Create(1), storage.Create(2), @@ -553,7 +553,7 @@ TEST(ExpressionEvaluator, ListSlicingOperator) { } TEST(ExpressionEvaluator, IfOperator) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; auto *then_expression = storage.Create(10); auto *else_expression = storage.Create(20); @@ -586,7 +586,7 @@ TEST(ExpressionEvaluator, IfOperator) { } TEST(ExpressionEvaluator, NotOperator) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; auto *op = storage.Create(storage.Create(false)); @@ -595,7 +595,7 @@ TEST(ExpressionEvaluator, NotOperator) { } TEST(ExpressionEvaluator, UnaryPlusOperator) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; auto *op = storage.Create(storage.Create(5)); @@ -604,7 +604,7 @@ TEST(ExpressionEvaluator, UnaryPlusOperator) { } TEST(ExpressionEvaluator, UnaryMinusOperator) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; auto *op = storage.Create(storage.Create(5)); @@ -613,7 +613,7 @@ TEST(ExpressionEvaluator, UnaryMinusOperator) { } TEST(ExpressionEvaluator, IsNullOperator) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; auto *op = storage.Create(storage.Create(1)); @@ -627,7 +627,7 @@ TEST(ExpressionEvaluator, IsNullOperator) { class ExpressionEvaluatorPropertyLookup : public testing::Test { protected: - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; database::SingleNode db; database::GraphDbAccessor dba{db}; @@ -675,7 +675,7 @@ TEST_F(ExpressionEvaluatorPropertyLookup, MapLiteral) { } TEST(ExpressionEvaluator, LabelsTest) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; database::SingleNode db; database::GraphDbAccessor dba(db); @@ -714,7 +714,7 @@ TEST(ExpressionEvaluator, LabelsTest) { } TEST(ExpressionEvaluator, Aggregation) { - AstTreeStorage storage; + AstStorage storage; auto aggr = storage.Create(storage.Create(42), nullptr, Aggregation::Op::COUNT); SymbolTable symbol_table; @@ -732,7 +732,7 @@ TEST(ExpressionEvaluator, Aggregation) { } TEST(ExpressionEvaluator, ListLiteral) { - AstTreeStorage storage; + AstStorage storage; NoContextExpressionEvaluator eval; auto *list_literal = storage.Create( std::vector{storage.Create(1), @@ -1196,7 +1196,7 @@ TEST(ExpressionEvaluator, FunctionContains) { } TEST(ExpressionEvaluator, FunctionAll) { - AstTreeStorage storage; + AstStorage storage; auto *ident_x = IDENT("x"); auto *all = ALL("x", LIST(LITERAL(1), LITERAL(2)), WHERE(EQ(ident_x, LITERAL(1)))); @@ -1210,7 +1210,7 @@ TEST(ExpressionEvaluator, FunctionAll) { } TEST(ExpressionEvaluator, FunctionAllNullList) { - AstTreeStorage storage; + AstStorage storage; auto *all = ALL("x", LITERAL(TypedValue::Null), WHERE(LITERAL(true))); NoContextExpressionEvaluator eval; const auto x_sym = eval.symbol_table.CreateSymbol("x", true); @@ -1220,7 +1220,7 @@ TEST(ExpressionEvaluator, FunctionAllNullList) { } TEST(ExpressionEvaluator, FunctionAllWhereWrongType) { - AstTreeStorage storage; + AstStorage storage; auto *all = ALL("x", LIST(LITERAL(1)), WHERE(LITERAL(2))); NoContextExpressionEvaluator eval; const auto x_sym = eval.symbol_table.CreateSymbol("x", true); @@ -1229,7 +1229,7 @@ TEST(ExpressionEvaluator, FunctionAllWhereWrongType) { } TEST(ExpressionEvaluator, FunctionSingle) { - AstTreeStorage storage; + AstStorage storage; auto *ident_x = IDENT("x"); auto *single = SINGLE("x", LIST(LITERAL(1), LITERAL(2)), WHERE(EQ(ident_x, LITERAL(1)))); @@ -1243,7 +1243,7 @@ TEST(ExpressionEvaluator, FunctionSingle) { } TEST(ExpressionEvaluator, FunctionSingle2) { - AstTreeStorage storage; + AstStorage storage; auto *ident_x = IDENT("x"); auto *single = SINGLE("x", LIST(LITERAL(1), LITERAL(2)), WHERE(GREATER(ident_x, LITERAL(0)))); @@ -1257,7 +1257,7 @@ TEST(ExpressionEvaluator, FunctionSingle2) { } TEST(ExpressionEvaluator, FunctionSingleNullList) { - AstTreeStorage storage; + AstStorage storage; auto *single = SINGLE("x", LITERAL(TypedValue::Null), WHERE(LITERAL(true))); NoContextExpressionEvaluator eval; const auto x_sym = eval.symbol_table.CreateSymbol("x", true); @@ -1267,7 +1267,7 @@ TEST(ExpressionEvaluator, FunctionSingleNullList) { } TEST(ExpressionEvaluator, FunctionReduce) { - AstTreeStorage storage; + AstStorage storage; auto *ident_sum = IDENT("sum"); auto *ident_x = IDENT("x"); auto *reduce = REDUCE("sum", LITERAL(0), "x", LIST(LITERAL(1), LITERAL(2)), @@ -1312,7 +1312,7 @@ TEST(ExpressionEvaluator, FunctionAssert) { TEST(ExpressionEvaluator, ParameterLookup) { NoContextExpressionEvaluator eval; eval.parameters.Add(0, 42); - AstTreeStorage storage; + AstStorage storage; auto *param_lookup = storage.Create(0); auto value = param_lookup->Accept(eval.eval); ASSERT_EQ(value.type(), TypedValue::Type::Int); diff --git a/tests/unit/query_plan_accumulate_aggregate.cpp b/tests/unit/query_plan_accumulate_aggregate.cpp index 6fb162a46..36caaae7a 100644 --- a/tests/unit/query_plan_accumulate_aggregate.cpp +++ b/tests/unit/query_plan_accumulate_aggregate.cpp @@ -38,7 +38,7 @@ TEST(QueryPlan, Accumulate) { dba.InsertEdge(v1, v2, dba.EdgeType("T")); dba.AdvanceCommand(); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n"); @@ -89,7 +89,7 @@ TEST(QueryPlan, AccumulateAdvance) { auto check = [&](bool advance) { database::SingleNode db; database::GraphDbAccessor dba(db); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto node = NODE("n"); @@ -107,7 +107,7 @@ TEST(QueryPlan, AccumulateAdvance) { std::shared_ptr MakeAggregationProduce( std::shared_ptr input, SymbolTable &symbol_table, - AstTreeStorage &storage, const std::vector aggr_inputs, + AstStorage &storage, const std::vector aggr_inputs, const std::vector aggr_ops, const std::vector group_by_exprs, const std::vector remember) { @@ -153,7 +153,7 @@ class QueryPlanAggregateOps : public ::testing::Test { database::GraphDbAccessor dba{db}; storage::Property prop = dba.Property("prop"); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; void AddData() { @@ -318,7 +318,7 @@ TEST(QueryPlan, AggregateGroupByValues) { dba.InsertVertex().PropsSet(prop, group_by_vals[i % group_by_vals.size()]); dba.AdvanceCommand(); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; // match all nodes and perform aggregations @@ -361,7 +361,7 @@ TEST(QueryPlan, AggregateMultipleGroupBy) { } dba.AdvanceCommand(); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; // match all nodes and perform aggregations @@ -384,7 +384,7 @@ TEST(QueryPlan, AggregateMultipleGroupBy) { TEST(QueryPlan, AggregateNoInput) { database::SingleNode db; database::GraphDbAccessor dba(db); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto two = LITERAL(2); @@ -413,7 +413,7 @@ TEST(QueryPlan, AggregateCountEdgeCases) { database::GraphDbAccessor dba(db); auto prop = dba.Property("prop"); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n"); @@ -471,7 +471,7 @@ TEST(QueryPlan, AggregateFirstValueTypes) { v1.PropsSet(prop_int, 12); dba.AdvanceCommand(); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n"); @@ -529,7 +529,7 @@ TEST(QueryPlan, AggregateTypes) { dba.InsertVertex().PropsSet(p2, true); dba.AdvanceCommand(); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n"); @@ -576,7 +576,7 @@ TEST(QueryPlan, AggregateTypes) { TEST(QueryPlan, Unwind) { database::SingleNode db; database::GraphDbAccessor dba(db); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; // UNWIND [ [1, true, "x"], [], ["bla"] ] AS x UNWIND x as y RETURN x, y diff --git a/tests/unit/query_plan_bag_semantics.cpp b/tests/unit/query_plan_bag_semantics.cpp index 1c3cb8e75..bf0082e67 100644 --- a/tests/unit/query_plan_bag_semantics.cpp +++ b/tests/unit/query_plan_bag_semantics.cpp @@ -25,7 +25,7 @@ TEST(QueryPlan, Skip) { database::SingleNode db; database::GraphDbAccessor dba(db); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n1"); @@ -54,7 +54,7 @@ TEST(QueryPlan, Limit) { database::SingleNode db; database::GraphDbAccessor dba(db); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n1"); @@ -89,7 +89,7 @@ TEST(QueryPlan, CreateLimit) { dba.InsertVertex(); dba.AdvanceCommand(); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n1"); @@ -106,7 +106,7 @@ TEST(QueryPlan, CreateLimit) { TEST(QueryPlan, OrderBy) { database::SingleNode db; database::GraphDbAccessor dba(db); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto prop = dba.Property("prop"); @@ -167,7 +167,7 @@ TEST(QueryPlan, OrderBy) { TEST(QueryPlan, OrderByMultiple) { database::SingleNode db; database::GraphDbAccessor dba(db); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto p1 = dba.Property("p1"); @@ -223,7 +223,7 @@ TEST(QueryPlan, OrderByMultiple) { TEST(QueryPlan, OrderByExceptions) { database::SingleNode db; database::GraphDbAccessor dba(db); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto prop = dba.Property("prop"); diff --git a/tests/unit/query_plan_common.hpp b/tests/unit/query_plan_common.hpp index 9bfc53798..a46bfa8e0 100644 --- a/tests/unit/query_plan_common.hpp +++ b/tests/unit/query_plan_common.hpp @@ -92,7 +92,7 @@ struct ScanAllTuple { * * Returns ScanAllTuple(node_atom, scan_all_logical_op, symbol). */ -ScanAllTuple MakeScanAll(AstTreeStorage &storage, SymbolTable &symbol_table, +ScanAllTuple MakeScanAll(AstStorage &storage, SymbolTable &symbol_table, const std::string &identifier, std::shared_ptr input = {nullptr}, GraphView graph_view = GraphView::OLD) { @@ -110,7 +110,7 @@ ScanAllTuple MakeScanAll(AstTreeStorage &storage, SymbolTable &symbol_table, * Returns ScanAllTuple(node_atom, scan_all_logical_op, symbol). */ ScanAllTuple MakeScanAllByLabel( - AstTreeStorage &storage, SymbolTable &symbol_table, + AstStorage &storage, SymbolTable &symbol_table, const std::string &identifier, storage::Label label, std::shared_ptr input = {nullptr}, GraphView graph_view = GraphView::OLD) { @@ -129,7 +129,7 @@ ScanAllTuple MakeScanAllByLabel( * Returns ScanAllTuple(node_atom, scan_all_logical_op, symbol). */ ScanAllTuple MakeScanAllByLabelPropertyRange( - AstTreeStorage &storage, SymbolTable &symbol_table, std::string identifier, + AstStorage &storage, SymbolTable &symbol_table, std::string identifier, storage::Label label, storage::Property property, std::experimental::optional lower_bound, std::experimental::optional upper_bound, @@ -150,7 +150,7 @@ ScanAllTuple MakeScanAllByLabelPropertyRange( * Returns ScanAllTuple(node_atom, scan_all_logical_op, symbol). */ ScanAllTuple MakeScanAllByLabelPropertyValue( - AstTreeStorage &storage, SymbolTable &symbol_table, std::string identifier, + AstStorage &storage, SymbolTable &symbol_table, std::string identifier, storage::Label label, storage::Property property, Expression *value, std::shared_ptr input = {nullptr}, GraphView graph_view = GraphView::OLD) { @@ -170,7 +170,7 @@ struct ExpandTuple { std::shared_ptr op_; }; -ExpandTuple MakeExpand(AstTreeStorage &storage, SymbolTable &symbol_table, +ExpandTuple MakeExpand(AstStorage &storage, SymbolTable &symbol_table, std::shared_ptr input, Symbol input_symbol, const std::string &edge_identifier, EdgeAtom::Direction direction, diff --git a/tests/unit/query_plan_create_set_remove_delete.cpp b/tests/unit/query_plan_create_set_remove_delete.cpp index 63e7014b7..619503258 100644 --- a/tests/unit/query_plan_create_set_remove_delete.cpp +++ b/tests/unit/query_plan_create_set_remove_delete.cpp @@ -23,7 +23,7 @@ TEST(QueryPlan, CreateNodeWithAttributes) { storage::Label label = dba.Label("Person"); auto property = PROPERTY_PAIR("prop"); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto node = NODE("n"); @@ -57,7 +57,7 @@ TEST(QueryPlan, CreateReturn) { storage::Label label = dba.Label("Person"); auto property = PROPERTY_PAIR("property"); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto node = NODE("n"); @@ -101,7 +101,7 @@ TEST(QueryPlan, CreateExpand) { storage::EdgeType edge_type = dba.EdgeType("edge_type"); SymbolTable symbol_table; - AstTreeStorage storage; + AstStorage storage; auto test_create_path = [&](bool cycle, int expected_nodes_created, int expected_edges_created) { @@ -176,7 +176,7 @@ TEST(QueryPlan, MatchCreateNode) { dba.AdvanceCommand(); SymbolTable symbol_table; - AstTreeStorage storage; + AstStorage storage; // first node auto n_scan_all = MakeScanAll(storage, symbol_table, "n"); @@ -208,7 +208,7 @@ TEST(QueryPlan, MatchCreateExpand) { storage::EdgeType edge_type = dba.EdgeType("edge_type"); SymbolTable symbol_table; - AstTreeStorage storage; + AstStorage storage; auto test_create_path = [&](bool cycle, int expected_nodes_created, int expected_edges_created) { @@ -260,7 +260,7 @@ TEST(QueryPlan, Delete) { EXPECT_EQ(4, CountIterable(dba.Vertices(false))); EXPECT_EQ(6, CountIterable(dba.Edges(false))); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; // attempt to delete a vertex, and fail @@ -345,7 +345,7 @@ TEST(QueryPlan, DeleteTwiceDeleteBlockingEdge) { EXPECT_EQ(2, CountIterable(dba.Vertices(false))); EXPECT_EQ(1, CountIterable(dba.Edges(false))); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n"); @@ -388,7 +388,7 @@ TEST(QueryPlan, DeleteReturn) { EXPECT_EQ(4, CountIterable(dba.Vertices(false))); EXPECT_EQ(0, CountIterable(dba.Edges(false))); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n"); @@ -415,7 +415,7 @@ TEST(QueryPlan, DeleteNull) { // test (simplified) WITH Null as x delete x database::SingleNode db; database::GraphDbAccessor dba(db); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto once = std::make_shared(); @@ -439,7 +439,7 @@ TEST(QueryPlan, DeleteAdvance) { dba.InsertVertex(); dba.AdvanceCommand(); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n"); @@ -468,7 +468,7 @@ TEST(QueryPlan, SetProperty) { dba.InsertEdge(v2, v4, edge_type); dba.AdvanceCommand(); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; // scan (n)-[r]->(m) @@ -520,7 +520,7 @@ TEST(QueryPlan, SetProperties) { v2.PropsSet(prop_c, 2); dba.AdvanceCommand(); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; // scan (n)-[r]->(m) @@ -585,7 +585,7 @@ TEST(QueryPlan, SetLabels) { dba.InsertVertex().add_label(label1); dba.AdvanceCommand(); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n"); @@ -624,7 +624,7 @@ TEST(QueryPlan, RemoveProperty) { v2.PropsSet(prop2, 0); dba.AdvanceCommand(); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; // scan (n)-[r]->(m) @@ -670,7 +670,7 @@ TEST(QueryPlan, RemoveLabels) { v2.add_label(label3); dba.AdvanceCommand(); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n"); @@ -702,7 +702,7 @@ TEST(QueryPlan, NodeFilterSet) { // 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. - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; // MATCH (n {prop: 42}) -[r]- (m) auto scan_all = MakeScanAll(storage, symbol_table, "n"); @@ -742,7 +742,7 @@ TEST(QueryPlan, FilterRemove) { 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; + AstStorage storage; SymbolTable symbol_table; // MATCH (n) -[r]- (m) WHERE n.prop < 43 auto scan_all = MakeScanAll(storage, symbol_table, "n"); @@ -773,7 +773,7 @@ TEST(QueryPlan, SetRemove) { 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; + AstStorage storage; SymbolTable symbol_table; // MATCH (n) SET n :label1 :label2 REMOVE n :label1 :label2 auto scan_all = MakeScanAll(storage, symbol_table, "n"); @@ -803,7 +803,7 @@ TEST(QueryPlan, Merge) { auto v3 = dba.InsertVertex(); dba.AdvanceCommand(); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto prop = PROPERTY_PAIR("property"); @@ -843,7 +843,7 @@ TEST(QueryPlan, MergeNoInput) { database::SingleNode db; database::GraphDbAccessor dba(db); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto node = NODE("n"); @@ -862,7 +862,7 @@ TEST(QueryPlan, SetPropertyOnNull) { // SET (Null).prop = 42 database::SingleNode db; database::GraphDbAccessor dba(db); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto prop = PROPERTY_PAIR("property"); auto null = LITERAL(TypedValue::Null); @@ -877,7 +877,7 @@ TEST(QueryPlan, SetPropertiesOnNull) { // OPTIONAL MATCH (n) SET n = n database::SingleNode db; database::GraphDbAccessor dba(db); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n"); auto n_ident = IDENT("n"); @@ -895,7 +895,7 @@ TEST(QueryPlan, SetLabelsOnNull) { database::SingleNode db; database::GraphDbAccessor dba(db); auto label = dba.Label("label"); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n"); auto n_ident = IDENT("n"); @@ -912,7 +912,7 @@ TEST(QueryPlan, RemovePropertyOnNull) { // REMOVE (Null).prop database::SingleNode db; database::GraphDbAccessor dba(db); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto prop = PROPERTY_PAIR("property"); auto null = LITERAL(TypedValue::Null); @@ -927,7 +927,7 @@ TEST(QueryPlan, RemoveLabelsOnNull) { database::SingleNode db; database::GraphDbAccessor dba(db); auto label = dba.Label("label"); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n"); auto n_ident = IDENT("n"); @@ -960,7 +960,7 @@ TEST(QueryPlan, DeleteSetProperty) { dba.InsertVertex(); dba.AdvanceCommand(); EXPECT_EQ(1, CountIterable(dba.Vertices(false))); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; // MATCH (n) DELETE n SET n.property = 42 auto n = MakeScanAll(storage, symbol_table, "n"); @@ -983,7 +983,7 @@ TEST(QueryPlan, DeleteSetPropertiesFromMap) { dba.InsertVertex(); dba.AdvanceCommand(); EXPECT_EQ(1, CountIterable(dba.Vertices(false))); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; // MATCH (n) DELETE n SET n = {property: 42} auto n = MakeScanAll(storage, symbol_table, "n"); @@ -1017,7 +1017,7 @@ TEST(QueryPlan, DeleteSetPropertiesFromVertex) { } dba.AdvanceCommand(); EXPECT_EQ(1, CountIterable(dba.Vertices(false))); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; // MATCH (n) DELETE n SET n = n auto n = MakeScanAll(storage, symbol_table, "n"); @@ -1045,7 +1045,7 @@ TEST(QueryPlan, DeleteRemoveLabels) { dba.InsertVertex(); dba.AdvanceCommand(); EXPECT_EQ(1, CountIterable(dba.Vertices(false))); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; // MATCH (n) DELETE n REMOVE n :label auto n = MakeScanAll(storage, symbol_table, "n"); @@ -1065,7 +1065,7 @@ TEST(QueryPlan, DeleteRemoveProperty) { dba.InsertVertex(); dba.AdvanceCommand(); EXPECT_EQ(1, CountIterable(dba.Vertices(false))); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; // MATCH (n) DELETE n REMOVE n.property auto n = MakeScanAll(storage, symbol_table, "n"); diff --git a/tests/unit/query_plan_match_filter_return.cpp b/tests/unit/query_plan_match_filter_return.cpp index f77472aac..3eef118b4 100644 --- a/tests/unit/query_plan_match_filter_return.cpp +++ b/tests/unit/query_plan_match_filter_return.cpp @@ -29,7 +29,7 @@ class MatchReturnFixture : public testing::Test { protected: database::SingleNode db_; database::GraphDbAccessor dba_{db_}; - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; void AddVertices(int count) { @@ -98,7 +98,7 @@ TEST(QueryPlan, MatchReturnCartesian) { dba.InsertVertex().add_label(dba.Label("l2")); dba.AdvanceCommand(); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n"); @@ -132,7 +132,7 @@ TEST(QueryPlan, StandaloneReturn) { dba.InsertVertex(); dba.AdvanceCommand(); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto output = NEXPR("n", LITERAL(42)); @@ -171,7 +171,7 @@ TEST(QueryPlan, NodeFilterLabelsAndProperties) { v5.PropsSet(property.second, 1); dba.AdvanceCommand(); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; // make a scan all @@ -226,7 +226,7 @@ TEST(QueryPlan, NodeFilterMultipleLabels) { v3.add_label(label3); dba.AdvanceCommand(); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; // make a scan all @@ -265,7 +265,7 @@ TEST(QueryPlan, Cartesian) { add_vertex("v3")}; dba.AdvanceCommand(); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n"); @@ -300,7 +300,7 @@ TEST(QueryPlan, CartesianEmptySet) { database::SingleNode db; database::GraphDbAccessor dba(db); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n"); @@ -338,7 +338,7 @@ TEST(QueryPlan, CartesianThreeWay) { add_vertex("v3")}; dba.AdvanceCommand(); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n"); @@ -388,7 +388,7 @@ class ExpandFixture : public testing::Test { protected: database::SingleNode db_; database::GraphDbAccessor dba_{db_}; - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; // make a V-graph (v3)<-[r2]-(v1)-[r1]->(v2) @@ -490,7 +490,7 @@ class QueryPlanExpandVariable : public testing::Test { // for all the edges storage::EdgeType edge_type = dba_.EdgeType("edge_type"); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; // using std::experimental::nullopt @@ -851,7 +851,7 @@ class QueryPlanExpandBfs std::vector v; std::unordered_map, storage::EdgeAddress> e; - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; // Inner edge and vertex symbols. @@ -1224,7 +1224,7 @@ class QueryPlanExpandWeightedShortestPath : public testing::Test { // make some edges too, in a map (from, to) vertex indices std::unordered_map, EdgeAccessor> e; - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; // inner edge and vertex symbols @@ -1567,7 +1567,7 @@ TEST(QueryPlan, ExpandOptional) { database::SingleNode db; database::GraphDbAccessor dba(db); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; // graph (v2 {p: 2})<-[:T]-(v1 {p: 1})-[:T]->(v3 {p: 2}) @@ -1627,7 +1627,7 @@ TEST(QueryPlan, OptionalMatchEmptyDB) { database::SingleNode db; database::GraphDbAccessor dba(db); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; // OPTIONAL MATCH (n) @@ -1648,7 +1648,7 @@ TEST(QueryPlan, OptionalMatchEmptyDB) { TEST(QueryPlan, OptionalMatchEmptyDBExpandFromNode) { database::SingleNode db; database::GraphDbAccessor dba(db); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; // OPTIONAL MATCH (n) auto n = MakeScanAll(storage, symbol_table, "n"); @@ -1684,7 +1684,7 @@ TEST(QueryPlan, OptionalMatchThenExpandToMissingNode) { dba.AdvanceCommand(); EXPECT_EQ(2, CountIterable(dba.Vertices(false))); EXPECT_EQ(1, CountIterable(dba.Edges(false))); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; // OPTIONAL MATCH (n :missing) auto n = MakeScanAll(storage, symbol_table, "n"); @@ -1735,7 +1735,7 @@ TEST(QueryPlan, ExpandExistingNode) { dba.InsertEdge(v1, v2, edge_type); dba.AdvanceCommand(); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto test_existing = [&](bool with_existing, int expected_result_count) { @@ -1774,7 +1774,7 @@ TEST(QueryPlan, ExpandBothCycleEdgeCase) { dba.InsertEdge(v, v, dba.EdgeType("et")); dba.AdvanceCommand(); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n"); @@ -1817,7 +1817,7 @@ TEST(QueryPlan, EdgeFilter) { for (auto &vertex : vertices) vertex.Reconstruct(); for (auto &edge : edges) edge.Reconstruct(); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto test_filter = [&]() { @@ -1867,7 +1867,7 @@ TEST(QueryPlan, EdgeFilterMultipleTypes) { dba.InsertEdge(v1, v2, type_3); dba.AdvanceCommand(); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; // make a scan all @@ -1899,7 +1899,7 @@ TEST(QueryPlan, Filter) { dba.InsertVertex(); // prop not set, gives NULL dba.AdvanceCommand(); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto n = MakeScanAll(storage, symbol_table, "n"); @@ -1931,7 +1931,7 @@ TEST(QueryPlan, ExpandUniquenessFilter) { auto check_expand_results = [&](bool vertex_uniqueness, bool edge_uniqueness) { - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto n1 = MakeScanAll(storage, symbol_table, "n1"); @@ -1968,7 +1968,7 @@ TEST(QueryPlan, Distinct) { database::SingleNode db; database::GraphDbAccessor dba(db); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto check_distinct = [&](const std::vector input, @@ -2019,7 +2019,7 @@ TEST(QueryPlan, ScanAllByLabel) { dba.AdvanceCommand(); EXPECT_EQ(2, CountIterable(dba.Vertices(false))); // MATCH (n :label) - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto scan_all_by_label = MakeScanAllByLabel(storage, symbol_table, "n", label); @@ -2063,7 +2063,7 @@ TEST(QueryPlan, ScanAllByLabelProperty) { auto check = [&dba, label, prop](TypedValue lower, Bound::Type lower_type, TypedValue upper, Bound::Type upper_type, const std::vector &expected) { - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto scan_all = MakeScanAllByLabelPropertyRange( storage, symbol_table, "n", label, prop, @@ -2125,7 +2125,7 @@ TEST(QueryPlan, ScanAllByLabelPropertyEqualityNoError) { database::GraphDbAccessor dba(db); EXPECT_EQ(2, CountIterable(dba.Vertices(false))); // MATCH (n :label {prop: 42}) - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto scan_all = MakeScanAllByLabelPropertyValue(storage, symbol_table, "n", label, prop, LITERAL(42)); @@ -2161,7 +2161,7 @@ TEST(QueryPlan, ScanAllByLabelPropertyValueError) { database::GraphDbAccessor dba(db); EXPECT_EQ(2, CountIterable(dba.Vertices(false))); // MATCH (m), (n :label {prop: m}) - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto scan_all = MakeScanAll(storage, symbol_table, "m"); auto *ident_m = IDENT("m"); @@ -2189,7 +2189,7 @@ TEST(QueryPlan, ScanAllByLabelPropertyRangeError) { database::GraphDbAccessor dba(db); EXPECT_EQ(2, CountIterable(dba.Vertices(false))); // MATCH (m), (n :label {prop: m}) - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto scan_all = MakeScanAll(storage, symbol_table, "m"); auto *ident_m = IDENT("m"); @@ -2242,7 +2242,7 @@ TEST(QueryPlan, ScanAllByLabelPropertyEqualNull) { database::GraphDbAccessor dba(db); EXPECT_EQ(2, CountIterable(dba.Vertices(false))); // MATCH (n :label {prop: 42}) - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto scan_all = MakeScanAllByLabelPropertyValue( storage, symbol_table, "n", label, prop, LITERAL(TypedValue::Null)); @@ -2275,7 +2275,7 @@ TEST(QueryPlan, ScanAllByLabelPropertyRangeNull) { database::GraphDbAccessor dba(db); EXPECT_EQ(2, CountIterable(dba.Vertices(false))); // MATCH (n :label) WHERE null <= n.prop < null - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; auto scan_all = MakeScanAllByLabelPropertyRange( storage, symbol_table, "n", label, prop, @@ -2305,7 +2305,7 @@ TEST(QueryPlan, ScanAllByLabelPropertyNoValueInIndexContinuation) { database::GraphDbAccessor dba(db); EXPECT_EQ(1, CountIterable(dba.Vertices(false))); - AstTreeStorage storage; + AstStorage storage; SymbolTable symbol_table; // UNWIND [1, 2, 3] as x diff --git a/tests/unit/query_planner.cpp b/tests/unit/query_planner.cpp index eccd344de..bea2d32b7 100644 --- a/tests/unit/query_planner.cpp +++ b/tests/unit/query_planner.cpp @@ -30,7 +30,7 @@ namespace query { } // namespace query using namespace query::plan; -using query::AstTreeStorage; +using query::AstStorage; using query::SingleQuery; using query::Symbol; using query::SymbolGenerator; @@ -504,7 +504,7 @@ class SerializedPlanner { auto &plan() { return *plan_; } private: - AstTreeStorage ast_storage_; + AstStorage ast_storage_; std::unique_ptr plan_; }; @@ -540,12 +540,12 @@ class CapnpPlanner { auto &plan() { return *plan_; } private: - AstTreeStorage ast_storage_; + AstStorage ast_storage_; std::unique_ptr plan_; }; template -TPlanner MakePlanner(database::MasterBase &master_db, AstTreeStorage &storage, +TPlanner MakePlanner(database::MasterBase &master_db, AstStorage &storage, SymbolTable &symbol_table) { database::GraphDbAccessor dba(master_db); auto planning_context = MakePlanningContext(storage, symbol_table, dba); @@ -564,7 +564,7 @@ auto CheckPlan(LogicalOperator &plan, const SymbolTable &symbol_table, } template -auto CheckPlan(AstTreeStorage &storage, TChecker... checker) { +auto CheckPlan(AstStorage &storage, TChecker... checker) { auto symbol_table = MakeSymbolTable(*storage.query()); database::SingleNode db; auto planner = MakePlanner(db, storage, symbol_table); @@ -577,7 +577,7 @@ struct ExpectedDistributedPlan { }; template -DistributedPlan MakeDistributedPlan(query::AstTreeStorage &storage) { +DistributedPlan MakeDistributedPlan(query::AstStorage &storage) { database::Master db; auto symbol_table = MakeSymbolTable(*storage.query()); auto planner = MakePlanner(db, storage, symbol_table); @@ -616,7 +616,7 @@ void CheckDistributedPlan(const LogicalOperator &plan, } template -void CheckDistributedPlan(AstTreeStorage &storage, +void CheckDistributedPlan(AstStorage &storage, ExpectedDistributedPlan &expected_distributed_plan) { auto distributed_plan = MakeDistributedPlan(storage); CheckDistributedPlan(distributed_plan, expected_distributed_plan); @@ -682,7 +682,7 @@ TYPED_TEST_CASE(TestPlanner, PlannerTypes); TYPED_TEST(TestPlanner, MatchNodeReturn) { // Test MATCH (n) RETURN n - AstTreeStorage storage; + AstStorage storage; auto *as_n = NEXPR("n", IDENT("n")); QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), RETURN(as_n))); auto symbol_table = MakeSymbolTable(*storage.query()); @@ -698,7 +698,7 @@ TYPED_TEST(TestPlanner, MatchNodeReturn) { TYPED_TEST(TestPlanner, CreateNodeReturn) { // Test CREATE (n) RETURN n AS n - AstTreeStorage storage; + AstStorage storage; auto ident_n = IDENT("n"); auto query = QUERY(SINGLE_QUERY(CREATE(PATTERN(NODE("n"))), RETURN(ident_n, AS("n")))); @@ -720,7 +720,7 @@ TYPED_TEST(TestPlanner, CreateNodeReturn) { TYPED_TEST(TestPlanner, CreateExpand) { // Test CREATE (n) -[r :rel1]-> (m) - AstTreeStorage storage; + AstStorage storage; database::SingleNode db; database::GraphDbAccessor dba(db); auto relationship = dba.EdgeType("relationship"); @@ -736,7 +736,7 @@ TYPED_TEST(TestPlanner, CreateExpand) { TYPED_TEST(TestPlanner, CreateMultipleNode) { // Test CREATE (n), (m) - AstTreeStorage storage; + AstStorage storage; QUERY(SINGLE_QUERY(CREATE(PATTERN(NODE("n")), PATTERN(NODE("m"))))); CheckPlan(storage, ExpectCreateNode(), ExpectCreateNode()); ExpectedDistributedPlan expected{ @@ -748,7 +748,7 @@ TYPED_TEST(TestPlanner, CreateMultipleNode) { TYPED_TEST(TestPlanner, CreateNodeExpandNode) { // Test CREATE (n) -[r :rel]-> (m), (l) - AstTreeStorage storage; + AstStorage storage; database::SingleNode db; database::GraphDbAccessor dba(db); auto relationship = dba.EdgeType("rel"); @@ -766,7 +766,7 @@ TYPED_TEST(TestPlanner, CreateNodeExpandNode) { TYPED_TEST(TestPlanner, CreateNamedPattern) { // Test CREATE p = (n) -[r :rel]-> (m) - AstTreeStorage storage; + AstStorage storage; database::SingleNode db; database::GraphDbAccessor dba(db); auto relationship = dba.EdgeType("rel"); @@ -783,7 +783,7 @@ TYPED_TEST(TestPlanner, CreateNamedPattern) { TYPED_TEST(TestPlanner, MatchCreateExpand) { // Test MATCH (n) CREATE (n) -[r :rel1]-> (m) - AstTreeStorage storage; + AstStorage storage; database::SingleNode db; database::GraphDbAccessor dba(db); auto relationship = dba.EdgeType("relationship"); @@ -800,7 +800,7 @@ TYPED_TEST(TestPlanner, MatchCreateExpand) { TYPED_TEST(TestPlanner, MatchLabeledNodes) { // Test MATCH (n :label) RETURN n - AstTreeStorage storage; + AstStorage storage; database::SingleNode db; database::GraphDbAccessor dba(db); auto label = dba.Label("label"); @@ -819,7 +819,7 @@ TYPED_TEST(TestPlanner, MatchLabeledNodes) { TYPED_TEST(TestPlanner, MatchPathReturn) { // Test MATCH (n) -[r :relationship]- (m) RETURN n - AstTreeStorage storage; + AstStorage storage; database::SingleNode db; database::GraphDbAccessor dba(db); auto relationship = dba.EdgeType("relationship"); @@ -841,7 +841,7 @@ TYPED_TEST(TestPlanner, MatchPathReturn) { TYPED_TEST(TestPlanner, MatchNamedPatternReturn) { // Test MATCH p = (n) -[r :relationship]- (m) RETURN p - AstTreeStorage storage; + AstStorage storage; database::SingleNode db; database::GraphDbAccessor dba(db); auto relationship = dba.EdgeType("relationship"); @@ -866,7 +866,7 @@ TYPED_TEST(TestPlanner, MatchNamedPatternReturn) { TYPED_TEST(TestPlanner, MatchNamedPatternWithPredicateReturn) { // Test MATCH p = (n) -[r :relationship]- (m) WHERE 2 = p RETURN p - AstTreeStorage storage; + AstStorage storage; database::SingleNode db; database::GraphDbAccessor dba(db); auto relationship = dba.EdgeType("relationship"); @@ -892,7 +892,7 @@ TYPED_TEST(TestPlanner, MatchNamedPatternWithPredicateReturn) { TYPED_TEST(TestPlanner, OptionalMatchNamedPatternReturn) { // Test OPTIONAL MATCH p = (n) -[r]- (m) RETURN p database::SingleNode db; - AstTreeStorage storage; + AstStorage storage; auto node_n = NODE("n"); auto edge = EDGE("r"); auto node_m = NODE("m"); @@ -920,7 +920,7 @@ TYPED_TEST(TestPlanner, OptionalMatchNamedPatternReturn) { TYPED_TEST(TestPlanner, MatchWhereReturn) { // Test MATCH (n) WHERE n.property < 42 RETURN n - AstTreeStorage storage; + AstStorage storage; database::SingleNode db; database::GraphDbAccessor dba(db); auto property = dba.Property("property"); @@ -941,7 +941,7 @@ TYPED_TEST(TestPlanner, MatchWhereReturn) { TYPED_TEST(TestPlanner, MatchDelete) { // Test MATCH (n) DELETE n - AstTreeStorage storage; + AstStorage storage; QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), DELETE(IDENT("n")))); CheckPlan(storage, ExpectScanAll(), ExpectDelete()); auto expected = ExpectDistributed( @@ -952,7 +952,7 @@ TYPED_TEST(TestPlanner, MatchDelete) { TYPED_TEST(TestPlanner, MatchNodeSet) { // Test MATCH (n) SET n.prop = 42, n = n, n :label - AstTreeStorage storage; + AstStorage storage; database::SingleNode db; database::GraphDbAccessor dba(db); auto prop = dba.Property("prop"); @@ -972,7 +972,7 @@ TYPED_TEST(TestPlanner, MatchNodeSet) { TYPED_TEST(TestPlanner, MatchRemove) { // Test MATCH (n) REMOVE n.prop REMOVE n :label - AstTreeStorage storage; + AstStorage storage; database::SingleNode db; database::GraphDbAccessor dba(db); auto prop = dba.Property("prop"); @@ -991,7 +991,7 @@ TYPED_TEST(TestPlanner, MatchRemove) { TYPED_TEST(TestPlanner, MatchMultiPattern) { // Test MATCH (n) -[r]- (m), (j) -[e]- (i) RETURN n - AstTreeStorage storage; + AstStorage storage; QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), EDGE("r"), NODE("m")), PATTERN(NODE("j"), EDGE("e"), NODE("i"))), RETURN("n"))); @@ -1004,7 +1004,7 @@ TYPED_TEST(TestPlanner, MatchMultiPattern) { TYPED_TEST(TestPlanner, MatchMultiPatternSameStart) { // Test MATCH (n), (n) -[e]- (m) RETURN n - AstTreeStorage storage; + AstStorage storage; QUERY(SINGLE_QUERY( MATCH(PATTERN(NODE("n")), PATTERN(NODE("n"), EDGE("e"), NODE("m"))), RETURN("n"))); @@ -1016,7 +1016,7 @@ TYPED_TEST(TestPlanner, MatchMultiPatternSameStart) { TYPED_TEST(TestPlanner, MatchMultiPatternSameExpandStart) { // Test MATCH (n) -[r]- (m), (m) -[e]- (l) RETURN n - AstTreeStorage storage; + AstStorage storage; QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), EDGE("r"), NODE("m")), PATTERN(NODE("m"), EDGE("e"), NODE("l"))), RETURN("n"))); @@ -1030,7 +1030,7 @@ TYPED_TEST(TestPlanner, MatchMultiPatternSameExpandStart) { TYPED_TEST(TestPlanner, MultiMatch) { // Test MATCH (n) -[r]- (m) MATCH (j) -[e]- (i) -[f]- (h) RETURN n - AstTreeStorage storage; + AstStorage storage; auto *node_n = NODE("n"); auto *edge_r = EDGE("r"); auto *node_m = NODE("m"); @@ -1073,7 +1073,7 @@ TYPED_TEST(TestPlanner, MultiMatch) { TYPED_TEST(TestPlanner, MultiMatchSameStart) { // Test MATCH (n) MATCH (n) -[r]- (m) RETURN n - AstTreeStorage storage; + AstStorage storage; auto *as_n = NEXPR("n", IDENT("n")); QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), MATCH(PATTERN(NODE("n"), EDGE("r"), NODE("m"))), @@ -1094,7 +1094,7 @@ TYPED_TEST(TestPlanner, MultiMatchSameStart) { TYPED_TEST(TestPlanner, MatchWithReturn) { // Test MATCH (old) WITH old AS new RETURN new - AstTreeStorage storage; + AstStorage storage; auto *as_new = NEXPR("new", IDENT("new")); QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("old"))), WITH("old", AS("new")), RETURN(as_new))); @@ -1116,7 +1116,7 @@ TYPED_TEST(TestPlanner, MatchWithWhereReturn) { database::SingleNode db; database::GraphDbAccessor dba(db); auto prop = dba.Property("prop"); - AstTreeStorage storage; + AstStorage storage; auto *as_new = NEXPR("new", IDENT("new")); QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("old"))), WITH("old", AS("new")), WHERE(LESS(PROPERTY_LOOKUP("new", prop), LITERAL(42))), @@ -1141,7 +1141,7 @@ TYPED_TEST(TestPlanner, CreateMultiExpand) { database::GraphDbAccessor dba(db); auto r = dba.EdgeType("r"); auto p = dba.EdgeType("p"); - AstTreeStorage storage; + AstStorage storage; QUERY(SINGLE_QUERY( CREATE(PATTERN(NODE("n"), EDGE("r", Direction::OUT, {r}), NODE("m")), PATTERN(NODE("n"), EDGE("p", Direction::OUT, {p}), NODE("l"))))); @@ -1160,7 +1160,7 @@ TYPED_TEST(TestPlanner, MatchWithSumWhereReturn) { database::SingleNode db; database::GraphDbAccessor dba(db); auto prop = dba.Property("prop"); - AstTreeStorage storage; + AstStorage storage; auto sum = SUM(PROPERTY_LOOKUP("n", prop)); auto literal = LITERAL(42); QUERY(SINGLE_QUERY( @@ -1177,7 +1177,7 @@ TYPED_TEST(TestPlanner, MatchReturnSum) { database::GraphDbAccessor dba(db); auto prop1 = dba.Property("prop1"); auto prop2 = dba.Property("prop2"); - AstTreeStorage storage; + AstStorage storage; auto sum = SUM(PROPERTY_LOOKUP("n", prop1)); auto n_prop2 = PROPERTY_LOOKUP("n", prop2); QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), @@ -1208,7 +1208,7 @@ TYPED_TEST(TestPlanner, CreateWithSum) { database::SingleNode db; database::GraphDbAccessor dba(db); auto prop = dba.Property("prop"); - AstTreeStorage storage; + AstStorage storage; auto n_prop = PROPERTY_LOOKUP("n", prop); auto sum = SUM(n_prop); auto query = @@ -1228,7 +1228,7 @@ TYPED_TEST(TestPlanner, MatchWithCreate) { database::SingleNode db; database::GraphDbAccessor dba(db); auto r_type = dba.EdgeType("r"); - AstTreeStorage storage; + AstStorage storage; QUERY(SINGLE_QUERY( MATCH(PATTERN(NODE("n"))), WITH("n", AS("a")), CREATE( @@ -1244,7 +1244,7 @@ TYPED_TEST(TestPlanner, MatchWithCreate) { TYPED_TEST(TestPlanner, MatchReturnSkipLimit) { // Test MATCH (n) RETURN n SKIP 2 LIMIT 1 - AstTreeStorage storage; + AstStorage storage; auto *as_n = NEXPR("n", IDENT("n")); QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), RETURN(as_n, SKIP(LITERAL(2)), LIMIT(LITERAL(1))))); @@ -1263,7 +1263,7 @@ TYPED_TEST(TestPlanner, MatchReturnSkipLimit) { TYPED_TEST(TestPlanner, CreateWithSkipReturnLimit) { // Test CREATE (n) WITH n AS m SKIP 2 RETURN m LIMIT 1 - AstTreeStorage storage; + AstStorage storage; auto ident_n = IDENT("n"); auto query = QUERY(SINGLE_QUERY(CREATE(PATTERN(NODE("n"))), WITH(ident_n, AS("m"), SKIP(LITERAL(2))), @@ -1292,7 +1292,7 @@ TYPED_TEST(TestPlanner, CreateReturnSumSkipLimit) { database::SingleNode db; database::GraphDbAccessor dba(db); auto prop = dba.Property("prop"); - AstTreeStorage storage; + AstStorage storage; auto n_prop = PROPERTY_LOOKUP("n", prop); auto sum = SUM(n_prop); auto query = QUERY( @@ -1311,7 +1311,7 @@ TYPED_TEST(TestPlanner, MatchReturnOrderBy) { database::SingleNode db; database::GraphDbAccessor dba(db); auto prop = dba.Property("prop"); - AstTreeStorage storage; + AstStorage storage; auto *as_m = NEXPR("m", IDENT("n")); auto *node_n = NODE("n"); auto ret = RETURN(as_m, ORDER_BY(PROPERTY_LOOKUP("n", prop))); @@ -1340,7 +1340,7 @@ TYPED_TEST(TestPlanner, CreateWithOrderByWhere) { database::GraphDbAccessor dba(db); auto prop = dba.Property("prop"); auto r_type = dba.EdgeType("r"); - AstTreeStorage storage; + AstStorage storage; auto ident_n = IDENT("n"); auto new_prop = PROPERTY_LOOKUP("new", prop); auto r_prop = PROPERTY_LOOKUP("r", prop); @@ -1369,7 +1369,7 @@ TYPED_TEST(TestPlanner, CreateWithOrderByWhere) { TYPED_TEST(TestPlanner, ReturnAddSumCountOrderBy) { // Test RETURN SUM(1) + COUNT(2) AS result ORDER BY result - AstTreeStorage storage; + AstStorage storage; auto sum = SUM(LITERAL(1)); auto count = COUNT(LITERAL(2)); QUERY(SINGLE_QUERY( @@ -1389,7 +1389,7 @@ TYPED_TEST(TestPlanner, MatchMerge) { database::GraphDbAccessor dba(db); auto r_type = dba.EdgeType("r"); auto prop = dba.Property("prop"); - AstTreeStorage storage; + AstStorage storage; auto ident_n = IDENT("n"); auto query = QUERY(SINGLE_QUERY( MATCH(PATTERN(NODE("n"))), @@ -1418,7 +1418,7 @@ TYPED_TEST(TestPlanner, MatchOptionalMatchWhereReturn) { database::SingleNode db; database::GraphDbAccessor dba(db); auto prop = dba.Property("prop"); - AstTreeStorage storage; + AstStorage storage; QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), OPTIONAL_MATCH(PATTERN(NODE("n"), EDGE("r"), NODE("m"))), WHERE(LESS(PROPERTY_LOOKUP("m", prop), LITERAL(42))), @@ -1431,7 +1431,7 @@ TYPED_TEST(TestPlanner, MatchOptionalMatchWhereReturn) { TYPED_TEST(TestPlanner, MatchUnwindReturn) { // Test MATCH (n) UNWIND [1,2,3] AS x RETURN n, x - AstTreeStorage storage; + AstStorage storage; auto *as_n = NEXPR("n", IDENT("n")); auto *as_x = NEXPR("x", IDENT("x")); QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), @@ -1451,7 +1451,7 @@ TYPED_TEST(TestPlanner, MatchUnwindReturn) { TYPED_TEST(TestPlanner, ReturnDistinctOrderBySkipLimit) { // Test RETURN DISTINCT 1 ORDER BY 1 SKIP 1 LIMIT 1 - AstTreeStorage storage; + AstStorage storage; QUERY(SINGLE_QUERY(RETURN_DISTINCT(LITERAL(1), AS("1"), ORDER_BY(LITERAL(1)), SKIP(LITERAL(1)), LIMIT(LITERAL(1))))); CheckPlan(storage, ExpectProduce(), ExpectDistinct(), @@ -1467,7 +1467,7 @@ TYPED_TEST(TestPlanner, CreateWithDistinctSumWhereReturn) { database::SingleNode db; database::GraphDbAccessor dba(db); auto prop = dba.Property("prop"); - AstTreeStorage storage; + AstStorage storage; auto node_n = NODE("n"); auto sum = SUM(PROPERTY_LOOKUP("n", prop)); auto query = @@ -1486,7 +1486,7 @@ TYPED_TEST(TestPlanner, MatchCrossReferenceVariable) { database::SingleNode db; database::GraphDbAccessor dba(db); auto prop = PROPERTY_PAIR("prop"); - AstTreeStorage storage; + AstStorage storage; auto node_n = NODE("n"); auto m_prop = PROPERTY_LOOKUP("m", prop.second); node_n->properties_[prop] = m_prop; @@ -1505,7 +1505,7 @@ TYPED_TEST(TestPlanner, MatchWhereBeforeExpand) { database::SingleNode db; database::GraphDbAccessor dba(db); auto prop = dba.Property("prop"); - AstTreeStorage storage; + AstStorage storage; auto *as_n = NEXPR("n", IDENT("n")); QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), EDGE("r"), NODE("m"))), WHERE(LESS(PROPERTY_LOOKUP("n", prop), LITERAL(42))), @@ -1529,7 +1529,7 @@ TYPED_TEST(TestPlanner, MultiMatchWhere) { database::SingleNode db; database::GraphDbAccessor dba(db); auto prop = dba.Property("prop"); - AstTreeStorage storage; + AstStorage storage; QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), EDGE("r"), NODE("m"))), MATCH(PATTERN(NODE("l"))), WHERE(LESS(PROPERTY_LOOKUP("n", prop), LITERAL(42))), @@ -1545,7 +1545,7 @@ TYPED_TEST(TestPlanner, MatchOptionalMatchWhere) { database::SingleNode db; database::GraphDbAccessor dba(db); auto prop = dba.Property("prop"); - AstTreeStorage storage; + AstStorage storage; QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), EDGE("r"), NODE("m"))), OPTIONAL_MATCH(PATTERN(NODE("l"))), WHERE(LESS(PROPERTY_LOOKUP("n", prop), LITERAL(42))), @@ -1563,7 +1563,7 @@ TYPED_TEST(TestPlanner, MatchReturnAsterisk) { database::SingleNode db; database::GraphDbAccessor dba(db); auto prop = dba.Property("prop"); - AstTreeStorage storage; + AstStorage storage; auto ret = RETURN(PROPERTY_LOOKUP("m", prop), AS("m.prop")); ret->body_.all_identifiers = true; auto query = @@ -1585,7 +1585,7 @@ TYPED_TEST(TestPlanner, MatchReturnAsteriskSum) { database::SingleNode db; database::GraphDbAccessor dba(db); auto prop = dba.Property("prop"); - AstTreeStorage storage; + AstStorage storage; auto sum = SUM(PROPERTY_LOOKUP("n", prop)); auto ret = RETURN(sum, AS("s")); ret->body_.all_identifiers = true; @@ -1614,7 +1614,7 @@ TYPED_TEST(TestPlanner, UnwindMergeNodeProperty) { // Test UNWIND [1] AS i MERGE (n {prop: i}) database::SingleNode db; database::GraphDbAccessor dba(db); - AstTreeStorage storage; + AstStorage storage; auto node_n = NODE("n"); node_n->properties_[PROPERTY_PAIR("prop")] = IDENT("i"); QUERY( @@ -1629,7 +1629,7 @@ TYPED_TEST(TestPlanner, UnwindMergeNodeProperty) { TYPED_TEST(TestPlanner, MultipleOptionalMatchReturn) { // Test OPTIONAL MATCH (n) OPTIONAL MATCH (m) RETURN n - AstTreeStorage storage; + AstStorage storage; QUERY(SINGLE_QUERY(OPTIONAL_MATCH(PATTERN(NODE("n"))), OPTIONAL_MATCH(PATTERN(NODE("m"))), RETURN("n"))); std::list optional{new ExpectScanAll()}; @@ -1639,7 +1639,7 @@ TYPED_TEST(TestPlanner, MultipleOptionalMatchReturn) { TYPED_TEST(TestPlanner, FunctionAggregationReturn) { // Test RETURN sqrt(SUM(2)) AS result, 42 AS group_by - AstTreeStorage storage; + AstStorage storage; auto sum = SUM(LITERAL(2)); auto group_by_literal = LITERAL(42); QUERY(SINGLE_QUERY( @@ -1652,7 +1652,7 @@ TYPED_TEST(TestPlanner, FunctionAggregationReturn) { TYPED_TEST(TestPlanner, FunctionWithoutArguments) { // Test RETURN pi() AS pi - AstTreeStorage storage; + AstStorage storage; QUERY(SINGLE_QUERY(RETURN(FN("pi"), AS("pi")))); CheckPlan(storage, ExpectProduce()); auto expected = ExpectDistributed(MakeCheckers(ExpectProduce())); @@ -1661,7 +1661,7 @@ TYPED_TEST(TestPlanner, FunctionWithoutArguments) { TYPED_TEST(TestPlanner, ListLiteralAggregationReturn) { // Test RETURN [SUM(2)] AS result, 42 AS group_by - AstTreeStorage storage; + AstStorage storage; auto sum = SUM(LITERAL(2)); auto group_by_literal = LITERAL(42); QUERY(SINGLE_QUERY( @@ -1672,7 +1672,7 @@ TYPED_TEST(TestPlanner, ListLiteralAggregationReturn) { TYPED_TEST(TestPlanner, MapLiteralAggregationReturn) { // Test RETURN {sum: SUM(2)} AS result, 42 AS group_by - AstTreeStorage storage; + AstStorage storage; database::SingleNode db; database::GraphDbAccessor dba(db); auto sum = SUM(LITERAL(2)); @@ -1685,7 +1685,7 @@ TYPED_TEST(TestPlanner, MapLiteralAggregationReturn) { TYPED_TEST(TestPlanner, EmptyListIndexAggregation) { // Test RETURN [][SUM(2)] AS result, 42 AS group_by - AstTreeStorage storage; + AstStorage storage; auto sum = SUM(LITERAL(2)); auto empty_list = LIST(); auto group_by_literal = LITERAL(42); @@ -1701,7 +1701,7 @@ TYPED_TEST(TestPlanner, EmptyListIndexAggregation) { TYPED_TEST(TestPlanner, ListSliceAggregationReturn) { // Test RETURN [1, 2][0..SUM(2)] AS result, 42 AS group_by - AstTreeStorage storage; + AstStorage storage; auto sum = SUM(LITERAL(2)); auto list = LIST(LITERAL(1), LITERAL(2)); auto group_by_literal = LITERAL(42); @@ -1715,7 +1715,7 @@ TYPED_TEST(TestPlanner, ListSliceAggregationReturn) { TYPED_TEST(TestPlanner, ListWithAggregationAndGroupBy) { // Test RETURN [sum(2), 42] - AstTreeStorage storage; + AstStorage storage; auto sum = SUM(LITERAL(2)); auto group_by_literal = LITERAL(42); QUERY(SINGLE_QUERY(RETURN(LIST(sum, group_by_literal), AS("result")))); @@ -1725,7 +1725,7 @@ TYPED_TEST(TestPlanner, ListWithAggregationAndGroupBy) { TYPED_TEST(TestPlanner, AggregatonWithListWithAggregationAndGroupBy) { // Test RETURN sum(2), [sum(3), 42] - AstTreeStorage storage; + AstStorage storage; auto sum2 = SUM(LITERAL(2)); auto sum3 = SUM(LITERAL(3)); auto group_by_literal = LITERAL(42); @@ -1738,7 +1738,7 @@ TYPED_TEST(TestPlanner, AggregatonWithListWithAggregationAndGroupBy) { TYPED_TEST(TestPlanner, MapWithAggregationAndGroupBy) { // Test RETURN {lit: 42, sum: sum(2)} database::SingleNode db; - AstTreeStorage storage; + AstStorage storage; auto sum = SUM(LITERAL(2)); auto group_by_literal = LITERAL(42); QUERY(SINGLE_QUERY(RETURN(MAP({PROPERTY_PAIR("sum"), sum}, @@ -1754,7 +1754,7 @@ TYPED_TEST(TestPlanner, CreateIndex) { database::GraphDbAccessor dba(db); auto label = dba.Label("label"); auto property = dba.Property("property"); - AstTreeStorage storage; + AstStorage storage; QUERY(SINGLE_QUERY(CREATE_INDEX_ON(label, property))); CheckPlan(storage, ExpectCreateIndex(label, property)); auto expected = @@ -1764,7 +1764,7 @@ TYPED_TEST(TestPlanner, CreateIndex) { TYPED_TEST(TestPlanner, AtomIndexedLabelProperty) { // Test MATCH (n :label {property: 42, not_indexed: 0}) RETURN n - AstTreeStorage storage; + AstStorage storage; database::SingleNode db; database::GraphDbAccessor dba(db); auto label = dba.Label("label"); @@ -1791,7 +1791,7 @@ TYPED_TEST(TestPlanner, AtomIndexedLabelProperty) { TYPED_TEST(TestPlanner, AtomPropertyWhereLabelIndexing) { // Test MATCH (n {property: 42}) WHERE n.not_indexed AND n:label RETURN n - AstTreeStorage storage; + AstStorage storage; database::SingleNode db; database::GraphDbAccessor dba(db); auto label = dba.Label("label"); @@ -1818,7 +1818,7 @@ TYPED_TEST(TestPlanner, AtomPropertyWhereLabelIndexing) { TYPED_TEST(TestPlanner, WhereIndexedLabelProperty) { // Test MATCH (n :label) WHERE n.property = 42 RETURN n - AstTreeStorage storage; + AstStorage storage; database::SingleNode db; database::GraphDbAccessor dba(db); auto label = dba.Label("label"); @@ -1839,7 +1839,7 @@ TYPED_TEST(TestPlanner, WhereIndexedLabelProperty) { TYPED_TEST(TestPlanner, BestPropertyIndexed) { // Test MATCH (n :label) WHERE n.property = 1 AND n.better = 42 RETURN n - AstTreeStorage storage; + AstStorage storage; database::SingleNode db; auto label = database::GraphDbAccessor(db).Label("label"); auto property = database::GraphDbAccessor(db).Property("property"); @@ -1882,7 +1882,7 @@ TYPED_TEST(TestPlanner, MultiPropertyIndexScan) { auto prop2 = PROPERTY_PAIR("prop2"); database::GraphDbAccessor(db).BuildIndex(label1, prop1.second); database::GraphDbAccessor(db).BuildIndex(label2, prop2.second); - AstTreeStorage storage; + AstStorage storage; auto lit_1 = LITERAL(1); auto lit_2 = LITERAL(2); QUERY(SINGLE_QUERY( @@ -1905,14 +1905,14 @@ TYPED_TEST(TestPlanner, WhereIndexedLabelPropertyRange) { auto label = database::GraphDbAccessor(db).Label("label"); auto property = database::GraphDbAccessor(db).Property("property"); database::GraphDbAccessor(db).BuildIndex(label, property); - AstTreeStorage storage; + AstStorage storage; auto lit_42 = LITERAL(42); auto n_prop = PROPERTY_LOOKUP("n", property); auto check_planned_range = [&label, &property, &db](const auto &rel_expr, auto lower_bound, auto upper_bound) { // Shadow the first storage, so that the query is created in this one. - AstTreeStorage storage; + AstStorage storage; QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n", label))), WHERE(rel_expr), RETURN("n"))); auto symbol_table = MakeSymbolTable(*storage.query()); @@ -1956,7 +1956,7 @@ TYPED_TEST(TestPlanner, UnableToUsePropertyIndex) { auto property = dba.Property("property"); dba.BuildIndex(label, property); { - AstTreeStorage storage; + AstStorage storage; QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n", label))), WHERE(EQ(PROPERTY_LOOKUP("n", property), PROPERTY_LOOKUP("n", property))), @@ -1978,7 +1978,7 @@ TYPED_TEST(TestPlanner, SecondPropertyIndex) { auto property = PROPERTY_PAIR("property"); dba.BuildIndex(label, dba.Property("property")); { - AstTreeStorage storage; + AstStorage storage; auto n_prop = PROPERTY_LOOKUP("n", property); auto m_prop = PROPERTY_LOOKUP("m", property); QUERY(SINGLE_QUERY( @@ -1996,7 +1996,7 @@ TYPED_TEST(TestPlanner, SecondPropertyIndex) { TYPED_TEST(TestPlanner, ReturnSumGroupByAll) { // Test RETURN sum([1,2,3]), all(x in [1] where x = 1) - AstTreeStorage storage; + AstStorage storage; auto sum = SUM(LIST(LITERAL(1), LITERAL(2), LITERAL(3))); auto *all = ALL("x", LIST(LITERAL(1)), WHERE(EQ(IDENT("x"), LITERAL(1)))); QUERY(SINGLE_QUERY(RETURN(sum, AS("sum"), all, AS("all")))); @@ -2006,7 +2006,7 @@ TYPED_TEST(TestPlanner, ReturnSumGroupByAll) { TYPED_TEST(TestPlanner, MatchExpandVariable) { // Test MATCH (n) -[r *..3]-> (m) RETURN r - AstTreeStorage storage; + AstStorage storage; auto edge = EDGE_VARIABLE("r"); edge->upper_bound_ = LITERAL(3); QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), edge, NODE("m"))), RETURN("r"))); @@ -2016,7 +2016,7 @@ TYPED_TEST(TestPlanner, MatchExpandVariable) { TYPED_TEST(TestPlanner, MatchExpandVariableNoBounds) { // Test MATCH (n) -[r *]-> (m) RETURN r - AstTreeStorage storage; + AstStorage storage; auto edge = EDGE_VARIABLE("r"); QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), edge, NODE("m"))), RETURN("r"))); CheckPlan(storage, ExpectScanAll(), ExpectExpandVariable(), @@ -2029,7 +2029,7 @@ TYPED_TEST(TestPlanner, MatchExpandVariableInlinedFilter) { database::GraphDbAccessor dba(db); auto type = dba.EdgeType("type"); auto prop = PROPERTY_PAIR("prop"); - AstTreeStorage storage; + AstStorage storage; auto edge = EDGE_VARIABLE("r", Direction::BOTH, {type}); edge->properties_[prop] = LITERAL(42); QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), edge, NODE("m"))), RETURN("r"))); @@ -2045,7 +2045,7 @@ TYPED_TEST(TestPlanner, MatchExpandVariableNotInlinedFilter) { database::GraphDbAccessor dba(db); auto type = dba.EdgeType("type"); auto prop = PROPERTY_PAIR("prop"); - AstTreeStorage storage; + AstStorage storage; auto edge = EDGE_VARIABLE("r", Direction::BOTH, {type}); edge->properties_[prop] = EQ(PROPERTY_LOOKUP("m", prop), LITERAL(42)); QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), edge, NODE("m"))), RETURN("r"))); @@ -2055,7 +2055,7 @@ TYPED_TEST(TestPlanner, MatchExpandVariableNotInlinedFilter) { TYPED_TEST(TestPlanner, UnwindMatchVariable) { // Test UNWIND [1,2,3] AS depth MATCH (n) -[r*d]-> (m) RETURN r - AstTreeStorage storage; + AstStorage storage; auto edge = EDGE_VARIABLE("r", Direction::OUT); edge->lower_bound_ = IDENT("d"); edge->upper_bound_ = IDENT("d"); @@ -2070,7 +2070,7 @@ TYPED_TEST(TestPlanner, MatchBfs) { database::SingleNode db; database::GraphDbAccessor dba(db); auto edge_type = dba.EdgeType("type"); - AstTreeStorage storage; + AstStorage storage; auto *bfs = storage.Create( IDENT("r"), query::EdgeAtom::Type::BREADTH_FIRST, Direction::OUT, std::vector{edge_type}); @@ -2088,7 +2088,7 @@ TYPED_TEST(TestPlanner, MatchDoubleScanToExpandExisting) { database::SingleNode db; database::GraphDbAccessor dba(db); auto label = dba.Label("label"); - AstTreeStorage storage; + AstStorage storage; QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), EDGE("r"), NODE("m", label))), RETURN("r"))); auto symbol_table = MakeSymbolTable(*storage.query()); @@ -2118,7 +2118,7 @@ TYPED_TEST(TestPlanner, MatchScanToExpand) { vertex.PropsSet(property, 1); dba.Commit(); { - AstTreeStorage storage; + AstStorage storage; auto node_m = NODE("m", label); node_m->properties_[std::make_pair("property", property)] = LITERAL(1); QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), EDGE("r"), node_m)), @@ -2137,7 +2137,7 @@ TYPED_TEST(TestPlanner, MatchWhereAndSplit) { database::SingleNode db; database::GraphDbAccessor dba(db); auto prop = PROPERTY_PAIR("prop"); - AstTreeStorage storage; + AstStorage storage; QUERY(SINGLE_QUERY( MATCH(PATTERN(NODE("n"), EDGE("r"), NODE("m"))), WHERE(AND(PROPERTY_LOOKUP("n", prop), PROPERTY_LOOKUP("r", prop))), @@ -2150,7 +2150,7 @@ TYPED_TEST(TestPlanner, MatchWhereAndSplit) { TYPED_TEST(TestPlanner, ReturnAsteriskOmitsLambdaSymbols) { // Test MATCH (n) -[r* (ie, in | true)]- (m) RETURN * database::SingleNode db; - AstTreeStorage storage; + AstStorage storage; auto edge = EDGE_VARIABLE("r", Direction::BOTH); edge->filter_lambda_.inner_edge = IDENT("ie"); edge->filter_lambda_.inner_node = IDENT("in"); @@ -2175,7 +2175,7 @@ TYPED_TEST(TestPlanner, ReturnAsteriskOmitsLambdaSymbols) { TYPED_TEST(TestPlanner, DistributedAvg) { // Test MATCH (n) RETURN AVG(n.prop) AS res - AstTreeStorage storage; + AstStorage storage; database::Master db; database::GraphDbAccessor dba(db); auto prop = dba.Property("prop"); @@ -2209,7 +2209,7 @@ TYPED_TEST(TestPlanner, DistributedAvg) { TYPED_TEST(TestPlanner, DistributedCollectList) { // Test MATCH (n) RETURN COLLECT(n.prop) AS res - AstTreeStorage storage; + AstStorage storage; database::Master db; database::GraphDbAccessor dba(db); auto prop = dba.Property("prop"); @@ -2228,7 +2228,7 @@ TYPED_TEST(TestPlanner, DistributedCollectList) { TYPED_TEST(TestPlanner, DistributedMatchCreateReturn) { // Test MATCH (n) CREATE (m) RETURN m - AstTreeStorage storage; + AstStorage storage; auto *ident_m = IDENT("m"); QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"))), CREATE(PATTERN(NODE("m"))), RETURN(ident_m, AS("m")))); @@ -2246,7 +2246,7 @@ TYPED_TEST(TestPlanner, DistributedMatchCreateReturn) { TYPED_TEST(TestPlanner, DistributedCartesianCreate) { // Test MATCH (a), (b) CREATE (a)-[e:r]->(b) RETURN e - AstTreeStorage storage; + AstStorage storage; database::Master db; database::GraphDbAccessor dba(db); auto relationship = dba.EdgeType("r"); @@ -2284,7 +2284,7 @@ TEST(CapnpSerial, Union) { std::unique_ptr loaded_plan; ::capnp::MallocMessageBuilder message; SavePlan(*union_op, &message); - AstTreeStorage new_storage; + AstStorage new_storage; std::tie(loaded_plan, new_storage) = LoadPlan(message.getRoot()); ASSERT_TRUE(loaded_plan); @@ -2307,7 +2307,7 @@ TEST(CapnpSerial, Cartesian) { std::unique_ptr loaded_plan; ::capnp::MallocMessageBuilder message; SavePlan(*cartesian, &message); - AstTreeStorage new_storage; + AstStorage new_storage; std::tie(loaded_plan, new_storage) = LoadPlan(message.getRoot()); ASSERT_TRUE(loaded_plan); @@ -2324,7 +2324,7 @@ TEST(CapnpSerial, Synchronize) { std::unique_ptr loaded_plan; ::capnp::MallocMessageBuilder message; SavePlan(*synchronize, &message); - AstTreeStorage new_storage; + AstStorage new_storage; std::tie(loaded_plan, new_storage) = LoadPlan(message.getRoot()); ASSERT_TRUE(loaded_plan); @@ -2342,7 +2342,7 @@ TEST(CapnpSerial, PullRemote) { std::unique_ptr loaded_plan; ::capnp::MallocMessageBuilder message; SavePlan(*pull_remote, &message); - AstTreeStorage new_storage; + AstStorage new_storage; std::tie(loaded_plan, new_storage) = LoadPlan(message.getRoot()); ASSERT_TRUE(loaded_plan); @@ -2355,7 +2355,7 @@ TEST(CapnpSerial, PullRemote) { TEST(CapnpSerial, PullRemoteOrderBy) { auto once = std::make_shared(); - AstTreeStorage storage; + AstStorage storage; std::vector symbols{ Symbol("my_symbol", 2, true, Symbol::Type::Vertex, 3)}; std::vector> order_by{ @@ -2365,7 +2365,7 @@ TEST(CapnpSerial, PullRemoteOrderBy) { std::unique_ptr loaded_plan; ::capnp::MallocMessageBuilder message; SavePlan(*pull_remote_order_by, &message); - AstTreeStorage new_storage; + AstStorage new_storage; std::tie(loaded_plan, new_storage) = LoadPlan(message.getRoot()); ASSERT_TRUE(loaded_plan); diff --git a/tests/unit/query_semantic.cpp b/tests/unit/query_semantic.cpp index 790e720b1..010bf57a2 100644 --- a/tests/unit/query_semantic.cpp +++ b/tests/unit/query_semantic.cpp @@ -19,7 +19,7 @@ class TestSymbolGenerator : public ::testing::Test { database::GraphDbAccessor dba{db}; SymbolTable symbol_table; SymbolGenerator symbol_generator{symbol_table}; - AstTreeStorage storage; + AstStorage storage; }; TEST_F(TestSymbolGenerator, MatchNodeReturn) { @@ -1091,7 +1091,7 @@ TEST_F(TestSymbolGenerator, MatchUnion) { TEST(TestSymbolTable, Serialization) { SymbolTable original_table; SymbolGenerator symbol_generator{original_table}; - AstTreeStorage storage; + AstStorage storage; auto ident_a = IDENT("a"); auto sym_a = original_table.CreateSymbol("a", true, Symbol::Type::Vertex, 0); original_table[*ident_a] = sym_a; diff --git a/tests/unit/query_variable_start_planner.cpp b/tests/unit/query_variable_start_planner.cpp index 73ff66638..949c51bf3 100644 --- a/tests/unit/query_variable_start_planner.cpp +++ b/tests/unit/query_variable_start_planner.cpp @@ -10,7 +10,7 @@ #include "query_plan_common.hpp" using namespace query::plan; -using query::AstTreeStorage; +using query::AstStorage; using Direction = query::EdgeAtom::Direction; namespace std { @@ -63,7 +63,7 @@ void AssertRows(const std::vector> &datum, }; void CheckPlansProduce( - size_t expected_plan_count, AstTreeStorage &storage, + size_t expected_plan_count, AstStorage &storage, database::GraphDbAccessor &dba, std::function> &)> check) { auto symbol_table = MakeSymbolTable(*storage.query()); @@ -91,7 +91,7 @@ TEST(TestVariableStartPlanner, MatchReturn) { dba.InsertEdge(v1, v2, dba.EdgeType("r")); dba.AdvanceCommand(); // Test MATCH (n) -[r]-> (m) RETURN n - AstTreeStorage storage; + AstStorage storage; QUERY(SINGLE_QUERY( MATCH(PATTERN(NODE("n"), EDGE("r", Direction::OUT), NODE("m"))), RETURN("n"))); @@ -114,7 +114,7 @@ TEST(TestVariableStartPlanner, MatchTripletPatternReturn) { dba.AdvanceCommand(); { // Test `MATCH (n) -[r]-> (m) -[e]-> (l) RETURN n` - AstTreeStorage storage; + AstStorage storage; QUERY(SINGLE_QUERY( MATCH(PATTERN(NODE("n"), EDGE("r", Direction::OUT), NODE("m"), EDGE("e", Direction::OUT), NODE("l"))), @@ -127,7 +127,7 @@ TEST(TestVariableStartPlanner, MatchTripletPatternReturn) { } { // Equivalent to `MATCH (n) -[r]-> (m), (m) -[e]-> (l) RETURN n`. - AstTreeStorage storage; + AstStorage storage; QUERY(SINGLE_QUERY( MATCH(PATTERN(NODE("n"), EDGE("r", Direction::OUT), NODE("m")), PATTERN(NODE("m"), EDGE("e", Direction::OUT), NODE("l"))), @@ -149,7 +149,7 @@ TEST(TestVariableStartPlanner, MatchOptionalMatchReturn) { dba.InsertEdge(v2, v3, dba.EdgeType("r")); dba.AdvanceCommand(); // Test MATCH (n) -[r]-> (m) OPTIONAL MATCH (m) -[e]-> (l) RETURN n, l - AstTreeStorage storage; + AstStorage storage; QUERY(SINGLE_QUERY( MATCH(PATTERN(NODE("n"), EDGE("r", Direction::OUT), NODE("m"))), OPTIONAL_MATCH(PATTERN(NODE("m"), EDGE("e", Direction::OUT), NODE("l"))), @@ -175,7 +175,7 @@ TEST(TestVariableStartPlanner, MatchOptionalMatchMergeReturn) { 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; + AstStorage storage; QUERY(SINGLE_QUERY( MATCH(PATTERN(NODE("n"), EDGE("r", Direction::OUT), NODE("m"))), OPTIONAL_MATCH(PATTERN(NODE("m"), EDGE("e", Direction::OUT), NODE("l"))), @@ -198,7 +198,7 @@ TEST(TestVariableStartPlanner, MatchWithMatchReturn) { 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; + AstStorage storage; QUERY(SINGLE_QUERY( MATCH(PATTERN(NODE("n"), EDGE("r", Direction::OUT), NODE("m"))), WITH("n"), @@ -223,7 +223,7 @@ TEST(TestVariableStartPlanner, MatchVariableExpand) { auto r2 = dba.InsertEdge(v2, v3, dba.EdgeType("r2")); dba.AdvanceCommand(); // Test MATCH (n) -[r*]-> (m) RETURN r - AstTreeStorage storage; + AstStorage storage; auto edge = EDGE_VARIABLE("r", Direction::OUT); QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), edge, NODE("m"))), RETURN("r"))); // We expect to get a single column with the following rows: @@ -250,7 +250,7 @@ TEST(TestVariableStartPlanner, MatchVariableExpandReferenceNode) { auto r2 = dba.InsertEdge(v2, v3, dba.EdgeType("r2")); dba.AdvanceCommand(); // Test MATCH (n) -[r*..n.id]-> (m) RETURN r - AstTreeStorage storage; + AstStorage storage; auto edge = EDGE_VARIABLE("r", Direction::OUT); edge->upper_bound_ = PROPERTY_LOOKUP("n", id); QUERY(SINGLE_QUERY(MATCH(PATTERN(NODE("n"), edge, NODE("m"))), RETURN("r"))); @@ -275,7 +275,7 @@ TEST(TestVariableStartPlanner, MatchVariableExpandBoth) { auto r2 = dba.InsertEdge(v2, v3, dba.EdgeType("r2")); dba.AdvanceCommand(); // Test MATCH (n {id:1}) -[r*]- (m) RETURN r - AstTreeStorage storage; + AstStorage storage; auto edge = EDGE_VARIABLE("r", Direction::BOTH); auto node_n = NODE("n"); node_n->properties_[std::make_pair("id", id)] = LITERAL(1); @@ -303,7 +303,7 @@ TEST(TestVariableStartPlanner, MatchBfs) { dba.InsertEdge(v2, v3, dba.EdgeType("r2")); dba.AdvanceCommand(); // Test MATCH (n) -[r *bfs..10](r, n | n.id <> 3)]-> (m) RETURN r - AstTreeStorage storage; + AstStorage storage; auto *bfs = storage.Create( IDENT("r"), EdgeAtom::Type::BREADTH_FIRST, Direction::OUT, std::vector{});