diff --git a/src/query/distributed/plan/ops.cpp b/src/query/distributed/plan/ops.cpp index 896538c08..3887e133d 100644 --- a/src/query/distributed/plan/ops.cpp +++ b/src/query/distributed/plan/ops.cpp @@ -389,13 +389,15 @@ class RemotePuller { class PullRemoteCursor : public Cursor { public: - PullRemoteCursor(const PullRemote &self, database::GraphDbAccessor &db) + PullRemoteCursor(const PullRemote &self, database::GraphDbAccessor *db, + utils::MemoryResource *mem) : self_(self), - input_cursor_(self.input() ? self.input()->MakeCursor(db) : nullptr), - command_id_(db.transaction().cid()), + input_cursor_(self.input() ? self.input()->MakeCursor(db, mem) + : nullptr), + command_id_(db->transaction().cid()), remote_puller_( // TODO: Pass in a Master GraphDb. - &dynamic_cast(&db.db())->pull_clients(), db, + &dynamic_cast(&db->db())->pull_clients(), *db, self.symbols_, self.plan_id_, command_id_) {} bool Pull(Frame &frame, ExecutionContext &context) override { @@ -494,24 +496,26 @@ class PullRemoteCursor : public Cursor { class SynchronizeCursor : public Cursor { public: - SynchronizeCursor(const Synchronize &self, database::GraphDbAccessor &db) + SynchronizeCursor(const Synchronize &self, database::GraphDbAccessor *db, + utils::MemoryResource *mem) : self_(self), pull_clients_( // TODO: Pass in a Master GraphDb. - &dynamic_cast(&db.db())->pull_clients()), + &dynamic_cast(&db->db())->pull_clients()), updates_clients_( // TODO: Pass in a Master GraphDb. - &dynamic_cast(&db.db())->updates_clients()), + &dynamic_cast(&db->db())->updates_clients()), updates_server_( // TODO: Pass in a Master GraphDb. - &dynamic_cast(&db.db())->updates_server()), - input_cursor_(self.input()->MakeCursor(db)), - pull_remote_cursor_( - self.pull_remote_ ? self.pull_remote_->MakeCursor(db) : nullptr), - command_id_(db.transaction().cid()), + &dynamic_cast(&db->db())->updates_server()), + input_cursor_(self.input()->MakeCursor(db, mem)), + pull_remote_cursor_(self.pull_remote_ + ? self.pull_remote_->MakeCursor(db, mem) + : nullptr), + command_id_(db->transaction().cid()), master_id_( // TODO: Pass in a Master GraphDb. - dynamic_cast(&db.db())->WorkerId()) {} + dynamic_cast(&db->db())->WorkerId()) {} bool Pull(Frame &frame, ExecutionContext &context) override { if (!initial_pull_done_) { @@ -663,13 +667,14 @@ class SynchronizeCursor : public Cursor { class PullRemoteOrderByCursor : public Cursor { public: PullRemoteOrderByCursor(const PullRemoteOrderBy &self, - database::GraphDbAccessor &db) + database::GraphDbAccessor *db, + utils::MemoryResource *mem) : self_(self), - input_(self.input()->MakeCursor(db)), - command_id_(db.transaction().cid()), + input_(self.input()->MakeCursor(db, mem)), + command_id_(db->transaction().cid()), remote_puller_( // TODO: Pass in a Master GraphDb. - &dynamic_cast(&db.db())->pull_clients(), db, + &dynamic_cast(&db->db())->pull_clients(), *db, self.symbols_, self.plan_id_, command_id_) {} bool Pull(Frame &frame, ExecutionContext &context) override { @@ -817,8 +822,9 @@ class PullRemoteOrderByCursor : public Cursor { class DistributedExpandCursor : public query::plan::Cursor { public: DistributedExpandCursor(const DistributedExpand *self, - database::GraphDbAccessor *db) - : input_cursor_(self->input()->MakeCursor(*db)), self_(self) {} + database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : input_cursor_(self->input()->MakeCursor(db, mem)), self_(self) {} bool Pull(Frame &frame, ExecutionContext &context) override { // A helper function for expanding a node from an edge. @@ -1056,8 +1062,11 @@ class DistributedExpandCursor : public query::plan::Cursor { class DistributedExpandBfsCursor : public query::plan::Cursor { public: DistributedExpandBfsCursor(const DistributedExpandBfs &self, - database::GraphDbAccessor &db) - : self_(self), db_(db), input_cursor_(self_.input()->MakeCursor(db)) {} + database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : self_(self), + db_(*db), + input_cursor_(self_.input()->MakeCursor(db, mem)) {} void InitSubcursors(database::GraphDbAccessor *dba, const query::SymbolTable &symbol_table, @@ -1082,9 +1091,9 @@ class DistributedExpandBfsCursor : public query::plan::Cursor { } // Evaluator for the filtering condition and expansion depth. - ExpressionEvaluator evaluator( - &frame, context.symbol_table, context.evaluation_context, - context.db_accessor, GraphView::OLD); + ExpressionEvaluator evaluator(&frame, context.symbol_table, + context.evaluation_context, + context.db_accessor, GraphView::OLD); while (true) { if (context.db_accessor->should_abort()) throw HintedAbortError(); @@ -1283,8 +1292,9 @@ VertexAccessor &CreateVertexOnWorker(int worker_id, class DistributedCreateNodeCursor : public query::plan::Cursor { public: DistributedCreateNodeCursor(const DistributedCreateNode *self, - database::GraphDbAccessor *dba) - : input_cursor_(self->input()->MakeCursor(*dba)), + database::GraphDbAccessor *dba, + utils::MemoryResource *mem) + : input_cursor_(self->input()->MakeCursor(dba, mem)), db_(&dba->db()), node_info_(self->node_info_), on_random_worker_(self->on_random_worker_) { @@ -1317,8 +1327,9 @@ class DistributedCreateNodeCursor : public query::plan::Cursor { class DistributedCreateExpandCursor : public query::plan::Cursor { public: DistributedCreateExpandCursor(const DistributedCreateExpand *self, - database::GraphDbAccessor *dba) - : input_cursor_(self->input()->MakeCursor(*dba)), + database::GraphDbAccessor *dba, + utils::MemoryResource *mem) + : input_cursor_(self->input()->MakeCursor(dba, mem)), self_(self), db_(&dba->db()) { CHECK(db_); @@ -1400,38 +1411,38 @@ class DistributedCreateExpandCursor : public query::plan::Cursor { } // namespace std::unique_ptr PullRemote::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); + database::GraphDbAccessor *db, utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::unique_ptr Synchronize::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); + database::GraphDbAccessor *db, utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::unique_ptr PullRemoteOrderBy::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); + database::GraphDbAccessor *db, utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::unique_ptr DistributedExpand::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(this, &db); + database::GraphDbAccessor *db, utils::MemoryResource *mem) const { + return std::make_unique(this, db, mem); } std::unique_ptr DistributedExpandBfs::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); + database::GraphDbAccessor *db, utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::unique_ptr DistributedCreateNode::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(this, &db); + database::GraphDbAccessor *db, utils::MemoryResource *mem) const { + return std::make_unique(this, db, mem); } std::unique_ptr DistributedCreateExpand::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(this, &db); + database::GraphDbAccessor *db, utils::MemoryResource *mem) const { + return std::make_unique(this, db, mem); } } // namespace query::plan diff --git a/src/query/distributed/plan/ops.lcp b/src/query/distributed/plan/ops.lcp index 3362e0cf6..df7fa867b 100644 --- a/src/query/distributed/plan/ops.lcp +++ b/src/query/distributed/plan/ops.lcp @@ -74,7 +74,7 @@ time on data transfer. It gives no guarantees on result order.") : input_(input), plan_id_(plan_id), symbols_(symbols) {} bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector OutputSymbols(const SymbolTable &) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; @@ -160,7 +160,7 @@ Logic of the synchronize operator is: advance_command_(advance_command) {} bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; std::vector OutputSymbols( @@ -209,7 +209,7 @@ by having only one result from each worker.") const std::vector &order_by, const std::vector &symbols); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; std::vector OutputSymbols(const SymbolTable &) const override; @@ -255,7 +255,7 @@ by having only one result from each worker.") bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -318,7 +318,7 @@ by having only one result from each worker.") bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -355,7 +355,7 @@ by having only one result from each worker.") bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -403,7 +403,7 @@ by having only one result from each worker.") Symbol input_symbol, bool existing_node); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } diff --git a/src/query/plan/operator.cpp b/src/query/plan/operator.cpp index 74d71f26e..b9d0b028d 100644 --- a/src/query/plan/operator.cpp +++ b/src/query/plan/operator.cpp @@ -92,7 +92,8 @@ bool Once::OnceCursor::Pull(Frame &, ExecutionContext &context) { return false; } -std::unique_ptr Once::MakeCursor(database::GraphDbAccessor &) const { +std::unique_ptr Once::MakeCursor(database::GraphDbAccessor *, + utils::MemoryResource *) const { return std::make_unique(); } @@ -128,8 +129,8 @@ VertexAccessor &CreateLocalVertex(const NodeCreationInfo &node_info, ACCEPT_WITH_INPUT(CreateNode) std::unique_ptr CreateNode::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); + database::GraphDbAccessor *db, utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::vector CreateNode::ModifiedSymbols( @@ -140,8 +141,9 @@ std::vector CreateNode::ModifiedSymbols( } CreateNode::CreateNodeCursor::CreateNodeCursor(const CreateNode &self, - database::GraphDbAccessor &db) - : self_(self), input_cursor_(self.input_->MakeCursor(db)) {} + database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : self_(self), input_cursor_(self.input_->MakeCursor(db, mem)) {} bool CreateNode::CreateNodeCursor::Pull(Frame &frame, ExecutionContext &context) { @@ -172,8 +174,8 @@ CreateExpand::CreateExpand(const NodeCreationInfo &node_info, ACCEPT_WITH_INPUT(CreateExpand) std::unique_ptr CreateExpand::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); + database::GraphDbAccessor *db, utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::vector CreateExpand::ModifiedSymbols( @@ -185,8 +187,9 @@ std::vector CreateExpand::ModifiedSymbols( } CreateExpand::CreateExpandCursor::CreateExpandCursor( - const CreateExpand &self, database::GraphDbAccessor &db) - : self_(self), db_(db), input_cursor_(self.input_->MakeCursor(db)) {} + const CreateExpand &self, database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : self_(self), db_(*db), input_cursor_(self.input_->MakeCursor(db, mem)) {} bool CreateExpand::CreateExpandCursor::Pull(Frame &frame, ExecutionContext &context) { @@ -316,13 +319,13 @@ ScanAll::ScanAll(const std::shared_ptr &input, ACCEPT_WITH_INPUT(ScanAll) -std::unique_ptr ScanAll::MakeCursor( - database::GraphDbAccessor &db) const { - auto vertices = [this, &db](Frame &, ExecutionContext &) { - return std::make_optional(db.Vertices(graph_view_ == GraphView::NEW)); +std::unique_ptr ScanAll::MakeCursor(database::GraphDbAccessor *db, + utils::MemoryResource *mem) const { + auto vertices = [this, db](Frame &, ExecutionContext &) { + return std::make_optional(db->Vertices(graph_view_ == GraphView::NEW)); }; return std::make_unique>( - output_symbol_, input_->MakeCursor(db), std::move(vertices), db); + output_symbol_, input_->MakeCursor(db, mem), std::move(vertices), *db); } std::vector ScanAll::ModifiedSymbols(const SymbolTable &table) const { @@ -339,13 +342,13 @@ ScanAllByLabel::ScanAllByLabel(const std::shared_ptr &input, ACCEPT_WITH_INPUT(ScanAllByLabel) std::unique_ptr ScanAllByLabel::MakeCursor( - database::GraphDbAccessor &db) const { - auto vertices = [this, &db](Frame &, ExecutionContext &) { + database::GraphDbAccessor *db, utils::MemoryResource *mem) const { + auto vertices = [this, db](Frame &, ExecutionContext &) { return std::make_optional( - db.Vertices(label_, graph_view_ == GraphView::NEW)); + db->Vertices(label_, graph_view_ == GraphView::NEW)); }; return std::make_unique>( - output_symbol_, input_->MakeCursor(db), std::move(vertices), db); + output_symbol_, input_->MakeCursor(db, mem), std::move(vertices), *db); } ScanAllByLabelPropertyRange::ScanAllByLabelPropertyRange( @@ -365,10 +368,10 @@ ScanAllByLabelPropertyRange::ScanAllByLabelPropertyRange( ACCEPT_WITH_INPUT(ScanAllByLabelPropertyRange) std::unique_ptr ScanAllByLabelPropertyRange::MakeCursor( - database::GraphDbAccessor &db) const { - auto vertices = [this, &db](Frame &frame, ExecutionContext &context) + database::GraphDbAccessor *db, utils::MemoryResource *mem) const { + auto vertices = [this, db](Frame &frame, ExecutionContext &context) -> std::optional { + db->Vertices(label_, property_, std::nullopt, std::nullopt, false))> { ExpressionEvaluator evaluator(&frame, context.symbol_table, context.evaluation_context, context.db_accessor, graph_view_); @@ -391,12 +394,12 @@ std::unique_ptr ScanAllByLabelPropertyRange::MakeCursor( // is treated as not satisfying the filter, so return no vertices. if (maybe_lower && maybe_lower->value().IsNull()) return std::nullopt; if (maybe_upper && maybe_upper->value().IsNull()) return std::nullopt; - return std::make_optional(db.Vertices(label_, property_, maybe_lower, - maybe_upper, - graph_view_ == GraphView::NEW)); + return std::make_optional(db->Vertices(label_, property_, maybe_lower, + maybe_upper, + graph_view_ == GraphView::NEW)); }; return std::make_unique>( - output_symbol_, input_->MakeCursor(db), std::move(vertices), db); + output_symbol_, input_->MakeCursor(db, mem), std::move(vertices), *db); } ScanAllByLabelPropertyValue::ScanAllByLabelPropertyValue( @@ -415,10 +418,10 @@ ScanAllByLabelPropertyValue::ScanAllByLabelPropertyValue( ACCEPT_WITH_INPUT(ScanAllByLabelPropertyValue) std::unique_ptr ScanAllByLabelPropertyValue::MakeCursor( - database::GraphDbAccessor &db) const { - auto vertices = [this, &db](Frame &frame, ExecutionContext &context) + database::GraphDbAccessor *db, utils::MemoryResource *mem) const { + auto vertices = [this, db](Frame &frame, ExecutionContext &context) -> std::optional { + db->Vertices(label_, property_, PropertyValue::Null, false))> { ExpressionEvaluator evaluator(&frame, context.symbol_table, context.evaluation_context, context.db_accessor, graph_view_); @@ -428,12 +431,12 @@ std::unique_ptr ScanAllByLabelPropertyValue::MakeCursor( throw QueryRuntimeException("'{}' cannot be used as a property value.", value.type()); } - return std::make_optional(db.Vertices(label_, property_, - PropertyValue(value), - graph_view_ == GraphView::NEW)); + return std::make_optional(db->Vertices(label_, property_, + PropertyValue(value), + graph_view_ == GraphView::NEW)); }; return std::make_unique>( - output_symbol_, input_->MakeCursor(db), std::move(vertices), db); + output_symbol_, input_->MakeCursor(db, mem), std::move(vertices), *db); } namespace { @@ -458,9 +461,9 @@ Expand::Expand(const std::shared_ptr &input, ACCEPT_WITH_INPUT(Expand) -std::unique_ptr Expand::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); +std::unique_ptr Expand::MakeCursor(database::GraphDbAccessor *db, + utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::vector Expand::ModifiedSymbols(const SymbolTable &table) const { @@ -471,8 +474,9 @@ std::vector Expand::ModifiedSymbols(const SymbolTable &table) const { } Expand::ExpandCursor::ExpandCursor(const Expand &self, - database::GraphDbAccessor &db) - : self_(self), input_cursor_(self.input_->MakeCursor(db)), db_(db) {} + database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : self_(self), input_cursor_(self.input_->MakeCursor(db, mem)), db_(*db) {} bool Expand::ExpandCursor::Pull(Frame &frame, ExecutionContext &context) { SCOPED_PROFILE_OP("Expand"); @@ -680,8 +684,9 @@ auto ExpandFromVertex(const VertexAccessor &vertex, class ExpandVariableCursor : public Cursor { public: ExpandVariableCursor(const ExpandVariable &self, - database::GraphDbAccessor &db) - : self_(self), input_cursor_(self.input_->MakeCursor(db)) {} + database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : self_(self), input_cursor_(self.input_->MakeCursor(db, mem)) {} bool Pull(Frame &frame, ExecutionContext &context) override { SCOPED_PROFILE_OP("ExpandVariable"); @@ -917,8 +922,9 @@ class ExpandVariableCursor : public Cursor { class STShortestPathCursor : public query::plan::Cursor { public: STShortestPathCursor(const ExpandVariable &self, - database::GraphDbAccessor &dba) - : self_(self), input_cursor_(self_.input()->MakeCursor(dba)) { + database::GraphDbAccessor *dba, + utils::MemoryResource *mem) + : self_(self), input_cursor_(self_.input()->MakeCursor(dba, mem)) { CHECK(self_.common_.existing_node) << "s-t shortest path algorithm should only " "be used when `existing_node` flag is " @@ -1149,8 +1155,9 @@ class STShortestPathCursor : public query::plan::Cursor { class SingleSourceShortestPathCursor : public query::plan::Cursor { public: SingleSourceShortestPathCursor(const ExpandVariable &self, - database::GraphDbAccessor &db) - : self_(self), input_cursor_(self_.input()->MakeCursor(db)) { + database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : self_(self), input_cursor_(self_.input()->MakeCursor(db, mem)) { CHECK(!self_.common_.existing_node) << "Single source shortest path algorithm " "should not be used when `existing_node` " @@ -1308,8 +1315,9 @@ class SingleSourceShortestPathCursor : public query::plan::Cursor { class ExpandWeightedShortestPathCursor : public query::plan::Cursor { public: ExpandWeightedShortestPathCursor(const ExpandVariable &self, - database::GraphDbAccessor &db) - : self_(self), input_cursor_(self_.input_->MakeCursor(db)) {} + database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : self_(self), input_cursor_(self_.input_->MakeCursor(db, mem)) {} bool Pull(Frame &frame, ExecutionContext &context) override { SCOPED_PROFILE_OP("ExpandWeightedShortestPath"); @@ -1546,18 +1554,18 @@ class ExpandWeightedShortestPathCursor : public query::plan::Cursor { }; std::unique_ptr ExpandVariable::MakeCursor( - database::GraphDbAccessor &db) const { + database::GraphDbAccessor *db, utils::MemoryResource *mem) const { switch (type_) { case EdgeAtom::Type::BREADTH_FIRST: if (common_.existing_node) { - return std::make_unique(*this, db); + return std::make_unique(*this, db, mem); } else { - return std::make_unique(*this, db); + return std::make_unique(*this, db, mem); } case EdgeAtom::Type::DEPTH_FIRST: - return std::make_unique(*this, db); + return std::make_unique(*this, db, mem); case EdgeAtom::Type::WEIGHTED_SHORTEST_PATH: - return std::make_unique(*this, db); + return std::make_unique(*this, db, mem); case EdgeAtom::Type::SINGLE: LOG(FATAL) << "ExpandVariable should not be planned for a single expansion!"; @@ -1567,8 +1575,9 @@ std::unique_ptr ExpandVariable::MakeCursor( class ConstructNamedPathCursor : public Cursor { public: ConstructNamedPathCursor(const ConstructNamedPath &self, - database::GraphDbAccessor &db) - : self_(self), input_cursor_(self_.input()->MakeCursor(db)) {} + database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : self_(self), input_cursor_(self_.input()->MakeCursor(db, mem)) {} bool Pull(Frame &frame, ExecutionContext &context) override { SCOPED_PROFILE_OP("ConstructNamedPath"); @@ -1650,8 +1659,8 @@ class ConstructNamedPathCursor : public Cursor { ACCEPT_WITH_INPUT(ConstructNamedPath) std::unique_ptr ConstructNamedPath::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); + database::GraphDbAccessor *db, utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::vector ConstructNamedPath::ModifiedSymbols( @@ -1668,9 +1677,9 @@ Filter::Filter(const std::shared_ptr &input, ACCEPT_WITH_INPUT(Filter) -std::unique_ptr Filter::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); +std::unique_ptr Filter::MakeCursor(database::GraphDbAccessor *db, + utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::vector Filter::ModifiedSymbols(const SymbolTable &table) const { @@ -1678,8 +1687,9 @@ std::vector Filter::ModifiedSymbols(const SymbolTable &table) const { } Filter::FilterCursor::FilterCursor(const Filter &self, - database::GraphDbAccessor &db) - : self_(self), input_cursor_(self_.input_->MakeCursor(db)) {} + database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : self_(self), input_cursor_(self_.input_->MakeCursor(db, mem)) {} bool Filter::FilterCursor::Pull(Frame &frame, ExecutionContext &context) { SCOPED_PROFILE_OP("Filter"); @@ -1706,9 +1716,9 @@ Produce::Produce(const std::shared_ptr &input, ACCEPT_WITH_INPUT(Produce) -std::unique_ptr Produce::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); +std::unique_ptr Produce::MakeCursor(database::GraphDbAccessor *db, + utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::vector Produce::OutputSymbols( @@ -1725,8 +1735,9 @@ std::vector Produce::ModifiedSymbols(const SymbolTable &table) const { } Produce::ProduceCursor::ProduceCursor(const Produce &self, - database::GraphDbAccessor &db) - : self_(self), input_cursor_(self_.input_->MakeCursor(db)) {} + database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : self_(self), input_cursor_(self_.input_->MakeCursor(db, mem)) {} bool Produce::ProduceCursor::Pull(Frame &frame, ExecutionContext &context) { SCOPED_PROFILE_OP("Produce"); @@ -1754,9 +1765,9 @@ Delete::Delete(const std::shared_ptr &input_, ACCEPT_WITH_INPUT(Delete) -std::unique_ptr Delete::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); +std::unique_ptr Delete::MakeCursor(database::GraphDbAccessor *db, + utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::vector Delete::ModifiedSymbols(const SymbolTable &table) const { @@ -1764,8 +1775,9 @@ std::vector Delete::ModifiedSymbols(const SymbolTable &table) const { } Delete::DeleteCursor::DeleteCursor(const Delete &self, - database::GraphDbAccessor &db) - : self_(self), db_(db), input_cursor_(self_.input_->MakeCursor(db)) {} + database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : self_(self), db_(*db), input_cursor_(self_.input_->MakeCursor(db, mem)) {} bool Delete::DeleteCursor::Pull(Frame &frame, ExecutionContext &context) { SCOPED_PROFILE_OP("Delete"); @@ -1835,8 +1847,8 @@ SetProperty::SetProperty(const std::shared_ptr &input, ACCEPT_WITH_INPUT(SetProperty) std::unique_ptr SetProperty::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); + database::GraphDbAccessor *db, utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::vector SetProperty::ModifiedSymbols( @@ -1845,8 +1857,9 @@ std::vector SetProperty::ModifiedSymbols( } SetProperty::SetPropertyCursor::SetPropertyCursor(const SetProperty &self, - database::GraphDbAccessor &db) - : self_(self), input_cursor_(self.input_->MakeCursor(db)) {} + database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : self_(self), input_cursor_(self.input_->MakeCursor(db, mem)) {} bool SetProperty::SetPropertyCursor::Pull(Frame &frame, ExecutionContext &context) { @@ -1895,8 +1908,8 @@ SetProperties::SetProperties(const std::shared_ptr &input, ACCEPT_WITH_INPUT(SetProperties) std::unique_ptr SetProperties::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); + database::GraphDbAccessor *db, utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::vector SetProperties::ModifiedSymbols( @@ -1905,8 +1918,9 @@ std::vector SetProperties::ModifiedSymbols( } SetProperties::SetPropertiesCursor::SetPropertiesCursor( - const SetProperties &self, database::GraphDbAccessor &db) - : self_(self), db_(db), input_cursor_(self.input_->MakeCursor(db)) {} + const SetProperties &self, database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : self_(self), db_(*db), input_cursor_(self.input_->MakeCursor(db, mem)) {} bool SetProperties::SetPropertiesCursor::Pull(Frame &frame, ExecutionContext &context) { @@ -2001,8 +2015,8 @@ SetLabels::SetLabels(const std::shared_ptr &input, ACCEPT_WITH_INPUT(SetLabels) std::unique_ptr SetLabels::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); + database::GraphDbAccessor *db, utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::vector SetLabels::ModifiedSymbols(const SymbolTable &table) const { @@ -2010,8 +2024,9 @@ std::vector SetLabels::ModifiedSymbols(const SymbolTable &table) const { } SetLabels::SetLabelsCursor::SetLabelsCursor(const SetLabels &self, - database::GraphDbAccessor &db) - : self_(self), input_cursor_(self.input_->MakeCursor(db)) {} + database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : self_(self), input_cursor_(self.input_->MakeCursor(db, mem)) {} bool SetLabels::SetLabelsCursor::Pull(Frame &frame, ExecutionContext &context) { SCOPED_PROFILE_OP("SetLabels"); @@ -2044,8 +2059,8 @@ RemoveProperty::RemoveProperty(const std::shared_ptr &input, ACCEPT_WITH_INPUT(RemoveProperty) std::unique_ptr RemoveProperty::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); + database::GraphDbAccessor *db, utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::vector RemoveProperty::ModifiedSymbols( @@ -2054,8 +2069,9 @@ std::vector RemoveProperty::ModifiedSymbols( } RemoveProperty::RemovePropertyCursor::RemovePropertyCursor( - const RemoveProperty &self, database::GraphDbAccessor &db) - : self_(self), input_cursor_(self.input_->MakeCursor(db)) {} + const RemoveProperty &self, database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : self_(self), input_cursor_(self.input_->MakeCursor(db, mem)) {} bool RemoveProperty::RemovePropertyCursor::Pull(Frame &frame, ExecutionContext &context) { @@ -2110,8 +2126,8 @@ RemoveLabels::RemoveLabels(const std::shared_ptr &input, ACCEPT_WITH_INPUT(RemoveLabels) std::unique_ptr RemoveLabels::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); + database::GraphDbAccessor *db, utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::vector RemoveLabels::ModifiedSymbols( @@ -2120,8 +2136,9 @@ std::vector RemoveLabels::ModifiedSymbols( } RemoveLabels::RemoveLabelsCursor::RemoveLabelsCursor( - const RemoveLabels &self, database::GraphDbAccessor &db) - : self_(self), input_cursor_(self.input_->MakeCursor(db)) {} + const RemoveLabels &self, database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : self_(self), input_cursor_(self.input_->MakeCursor(db, mem)) {} bool RemoveLabels::RemoveLabelsCursor::Pull(Frame &frame, ExecutionContext &context) { @@ -2158,8 +2175,8 @@ EdgeUniquenessFilter::EdgeUniquenessFilter( ACCEPT_WITH_INPUT(EdgeUniquenessFilter) std::unique_ptr EdgeUniquenessFilter::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); + database::GraphDbAccessor *db, utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::vector EdgeUniquenessFilter::ModifiedSymbols( @@ -2168,8 +2185,9 @@ std::vector EdgeUniquenessFilter::ModifiedSymbols( } EdgeUniquenessFilter::EdgeUniquenessFilterCursor::EdgeUniquenessFilterCursor( - const EdgeUniquenessFilter &self, database::GraphDbAccessor &db) - : self_(self), input_cursor_(self.input_->MakeCursor(db)) {} + const EdgeUniquenessFilter &self, database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : self_(self), input_cursor_(self.input_->MakeCursor(db, mem)) {} namespace { /** @@ -2227,8 +2245,8 @@ Accumulate::Accumulate(const std::shared_ptr &input, ACCEPT_WITH_INPUT(Accumulate) std::unique_ptr Accumulate::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); + database::GraphDbAccessor *db, utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::vector Accumulate::ModifiedSymbols(const SymbolTable &) const { @@ -2236,8 +2254,9 @@ std::vector Accumulate::ModifiedSymbols(const SymbolTable &) const { } Accumulate::AccumulateCursor::AccumulateCursor(const Accumulate &self, - database::GraphDbAccessor &db) - : self_(self), db_(db), input_cursor_(self.input_->MakeCursor(db)) {} + database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : self_(self), db_(*db), input_cursor_(self.input_->MakeCursor(db, mem)) {} bool Accumulate::AccumulateCursor::Pull(Frame &frame, ExecutionContext &context) { @@ -2290,8 +2309,8 @@ Aggregate::Aggregate(const std::shared_ptr &input, ACCEPT_WITH_INPUT(Aggregate) std::unique_ptr Aggregate::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); + database::GraphDbAccessor *db, utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::vector Aggregate::ModifiedSymbols(const SymbolTable &) const { @@ -2301,8 +2320,9 @@ std::vector Aggregate::ModifiedSymbols(const SymbolTable &) const { } Aggregate::AggregateCursor::AggregateCursor(const Aggregate &self, - database::GraphDbAccessor &db) - : self_(self), input_cursor_(self_.input_->MakeCursor(db)) {} + database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : self_(self), input_cursor_(self_.input_->MakeCursor(db, mem)) {} namespace { /** Returns the default TypedValue for an Aggregation element. @@ -2575,8 +2595,9 @@ Skip::Skip(const std::shared_ptr &input, ACCEPT_WITH_INPUT(Skip) -std::unique_ptr Skip::MakeCursor(database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); +std::unique_ptr Skip::MakeCursor(database::GraphDbAccessor *db, + utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::vector Skip::OutputSymbols(const SymbolTable &symbol_table) const { @@ -2588,8 +2609,9 @@ std::vector Skip::ModifiedSymbols(const SymbolTable &table) const { return input_->ModifiedSymbols(table); } -Skip::SkipCursor::SkipCursor(const Skip &self, database::GraphDbAccessor &db) - : self_(self), input_cursor_(self_.input_->MakeCursor(db)) {} +Skip::SkipCursor::SkipCursor(const Skip &self, database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : self_(self), input_cursor_(self_.input_->MakeCursor(db, mem)) {} bool Skip::SkipCursor::Pull(Frame &frame, ExecutionContext &context) { SCOPED_PROFILE_OP("Skip"); @@ -2633,8 +2655,9 @@ Limit::Limit(const std::shared_ptr &input, ACCEPT_WITH_INPUT(Limit) -std::unique_ptr Limit::MakeCursor(database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); +std::unique_ptr Limit::MakeCursor(database::GraphDbAccessor *db, + utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::vector Limit::OutputSymbols( @@ -2648,8 +2671,9 @@ std::vector Limit::ModifiedSymbols(const SymbolTable &table) const { } Limit::LimitCursor::LimitCursor(const Limit &self, - database::GraphDbAccessor &db) - : self_(self), input_cursor_(self_.input_->MakeCursor(db)) {} + database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : self_(self), input_cursor_(self_.input_->MakeCursor(db, mem)) {} bool Limit::LimitCursor::Pull(Frame &frame, ExecutionContext &context) { SCOPED_PROFILE_OP("Limit"); @@ -2706,9 +2730,9 @@ OrderBy::OrderBy(const std::shared_ptr &input, ACCEPT_WITH_INPUT(OrderBy) -std::unique_ptr OrderBy::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); +std::unique_ptr OrderBy::MakeCursor(database::GraphDbAccessor *db, + utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::vector OrderBy::OutputSymbols( @@ -2722,8 +2746,9 @@ std::vector OrderBy::ModifiedSymbols(const SymbolTable &table) const { } OrderBy::OrderByCursor::OrderByCursor(const OrderBy &self, - database::GraphDbAccessor &db) - : self_(self), input_cursor_(self_.input_->MakeCursor(db)) {} + database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : self_(self), input_cursor_(self_.input_->MakeCursor(db, mem)) {} bool OrderBy::OrderByCursor::Pull(Frame &frame, ExecutionContext &context) { SCOPED_PROFILE_OP("OrderBy"); @@ -2798,8 +2823,9 @@ bool Merge::Accept(HierarchicalLogicalOperatorVisitor &visitor) { return visitor.PostVisit(*this); } -std::unique_ptr Merge::MakeCursor(database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); +std::unique_ptr Merge::MakeCursor(database::GraphDbAccessor *db, + utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::vector Merge::ModifiedSymbols(const SymbolTable &table) const { @@ -2812,10 +2838,11 @@ std::vector Merge::ModifiedSymbols(const SymbolTable &table) const { } Merge::MergeCursor::MergeCursor(const Merge &self, - database::GraphDbAccessor &db) - : input_cursor_(self.input_->MakeCursor(db)), - merge_match_cursor_(self.merge_match_->MakeCursor(db)), - merge_create_cursor_(self.merge_create_->MakeCursor(db)) {} + database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : input_cursor_(self.input_->MakeCursor(db, mem)), + merge_match_cursor_(self.merge_match_->MakeCursor(db, mem)), + merge_create_cursor_(self.merge_create_->MakeCursor(db, mem)) {} bool Merge::MergeCursor::Pull(Frame &frame, ExecutionContext &context) { SCOPED_PROFILE_OP("Merge"); @@ -2883,9 +2910,9 @@ bool Optional::Accept(HierarchicalLogicalOperatorVisitor &visitor) { return visitor.PostVisit(*this); } -std::unique_ptr Optional::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); +std::unique_ptr Optional::MakeCursor(database::GraphDbAccessor *db, + utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::vector Optional::ModifiedSymbols(const SymbolTable &table) const { @@ -2896,10 +2923,11 @@ std::vector Optional::ModifiedSymbols(const SymbolTable &table) const { } Optional::OptionalCursor::OptionalCursor(const Optional &self, - database::GraphDbAccessor &db) + database::GraphDbAccessor *db, + utils::MemoryResource *mem) : self_(self), - input_cursor_(self.input_->MakeCursor(db)), - optional_cursor_(self.optional_->MakeCursor(db)) {} + input_cursor_(self.input_->MakeCursor(db, mem)), + optional_cursor_(self.optional_->MakeCursor(db, mem)) {} bool Optional::OptionalCursor::Pull(Frame &frame, ExecutionContext &context) { SCOPED_PROFILE_OP("Optional"); @@ -2959,9 +2987,9 @@ Unwind::Unwind(const std::shared_ptr &input, ACCEPT_WITH_INPUT(Unwind) -std::unique_ptr Unwind::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); +std::unique_ptr Unwind::MakeCursor(database::GraphDbAccessor *db, + utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::vector Unwind::ModifiedSymbols(const SymbolTable &table) const { @@ -2971,8 +2999,9 @@ std::vector Unwind::ModifiedSymbols(const SymbolTable &table) const { } Unwind::UnwindCursor::UnwindCursor(const Unwind &self, - database::GraphDbAccessor &db) - : self_(self), db_(db), input_cursor_(self.input_->MakeCursor(db)) {} + database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : self_(self), db_(*db), input_cursor_(self.input_->MakeCursor(db, mem)) {} bool Unwind::UnwindCursor::Pull(Frame &frame, ExecutionContext &context) { SCOPED_PROFILE_OP("Unwind"); @@ -3020,9 +3049,9 @@ Distinct::Distinct(const std::shared_ptr &input, ACCEPT_WITH_INPUT(Distinct) -std::unique_ptr Distinct::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); +std::unique_ptr Distinct::MakeCursor(database::GraphDbAccessor *db, + utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } std::vector Distinct::OutputSymbols( @@ -3036,8 +3065,9 @@ std::vector Distinct::ModifiedSymbols(const SymbolTable &table) const { } Distinct::DistinctCursor::DistinctCursor(const Distinct &self, - database::GraphDbAccessor &db) - : self_(self), input_cursor_(self.input_->MakeCursor(db)) {} + database::GraphDbAccessor *db, + utils::MemoryResource *mem) + : self_(self), input_cursor_(self.input_->MakeCursor(db, mem)) {} bool Distinct::DistinctCursor::Pull(Frame &frame, ExecutionContext &context) { SCOPED_PROFILE_OP("Distinct"); @@ -3071,8 +3101,9 @@ Union::Union(const std::shared_ptr &left_op, left_symbols_(left_symbols), right_symbols_(right_symbols) {} -std::unique_ptr Union::MakeCursor(database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); +std::unique_ptr Union::MakeCursor(database::GraphDbAccessor *db, + utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } bool Union::Accept(HierarchicalLogicalOperatorVisitor &visitor) { @@ -3095,10 +3126,11 @@ std::vector Union::ModifiedSymbols(const SymbolTable &) const { WITHOUT_SINGLE_INPUT(Union); Union::UnionCursor::UnionCursor(const Union &self, - database::GraphDbAccessor &db) + database::GraphDbAccessor *db, + utils::MemoryResource *mem) : self_(self), - left_cursor_(self.left_op_->MakeCursor(db)), - right_cursor_(self.right_op_->MakeCursor(db)) {} + left_cursor_(self.left_op_->MakeCursor(db, mem)), + right_cursor_(self.right_op_->MakeCursor(db, mem)) {} bool Union::UnionCursor::Pull(Frame &frame, ExecutionContext &context) { SCOPED_PROFILE_OP("Union"); @@ -3155,10 +3187,11 @@ namespace { class CartesianCursor : public Cursor { public: - CartesianCursor(const Cartesian &self, database::GraphDbAccessor &db) + CartesianCursor(const Cartesian &self, database::GraphDbAccessor *db, + utils::MemoryResource *mem) : self_(self), - left_op_cursor_(self.left_op_->MakeCursor(db)), - right_op_cursor_(self_.right_op_->MakeCursor(db)) { + left_op_cursor_(self.left_op_->MakeCursor(db, mem)), + right_op_cursor_(self_.right_op_->MakeCursor(db, mem)) { CHECK(left_op_cursor_ != nullptr) << "CartesianCursor: Missing left operator cursor."; CHECK(right_op_cursor_ != nullptr) @@ -3237,8 +3270,8 @@ class CartesianCursor : public Cursor { } // namespace std::unique_ptr Cartesian::MakeCursor( - database::GraphDbAccessor &db) const { - return std::make_unique(*this, db); + database::GraphDbAccessor *db, utils::MemoryResource *mem) const { + return std::make_unique(*this, db, mem); } OutputTable::OutputTable(std::vector output_symbols, @@ -3293,8 +3326,8 @@ class OutputTableCursor : public Cursor { bool pulled_{false}; }; -std::unique_ptr OutputTable::MakeCursor( - database::GraphDbAccessor &dba) const { +std::unique_ptr OutputTable::MakeCursor(database::GraphDbAccessor *, + utils::MemoryResource *) const { return std::make_unique(*this); } diff --git a/src/query/plan/operator.lcp b/src/query/plan/operator.lcp index c66572693..c9cc7d848 100644 --- a/src/query/plan/operator.lcp +++ b/src/query/plan/operator.lcp @@ -18,6 +18,7 @@ #include "utils/bound.hpp" #include "utils/future.hpp" #include "utils/hashing/fnv.hpp" +#include "utils/memory.hpp" #include "utils/visitor.hpp" namespace database { @@ -148,13 +149,19 @@ can serve as inputs to others and thus a sequence of operations is formed.") #>cpp virtual ~LogicalOperator() {} - /** Constructs a @c Cursor which is used to run this operator. + /** Construct a @c Cursor which is used to run this operator. * - * @param database::GraphDbAccessor Used to perform operations on the - * database. + * @param database::GraphDbAccessor Used to perform operations on the + * database. + * @param utils::MemoryResource Memory resource used for allocations during + * the lifetime of the returned Cursor. */ virtual std::unique_ptr MakeCursor( - database::GraphDbAccessor &) const = 0; + database::GraphDbAccessor *, utils::MemoryResource *) const = 0; + + std::unique_ptr MakeCursor(database::GraphDbAccessor &dba) const { + return MakeCursor(&dba, utils::NewDeleteResource()); + } /** Return @c Symbol vector where the query results will be stored. * @@ -347,7 +354,7 @@ and false on every following Pull.") #>cpp DEFVISITABLE(HierarchicalLogicalOperatorVisitor); std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override { return {}; } @@ -471,7 +478,7 @@ a preceeding `MATCH`), or multiple nodes (`MATCH ... CREATE` or const NodeCreationInfo &node_info); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -484,7 +491,8 @@ a preceeding `MATCH`), or multiple nodes (`MATCH ... CREATE` or #>cpp class CreateNodeCursor : public Cursor { public: - CreateNodeCursor(const CreateNode &self, database::GraphDbAccessor &db); + CreateNodeCursor(const CreateNode &, database::GraphDbAccessor *, + utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -584,7 +592,7 @@ chained in cases when longer paths need creating. Symbol input_symbol, bool existing_node); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -597,7 +605,8 @@ chained in cases when longer paths need creating. #>cpp class CreateExpandCursor : public Cursor { public: - CreateExpandCursor(const CreateExpand &self, database::GraphDbAccessor &db); + CreateExpandCursor(const CreateExpand &, database::GraphDbAccessor *, + utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -669,7 +678,7 @@ with a constructor argument. GraphView graph_view = GraphView::OLD); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -698,7 +707,7 @@ given label. GraphView graph_view = GraphView::OLD); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; cpp<#) (:serialize (:slk) (:capnp)) (:clone)) @@ -844,7 +853,7 @@ property value which is inside a range (inclusive or exlusive). bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; cpp<#) (:serialize (:slk) (:capnp)) (:clone)) @@ -887,7 +896,7 @@ property value. bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; cpp<#) (:serialize (:slk) (:capnp)) (:clone)) @@ -973,7 +982,7 @@ pulled.") bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -984,7 +993,8 @@ pulled.") class ExpandCursor : public Cursor { public: - ExpandCursor(const Expand &self, database::GraphDbAccessor &db); + ExpandCursor(const Expand &, database::GraphDbAccessor *, + utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -1162,7 +1172,7 @@ pulled.") bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -1205,7 +1215,7 @@ pulled.") path_elements_(path_elements) {} bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -1242,7 +1252,7 @@ a boolean value.") Expression *expression_); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -1255,7 +1265,8 @@ a boolean value.") #>cpp class FilterCursor : public Cursor { public: - FilterCursor(const Filter &self, database::GraphDbAccessor &db); + FilterCursor(const Filter &, database::GraphDbAccessor *, + utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -1298,7 +1309,7 @@ RETURN clause) the Produce's pull succeeds exactly once.") const std::vector &named_expressions); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector OutputSymbols(const SymbolTable &) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; @@ -1312,7 +1323,8 @@ RETURN clause) the Produce's pull succeeds exactly once.") #>cpp class ProduceCursor : public Cursor { public: - ProduceCursor(const Produce &self, database::GraphDbAccessor &db); + ProduceCursor(const Produce &, database::GraphDbAccessor *, + utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -1352,7 +1364,7 @@ Has a flag for using DETACH DELETE when deleting vertices.") const std::vector &expressions, bool detach_); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -1365,7 +1377,8 @@ Has a flag for using DETACH DELETE when deleting vertices.") #>cpp class DeleteCursor : public Cursor { public: - DeleteCursor(const Delete &self, database::GraphDbAccessor &db); + DeleteCursor(const Delete &, database::GraphDbAccessor *, + utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -1410,7 +1423,7 @@ can be stored (a TypedValue that can be converted to PropertyValue).") Expression *rhs); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -1423,7 +1436,8 @@ can be stored (a TypedValue that can be converted to PropertyValue).") #>cpp class SetPropertyCursor : public Cursor { public: - SetPropertyCursor(const SetProperty &self, database::GraphDbAccessor &db); + SetPropertyCursor(const SetProperty &, database::GraphDbAccessor *, + utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -1474,7 +1488,7 @@ that the old properties are discarded and replaced with new ones.") Symbol input_symbol, Expression *rhs, Op op); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -1487,8 +1501,8 @@ that the old properties are discarded and replaced with new ones.") #>cpp class SetPropertiesCursor : public Cursor { public: - SetPropertiesCursor(const SetProperties &self, - database::GraphDbAccessor &db); + SetPropertiesCursor(const SetProperties &, database::GraphDbAccessor *, + utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -1532,7 +1546,7 @@ It does NOT remove labels that are already set on that Vertex.") const std::vector &labels); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -1545,7 +1559,8 @@ It does NOT remove labels that are already set on that Vertex.") #>cpp class SetLabelsCursor : public Cursor { public: - SetLabelsCursor(const SetLabels &self, database::GraphDbAccessor &db); + SetLabelsCursor(const SetLabels &, database::GraphDbAccessor *, + utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -1580,7 +1595,7 @@ It does NOT remove labels that are already set on that Vertex.") storage::Property property, PropertyLookup *lhs); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -1593,8 +1608,8 @@ It does NOT remove labels that are already set on that Vertex.") #>cpp class RemovePropertyCursor : public Cursor { public: - RemovePropertyCursor(const RemoveProperty &self, - database::GraphDbAccessor &db); + RemovePropertyCursor(const RemoveProperty &, database::GraphDbAccessor *, + utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -1629,7 +1644,7 @@ If a label does not exist on a Vertex, nothing happens.") Symbol input_symbol, const std::vector &labels); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -1642,7 +1657,8 @@ If a label does not exist on a Vertex, nothing happens.") #>cpp class RemoveLabelsCursor : public Cursor { public: - RemoveLabelsCursor(const RemoveLabels &self, database::GraphDbAccessor &db); + RemoveLabelsCursor(const RemoveLabels &, database::GraphDbAccessor *, + utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -1688,7 +1704,7 @@ edge lists).") const std::vector &previous_symbols); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -1701,8 +1717,9 @@ edge lists).") #>cpp class EdgeUniquenessFilterCursor : public Cursor { public: - EdgeUniquenessFilterCursor(const EdgeUniquenessFilter &self, - database::GraphDbAccessor &db); + EdgeUniquenessFilterCursor(const EdgeUniquenessFilter &, + database::GraphDbAccessor *, + utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -1760,7 +1777,7 @@ has been cached will be reconstructed before Pull returns. const std::vector &symbols, bool advance_command = false); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -1773,7 +1790,8 @@ has been cached will be reconstructed before Pull returns. #>cpp class AccumulateCursor : public Cursor { public: - AccumulateCursor(const Accumulate &self, database::GraphDbAccessor &db); + AccumulateCursor(const Accumulate &, database::GraphDbAccessor *, + utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -1893,7 +1911,7 @@ elements are in an undefined state after aggregation.") const std::vector &remember); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -1906,7 +1924,8 @@ elements are in an undefined state after aggregation.") #>cpp class AggregateCursor : public Cursor { public: - AggregateCursor(const Aggregate &self, database::GraphDbAccessor &db); + AggregateCursor(const Aggregate &, database::GraphDbAccessor *, + utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -2017,7 +2036,7 @@ operator's implementation does not expect this.") Skip(const std::shared_ptr &input, Expression *expression); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector OutputSymbols(const SymbolTable &) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; @@ -2031,7 +2050,8 @@ operator's implementation does not expect this.") #>cpp class SkipCursor : public Cursor { public: - SkipCursor(const Skip &self, database::GraphDbAccessor &db); + SkipCursor(const Skip &, database::GraphDbAccessor *, + utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -2081,7 +2101,7 @@ input should be performed).") Limit(const std::shared_ptr &input, Expression *expression); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector OutputSymbols(const SymbolTable &) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; @@ -2095,7 +2115,8 @@ input should be performed).") #>cpp class LimitCursor : public Cursor { public: - LimitCursor(const Limit &self, database::GraphDbAccessor &db); + LimitCursor(const Limit &, database::GraphDbAccessor *, + utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -2149,7 +2170,7 @@ are valid for usage after the OrderBy operator.") const std::vector &output_symbols); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector OutputSymbols(const SymbolTable &) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; @@ -2163,7 +2184,8 @@ are valid for usage after the OrderBy operator.") #>cpp class OrderByCursor : public Cursor { public: - OrderByCursor(const OrderBy &self, database::GraphDbAccessor &db); + OrderByCursor(const OrderBy &, database::GraphDbAccessor *, + utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -2222,7 +2244,7 @@ documentation.") const std::shared_ptr &merge_create); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; // TODO: Consider whether we want to treat Merge as having single input. It @@ -2238,7 +2260,8 @@ documentation.") #>cpp class MergeCursor : public Cursor { public: - MergeCursor(const Merge &self, database::GraphDbAccessor &db); + MergeCursor(const Merge &, database::GraphDbAccessor *, + utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -2289,7 +2312,7 @@ and returns true, once.") const std::vector &optional_symbols); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { return true; } @@ -2302,7 +2325,8 @@ and returns true, once.") #>cpp class OptionalCursor : public Cursor { public: - OptionalCursor(const Optional &self, database::GraphDbAccessor &db); + OptionalCursor(const Optional &, database::GraphDbAccessor *, + utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -2347,7 +2371,7 @@ Input is optional (unwind can be the first clause in a query).") Expression *input_expression_, Symbol output_symbol); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override { @@ -2362,7 +2386,8 @@ Input is optional (unwind can be the first clause in a query).") #>cpp class UnwindCursor : public Cursor { public: - UnwindCursor(const Unwind &self, database::GraphDbAccessor &db); + UnwindCursor(const Unwind &, database::GraphDbAccessor *, + utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -2404,7 +2429,7 @@ This implementation maintains input ordering.") const std::vector &value_symbols); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector OutputSymbols(const SymbolTable &) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; @@ -2418,7 +2443,8 @@ This implementation maintains input ordering.") #>cpp class DistinctCursor : public Cursor { public: - DistinctCursor(const Distinct &self, database::GraphDbAccessor &db); + DistinctCursor(const Distinct &, database::GraphDbAccessor *, + utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; @@ -2477,7 +2503,7 @@ of symbols used by each of the inputs.") const std::vector &right_symbols); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector OutputSymbols(const SymbolTable &) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; @@ -2489,7 +2515,8 @@ of symbols used by each of the inputs.") #>cpp class UnionCursor : public Cursor { public: - UnionCursor(const Union &self, database::GraphDbAccessor &db); + UnionCursor(const Union &, database::GraphDbAccessor *, + utils::MemoryResource *); bool Pull(Frame &, ExecutionContext &) override; void Shutdown() override; void Reset() override; @@ -2537,8 +2564,8 @@ of symbols used by each of the inputs.") right_symbols_(right_symbols) {} bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; - std::unique_ptr MakeCursor( - database::GraphDbAccessor &db) const override; + std::unique_ptr MakeCursor( + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector ModifiedSymbols(const SymbolTable &) const override; bool HasSingleInput() const override; @@ -2568,7 +2595,7 @@ of symbols used by each of the inputs.") } std::unique_ptr MakeCursor( - database::GraphDbAccessor &) const override; + database::GraphDbAccessor *, utils::MemoryResource *) const override; std::vector OutputSymbols(const SymbolTable &) const override { return output_symbols_; } diff --git a/tests/unit/bfs_common.hpp b/tests/unit/bfs_common.hpp index 872a2defc..c06d459f8 100644 --- a/tests/unit/bfs_common.hpp +++ b/tests/unit/bfs_common.hpp @@ -110,8 +110,9 @@ class Yield : public query::plan::LogicalOperator { values_(values) {} std::unique_ptr MakeCursor( - database::GraphDbAccessor &dba) const override { - return std::make_unique(this, input_->MakeCursor(dba)); + database::GraphDbAccessor *dba, + utils::MemoryResource *mem) const override { + return std::make_unique(this, input_->MakeCursor(dba, mem)); } std::vector ModifiedSymbols( const query::SymbolTable &) const override { diff --git a/tests/unit/distributed_reset.cpp b/tests/unit/distributed_reset.cpp index 6b2d16d61..e6df8efea 100644 --- a/tests/unit/distributed_reset.cpp +++ b/tests/unit/distributed_reset.cpp @@ -20,7 +20,8 @@ TEST_F(DistributedReset, ResetTest) { auto dba = master().Access(); query::Frame frame(0); query::ExecutionContext context{dba.get()}; - auto pull_remote_cursor = pull_remote->MakeCursor(*dba); + auto pull_remote_cursor = + pull_remote->query::plan::LogicalOperator::MakeCursor(*dba); for (int i = 0; i < 3; ++i) { EXPECT_TRUE(pull_remote_cursor->Pull(frame, context)); diff --git a/tests/unit/query_plan_common.hpp b/tests/unit/query_plan_common.hpp index abb9eab8d..fa16e6e19 100644 --- a/tests/unit/query_plan_common.hpp +++ b/tests/unit/query_plan_common.hpp @@ -42,7 +42,8 @@ std::vector> CollectProduce(const Produce &produce, symbols.emplace_back(context->symbol_table.at(*named_expression)); // stream out results - auto cursor = produce.MakeCursor(*context->db_accessor); + auto cursor = + produce.query::plan::LogicalOperator::MakeCursor(*context->db_accessor); std::vector> results; while (cursor->Pull(frame, *context)) { std::vector values; diff --git a/tests/unit/query_plan_create_set_remove_delete.cpp b/tests/unit/query_plan_create_set_remove_delete.cpp index 91ecf982d..95ffe3136 100644 --- a/tests/unit/query_plan_create_set_remove_delete.cpp +++ b/tests/unit/query_plan_create_set_remove_delete.cpp @@ -280,7 +280,8 @@ TEST(QueryPlan, Delete) { n.op_, std::vector{n_get}, true); Frame frame(symbol_table.max_position()); auto context = MakeContext(storage, symbol_table, &dba); - delete_op->MakeCursor(dba)->Pull(frame, context); + delete_op->query::plan::LogicalOperator::MakeCursor(dba)->Pull(frame, + context); dba.AdvanceCommand(); EXPECT_EQ(3, CountIterable(dba.Vertices(false))); EXPECT_EQ(3, CountIterable(dba.Edges(false)));