Accept utils::MemoryResource in MakeCursor

Summary:
This API change is needed in order to propagate the memory allocation
scheme for the execution of LogicalOperator::Cursor

Depends on D1990

Reviewers: mtomic, mferencevic

Reviewed By: mtomic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1980
This commit is contained in:
Teon Banek 2019-04-24 11:14:16 +02:00
parent 2904e86158
commit e3fbe56588
8 changed files with 338 additions and 263 deletions

View File

@ -389,13 +389,15 @@ class RemotePuller {
class PullRemoteCursor : public Cursor { class PullRemoteCursor : public Cursor {
public: public:
PullRemoteCursor(const PullRemote &self, database::GraphDbAccessor &db) PullRemoteCursor(const PullRemote &self, database::GraphDbAccessor *db,
utils::MemoryResource *mem)
: self_(self), : self_(self),
input_cursor_(self.input() ? self.input()->MakeCursor(db) : nullptr), input_cursor_(self.input() ? self.input()->MakeCursor(db, mem)
command_id_(db.transaction().cid()), : nullptr),
command_id_(db->transaction().cid()),
remote_puller_( remote_puller_(
// TODO: Pass in a Master GraphDb. // TODO: Pass in a Master GraphDb.
&dynamic_cast<database::Master *>(&db.db())->pull_clients(), db, &dynamic_cast<database::Master *>(&db->db())->pull_clients(), *db,
self.symbols_, self.plan_id_, command_id_) {} self.symbols_, self.plan_id_, command_id_) {}
bool Pull(Frame &frame, ExecutionContext &context) override { bool Pull(Frame &frame, ExecutionContext &context) override {
@ -494,24 +496,26 @@ class PullRemoteCursor : public Cursor {
class SynchronizeCursor : public Cursor { class SynchronizeCursor : public Cursor {
public: public:
SynchronizeCursor(const Synchronize &self, database::GraphDbAccessor &db) SynchronizeCursor(const Synchronize &self, database::GraphDbAccessor *db,
utils::MemoryResource *mem)
: self_(self), : self_(self),
pull_clients_( pull_clients_(
// TODO: Pass in a Master GraphDb. // TODO: Pass in a Master GraphDb.
&dynamic_cast<database::Master *>(&db.db())->pull_clients()), &dynamic_cast<database::Master *>(&db->db())->pull_clients()),
updates_clients_( updates_clients_(
// TODO: Pass in a Master GraphDb. // TODO: Pass in a Master GraphDb.
&dynamic_cast<database::Master *>(&db.db())->updates_clients()), &dynamic_cast<database::Master *>(&db->db())->updates_clients()),
updates_server_( updates_server_(
// TODO: Pass in a Master GraphDb. // TODO: Pass in a Master GraphDb.
&dynamic_cast<database::Master *>(&db.db())->updates_server()), &dynamic_cast<database::Master *>(&db->db())->updates_server()),
input_cursor_(self.input()->MakeCursor(db)), input_cursor_(self.input()->MakeCursor(db, mem)),
pull_remote_cursor_( pull_remote_cursor_(self.pull_remote_
self.pull_remote_ ? self.pull_remote_->MakeCursor(db) : nullptr), ? self.pull_remote_->MakeCursor(db, mem)
command_id_(db.transaction().cid()), : nullptr),
command_id_(db->transaction().cid()),
master_id_( master_id_(
// TODO: Pass in a Master GraphDb. // TODO: Pass in a Master GraphDb.
dynamic_cast<database::Master *>(&db.db())->WorkerId()) {} dynamic_cast<database::Master *>(&db->db())->WorkerId()) {}
bool Pull(Frame &frame, ExecutionContext &context) override { bool Pull(Frame &frame, ExecutionContext &context) override {
if (!initial_pull_done_) { if (!initial_pull_done_) {
@ -663,13 +667,14 @@ class SynchronizeCursor : public Cursor {
class PullRemoteOrderByCursor : public Cursor { class PullRemoteOrderByCursor : public Cursor {
public: public:
PullRemoteOrderByCursor(const PullRemoteOrderBy &self, PullRemoteOrderByCursor(const PullRemoteOrderBy &self,
database::GraphDbAccessor &db) database::GraphDbAccessor *db,
utils::MemoryResource *mem)
: self_(self), : self_(self),
input_(self.input()->MakeCursor(db)), input_(self.input()->MakeCursor(db, mem)),
command_id_(db.transaction().cid()), command_id_(db->transaction().cid()),
remote_puller_( remote_puller_(
// TODO: Pass in a Master GraphDb. // TODO: Pass in a Master GraphDb.
&dynamic_cast<database::Master *>(&db.db())->pull_clients(), db, &dynamic_cast<database::Master *>(&db->db())->pull_clients(), *db,
self.symbols_, self.plan_id_, command_id_) {} self.symbols_, self.plan_id_, command_id_) {}
bool Pull(Frame &frame, ExecutionContext &context) override { bool Pull(Frame &frame, ExecutionContext &context) override {
@ -817,8 +822,9 @@ class PullRemoteOrderByCursor : public Cursor {
class DistributedExpandCursor : public query::plan::Cursor { class DistributedExpandCursor : public query::plan::Cursor {
public: public:
DistributedExpandCursor(const DistributedExpand *self, DistributedExpandCursor(const DistributedExpand *self,
database::GraphDbAccessor *db) database::GraphDbAccessor *db,
: input_cursor_(self->input()->MakeCursor(*db)), self_(self) {} utils::MemoryResource *mem)
: input_cursor_(self->input()->MakeCursor(db, mem)), self_(self) {}
bool Pull(Frame &frame, ExecutionContext &context) override { bool Pull(Frame &frame, ExecutionContext &context) override {
// A helper function for expanding a node from an edge. // 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 { class DistributedExpandBfsCursor : public query::plan::Cursor {
public: public:
DistributedExpandBfsCursor(const DistributedExpandBfs &self, DistributedExpandBfsCursor(const DistributedExpandBfs &self,
database::GraphDbAccessor &db) database::GraphDbAccessor *db,
: self_(self), db_(db), input_cursor_(self_.input()->MakeCursor(db)) {} utils::MemoryResource *mem)
: self_(self),
db_(*db),
input_cursor_(self_.input()->MakeCursor(db, mem)) {}
void InitSubcursors(database::GraphDbAccessor *dba, void InitSubcursors(database::GraphDbAccessor *dba,
const query::SymbolTable &symbol_table, const query::SymbolTable &symbol_table,
@ -1082,9 +1091,9 @@ class DistributedExpandBfsCursor : public query::plan::Cursor {
} }
// Evaluator for the filtering condition and expansion depth. // Evaluator for the filtering condition and expansion depth.
ExpressionEvaluator evaluator( ExpressionEvaluator evaluator(&frame, context.symbol_table,
&frame, context.symbol_table, context.evaluation_context, context.evaluation_context,
context.db_accessor, GraphView::OLD); context.db_accessor, GraphView::OLD);
while (true) { while (true) {
if (context.db_accessor->should_abort()) throw HintedAbortError(); if (context.db_accessor->should_abort()) throw HintedAbortError();
@ -1283,8 +1292,9 @@ VertexAccessor &CreateVertexOnWorker(int worker_id,
class DistributedCreateNodeCursor : public query::plan::Cursor { class DistributedCreateNodeCursor : public query::plan::Cursor {
public: public:
DistributedCreateNodeCursor(const DistributedCreateNode *self, DistributedCreateNodeCursor(const DistributedCreateNode *self,
database::GraphDbAccessor *dba) database::GraphDbAccessor *dba,
: input_cursor_(self->input()->MakeCursor(*dba)), utils::MemoryResource *mem)
: input_cursor_(self->input()->MakeCursor(dba, mem)),
db_(&dba->db()), db_(&dba->db()),
node_info_(self->node_info_), node_info_(self->node_info_),
on_random_worker_(self->on_random_worker_) { on_random_worker_(self->on_random_worker_) {
@ -1317,8 +1327,9 @@ class DistributedCreateNodeCursor : public query::plan::Cursor {
class DistributedCreateExpandCursor : public query::plan::Cursor { class DistributedCreateExpandCursor : public query::plan::Cursor {
public: public:
DistributedCreateExpandCursor(const DistributedCreateExpand *self, DistributedCreateExpandCursor(const DistributedCreateExpand *self,
database::GraphDbAccessor *dba) database::GraphDbAccessor *dba,
: input_cursor_(self->input()->MakeCursor(*dba)), utils::MemoryResource *mem)
: input_cursor_(self->input()->MakeCursor(dba, mem)),
self_(self), self_(self),
db_(&dba->db()) { db_(&dba->db()) {
CHECK(db_); CHECK(db_);
@ -1400,38 +1411,38 @@ class DistributedCreateExpandCursor : public query::plan::Cursor {
} // namespace } // namespace
std::unique_ptr<Cursor> PullRemote::MakeCursor( std::unique_ptr<Cursor> PullRemote::MakeCursor(
database::GraphDbAccessor &db) const { database::GraphDbAccessor *db, utils::MemoryResource *mem) const {
return std::make_unique<PullRemoteCursor>(*this, db); return std::make_unique<PullRemoteCursor>(*this, db, mem);
} }
std::unique_ptr<Cursor> Synchronize::MakeCursor( std::unique_ptr<Cursor> Synchronize::MakeCursor(
database::GraphDbAccessor &db) const { database::GraphDbAccessor *db, utils::MemoryResource *mem) const {
return std::make_unique<SynchronizeCursor>(*this, db); return std::make_unique<SynchronizeCursor>(*this, db, mem);
} }
std::unique_ptr<Cursor> PullRemoteOrderBy::MakeCursor( std::unique_ptr<Cursor> PullRemoteOrderBy::MakeCursor(
database::GraphDbAccessor &db) const { database::GraphDbAccessor *db, utils::MemoryResource *mem) const {
return std::make_unique<PullRemoteOrderByCursor>(*this, db); return std::make_unique<PullRemoteOrderByCursor>(*this, db, mem);
} }
std::unique_ptr<Cursor> DistributedExpand::MakeCursor( std::unique_ptr<Cursor> DistributedExpand::MakeCursor(
database::GraphDbAccessor &db) const { database::GraphDbAccessor *db, utils::MemoryResource *mem) const {
return std::make_unique<DistributedExpandCursor>(this, &db); return std::make_unique<DistributedExpandCursor>(this, db, mem);
} }
std::unique_ptr<Cursor> DistributedExpandBfs::MakeCursor( std::unique_ptr<Cursor> DistributedExpandBfs::MakeCursor(
database::GraphDbAccessor &db) const { database::GraphDbAccessor *db, utils::MemoryResource *mem) const {
return std::make_unique<DistributedExpandBfsCursor>(*this, db); return std::make_unique<DistributedExpandBfsCursor>(*this, db, mem);
} }
std::unique_ptr<Cursor> DistributedCreateNode::MakeCursor( std::unique_ptr<Cursor> DistributedCreateNode::MakeCursor(
database::GraphDbAccessor &db) const { database::GraphDbAccessor *db, utils::MemoryResource *mem) const {
return std::make_unique<DistributedCreateNodeCursor>(this, &db); return std::make_unique<DistributedCreateNodeCursor>(this, db, mem);
} }
std::unique_ptr<Cursor> DistributedCreateExpand::MakeCursor( std::unique_ptr<Cursor> DistributedCreateExpand::MakeCursor(
database::GraphDbAccessor &db) const { database::GraphDbAccessor *db, utils::MemoryResource *mem) const {
return std::make_unique<DistributedCreateExpandCursor>(this, &db); return std::make_unique<DistributedCreateExpandCursor>(this, db, mem);
} }
} // namespace query::plan } // namespace query::plan

View File

@ -74,7 +74,7 @@ time on data transfer. It gives no guarantees on result order.")
: input_(input), plan_id_(plan_id), symbols_(symbols) {} : input_(input), plan_id_(plan_id), symbols_(symbols) {}
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> OutputSymbols(const SymbolTable &) const override; std::vector<Symbol> OutputSymbols(const SymbolTable &) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
@ -160,7 +160,7 @@ Logic of the synchronize operator is:
advance_command_(advance_command) {} advance_command_(advance_command) {}
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
std::vector<Symbol> OutputSymbols( std::vector<Symbol> OutputSymbols(
@ -209,7 +209,7 @@ by having only one result from each worker.")
const std::vector<SortItem> &order_by, const std::vector<Symbol> &symbols); const std::vector<SortItem> &order_by, const std::vector<Symbol> &symbols);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
std::vector<Symbol> OutputSymbols(const SymbolTable &) const override; std::vector<Symbol> OutputSymbols(const SymbolTable &) const override;
@ -255,7 +255,7 @@ by having only one result from each worker.")
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -318,7 +318,7 @@ by having only one result from each worker.")
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -355,7 +355,7 @@ by having only one result from each worker.")
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -403,7 +403,7 @@ by having only one result from each worker.")
Symbol input_symbol, bool existing_node); Symbol input_symbol, bool existing_node);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }

View File

@ -92,7 +92,8 @@ bool Once::OnceCursor::Pull(Frame &, ExecutionContext &context) {
return false; return false;
} }
std::unique_ptr<Cursor> Once::MakeCursor(database::GraphDbAccessor &) const { std::unique_ptr<Cursor> Once::MakeCursor(database::GraphDbAccessor *,
utils::MemoryResource *) const {
return std::make_unique<OnceCursor>(); return std::make_unique<OnceCursor>();
} }
@ -128,8 +129,8 @@ VertexAccessor &CreateLocalVertex(const NodeCreationInfo &node_info,
ACCEPT_WITH_INPUT(CreateNode) ACCEPT_WITH_INPUT(CreateNode)
std::unique_ptr<Cursor> CreateNode::MakeCursor( std::unique_ptr<Cursor> CreateNode::MakeCursor(
database::GraphDbAccessor &db) const { database::GraphDbAccessor *db, utils::MemoryResource *mem) const {
return std::make_unique<CreateNodeCursor>(*this, db); return std::make_unique<CreateNodeCursor>(*this, db, mem);
} }
std::vector<Symbol> CreateNode::ModifiedSymbols( std::vector<Symbol> CreateNode::ModifiedSymbols(
@ -140,8 +141,9 @@ std::vector<Symbol> CreateNode::ModifiedSymbols(
} }
CreateNode::CreateNodeCursor::CreateNodeCursor(const CreateNode &self, CreateNode::CreateNodeCursor::CreateNodeCursor(const CreateNode &self,
database::GraphDbAccessor &db) database::GraphDbAccessor *db,
: self_(self), input_cursor_(self.input_->MakeCursor(db)) {} utils::MemoryResource *mem)
: self_(self), input_cursor_(self.input_->MakeCursor(db, mem)) {}
bool CreateNode::CreateNodeCursor::Pull(Frame &frame, bool CreateNode::CreateNodeCursor::Pull(Frame &frame,
ExecutionContext &context) { ExecutionContext &context) {
@ -172,8 +174,8 @@ CreateExpand::CreateExpand(const NodeCreationInfo &node_info,
ACCEPT_WITH_INPUT(CreateExpand) ACCEPT_WITH_INPUT(CreateExpand)
std::unique_ptr<Cursor> CreateExpand::MakeCursor( std::unique_ptr<Cursor> CreateExpand::MakeCursor(
database::GraphDbAccessor &db) const { database::GraphDbAccessor *db, utils::MemoryResource *mem) const {
return std::make_unique<CreateExpandCursor>(*this, db); return std::make_unique<CreateExpandCursor>(*this, db, mem);
} }
std::vector<Symbol> CreateExpand::ModifiedSymbols( std::vector<Symbol> CreateExpand::ModifiedSymbols(
@ -185,8 +187,9 @@ std::vector<Symbol> CreateExpand::ModifiedSymbols(
} }
CreateExpand::CreateExpandCursor::CreateExpandCursor( CreateExpand::CreateExpandCursor::CreateExpandCursor(
const CreateExpand &self, database::GraphDbAccessor &db) const CreateExpand &self, database::GraphDbAccessor *db,
: self_(self), db_(db), input_cursor_(self.input_->MakeCursor(db)) {} utils::MemoryResource *mem)
: self_(self), db_(*db), input_cursor_(self.input_->MakeCursor(db, mem)) {}
bool CreateExpand::CreateExpandCursor::Pull(Frame &frame, bool CreateExpand::CreateExpandCursor::Pull(Frame &frame,
ExecutionContext &context) { ExecutionContext &context) {
@ -316,13 +319,13 @@ ScanAll::ScanAll(const std::shared_ptr<LogicalOperator> &input,
ACCEPT_WITH_INPUT(ScanAll) ACCEPT_WITH_INPUT(ScanAll)
std::unique_ptr<Cursor> ScanAll::MakeCursor( std::unique_ptr<Cursor> ScanAll::MakeCursor(database::GraphDbAccessor *db,
database::GraphDbAccessor &db) const { utils::MemoryResource *mem) const {
auto vertices = [this, &db](Frame &, ExecutionContext &) { auto vertices = [this, db](Frame &, ExecutionContext &) {
return std::make_optional(db.Vertices(graph_view_ == GraphView::NEW)); return std::make_optional(db->Vertices(graph_view_ == GraphView::NEW));
}; };
return std::make_unique<ScanAllCursor<decltype(vertices)>>( return std::make_unique<ScanAllCursor<decltype(vertices)>>(
output_symbol_, input_->MakeCursor(db), std::move(vertices), db); output_symbol_, input_->MakeCursor(db, mem), std::move(vertices), *db);
} }
std::vector<Symbol> ScanAll::ModifiedSymbols(const SymbolTable &table) const { std::vector<Symbol> ScanAll::ModifiedSymbols(const SymbolTable &table) const {
@ -339,13 +342,13 @@ ScanAllByLabel::ScanAllByLabel(const std::shared_ptr<LogicalOperator> &input,
ACCEPT_WITH_INPUT(ScanAllByLabel) ACCEPT_WITH_INPUT(ScanAllByLabel)
std::unique_ptr<Cursor> ScanAllByLabel::MakeCursor( std::unique_ptr<Cursor> ScanAllByLabel::MakeCursor(
database::GraphDbAccessor &db) const { database::GraphDbAccessor *db, utils::MemoryResource *mem) const {
auto vertices = [this, &db](Frame &, ExecutionContext &) { auto vertices = [this, db](Frame &, ExecutionContext &) {
return std::make_optional( return std::make_optional(
db.Vertices(label_, graph_view_ == GraphView::NEW)); db->Vertices(label_, graph_view_ == GraphView::NEW));
}; };
return std::make_unique<ScanAllCursor<decltype(vertices)>>( return std::make_unique<ScanAllCursor<decltype(vertices)>>(
output_symbol_, input_->MakeCursor(db), std::move(vertices), db); output_symbol_, input_->MakeCursor(db, mem), std::move(vertices), *db);
} }
ScanAllByLabelPropertyRange::ScanAllByLabelPropertyRange( ScanAllByLabelPropertyRange::ScanAllByLabelPropertyRange(
@ -365,10 +368,10 @@ ScanAllByLabelPropertyRange::ScanAllByLabelPropertyRange(
ACCEPT_WITH_INPUT(ScanAllByLabelPropertyRange) ACCEPT_WITH_INPUT(ScanAllByLabelPropertyRange)
std::unique_ptr<Cursor> ScanAllByLabelPropertyRange::MakeCursor( std::unique_ptr<Cursor> ScanAllByLabelPropertyRange::MakeCursor(
database::GraphDbAccessor &db) const { database::GraphDbAccessor *db, utils::MemoryResource *mem) const {
auto vertices = [this, &db](Frame &frame, ExecutionContext &context) auto vertices = [this, db](Frame &frame, ExecutionContext &context)
-> std::optional<decltype( -> std::optional<decltype(
db.Vertices(label_, property_, std::nullopt, std::nullopt, false))> { db->Vertices(label_, property_, std::nullopt, std::nullopt, false))> {
ExpressionEvaluator evaluator(&frame, context.symbol_table, ExpressionEvaluator evaluator(&frame, context.symbol_table,
context.evaluation_context, context.evaluation_context,
context.db_accessor, graph_view_); context.db_accessor, graph_view_);
@ -391,12 +394,12 @@ std::unique_ptr<Cursor> ScanAllByLabelPropertyRange::MakeCursor(
// is treated as not satisfying the filter, so return no vertices. // is treated as not satisfying the filter, so return no vertices.
if (maybe_lower && maybe_lower->value().IsNull()) return std::nullopt; if (maybe_lower && maybe_lower->value().IsNull()) return std::nullopt;
if (maybe_upper && maybe_upper->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, return std::make_optional(db->Vertices(label_, property_, maybe_lower,
maybe_upper, maybe_upper,
graph_view_ == GraphView::NEW)); graph_view_ == GraphView::NEW));
}; };
return std::make_unique<ScanAllCursor<decltype(vertices)>>( return std::make_unique<ScanAllCursor<decltype(vertices)>>(
output_symbol_, input_->MakeCursor(db), std::move(vertices), db); output_symbol_, input_->MakeCursor(db, mem), std::move(vertices), *db);
} }
ScanAllByLabelPropertyValue::ScanAllByLabelPropertyValue( ScanAllByLabelPropertyValue::ScanAllByLabelPropertyValue(
@ -415,10 +418,10 @@ ScanAllByLabelPropertyValue::ScanAllByLabelPropertyValue(
ACCEPT_WITH_INPUT(ScanAllByLabelPropertyValue) ACCEPT_WITH_INPUT(ScanAllByLabelPropertyValue)
std::unique_ptr<Cursor> ScanAllByLabelPropertyValue::MakeCursor( std::unique_ptr<Cursor> ScanAllByLabelPropertyValue::MakeCursor(
database::GraphDbAccessor &db) const { database::GraphDbAccessor *db, utils::MemoryResource *mem) const {
auto vertices = [this, &db](Frame &frame, ExecutionContext &context) auto vertices = [this, db](Frame &frame, ExecutionContext &context)
-> std::optional<decltype( -> std::optional<decltype(
db.Vertices(label_, property_, PropertyValue::Null, false))> { db->Vertices(label_, property_, PropertyValue::Null, false))> {
ExpressionEvaluator evaluator(&frame, context.symbol_table, ExpressionEvaluator evaluator(&frame, context.symbol_table,
context.evaluation_context, context.evaluation_context,
context.db_accessor, graph_view_); context.db_accessor, graph_view_);
@ -428,12 +431,12 @@ std::unique_ptr<Cursor> ScanAllByLabelPropertyValue::MakeCursor(
throw QueryRuntimeException("'{}' cannot be used as a property value.", throw QueryRuntimeException("'{}' cannot be used as a property value.",
value.type()); value.type());
} }
return std::make_optional(db.Vertices(label_, property_, return std::make_optional(db->Vertices(label_, property_,
PropertyValue(value), PropertyValue(value),
graph_view_ == GraphView::NEW)); graph_view_ == GraphView::NEW));
}; };
return std::make_unique<ScanAllCursor<decltype(vertices)>>( return std::make_unique<ScanAllCursor<decltype(vertices)>>(
output_symbol_, input_->MakeCursor(db), std::move(vertices), db); output_symbol_, input_->MakeCursor(db, mem), std::move(vertices), *db);
} }
namespace { namespace {
@ -458,9 +461,9 @@ Expand::Expand(const std::shared_ptr<LogicalOperator> &input,
ACCEPT_WITH_INPUT(Expand) ACCEPT_WITH_INPUT(Expand)
std::unique_ptr<Cursor> Expand::MakeCursor( std::unique_ptr<Cursor> Expand::MakeCursor(database::GraphDbAccessor *db,
database::GraphDbAccessor &db) const { utils::MemoryResource *mem) const {
return std::make_unique<ExpandCursor>(*this, db); return std::make_unique<ExpandCursor>(*this, db, mem);
} }
std::vector<Symbol> Expand::ModifiedSymbols(const SymbolTable &table) const { std::vector<Symbol> Expand::ModifiedSymbols(const SymbolTable &table) const {
@ -471,8 +474,9 @@ std::vector<Symbol> Expand::ModifiedSymbols(const SymbolTable &table) const {
} }
Expand::ExpandCursor::ExpandCursor(const Expand &self, Expand::ExpandCursor::ExpandCursor(const Expand &self,
database::GraphDbAccessor &db) database::GraphDbAccessor *db,
: self_(self), input_cursor_(self.input_->MakeCursor(db)), db_(db) {} utils::MemoryResource *mem)
: self_(self), input_cursor_(self.input_->MakeCursor(db, mem)), db_(*db) {}
bool Expand::ExpandCursor::Pull(Frame &frame, ExecutionContext &context) { bool Expand::ExpandCursor::Pull(Frame &frame, ExecutionContext &context) {
SCOPED_PROFILE_OP("Expand"); SCOPED_PROFILE_OP("Expand");
@ -680,8 +684,9 @@ auto ExpandFromVertex(const VertexAccessor &vertex,
class ExpandVariableCursor : public Cursor { class ExpandVariableCursor : public Cursor {
public: public:
ExpandVariableCursor(const ExpandVariable &self, ExpandVariableCursor(const ExpandVariable &self,
database::GraphDbAccessor &db) database::GraphDbAccessor *db,
: self_(self), input_cursor_(self.input_->MakeCursor(db)) {} utils::MemoryResource *mem)
: self_(self), input_cursor_(self.input_->MakeCursor(db, mem)) {}
bool Pull(Frame &frame, ExecutionContext &context) override { bool Pull(Frame &frame, ExecutionContext &context) override {
SCOPED_PROFILE_OP("ExpandVariable"); SCOPED_PROFILE_OP("ExpandVariable");
@ -917,8 +922,9 @@ class ExpandVariableCursor : public Cursor {
class STShortestPathCursor : public query::plan::Cursor { class STShortestPathCursor : public query::plan::Cursor {
public: public:
STShortestPathCursor(const ExpandVariable &self, STShortestPathCursor(const ExpandVariable &self,
database::GraphDbAccessor &dba) database::GraphDbAccessor *dba,
: self_(self), input_cursor_(self_.input()->MakeCursor(dba)) { utils::MemoryResource *mem)
: self_(self), input_cursor_(self_.input()->MakeCursor(dba, mem)) {
CHECK(self_.common_.existing_node) CHECK(self_.common_.existing_node)
<< "s-t shortest path algorithm should only " << "s-t shortest path algorithm should only "
"be used when `existing_node` flag is " "be used when `existing_node` flag is "
@ -1149,8 +1155,9 @@ class STShortestPathCursor : public query::plan::Cursor {
class SingleSourceShortestPathCursor : public query::plan::Cursor { class SingleSourceShortestPathCursor : public query::plan::Cursor {
public: public:
SingleSourceShortestPathCursor(const ExpandVariable &self, SingleSourceShortestPathCursor(const ExpandVariable &self,
database::GraphDbAccessor &db) database::GraphDbAccessor *db,
: self_(self), input_cursor_(self_.input()->MakeCursor(db)) { utils::MemoryResource *mem)
: self_(self), input_cursor_(self_.input()->MakeCursor(db, mem)) {
CHECK(!self_.common_.existing_node) CHECK(!self_.common_.existing_node)
<< "Single source shortest path algorithm " << "Single source shortest path algorithm "
"should not be used when `existing_node` " "should not be used when `existing_node` "
@ -1308,8 +1315,9 @@ class SingleSourceShortestPathCursor : public query::plan::Cursor {
class ExpandWeightedShortestPathCursor : public query::plan::Cursor { class ExpandWeightedShortestPathCursor : public query::plan::Cursor {
public: public:
ExpandWeightedShortestPathCursor(const ExpandVariable &self, ExpandWeightedShortestPathCursor(const ExpandVariable &self,
database::GraphDbAccessor &db) database::GraphDbAccessor *db,
: self_(self), input_cursor_(self_.input_->MakeCursor(db)) {} utils::MemoryResource *mem)
: self_(self), input_cursor_(self_.input_->MakeCursor(db, mem)) {}
bool Pull(Frame &frame, ExecutionContext &context) override { bool Pull(Frame &frame, ExecutionContext &context) override {
SCOPED_PROFILE_OP("ExpandWeightedShortestPath"); SCOPED_PROFILE_OP("ExpandWeightedShortestPath");
@ -1546,18 +1554,18 @@ class ExpandWeightedShortestPathCursor : public query::plan::Cursor {
}; };
std::unique_ptr<Cursor> ExpandVariable::MakeCursor( std::unique_ptr<Cursor> ExpandVariable::MakeCursor(
database::GraphDbAccessor &db) const { database::GraphDbAccessor *db, utils::MemoryResource *mem) const {
switch (type_) { switch (type_) {
case EdgeAtom::Type::BREADTH_FIRST: case EdgeAtom::Type::BREADTH_FIRST:
if (common_.existing_node) { if (common_.existing_node) {
return std::make_unique<STShortestPathCursor>(*this, db); return std::make_unique<STShortestPathCursor>(*this, db, mem);
} else { } else {
return std::make_unique<SingleSourceShortestPathCursor>(*this, db); return std::make_unique<SingleSourceShortestPathCursor>(*this, db, mem);
} }
case EdgeAtom::Type::DEPTH_FIRST: case EdgeAtom::Type::DEPTH_FIRST:
return std::make_unique<ExpandVariableCursor>(*this, db); return std::make_unique<ExpandVariableCursor>(*this, db, mem);
case EdgeAtom::Type::WEIGHTED_SHORTEST_PATH: case EdgeAtom::Type::WEIGHTED_SHORTEST_PATH:
return std::make_unique<ExpandWeightedShortestPathCursor>(*this, db); return std::make_unique<ExpandWeightedShortestPathCursor>(*this, db, mem);
case EdgeAtom::Type::SINGLE: case EdgeAtom::Type::SINGLE:
LOG(FATAL) LOG(FATAL)
<< "ExpandVariable should not be planned for a single expansion!"; << "ExpandVariable should not be planned for a single expansion!";
@ -1567,8 +1575,9 @@ std::unique_ptr<Cursor> ExpandVariable::MakeCursor(
class ConstructNamedPathCursor : public Cursor { class ConstructNamedPathCursor : public Cursor {
public: public:
ConstructNamedPathCursor(const ConstructNamedPath &self, ConstructNamedPathCursor(const ConstructNamedPath &self,
database::GraphDbAccessor &db) database::GraphDbAccessor *db,
: self_(self), input_cursor_(self_.input()->MakeCursor(db)) {} utils::MemoryResource *mem)
: self_(self), input_cursor_(self_.input()->MakeCursor(db, mem)) {}
bool Pull(Frame &frame, ExecutionContext &context) override { bool Pull(Frame &frame, ExecutionContext &context) override {
SCOPED_PROFILE_OP("ConstructNamedPath"); SCOPED_PROFILE_OP("ConstructNamedPath");
@ -1650,8 +1659,8 @@ class ConstructNamedPathCursor : public Cursor {
ACCEPT_WITH_INPUT(ConstructNamedPath) ACCEPT_WITH_INPUT(ConstructNamedPath)
std::unique_ptr<Cursor> ConstructNamedPath::MakeCursor( std::unique_ptr<Cursor> ConstructNamedPath::MakeCursor(
database::GraphDbAccessor &db) const { database::GraphDbAccessor *db, utils::MemoryResource *mem) const {
return std::make_unique<ConstructNamedPathCursor>(*this, db); return std::make_unique<ConstructNamedPathCursor>(*this, db, mem);
} }
std::vector<Symbol> ConstructNamedPath::ModifiedSymbols( std::vector<Symbol> ConstructNamedPath::ModifiedSymbols(
@ -1668,9 +1677,9 @@ Filter::Filter(const std::shared_ptr<LogicalOperator> &input,
ACCEPT_WITH_INPUT(Filter) ACCEPT_WITH_INPUT(Filter)
std::unique_ptr<Cursor> Filter::MakeCursor( std::unique_ptr<Cursor> Filter::MakeCursor(database::GraphDbAccessor *db,
database::GraphDbAccessor &db) const { utils::MemoryResource *mem) const {
return std::make_unique<FilterCursor>(*this, db); return std::make_unique<FilterCursor>(*this, db, mem);
} }
std::vector<Symbol> Filter::ModifiedSymbols(const SymbolTable &table) const { std::vector<Symbol> Filter::ModifiedSymbols(const SymbolTable &table) const {
@ -1678,8 +1687,9 @@ std::vector<Symbol> Filter::ModifiedSymbols(const SymbolTable &table) const {
} }
Filter::FilterCursor::FilterCursor(const Filter &self, Filter::FilterCursor::FilterCursor(const Filter &self,
database::GraphDbAccessor &db) database::GraphDbAccessor *db,
: self_(self), input_cursor_(self_.input_->MakeCursor(db)) {} utils::MemoryResource *mem)
: self_(self), input_cursor_(self_.input_->MakeCursor(db, mem)) {}
bool Filter::FilterCursor::Pull(Frame &frame, ExecutionContext &context) { bool Filter::FilterCursor::Pull(Frame &frame, ExecutionContext &context) {
SCOPED_PROFILE_OP("Filter"); SCOPED_PROFILE_OP("Filter");
@ -1706,9 +1716,9 @@ Produce::Produce(const std::shared_ptr<LogicalOperator> &input,
ACCEPT_WITH_INPUT(Produce) ACCEPT_WITH_INPUT(Produce)
std::unique_ptr<Cursor> Produce::MakeCursor( std::unique_ptr<Cursor> Produce::MakeCursor(database::GraphDbAccessor *db,
database::GraphDbAccessor &db) const { utils::MemoryResource *mem) const {
return std::make_unique<ProduceCursor>(*this, db); return std::make_unique<ProduceCursor>(*this, db, mem);
} }
std::vector<Symbol> Produce::OutputSymbols( std::vector<Symbol> Produce::OutputSymbols(
@ -1725,8 +1735,9 @@ std::vector<Symbol> Produce::ModifiedSymbols(const SymbolTable &table) const {
} }
Produce::ProduceCursor::ProduceCursor(const Produce &self, Produce::ProduceCursor::ProduceCursor(const Produce &self,
database::GraphDbAccessor &db) database::GraphDbAccessor *db,
: self_(self), input_cursor_(self_.input_->MakeCursor(db)) {} utils::MemoryResource *mem)
: self_(self), input_cursor_(self_.input_->MakeCursor(db, mem)) {}
bool Produce::ProduceCursor::Pull(Frame &frame, ExecutionContext &context) { bool Produce::ProduceCursor::Pull(Frame &frame, ExecutionContext &context) {
SCOPED_PROFILE_OP("Produce"); SCOPED_PROFILE_OP("Produce");
@ -1754,9 +1765,9 @@ Delete::Delete(const std::shared_ptr<LogicalOperator> &input_,
ACCEPT_WITH_INPUT(Delete) ACCEPT_WITH_INPUT(Delete)
std::unique_ptr<Cursor> Delete::MakeCursor( std::unique_ptr<Cursor> Delete::MakeCursor(database::GraphDbAccessor *db,
database::GraphDbAccessor &db) const { utils::MemoryResource *mem) const {
return std::make_unique<DeleteCursor>(*this, db); return std::make_unique<DeleteCursor>(*this, db, mem);
} }
std::vector<Symbol> Delete::ModifiedSymbols(const SymbolTable &table) const { std::vector<Symbol> Delete::ModifiedSymbols(const SymbolTable &table) const {
@ -1764,8 +1775,9 @@ std::vector<Symbol> Delete::ModifiedSymbols(const SymbolTable &table) const {
} }
Delete::DeleteCursor::DeleteCursor(const Delete &self, Delete::DeleteCursor::DeleteCursor(const Delete &self,
database::GraphDbAccessor &db) database::GraphDbAccessor *db,
: self_(self), db_(db), input_cursor_(self_.input_->MakeCursor(db)) {} utils::MemoryResource *mem)
: self_(self), db_(*db), input_cursor_(self_.input_->MakeCursor(db, mem)) {}
bool Delete::DeleteCursor::Pull(Frame &frame, ExecutionContext &context) { bool Delete::DeleteCursor::Pull(Frame &frame, ExecutionContext &context) {
SCOPED_PROFILE_OP("Delete"); SCOPED_PROFILE_OP("Delete");
@ -1835,8 +1847,8 @@ SetProperty::SetProperty(const std::shared_ptr<LogicalOperator> &input,
ACCEPT_WITH_INPUT(SetProperty) ACCEPT_WITH_INPUT(SetProperty)
std::unique_ptr<Cursor> SetProperty::MakeCursor( std::unique_ptr<Cursor> SetProperty::MakeCursor(
database::GraphDbAccessor &db) const { database::GraphDbAccessor *db, utils::MemoryResource *mem) const {
return std::make_unique<SetPropertyCursor>(*this, db); return std::make_unique<SetPropertyCursor>(*this, db, mem);
} }
std::vector<Symbol> SetProperty::ModifiedSymbols( std::vector<Symbol> SetProperty::ModifiedSymbols(
@ -1845,8 +1857,9 @@ std::vector<Symbol> SetProperty::ModifiedSymbols(
} }
SetProperty::SetPropertyCursor::SetPropertyCursor(const SetProperty &self, SetProperty::SetPropertyCursor::SetPropertyCursor(const SetProperty &self,
database::GraphDbAccessor &db) database::GraphDbAccessor *db,
: self_(self), input_cursor_(self.input_->MakeCursor(db)) {} utils::MemoryResource *mem)
: self_(self), input_cursor_(self.input_->MakeCursor(db, mem)) {}
bool SetProperty::SetPropertyCursor::Pull(Frame &frame, bool SetProperty::SetPropertyCursor::Pull(Frame &frame,
ExecutionContext &context) { ExecutionContext &context) {
@ -1895,8 +1908,8 @@ SetProperties::SetProperties(const std::shared_ptr<LogicalOperator> &input,
ACCEPT_WITH_INPUT(SetProperties) ACCEPT_WITH_INPUT(SetProperties)
std::unique_ptr<Cursor> SetProperties::MakeCursor( std::unique_ptr<Cursor> SetProperties::MakeCursor(
database::GraphDbAccessor &db) const { database::GraphDbAccessor *db, utils::MemoryResource *mem) const {
return std::make_unique<SetPropertiesCursor>(*this, db); return std::make_unique<SetPropertiesCursor>(*this, db, mem);
} }
std::vector<Symbol> SetProperties::ModifiedSymbols( std::vector<Symbol> SetProperties::ModifiedSymbols(
@ -1905,8 +1918,9 @@ std::vector<Symbol> SetProperties::ModifiedSymbols(
} }
SetProperties::SetPropertiesCursor::SetPropertiesCursor( SetProperties::SetPropertiesCursor::SetPropertiesCursor(
const SetProperties &self, database::GraphDbAccessor &db) const SetProperties &self, database::GraphDbAccessor *db,
: self_(self), db_(db), input_cursor_(self.input_->MakeCursor(db)) {} utils::MemoryResource *mem)
: self_(self), db_(*db), input_cursor_(self.input_->MakeCursor(db, mem)) {}
bool SetProperties::SetPropertiesCursor::Pull(Frame &frame, bool SetProperties::SetPropertiesCursor::Pull(Frame &frame,
ExecutionContext &context) { ExecutionContext &context) {
@ -2001,8 +2015,8 @@ SetLabels::SetLabels(const std::shared_ptr<LogicalOperator> &input,
ACCEPT_WITH_INPUT(SetLabels) ACCEPT_WITH_INPUT(SetLabels)
std::unique_ptr<Cursor> SetLabels::MakeCursor( std::unique_ptr<Cursor> SetLabels::MakeCursor(
database::GraphDbAccessor &db) const { database::GraphDbAccessor *db, utils::MemoryResource *mem) const {
return std::make_unique<SetLabelsCursor>(*this, db); return std::make_unique<SetLabelsCursor>(*this, db, mem);
} }
std::vector<Symbol> SetLabels::ModifiedSymbols(const SymbolTable &table) const { std::vector<Symbol> SetLabels::ModifiedSymbols(const SymbolTable &table) const {
@ -2010,8 +2024,9 @@ std::vector<Symbol> SetLabels::ModifiedSymbols(const SymbolTable &table) const {
} }
SetLabels::SetLabelsCursor::SetLabelsCursor(const SetLabels &self, SetLabels::SetLabelsCursor::SetLabelsCursor(const SetLabels &self,
database::GraphDbAccessor &db) database::GraphDbAccessor *db,
: self_(self), input_cursor_(self.input_->MakeCursor(db)) {} utils::MemoryResource *mem)
: self_(self), input_cursor_(self.input_->MakeCursor(db, mem)) {}
bool SetLabels::SetLabelsCursor::Pull(Frame &frame, ExecutionContext &context) { bool SetLabels::SetLabelsCursor::Pull(Frame &frame, ExecutionContext &context) {
SCOPED_PROFILE_OP("SetLabels"); SCOPED_PROFILE_OP("SetLabels");
@ -2044,8 +2059,8 @@ RemoveProperty::RemoveProperty(const std::shared_ptr<LogicalOperator> &input,
ACCEPT_WITH_INPUT(RemoveProperty) ACCEPT_WITH_INPUT(RemoveProperty)
std::unique_ptr<Cursor> RemoveProperty::MakeCursor( std::unique_ptr<Cursor> RemoveProperty::MakeCursor(
database::GraphDbAccessor &db) const { database::GraphDbAccessor *db, utils::MemoryResource *mem) const {
return std::make_unique<RemovePropertyCursor>(*this, db); return std::make_unique<RemovePropertyCursor>(*this, db, mem);
} }
std::vector<Symbol> RemoveProperty::ModifiedSymbols( std::vector<Symbol> RemoveProperty::ModifiedSymbols(
@ -2054,8 +2069,9 @@ std::vector<Symbol> RemoveProperty::ModifiedSymbols(
} }
RemoveProperty::RemovePropertyCursor::RemovePropertyCursor( RemoveProperty::RemovePropertyCursor::RemovePropertyCursor(
const RemoveProperty &self, database::GraphDbAccessor &db) const RemoveProperty &self, database::GraphDbAccessor *db,
: self_(self), input_cursor_(self.input_->MakeCursor(db)) {} utils::MemoryResource *mem)
: self_(self), input_cursor_(self.input_->MakeCursor(db, mem)) {}
bool RemoveProperty::RemovePropertyCursor::Pull(Frame &frame, bool RemoveProperty::RemovePropertyCursor::Pull(Frame &frame,
ExecutionContext &context) { ExecutionContext &context) {
@ -2110,8 +2126,8 @@ RemoveLabels::RemoveLabels(const std::shared_ptr<LogicalOperator> &input,
ACCEPT_WITH_INPUT(RemoveLabels) ACCEPT_WITH_INPUT(RemoveLabels)
std::unique_ptr<Cursor> RemoveLabels::MakeCursor( std::unique_ptr<Cursor> RemoveLabels::MakeCursor(
database::GraphDbAccessor &db) const { database::GraphDbAccessor *db, utils::MemoryResource *mem) const {
return std::make_unique<RemoveLabelsCursor>(*this, db); return std::make_unique<RemoveLabelsCursor>(*this, db, mem);
} }
std::vector<Symbol> RemoveLabels::ModifiedSymbols( std::vector<Symbol> RemoveLabels::ModifiedSymbols(
@ -2120,8 +2136,9 @@ std::vector<Symbol> RemoveLabels::ModifiedSymbols(
} }
RemoveLabels::RemoveLabelsCursor::RemoveLabelsCursor( RemoveLabels::RemoveLabelsCursor::RemoveLabelsCursor(
const RemoveLabels &self, database::GraphDbAccessor &db) const RemoveLabels &self, database::GraphDbAccessor *db,
: self_(self), input_cursor_(self.input_->MakeCursor(db)) {} utils::MemoryResource *mem)
: self_(self), input_cursor_(self.input_->MakeCursor(db, mem)) {}
bool RemoveLabels::RemoveLabelsCursor::Pull(Frame &frame, bool RemoveLabels::RemoveLabelsCursor::Pull(Frame &frame,
ExecutionContext &context) { ExecutionContext &context) {
@ -2158,8 +2175,8 @@ EdgeUniquenessFilter::EdgeUniquenessFilter(
ACCEPT_WITH_INPUT(EdgeUniquenessFilter) ACCEPT_WITH_INPUT(EdgeUniquenessFilter)
std::unique_ptr<Cursor> EdgeUniquenessFilter::MakeCursor( std::unique_ptr<Cursor> EdgeUniquenessFilter::MakeCursor(
database::GraphDbAccessor &db) const { database::GraphDbAccessor *db, utils::MemoryResource *mem) const {
return std::make_unique<EdgeUniquenessFilterCursor>(*this, db); return std::make_unique<EdgeUniquenessFilterCursor>(*this, db, mem);
} }
std::vector<Symbol> EdgeUniquenessFilter::ModifiedSymbols( std::vector<Symbol> EdgeUniquenessFilter::ModifiedSymbols(
@ -2168,8 +2185,9 @@ std::vector<Symbol> EdgeUniquenessFilter::ModifiedSymbols(
} }
EdgeUniquenessFilter::EdgeUniquenessFilterCursor::EdgeUniquenessFilterCursor( EdgeUniquenessFilter::EdgeUniquenessFilterCursor::EdgeUniquenessFilterCursor(
const EdgeUniquenessFilter &self, database::GraphDbAccessor &db) const EdgeUniquenessFilter &self, database::GraphDbAccessor *db,
: self_(self), input_cursor_(self.input_->MakeCursor(db)) {} utils::MemoryResource *mem)
: self_(self), input_cursor_(self.input_->MakeCursor(db, mem)) {}
namespace { namespace {
/** /**
@ -2227,8 +2245,8 @@ Accumulate::Accumulate(const std::shared_ptr<LogicalOperator> &input,
ACCEPT_WITH_INPUT(Accumulate) ACCEPT_WITH_INPUT(Accumulate)
std::unique_ptr<Cursor> Accumulate::MakeCursor( std::unique_ptr<Cursor> Accumulate::MakeCursor(
database::GraphDbAccessor &db) const { database::GraphDbAccessor *db, utils::MemoryResource *mem) const {
return std::make_unique<Accumulate::AccumulateCursor>(*this, db); return std::make_unique<Accumulate::AccumulateCursor>(*this, db, mem);
} }
std::vector<Symbol> Accumulate::ModifiedSymbols(const SymbolTable &) const { std::vector<Symbol> Accumulate::ModifiedSymbols(const SymbolTable &) const {
@ -2236,8 +2254,9 @@ std::vector<Symbol> Accumulate::ModifiedSymbols(const SymbolTable &) const {
} }
Accumulate::AccumulateCursor::AccumulateCursor(const Accumulate &self, Accumulate::AccumulateCursor::AccumulateCursor(const Accumulate &self,
database::GraphDbAccessor &db) database::GraphDbAccessor *db,
: self_(self), db_(db), input_cursor_(self.input_->MakeCursor(db)) {} utils::MemoryResource *mem)
: self_(self), db_(*db), input_cursor_(self.input_->MakeCursor(db, mem)) {}
bool Accumulate::AccumulateCursor::Pull(Frame &frame, bool Accumulate::AccumulateCursor::Pull(Frame &frame,
ExecutionContext &context) { ExecutionContext &context) {
@ -2290,8 +2309,8 @@ Aggregate::Aggregate(const std::shared_ptr<LogicalOperator> &input,
ACCEPT_WITH_INPUT(Aggregate) ACCEPT_WITH_INPUT(Aggregate)
std::unique_ptr<Cursor> Aggregate::MakeCursor( std::unique_ptr<Cursor> Aggregate::MakeCursor(
database::GraphDbAccessor &db) const { database::GraphDbAccessor *db, utils::MemoryResource *mem) const {
return std::make_unique<AggregateCursor>(*this, db); return std::make_unique<AggregateCursor>(*this, db, mem);
} }
std::vector<Symbol> Aggregate::ModifiedSymbols(const SymbolTable &) const { std::vector<Symbol> Aggregate::ModifiedSymbols(const SymbolTable &) const {
@ -2301,8 +2320,9 @@ std::vector<Symbol> Aggregate::ModifiedSymbols(const SymbolTable &) const {
} }
Aggregate::AggregateCursor::AggregateCursor(const Aggregate &self, Aggregate::AggregateCursor::AggregateCursor(const Aggregate &self,
database::GraphDbAccessor &db) database::GraphDbAccessor *db,
: self_(self), input_cursor_(self_.input_->MakeCursor(db)) {} utils::MemoryResource *mem)
: self_(self), input_cursor_(self_.input_->MakeCursor(db, mem)) {}
namespace { namespace {
/** Returns the default TypedValue for an Aggregation element. /** Returns the default TypedValue for an Aggregation element.
@ -2575,8 +2595,9 @@ Skip::Skip(const std::shared_ptr<LogicalOperator> &input,
ACCEPT_WITH_INPUT(Skip) ACCEPT_WITH_INPUT(Skip)
std::unique_ptr<Cursor> Skip::MakeCursor(database::GraphDbAccessor &db) const { std::unique_ptr<Cursor> Skip::MakeCursor(database::GraphDbAccessor *db,
return std::make_unique<SkipCursor>(*this, db); utils::MemoryResource *mem) const {
return std::make_unique<SkipCursor>(*this, db, mem);
} }
std::vector<Symbol> Skip::OutputSymbols(const SymbolTable &symbol_table) const { std::vector<Symbol> Skip::OutputSymbols(const SymbolTable &symbol_table) const {
@ -2588,8 +2609,9 @@ std::vector<Symbol> Skip::ModifiedSymbols(const SymbolTable &table) const {
return input_->ModifiedSymbols(table); return input_->ModifiedSymbols(table);
} }
Skip::SkipCursor::SkipCursor(const Skip &self, database::GraphDbAccessor &db) Skip::SkipCursor::SkipCursor(const Skip &self, database::GraphDbAccessor *db,
: self_(self), input_cursor_(self_.input_->MakeCursor(db)) {} utils::MemoryResource *mem)
: self_(self), input_cursor_(self_.input_->MakeCursor(db, mem)) {}
bool Skip::SkipCursor::Pull(Frame &frame, ExecutionContext &context) { bool Skip::SkipCursor::Pull(Frame &frame, ExecutionContext &context) {
SCOPED_PROFILE_OP("Skip"); SCOPED_PROFILE_OP("Skip");
@ -2633,8 +2655,9 @@ Limit::Limit(const std::shared_ptr<LogicalOperator> &input,
ACCEPT_WITH_INPUT(Limit) ACCEPT_WITH_INPUT(Limit)
std::unique_ptr<Cursor> Limit::MakeCursor(database::GraphDbAccessor &db) const { std::unique_ptr<Cursor> Limit::MakeCursor(database::GraphDbAccessor *db,
return std::make_unique<LimitCursor>(*this, db); utils::MemoryResource *mem) const {
return std::make_unique<LimitCursor>(*this, db, mem);
} }
std::vector<Symbol> Limit::OutputSymbols( std::vector<Symbol> Limit::OutputSymbols(
@ -2648,8 +2671,9 @@ std::vector<Symbol> Limit::ModifiedSymbols(const SymbolTable &table) const {
} }
Limit::LimitCursor::LimitCursor(const Limit &self, Limit::LimitCursor::LimitCursor(const Limit &self,
database::GraphDbAccessor &db) database::GraphDbAccessor *db,
: self_(self), input_cursor_(self_.input_->MakeCursor(db)) {} utils::MemoryResource *mem)
: self_(self), input_cursor_(self_.input_->MakeCursor(db, mem)) {}
bool Limit::LimitCursor::Pull(Frame &frame, ExecutionContext &context) { bool Limit::LimitCursor::Pull(Frame &frame, ExecutionContext &context) {
SCOPED_PROFILE_OP("Limit"); SCOPED_PROFILE_OP("Limit");
@ -2706,9 +2730,9 @@ OrderBy::OrderBy(const std::shared_ptr<LogicalOperator> &input,
ACCEPT_WITH_INPUT(OrderBy) ACCEPT_WITH_INPUT(OrderBy)
std::unique_ptr<Cursor> OrderBy::MakeCursor( std::unique_ptr<Cursor> OrderBy::MakeCursor(database::GraphDbAccessor *db,
database::GraphDbAccessor &db) const { utils::MemoryResource *mem) const {
return std::make_unique<OrderByCursor>(*this, db); return std::make_unique<OrderByCursor>(*this, db, mem);
} }
std::vector<Symbol> OrderBy::OutputSymbols( std::vector<Symbol> OrderBy::OutputSymbols(
@ -2722,8 +2746,9 @@ std::vector<Symbol> OrderBy::ModifiedSymbols(const SymbolTable &table) const {
} }
OrderBy::OrderByCursor::OrderByCursor(const OrderBy &self, OrderBy::OrderByCursor::OrderByCursor(const OrderBy &self,
database::GraphDbAccessor &db) database::GraphDbAccessor *db,
: self_(self), input_cursor_(self_.input_->MakeCursor(db)) {} utils::MemoryResource *mem)
: self_(self), input_cursor_(self_.input_->MakeCursor(db, mem)) {}
bool OrderBy::OrderByCursor::Pull(Frame &frame, ExecutionContext &context) { bool OrderBy::OrderByCursor::Pull(Frame &frame, ExecutionContext &context) {
SCOPED_PROFILE_OP("OrderBy"); SCOPED_PROFILE_OP("OrderBy");
@ -2798,8 +2823,9 @@ bool Merge::Accept(HierarchicalLogicalOperatorVisitor &visitor) {
return visitor.PostVisit(*this); return visitor.PostVisit(*this);
} }
std::unique_ptr<Cursor> Merge::MakeCursor(database::GraphDbAccessor &db) const { std::unique_ptr<Cursor> Merge::MakeCursor(database::GraphDbAccessor *db,
return std::make_unique<MergeCursor>(*this, db); utils::MemoryResource *mem) const {
return std::make_unique<MergeCursor>(*this, db, mem);
} }
std::vector<Symbol> Merge::ModifiedSymbols(const SymbolTable &table) const { std::vector<Symbol> Merge::ModifiedSymbols(const SymbolTable &table) const {
@ -2812,10 +2838,11 @@ std::vector<Symbol> Merge::ModifiedSymbols(const SymbolTable &table) const {
} }
Merge::MergeCursor::MergeCursor(const Merge &self, Merge::MergeCursor::MergeCursor(const Merge &self,
database::GraphDbAccessor &db) database::GraphDbAccessor *db,
: input_cursor_(self.input_->MakeCursor(db)), utils::MemoryResource *mem)
merge_match_cursor_(self.merge_match_->MakeCursor(db)), : input_cursor_(self.input_->MakeCursor(db, mem)),
merge_create_cursor_(self.merge_create_->MakeCursor(db)) {} 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) { bool Merge::MergeCursor::Pull(Frame &frame, ExecutionContext &context) {
SCOPED_PROFILE_OP("Merge"); SCOPED_PROFILE_OP("Merge");
@ -2883,9 +2910,9 @@ bool Optional::Accept(HierarchicalLogicalOperatorVisitor &visitor) {
return visitor.PostVisit(*this); return visitor.PostVisit(*this);
} }
std::unique_ptr<Cursor> Optional::MakeCursor( std::unique_ptr<Cursor> Optional::MakeCursor(database::GraphDbAccessor *db,
database::GraphDbAccessor &db) const { utils::MemoryResource *mem) const {
return std::make_unique<OptionalCursor>(*this, db); return std::make_unique<OptionalCursor>(*this, db, mem);
} }
std::vector<Symbol> Optional::ModifiedSymbols(const SymbolTable &table) const { std::vector<Symbol> Optional::ModifiedSymbols(const SymbolTable &table) const {
@ -2896,10 +2923,11 @@ std::vector<Symbol> Optional::ModifiedSymbols(const SymbolTable &table) const {
} }
Optional::OptionalCursor::OptionalCursor(const Optional &self, Optional::OptionalCursor::OptionalCursor(const Optional &self,
database::GraphDbAccessor &db) database::GraphDbAccessor *db,
utils::MemoryResource *mem)
: self_(self), : self_(self),
input_cursor_(self.input_->MakeCursor(db)), input_cursor_(self.input_->MakeCursor(db, mem)),
optional_cursor_(self.optional_->MakeCursor(db)) {} optional_cursor_(self.optional_->MakeCursor(db, mem)) {}
bool Optional::OptionalCursor::Pull(Frame &frame, ExecutionContext &context) { bool Optional::OptionalCursor::Pull(Frame &frame, ExecutionContext &context) {
SCOPED_PROFILE_OP("Optional"); SCOPED_PROFILE_OP("Optional");
@ -2959,9 +2987,9 @@ Unwind::Unwind(const std::shared_ptr<LogicalOperator> &input,
ACCEPT_WITH_INPUT(Unwind) ACCEPT_WITH_INPUT(Unwind)
std::unique_ptr<Cursor> Unwind::MakeCursor( std::unique_ptr<Cursor> Unwind::MakeCursor(database::GraphDbAccessor *db,
database::GraphDbAccessor &db) const { utils::MemoryResource *mem) const {
return std::make_unique<UnwindCursor>(*this, db); return std::make_unique<UnwindCursor>(*this, db, mem);
} }
std::vector<Symbol> Unwind::ModifiedSymbols(const SymbolTable &table) const { std::vector<Symbol> Unwind::ModifiedSymbols(const SymbolTable &table) const {
@ -2971,8 +2999,9 @@ std::vector<Symbol> Unwind::ModifiedSymbols(const SymbolTable &table) const {
} }
Unwind::UnwindCursor::UnwindCursor(const Unwind &self, Unwind::UnwindCursor::UnwindCursor(const Unwind &self,
database::GraphDbAccessor &db) database::GraphDbAccessor *db,
: self_(self), db_(db), input_cursor_(self.input_->MakeCursor(db)) {} utils::MemoryResource *mem)
: self_(self), db_(*db), input_cursor_(self.input_->MakeCursor(db, mem)) {}
bool Unwind::UnwindCursor::Pull(Frame &frame, ExecutionContext &context) { bool Unwind::UnwindCursor::Pull(Frame &frame, ExecutionContext &context) {
SCOPED_PROFILE_OP("Unwind"); SCOPED_PROFILE_OP("Unwind");
@ -3020,9 +3049,9 @@ Distinct::Distinct(const std::shared_ptr<LogicalOperator> &input,
ACCEPT_WITH_INPUT(Distinct) ACCEPT_WITH_INPUT(Distinct)
std::unique_ptr<Cursor> Distinct::MakeCursor( std::unique_ptr<Cursor> Distinct::MakeCursor(database::GraphDbAccessor *db,
database::GraphDbAccessor &db) const { utils::MemoryResource *mem) const {
return std::make_unique<DistinctCursor>(*this, db); return std::make_unique<DistinctCursor>(*this, db, mem);
} }
std::vector<Symbol> Distinct::OutputSymbols( std::vector<Symbol> Distinct::OutputSymbols(
@ -3036,8 +3065,9 @@ std::vector<Symbol> Distinct::ModifiedSymbols(const SymbolTable &table) const {
} }
Distinct::DistinctCursor::DistinctCursor(const Distinct &self, Distinct::DistinctCursor::DistinctCursor(const Distinct &self,
database::GraphDbAccessor &db) database::GraphDbAccessor *db,
: self_(self), input_cursor_(self.input_->MakeCursor(db)) {} utils::MemoryResource *mem)
: self_(self), input_cursor_(self.input_->MakeCursor(db, mem)) {}
bool Distinct::DistinctCursor::Pull(Frame &frame, ExecutionContext &context) { bool Distinct::DistinctCursor::Pull(Frame &frame, ExecutionContext &context) {
SCOPED_PROFILE_OP("Distinct"); SCOPED_PROFILE_OP("Distinct");
@ -3071,8 +3101,9 @@ Union::Union(const std::shared_ptr<LogicalOperator> &left_op,
left_symbols_(left_symbols), left_symbols_(left_symbols),
right_symbols_(right_symbols) {} right_symbols_(right_symbols) {}
std::unique_ptr<Cursor> Union::MakeCursor(database::GraphDbAccessor &db) const { std::unique_ptr<Cursor> Union::MakeCursor(database::GraphDbAccessor *db,
return std::make_unique<Union::UnionCursor>(*this, db); utils::MemoryResource *mem) const {
return std::make_unique<Union::UnionCursor>(*this, db, mem);
} }
bool Union::Accept(HierarchicalLogicalOperatorVisitor &visitor) { bool Union::Accept(HierarchicalLogicalOperatorVisitor &visitor) {
@ -3095,10 +3126,11 @@ std::vector<Symbol> Union::ModifiedSymbols(const SymbolTable &) const {
WITHOUT_SINGLE_INPUT(Union); WITHOUT_SINGLE_INPUT(Union);
Union::UnionCursor::UnionCursor(const Union &self, Union::UnionCursor::UnionCursor(const Union &self,
database::GraphDbAccessor &db) database::GraphDbAccessor *db,
utils::MemoryResource *mem)
: self_(self), : self_(self),
left_cursor_(self.left_op_->MakeCursor(db)), left_cursor_(self.left_op_->MakeCursor(db, mem)),
right_cursor_(self.right_op_->MakeCursor(db)) {} right_cursor_(self.right_op_->MakeCursor(db, mem)) {}
bool Union::UnionCursor::Pull(Frame &frame, ExecutionContext &context) { bool Union::UnionCursor::Pull(Frame &frame, ExecutionContext &context) {
SCOPED_PROFILE_OP("Union"); SCOPED_PROFILE_OP("Union");
@ -3155,10 +3187,11 @@ namespace {
class CartesianCursor : public Cursor { class CartesianCursor : public Cursor {
public: public:
CartesianCursor(const Cartesian &self, database::GraphDbAccessor &db) CartesianCursor(const Cartesian &self, database::GraphDbAccessor *db,
utils::MemoryResource *mem)
: self_(self), : self_(self),
left_op_cursor_(self.left_op_->MakeCursor(db)), left_op_cursor_(self.left_op_->MakeCursor(db, mem)),
right_op_cursor_(self_.right_op_->MakeCursor(db)) { right_op_cursor_(self_.right_op_->MakeCursor(db, mem)) {
CHECK(left_op_cursor_ != nullptr) CHECK(left_op_cursor_ != nullptr)
<< "CartesianCursor: Missing left operator cursor."; << "CartesianCursor: Missing left operator cursor.";
CHECK(right_op_cursor_ != nullptr) CHECK(right_op_cursor_ != nullptr)
@ -3237,8 +3270,8 @@ class CartesianCursor : public Cursor {
} // namespace } // namespace
std::unique_ptr<Cursor> Cartesian::MakeCursor( std::unique_ptr<Cursor> Cartesian::MakeCursor(
database::GraphDbAccessor &db) const { database::GraphDbAccessor *db, utils::MemoryResource *mem) const {
return std::make_unique<CartesianCursor>(*this, db); return std::make_unique<CartesianCursor>(*this, db, mem);
} }
OutputTable::OutputTable(std::vector<Symbol> output_symbols, OutputTable::OutputTable(std::vector<Symbol> output_symbols,
@ -3293,8 +3326,8 @@ class OutputTableCursor : public Cursor {
bool pulled_{false}; bool pulled_{false};
}; };
std::unique_ptr<Cursor> OutputTable::MakeCursor( std::unique_ptr<Cursor> OutputTable::MakeCursor(database::GraphDbAccessor *,
database::GraphDbAccessor &dba) const { utils::MemoryResource *) const {
return std::make_unique<OutputTableCursor>(*this); return std::make_unique<OutputTableCursor>(*this);
} }

View File

@ -18,6 +18,7 @@
#include "utils/bound.hpp" #include "utils/bound.hpp"
#include "utils/future.hpp" #include "utils/future.hpp"
#include "utils/hashing/fnv.hpp" #include "utils/hashing/fnv.hpp"
#include "utils/memory.hpp"
#include "utils/visitor.hpp" #include "utils/visitor.hpp"
namespace database { namespace database {
@ -148,13 +149,19 @@ can serve as inputs to others and thus a sequence of operations is formed.")
#>cpp #>cpp
virtual ~LogicalOperator() {} 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 * @param database::GraphDbAccessor Used to perform operations on the
* database. * database.
* @param utils::MemoryResource Memory resource used for allocations during
* the lifetime of the returned Cursor.
*/ */
virtual std::unique_ptr<Cursor> MakeCursor( virtual std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &) const = 0; database::GraphDbAccessor *, utils::MemoryResource *) const = 0;
std::unique_ptr<Cursor> MakeCursor(database::GraphDbAccessor &dba) const {
return MakeCursor(&dba, utils::NewDeleteResource());
}
/** Return @c Symbol vector where the query results will be stored. /** Return @c Symbol vector where the query results will be stored.
* *
@ -347,7 +354,7 @@ and false on every following Pull.")
#>cpp #>cpp
DEFVISITABLE(HierarchicalLogicalOperatorVisitor); DEFVISITABLE(HierarchicalLogicalOperatorVisitor);
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override { std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override {
return {}; return {};
} }
@ -471,7 +478,7 @@ a preceeding `MATCH`), or multiple nodes (`MATCH ... CREATE` or
const NodeCreationInfo &node_info); const NodeCreationInfo &node_info);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -484,7 +491,8 @@ a preceeding `MATCH`), or multiple nodes (`MATCH ... CREATE` or
#>cpp #>cpp
class CreateNodeCursor : public Cursor { class CreateNodeCursor : public Cursor {
public: public:
CreateNodeCursor(const CreateNode &self, database::GraphDbAccessor &db); CreateNodeCursor(const CreateNode &, database::GraphDbAccessor *,
utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -584,7 +592,7 @@ chained in cases when longer paths need creating.
Symbol input_symbol, bool existing_node); Symbol input_symbol, bool existing_node);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -597,7 +605,8 @@ chained in cases when longer paths need creating.
#>cpp #>cpp
class CreateExpandCursor : public Cursor { class CreateExpandCursor : public Cursor {
public: public:
CreateExpandCursor(const CreateExpand &self, database::GraphDbAccessor &db); CreateExpandCursor(const CreateExpand &, database::GraphDbAccessor *,
utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -669,7 +678,7 @@ with a constructor argument.
GraphView graph_view = GraphView::OLD); GraphView graph_view = GraphView::OLD);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -698,7 +707,7 @@ given label.
GraphView graph_view = GraphView::OLD); GraphView graph_view = GraphView::OLD);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
cpp<#) cpp<#)
(:serialize (:slk) (:capnp)) (:serialize (:slk) (:capnp))
(:clone)) (:clone))
@ -844,7 +853,7 @@ property value which is inside a range (inclusive or exlusive).
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
cpp<#) cpp<#)
(:serialize (:slk) (:capnp)) (:serialize (:slk) (:capnp))
(:clone)) (:clone))
@ -887,7 +896,7 @@ property value.
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
cpp<#) cpp<#)
(:serialize (:slk) (:capnp)) (:serialize (:slk) (:capnp))
(:clone)) (:clone))
@ -973,7 +982,7 @@ pulled.")
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -984,7 +993,8 @@ pulled.")
class ExpandCursor : public Cursor { class ExpandCursor : public Cursor {
public: public:
ExpandCursor(const Expand &self, database::GraphDbAccessor &db); ExpandCursor(const Expand &, database::GraphDbAccessor *,
utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -1162,7 +1172,7 @@ pulled.")
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -1205,7 +1215,7 @@ pulled.")
path_elements_(path_elements) {} path_elements_(path_elements) {}
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -1242,7 +1252,7 @@ a boolean value.")
Expression *expression_); Expression *expression_);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -1255,7 +1265,8 @@ a boolean value.")
#>cpp #>cpp
class FilterCursor : public Cursor { class FilterCursor : public Cursor {
public: public:
FilterCursor(const Filter &self, database::GraphDbAccessor &db); FilterCursor(const Filter &, database::GraphDbAccessor *,
utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -1298,7 +1309,7 @@ RETURN clause) the Produce's pull succeeds exactly once.")
const std::vector<NamedExpression *> &named_expressions); const std::vector<NamedExpression *> &named_expressions);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> OutputSymbols(const SymbolTable &) const override; std::vector<Symbol> OutputSymbols(const SymbolTable &) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
@ -1312,7 +1323,8 @@ RETURN clause) the Produce's pull succeeds exactly once.")
#>cpp #>cpp
class ProduceCursor : public Cursor { class ProduceCursor : public Cursor {
public: public:
ProduceCursor(const Produce &self, database::GraphDbAccessor &db); ProduceCursor(const Produce &, database::GraphDbAccessor *,
utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -1352,7 +1364,7 @@ Has a flag for using DETACH DELETE when deleting vertices.")
const std::vector<Expression *> &expressions, bool detach_); const std::vector<Expression *> &expressions, bool detach_);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -1365,7 +1377,8 @@ Has a flag for using DETACH DELETE when deleting vertices.")
#>cpp #>cpp
class DeleteCursor : public Cursor { class DeleteCursor : public Cursor {
public: public:
DeleteCursor(const Delete &self, database::GraphDbAccessor &db); DeleteCursor(const Delete &, database::GraphDbAccessor *,
utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -1410,7 +1423,7 @@ can be stored (a TypedValue that can be converted to PropertyValue).")
Expression *rhs); Expression *rhs);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -1423,7 +1436,8 @@ can be stored (a TypedValue that can be converted to PropertyValue).")
#>cpp #>cpp
class SetPropertyCursor : public Cursor { class SetPropertyCursor : public Cursor {
public: public:
SetPropertyCursor(const SetProperty &self, database::GraphDbAccessor &db); SetPropertyCursor(const SetProperty &, database::GraphDbAccessor *,
utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() 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); Symbol input_symbol, Expression *rhs, Op op);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -1487,8 +1501,8 @@ that the old properties are discarded and replaced with new ones.")
#>cpp #>cpp
class SetPropertiesCursor : public Cursor { class SetPropertiesCursor : public Cursor {
public: public:
SetPropertiesCursor(const SetProperties &self, SetPropertiesCursor(const SetProperties &, database::GraphDbAccessor *,
database::GraphDbAccessor &db); utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -1532,7 +1546,7 @@ It does NOT remove labels that are already set on that Vertex.")
const std::vector<storage::Label> &labels); const std::vector<storage::Label> &labels);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -1545,7 +1559,8 @@ It does NOT remove labels that are already set on that Vertex.")
#>cpp #>cpp
class SetLabelsCursor : public Cursor { class SetLabelsCursor : public Cursor {
public: public:
SetLabelsCursor(const SetLabels &self, database::GraphDbAccessor &db); SetLabelsCursor(const SetLabels &, database::GraphDbAccessor *,
utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() 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); storage::Property property, PropertyLookup *lhs);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -1593,8 +1608,8 @@ It does NOT remove labels that are already set on that Vertex.")
#>cpp #>cpp
class RemovePropertyCursor : public Cursor { class RemovePropertyCursor : public Cursor {
public: public:
RemovePropertyCursor(const RemoveProperty &self, RemovePropertyCursor(const RemoveProperty &, database::GraphDbAccessor *,
database::GraphDbAccessor &db); utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() 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<storage::Label> &labels); Symbol input_symbol, const std::vector<storage::Label> &labels);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -1642,7 +1657,8 @@ If a label does not exist on a Vertex, nothing happens.")
#>cpp #>cpp
class RemoveLabelsCursor : public Cursor { class RemoveLabelsCursor : public Cursor {
public: public:
RemoveLabelsCursor(const RemoveLabels &self, database::GraphDbAccessor &db); RemoveLabelsCursor(const RemoveLabels &, database::GraphDbAccessor *,
utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -1688,7 +1704,7 @@ edge lists).")
const std::vector<Symbol> &previous_symbols); const std::vector<Symbol> &previous_symbols);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -1701,8 +1717,9 @@ edge lists).")
#>cpp #>cpp
class EdgeUniquenessFilterCursor : public Cursor { class EdgeUniquenessFilterCursor : public Cursor {
public: public:
EdgeUniquenessFilterCursor(const EdgeUniquenessFilter &self, EdgeUniquenessFilterCursor(const EdgeUniquenessFilter &,
database::GraphDbAccessor &db); database::GraphDbAccessor *,
utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -1760,7 +1777,7 @@ has been cached will be reconstructed before Pull returns.
const std::vector<Symbol> &symbols, bool advance_command = false); const std::vector<Symbol> &symbols, bool advance_command = false);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -1773,7 +1790,8 @@ has been cached will be reconstructed before Pull returns.
#>cpp #>cpp
class AccumulateCursor : public Cursor { class AccumulateCursor : public Cursor {
public: public:
AccumulateCursor(const Accumulate &self, database::GraphDbAccessor &db); AccumulateCursor(const Accumulate &, database::GraphDbAccessor *,
utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -1893,7 +1911,7 @@ elements are in an undefined state after aggregation.")
const std::vector<Symbol> &remember); const std::vector<Symbol> &remember);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -1906,7 +1924,8 @@ elements are in an undefined state after aggregation.")
#>cpp #>cpp
class AggregateCursor : public Cursor { class AggregateCursor : public Cursor {
public: public:
AggregateCursor(const Aggregate &self, database::GraphDbAccessor &db); AggregateCursor(const Aggregate &, database::GraphDbAccessor *,
utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -2017,7 +2036,7 @@ operator's implementation does not expect this.")
Skip(const std::shared_ptr<LogicalOperator> &input, Expression *expression); Skip(const std::shared_ptr<LogicalOperator> &input, Expression *expression);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> OutputSymbols(const SymbolTable &) const override; std::vector<Symbol> OutputSymbols(const SymbolTable &) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
@ -2031,7 +2050,8 @@ operator's implementation does not expect this.")
#>cpp #>cpp
class SkipCursor : public Cursor { class SkipCursor : public Cursor {
public: public:
SkipCursor(const Skip &self, database::GraphDbAccessor &db); SkipCursor(const Skip &, database::GraphDbAccessor *,
utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -2081,7 +2101,7 @@ input should be performed).")
Limit(const std::shared_ptr<LogicalOperator> &input, Expression *expression); Limit(const std::shared_ptr<LogicalOperator> &input, Expression *expression);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> OutputSymbols(const SymbolTable &) const override; std::vector<Symbol> OutputSymbols(const SymbolTable &) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
@ -2095,7 +2115,8 @@ input should be performed).")
#>cpp #>cpp
class LimitCursor : public Cursor { class LimitCursor : public Cursor {
public: public:
LimitCursor(const Limit &self, database::GraphDbAccessor &db); LimitCursor(const Limit &, database::GraphDbAccessor *,
utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -2149,7 +2170,7 @@ are valid for usage after the OrderBy operator.")
const std::vector<Symbol> &output_symbols); const std::vector<Symbol> &output_symbols);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> OutputSymbols(const SymbolTable &) const override; std::vector<Symbol> OutputSymbols(const SymbolTable &) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
@ -2163,7 +2184,8 @@ are valid for usage after the OrderBy operator.")
#>cpp #>cpp
class OrderByCursor : public Cursor { class OrderByCursor : public Cursor {
public: public:
OrderByCursor(const OrderBy &self, database::GraphDbAccessor &db); OrderByCursor(const OrderBy &, database::GraphDbAccessor *,
utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -2222,7 +2244,7 @@ documentation.")
const std::shared_ptr<LogicalOperator> &merge_create); const std::shared_ptr<LogicalOperator> &merge_create);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
// TODO: Consider whether we want to treat Merge as having single input. It // TODO: Consider whether we want to treat Merge as having single input. It
@ -2238,7 +2260,8 @@ documentation.")
#>cpp #>cpp
class MergeCursor : public Cursor { class MergeCursor : public Cursor {
public: public:
MergeCursor(const Merge &self, database::GraphDbAccessor &db); MergeCursor(const Merge &, database::GraphDbAccessor *,
utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -2289,7 +2312,7 @@ and returns true, once.")
const std::vector<Symbol> &optional_symbols); const std::vector<Symbol> &optional_symbols);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -2302,7 +2325,8 @@ and returns true, once.")
#>cpp #>cpp
class OptionalCursor : public Cursor { class OptionalCursor : public Cursor {
public: public:
OptionalCursor(const Optional &self, database::GraphDbAccessor &db); OptionalCursor(const Optional &, database::GraphDbAccessor *,
utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() 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); Expression *input_expression_, Symbol output_symbol);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { bool HasSingleInput() const override {
@ -2362,7 +2386,8 @@ Input is optional (unwind can be the first clause in a query).")
#>cpp #>cpp
class UnwindCursor : public Cursor { class UnwindCursor : public Cursor {
public: public:
UnwindCursor(const Unwind &self, database::GraphDbAccessor &db); UnwindCursor(const Unwind &, database::GraphDbAccessor *,
utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -2404,7 +2429,7 @@ This implementation maintains input ordering.")
const std::vector<Symbol> &value_symbols); const std::vector<Symbol> &value_symbols);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> OutputSymbols(const SymbolTable &) const override; std::vector<Symbol> OutputSymbols(const SymbolTable &) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
@ -2418,7 +2443,8 @@ This implementation maintains input ordering.")
#>cpp #>cpp
class DistinctCursor : public Cursor { class DistinctCursor : public Cursor {
public: public:
DistinctCursor(const Distinct &self, database::GraphDbAccessor &db); DistinctCursor(const Distinct &, database::GraphDbAccessor *,
utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
@ -2477,7 +2503,7 @@ of symbols used by each of the inputs.")
const std::vector<Symbol> &right_symbols); const std::vector<Symbol> &right_symbols);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> OutputSymbols(const SymbolTable &) const override; std::vector<Symbol> OutputSymbols(const SymbolTable &) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
@ -2489,7 +2515,8 @@ of symbols used by each of the inputs.")
#>cpp #>cpp
class UnionCursor : public Cursor { class UnionCursor : public Cursor {
public: public:
UnionCursor(const Union &self, database::GraphDbAccessor &db); UnionCursor(const Union &, database::GraphDbAccessor *,
utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -2537,8 +2564,8 @@ of symbols used by each of the inputs.")
right_symbols_(right_symbols) {} right_symbols_(right_symbols) {}
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &db) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override; bool HasSingleInput() const override;
@ -2568,7 +2595,7 @@ of symbols used by each of the inputs.")
} }
std::unique_ptr<Cursor> MakeCursor( std::unique_ptr<Cursor> MakeCursor(
database::GraphDbAccessor &) const override; database::GraphDbAccessor *, utils::MemoryResource *) const override;
std::vector<Symbol> OutputSymbols(const SymbolTable &) const override { std::vector<Symbol> OutputSymbols(const SymbolTable &) const override {
return output_symbols_; return output_symbols_;
} }

View File

@ -110,8 +110,9 @@ class Yield : public query::plan::LogicalOperator {
values_(values) {} values_(values) {}
std::unique_ptr<query::plan::Cursor> MakeCursor( std::unique_ptr<query::plan::Cursor> MakeCursor(
database::GraphDbAccessor &dba) const override { database::GraphDbAccessor *dba,
return std::make_unique<YieldCursor>(this, input_->MakeCursor(dba)); utils::MemoryResource *mem) const override {
return std::make_unique<YieldCursor>(this, input_->MakeCursor(dba, mem));
} }
std::vector<query::Symbol> ModifiedSymbols( std::vector<query::Symbol> ModifiedSymbols(
const query::SymbolTable &) const override { const query::SymbolTable &) const override {

View File

@ -20,7 +20,8 @@ TEST_F(DistributedReset, ResetTest) {
auto dba = master().Access(); auto dba = master().Access();
query::Frame frame(0); query::Frame frame(0);
query::ExecutionContext context{dba.get()}; 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) { for (int i = 0; i < 3; ++i) {
EXPECT_TRUE(pull_remote_cursor->Pull(frame, context)); EXPECT_TRUE(pull_remote_cursor->Pull(frame, context));

View File

@ -42,7 +42,8 @@ std::vector<std::vector<TypedValue>> CollectProduce(const Produce &produce,
symbols.emplace_back(context->symbol_table.at(*named_expression)); symbols.emplace_back(context->symbol_table.at(*named_expression));
// stream out results // stream out results
auto cursor = produce.MakeCursor(*context->db_accessor); auto cursor =
produce.query::plan::LogicalOperator::MakeCursor(*context->db_accessor);
std::vector<std::vector<TypedValue>> results; std::vector<std::vector<TypedValue>> results;
while (cursor->Pull(frame, *context)) { while (cursor->Pull(frame, *context)) {
std::vector<TypedValue> values; std::vector<TypedValue> values;

View File

@ -280,7 +280,8 @@ TEST(QueryPlan, Delete) {
n.op_, std::vector<Expression *>{n_get}, true); n.op_, std::vector<Expression *>{n_get}, true);
Frame frame(symbol_table.max_position()); Frame frame(symbol_table.max_position());
auto context = MakeContext(storage, symbol_table, &dba); 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(); dba.AdvanceCommand();
EXPECT_EQ(3, CountIterable(dba.Vertices(false))); EXPECT_EQ(3, CountIterable(dba.Vertices(false)));
EXPECT_EQ(3, CountIterable(dba.Edges(false))); EXPECT_EQ(3, CountIterable(dba.Edges(false)));