Query::Plan::Operator - ACCEPT macro, Cursor::Reset, const correctness
Summary: Query::Plan::Operator - ACCEPT_WITH_INPUT macro for default accept implementation Query::Plan::Cursor Reset() function added (NOT tested), will be needed for MERGE Query::Plan - logical const correctness and cleanup Reviewers: teon.banek, buda Reviewed By: teon.banek Differential Revision: https://phabricator.memgraph.io/D311
This commit is contained in:
parent
f86c96e62c
commit
d29a1f5353
@ -6,6 +6,17 @@
|
|||||||
#include "query/frontend/ast/ast.hpp"
|
#include "query/frontend/ast/ast.hpp"
|
||||||
#include "query/interpret/eval.hpp"
|
#include "query/interpret/eval.hpp"
|
||||||
|
|
||||||
|
// macro for the default implementation of LogicalOperator::Accept
|
||||||
|
// that accepts the visitor and visits it's input_ operator
|
||||||
|
#define ACCEPT_WITH_INPUT(class_name) \
|
||||||
|
void class_name::Accept(LogicalOperatorVisitor &visitor) { \
|
||||||
|
if (visitor.PreVisit(*this)) { \
|
||||||
|
visitor.Visit(*this); \
|
||||||
|
input_->Accept(visitor); \
|
||||||
|
visitor.PostVisit(*this); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
namespace query {
|
namespace query {
|
||||||
namespace plan {
|
namespace plan {
|
||||||
|
|
||||||
@ -27,17 +38,13 @@ bool Once::OnceCursor::Pull(Frame &frame, const SymbolTable &symbol_table) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Once::OnceCursor::Reset() { did_pull_ = false; }
|
||||||
|
|
||||||
CreateNode::CreateNode(const NodeAtom *node_atom,
|
CreateNode::CreateNode(const NodeAtom *node_atom,
|
||||||
const std::shared_ptr<LogicalOperator> &input)
|
const std::shared_ptr<LogicalOperator> &input)
|
||||||
: node_atom_(node_atom), input_(input ? input : std::make_shared<Once>()) {}
|
: node_atom_(node_atom), input_(input ? input : std::make_shared<Once>()) {}
|
||||||
|
|
||||||
void CreateNode::Accept(LogicalOperatorVisitor &visitor) {
|
ACCEPT_WITH_INPUT(CreateNode)
|
||||||
if (visitor.PreVisit(*this)) {
|
|
||||||
visitor.Visit(*this);
|
|
||||||
input_->Accept(visitor);
|
|
||||||
visitor.PostVisit(*this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<Cursor> CreateNode::MakeCursor(GraphDbAccessor &db) {
|
std::unique_ptr<Cursor> CreateNode::MakeCursor(GraphDbAccessor &db) {
|
||||||
return std::make_unique<CreateNodeCursor>(*this, db);
|
return std::make_unique<CreateNodeCursor>(*this, db);
|
||||||
@ -56,6 +63,8 @@ bool CreateNode::CreateNodeCursor::Pull(Frame &frame,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CreateNode::CreateNodeCursor::Reset() { input_cursor_->Reset(); }
|
||||||
|
|
||||||
void CreateNode::CreateNodeCursor::Create(Frame &frame,
|
void CreateNode::CreateNodeCursor::Create(Frame &frame,
|
||||||
const SymbolTable &symbol_table) {
|
const SymbolTable &symbol_table) {
|
||||||
auto new_node = db_.insert_vertex();
|
auto new_node = db_.insert_vertex();
|
||||||
@ -81,13 +90,7 @@ CreateExpand::CreateExpand(const NodeAtom *node_atom, const EdgeAtom *edge_atom,
|
|||||||
input_symbol_(input_symbol),
|
input_symbol_(input_symbol),
|
||||||
node_existing_(node_existing) {}
|
node_existing_(node_existing) {}
|
||||||
|
|
||||||
void CreateExpand::Accept(LogicalOperatorVisitor &visitor) {
|
ACCEPT_WITH_INPUT(CreateExpand)
|
||||||
if (visitor.PreVisit(*this)) {
|
|
||||||
visitor.Visit(*this);
|
|
||||||
input_->Accept(visitor);
|
|
||||||
visitor.PostVisit(*this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<Cursor> CreateExpand::MakeCursor(GraphDbAccessor &db) {
|
std::unique_ptr<Cursor> CreateExpand::MakeCursor(GraphDbAccessor &db) {
|
||||||
return std::make_unique<CreateExpandCursor>(*this, db);
|
return std::make_unique<CreateExpandCursor>(*this, db);
|
||||||
@ -131,6 +134,8 @@ bool CreateExpand::CreateExpandCursor::Pull(Frame &frame,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CreateExpand::CreateExpandCursor::Reset() { input_cursor_->Reset(); }
|
||||||
|
|
||||||
VertexAccessor &CreateExpand::CreateExpandCursor::OtherVertex(
|
VertexAccessor &CreateExpand::CreateExpandCursor::OtherVertex(
|
||||||
Frame &frame, const SymbolTable &symbol_table,
|
Frame &frame, const SymbolTable &symbol_table,
|
||||||
ExpressionEvaluator &evaluator) {
|
ExpressionEvaluator &evaluator) {
|
||||||
@ -168,13 +173,7 @@ ScanAll::ScanAll(const NodeAtom *node_atom,
|
|||||||
const std::shared_ptr<LogicalOperator> &input)
|
const std::shared_ptr<LogicalOperator> &input)
|
||||||
: node_atom_(node_atom), input_(input ? input : std::make_shared<Once>()) {}
|
: node_atom_(node_atom), input_(input ? input : std::make_shared<Once>()) {}
|
||||||
|
|
||||||
void ScanAll::Accept(LogicalOperatorVisitor &visitor) {
|
ACCEPT_WITH_INPUT(ScanAll)
|
||||||
if (visitor.PreVisit(*this)) {
|
|
||||||
visitor.Visit(*this);
|
|
||||||
input_->Accept(visitor);
|
|
||||||
visitor.PostVisit(*this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<Cursor> ScanAll::MakeCursor(GraphDbAccessor &db) {
|
std::unique_ptr<Cursor> ScanAll::MakeCursor(GraphDbAccessor &db) {
|
||||||
return std::make_unique<ScanAllCursor>(*this, db);
|
return std::make_unique<ScanAllCursor>(*this, db);
|
||||||
@ -201,6 +200,11 @@ bool ScanAll::ScanAllCursor::Pull(Frame &frame,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScanAll::ScanAllCursor::Reset() {
|
||||||
|
input_cursor_->Reset();
|
||||||
|
vertices_it_ = vertices_.end();
|
||||||
|
}
|
||||||
|
|
||||||
Expand::Expand(const NodeAtom *node_atom, const EdgeAtom *edge_atom,
|
Expand::Expand(const NodeAtom *node_atom, const EdgeAtom *edge_atom,
|
||||||
const std::shared_ptr<LogicalOperator> &input,
|
const std::shared_ptr<LogicalOperator> &input,
|
||||||
Symbol input_symbol, bool node_cycle, bool edge_cycle)
|
Symbol input_symbol, bool node_cycle, bool edge_cycle)
|
||||||
@ -211,13 +215,7 @@ Expand::Expand(const NodeAtom *node_atom, const EdgeAtom *edge_atom,
|
|||||||
node_cycle_(node_cycle),
|
node_cycle_(node_cycle),
|
||||||
edge_cycle_(edge_cycle) {}
|
edge_cycle_(edge_cycle) {}
|
||||||
|
|
||||||
void Expand::Accept(LogicalOperatorVisitor &visitor) {
|
ACCEPT_WITH_INPUT(Expand)
|
||||||
if (visitor.PreVisit(*this)) {
|
|
||||||
visitor.Visit(*this);
|
|
||||||
input_->Accept(visitor);
|
|
||||||
visitor.PostVisit(*this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<Cursor> Expand::MakeCursor(GraphDbAccessor &db) {
|
std::unique_ptr<Cursor> Expand::MakeCursor(GraphDbAccessor &db) {
|
||||||
return std::make_unique<ExpandCursor>(*this, db);
|
return std::make_unique<ExpandCursor>(*this, db);
|
||||||
@ -263,6 +261,14 @@ bool Expand::ExpandCursor::Pull(Frame &frame, const SymbolTable &symbol_table) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Expand::ExpandCursor::Reset() {
|
||||||
|
input_cursor_->Reset();
|
||||||
|
in_edges_.release();
|
||||||
|
in_edges_it_.release();
|
||||||
|
out_edges_.release();
|
||||||
|
out_edges_it_.release();
|
||||||
|
}
|
||||||
|
|
||||||
bool Expand::ExpandCursor::InitEdges(Frame &frame,
|
bool Expand::ExpandCursor::InitEdges(Frame &frame,
|
||||||
const SymbolTable &symbol_table) {
|
const SymbolTable &symbol_table) {
|
||||||
if (!input_cursor_->Pull(frame, symbol_table)) return false;
|
if (!input_cursor_->Pull(frame, symbol_table)) return false;
|
||||||
@ -341,13 +347,7 @@ NodeFilter::NodeFilter(const std::shared_ptr<LogicalOperator> &input,
|
|||||||
Symbol input_symbol, const NodeAtom *node_atom)
|
Symbol input_symbol, const NodeAtom *node_atom)
|
||||||
: input_(input), input_symbol_(input_symbol), node_atom_(node_atom) {}
|
: input_(input), input_symbol_(input_symbol), node_atom_(node_atom) {}
|
||||||
|
|
||||||
void NodeFilter::Accept(LogicalOperatorVisitor &visitor) {
|
ACCEPT_WITH_INPUT(NodeFilter)
|
||||||
if (visitor.PreVisit(*this)) {
|
|
||||||
visitor.Visit(*this);
|
|
||||||
input_->Accept(visitor);
|
|
||||||
visitor.PostVisit(*this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<Cursor> NodeFilter::MakeCursor(GraphDbAccessor &db) {
|
std::unique_ptr<Cursor> NodeFilter::MakeCursor(GraphDbAccessor &db) {
|
||||||
return std::make_unique<NodeFilterCursor>(*this, db);
|
return std::make_unique<NodeFilterCursor>(*this, db);
|
||||||
@ -369,6 +369,8 @@ bool NodeFilter::NodeFilterCursor::Pull(Frame &frame,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NodeFilter::NodeFilterCursor::Reset() { input_cursor_->Reset(); }
|
||||||
|
|
||||||
bool NodeFilter::NodeFilterCursor::VertexPasses(
|
bool NodeFilter::NodeFilterCursor::VertexPasses(
|
||||||
const VertexAccessor &vertex, Frame &frame,
|
const VertexAccessor &vertex, Frame &frame,
|
||||||
const SymbolTable &symbol_table) {
|
const SymbolTable &symbol_table) {
|
||||||
@ -392,13 +394,7 @@ EdgeFilter::EdgeFilter(const std::shared_ptr<LogicalOperator> &input,
|
|||||||
Symbol input_symbol, const EdgeAtom *edge_atom)
|
Symbol input_symbol, const EdgeAtom *edge_atom)
|
||||||
: input_(input), input_symbol_(input_symbol), edge_atom_(edge_atom) {}
|
: input_(input), input_symbol_(input_symbol), edge_atom_(edge_atom) {}
|
||||||
|
|
||||||
void EdgeFilter::Accept(LogicalOperatorVisitor &visitor) {
|
ACCEPT_WITH_INPUT(EdgeFilter)
|
||||||
if (visitor.PreVisit(*this)) {
|
|
||||||
visitor.Visit(*this);
|
|
||||||
input_->Accept(visitor);
|
|
||||||
visitor.PostVisit(*this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<Cursor> EdgeFilter::MakeCursor(GraphDbAccessor &db) {
|
std::unique_ptr<Cursor> EdgeFilter::MakeCursor(GraphDbAccessor &db) {
|
||||||
return std::make_unique<EdgeFilterCursor>(*this, db);
|
return std::make_unique<EdgeFilterCursor>(*this, db);
|
||||||
@ -419,6 +415,8 @@ bool EdgeFilter::EdgeFilterCursor::Pull(Frame &frame,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EdgeFilter::EdgeFilterCursor::Reset() { input_cursor_->Reset(); }
|
||||||
|
|
||||||
bool EdgeFilter::EdgeFilterCursor::EdgePasses(const EdgeAccessor &edge,
|
bool EdgeFilter::EdgeFilterCursor::EdgePasses(const EdgeAccessor &edge,
|
||||||
Frame &frame,
|
Frame &frame,
|
||||||
const SymbolTable &symbol_table) {
|
const SymbolTable &symbol_table) {
|
||||||
@ -446,13 +444,7 @@ Filter::Filter(const std::shared_ptr<LogicalOperator> &input_,
|
|||||||
Expression *expression_)
|
Expression *expression_)
|
||||||
: input_(input_), expression_(expression_) {}
|
: input_(input_), expression_(expression_) {}
|
||||||
|
|
||||||
void Filter::Accept(LogicalOperatorVisitor &visitor) {
|
ACCEPT_WITH_INPUT(Filter)
|
||||||
if (visitor.PreVisit(*this)) {
|
|
||||||
visitor.Visit(*this);
|
|
||||||
input_->Accept(visitor);
|
|
||||||
visitor.PostVisit(*this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<Cursor> Filter::MakeCursor(GraphDbAccessor &db) {
|
std::unique_ptr<Cursor> Filter::MakeCursor(GraphDbAccessor &db) {
|
||||||
return std::make_unique<FilterCursor>(*this, db);
|
return std::make_unique<FilterCursor>(*this, db);
|
||||||
@ -475,18 +467,14 @@ bool Filter::FilterCursor::Pull(Frame &frame, const SymbolTable &symbol_table) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Filter::FilterCursor::Reset() { input_cursor_->Reset(); }
|
||||||
|
|
||||||
Produce::Produce(const std::shared_ptr<LogicalOperator> &input,
|
Produce::Produce(const std::shared_ptr<LogicalOperator> &input,
|
||||||
const std::vector<NamedExpression *> named_expressions)
|
const std::vector<NamedExpression *> named_expressions)
|
||||||
: input_(input ? input : std::make_shared<Once>()),
|
: input_(input ? input : std::make_shared<Once>()),
|
||||||
named_expressions_(named_expressions) {}
|
named_expressions_(named_expressions) {}
|
||||||
|
|
||||||
void Produce::Accept(LogicalOperatorVisitor &visitor) {
|
ACCEPT_WITH_INPUT(Produce)
|
||||||
if (visitor.PreVisit(*this)) {
|
|
||||||
visitor.Visit(*this);
|
|
||||||
input_->Accept(visitor);
|
|
||||||
visitor.PostVisit(*this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<Cursor> Produce::MakeCursor(GraphDbAccessor &db) {
|
std::unique_ptr<Cursor> Produce::MakeCursor(GraphDbAccessor &db) {
|
||||||
return std::make_unique<ProduceCursor>(*this, db);
|
return std::make_unique<ProduceCursor>(*this, db);
|
||||||
@ -498,6 +486,7 @@ const std::vector<NamedExpression *> &Produce::named_expressions() {
|
|||||||
|
|
||||||
Produce::ProduceCursor::ProduceCursor(const Produce &self, GraphDbAccessor &db)
|
Produce::ProduceCursor::ProduceCursor(const Produce &self, GraphDbAccessor &db)
|
||||||
: self_(self), input_cursor_(self_.input_->MakeCursor(db)) {}
|
: self_(self), input_cursor_(self_.input_->MakeCursor(db)) {}
|
||||||
|
|
||||||
bool Produce::ProduceCursor::Pull(Frame &frame,
|
bool Produce::ProduceCursor::Pull(Frame &frame,
|
||||||
const SymbolTable &symbol_table) {
|
const SymbolTable &symbol_table) {
|
||||||
if (input_cursor_->Pull(frame, symbol_table)) {
|
if (input_cursor_->Pull(frame, symbol_table)) {
|
||||||
@ -511,17 +500,13 @@ bool Produce::ProduceCursor::Pull(Frame &frame,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Produce::ProduceCursor::Reset() { input_cursor_->Reset(); }
|
||||||
|
|
||||||
Delete::Delete(const std::shared_ptr<LogicalOperator> &input_,
|
Delete::Delete(const std::shared_ptr<LogicalOperator> &input_,
|
||||||
const std::vector<Expression *> &expressions, bool detach_)
|
const std::vector<Expression *> &expressions, bool detach_)
|
||||||
: input_(input_), expressions_(expressions), detach_(detach_) {}
|
: input_(input_), expressions_(expressions), detach_(detach_) {}
|
||||||
|
|
||||||
void Delete::Accept(LogicalOperatorVisitor &visitor) {
|
ACCEPT_WITH_INPUT(Delete)
|
||||||
if (visitor.PreVisit(*this)) {
|
|
||||||
visitor.Visit(*this);
|
|
||||||
input_->Accept(visitor);
|
|
||||||
visitor.PostVisit(*this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<Cursor> Delete::MakeCursor(GraphDbAccessor &db) {
|
std::unique_ptr<Cursor> Delete::MakeCursor(GraphDbAccessor &db) {
|
||||||
return std::make_unique<DeleteCursor>(*this, db);
|
return std::make_unique<DeleteCursor>(*this, db);
|
||||||
@ -577,17 +562,13 @@ bool Delete::DeleteCursor::Pull(Frame &frame, const SymbolTable &symbol_table) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Delete::DeleteCursor::Reset() { input_cursor_->Reset(); }
|
||||||
|
|
||||||
SetProperty::SetProperty(const std::shared_ptr<LogicalOperator> &input,
|
SetProperty::SetProperty(const std::shared_ptr<LogicalOperator> &input,
|
||||||
PropertyLookup *lhs, Expression *rhs)
|
PropertyLookup *lhs, Expression *rhs)
|
||||||
: input_(input), lhs_(lhs), rhs_(rhs) {}
|
: input_(input), lhs_(lhs), rhs_(rhs) {}
|
||||||
|
|
||||||
void SetProperty::Accept(LogicalOperatorVisitor &visitor) {
|
ACCEPT_WITH_INPUT(SetProperty)
|
||||||
if (visitor.PreVisit(*this)) {
|
|
||||||
visitor.Visit(*this);
|
|
||||||
input_->Accept(visitor);
|
|
||||||
visitor.PostVisit(*this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<Cursor> SetProperty::MakeCursor(GraphDbAccessor &db) {
|
std::unique_ptr<Cursor> SetProperty::MakeCursor(GraphDbAccessor &db) {
|
||||||
return std::make_unique<SetPropertyCursor>(*this, db);
|
return std::make_unique<SetPropertyCursor>(*this, db);
|
||||||
@ -628,17 +609,13 @@ bool SetProperty::SetPropertyCursor::Pull(Frame &frame,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetProperty::SetPropertyCursor::Reset() { input_cursor_->Reset(); }
|
||||||
|
|
||||||
SetProperties::SetProperties(const std::shared_ptr<LogicalOperator> &input,
|
SetProperties::SetProperties(const std::shared_ptr<LogicalOperator> &input,
|
||||||
Symbol input_symbol, Expression *rhs, Op op)
|
Symbol input_symbol, Expression *rhs, Op op)
|
||||||
: input_(input), input_symbol_(input_symbol), rhs_(rhs), op_(op) {}
|
: input_(input), input_symbol_(input_symbol), rhs_(rhs), op_(op) {}
|
||||||
|
|
||||||
void SetProperties::Accept(LogicalOperatorVisitor &visitor) {
|
ACCEPT_WITH_INPUT(SetProperties)
|
||||||
if (visitor.PreVisit(*this)) {
|
|
||||||
visitor.Visit(*this);
|
|
||||||
input_->Accept(visitor);
|
|
||||||
visitor.PostVisit(*this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<Cursor> SetProperties::MakeCursor(GraphDbAccessor &db) {
|
std::unique_ptr<Cursor> SetProperties::MakeCursor(GraphDbAccessor &db) {
|
||||||
return std::make_unique<SetPropertiesCursor>(*this, db);
|
return std::make_unique<SetPropertiesCursor>(*this, db);
|
||||||
@ -674,9 +651,11 @@ bool SetProperties::SetPropertiesCursor::Pull(Frame &frame,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetProperties::SetPropertiesCursor::Reset() { input_cursor_->Reset(); }
|
||||||
|
|
||||||
template <typename TRecordAccessor>
|
template <typename TRecordAccessor>
|
||||||
void SetProperties::SetPropertiesCursor::Set(TRecordAccessor &record,
|
void SetProperties::SetPropertiesCursor::Set(TRecordAccessor &record,
|
||||||
const TypedValue &rhs) {
|
const TypedValue &rhs) const {
|
||||||
record.SwitchNew();
|
record.SwitchNew();
|
||||||
if (self_.op_ == Op::REPLACE) record.PropsClear();
|
if (self_.op_ == Op::REPLACE) record.PropsClear();
|
||||||
|
|
||||||
@ -708,22 +687,16 @@ void SetProperties::SetPropertiesCursor::Set(TRecordAccessor &record,
|
|||||||
|
|
||||||
// instantiate the SetProperties function with concrete TRecordAccessor types
|
// instantiate the SetProperties function with concrete TRecordAccessor types
|
||||||
template void SetProperties::SetPropertiesCursor::Set(
|
template void SetProperties::SetPropertiesCursor::Set(
|
||||||
RecordAccessor<Vertex> &record, const TypedValue &rhs);
|
RecordAccessor<Vertex> &record, const TypedValue &rhs) const;
|
||||||
template void SetProperties::SetPropertiesCursor::Set(
|
template void SetProperties::SetPropertiesCursor::Set(
|
||||||
RecordAccessor<Edge> &record, const TypedValue &rhs);
|
RecordAccessor<Edge> &record, const TypedValue &rhs) const;
|
||||||
|
|
||||||
SetLabels::SetLabels(const std::shared_ptr<LogicalOperator> &input,
|
SetLabels::SetLabels(const std::shared_ptr<LogicalOperator> &input,
|
||||||
Symbol input_symbol,
|
Symbol input_symbol,
|
||||||
const std::vector<GraphDbTypes::Label> &labels)
|
const std::vector<GraphDbTypes::Label> &labels)
|
||||||
: input_(input), input_symbol_(input_symbol), labels_(labels) {}
|
: input_(input), input_symbol_(input_symbol), labels_(labels) {}
|
||||||
|
|
||||||
void SetLabels::Accept(LogicalOperatorVisitor &visitor) {
|
ACCEPT_WITH_INPUT(SetLabels)
|
||||||
if (visitor.PreVisit(*this)) {
|
|
||||||
visitor.Visit(*this);
|
|
||||||
input_->Accept(visitor);
|
|
||||||
visitor.PostVisit(*this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<Cursor> SetLabels::MakeCursor(GraphDbAccessor &db) {
|
std::unique_ptr<Cursor> SetLabels::MakeCursor(GraphDbAccessor &db) {
|
||||||
return std::make_unique<SetLabelsCursor>(*this, db);
|
return std::make_unique<SetLabelsCursor>(*this, db);
|
||||||
@ -745,17 +718,13 @@ bool SetLabels::SetLabelsCursor::Pull(Frame &frame,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetLabels::SetLabelsCursor::Reset() { input_cursor_->Reset(); }
|
||||||
|
|
||||||
RemoveProperty::RemoveProperty(const std::shared_ptr<LogicalOperator> &input,
|
RemoveProperty::RemoveProperty(const std::shared_ptr<LogicalOperator> &input,
|
||||||
PropertyLookup *lhs)
|
PropertyLookup *lhs)
|
||||||
: input_(input), lhs_(lhs) {}
|
: input_(input), lhs_(lhs) {}
|
||||||
|
|
||||||
void RemoveProperty::Accept(LogicalOperatorVisitor &visitor) {
|
ACCEPT_WITH_INPUT(RemoveProperty)
|
||||||
if (visitor.PreVisit(*this)) {
|
|
||||||
visitor.Visit(*this);
|
|
||||||
input_->Accept(visitor);
|
|
||||||
visitor.PostVisit(*this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<Cursor> RemoveProperty::MakeCursor(GraphDbAccessor &db) {
|
std::unique_ptr<Cursor> RemoveProperty::MakeCursor(GraphDbAccessor &db) {
|
||||||
return std::make_unique<RemovePropertyCursor>(*this, db);
|
return std::make_unique<RemovePropertyCursor>(*this, db);
|
||||||
@ -791,18 +760,14 @@ bool RemoveProperty::RemovePropertyCursor::Pull(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RemoveProperty::RemovePropertyCursor::Reset() { input_cursor_->Reset(); }
|
||||||
|
|
||||||
RemoveLabels::RemoveLabels(const std::shared_ptr<LogicalOperator> &input,
|
RemoveLabels::RemoveLabels(const std::shared_ptr<LogicalOperator> &input,
|
||||||
Symbol input_symbol,
|
Symbol input_symbol,
|
||||||
const std::vector<GraphDbTypes::Label> &labels)
|
const std::vector<GraphDbTypes::Label> &labels)
|
||||||
: input_(input), input_symbol_(input_symbol), labels_(labels) {}
|
: input_(input), input_symbol_(input_symbol), labels_(labels) {}
|
||||||
|
|
||||||
void RemoveLabels::Accept(LogicalOperatorVisitor &visitor) {
|
ACCEPT_WITH_INPUT(RemoveLabels)
|
||||||
if (visitor.PreVisit(*this)) {
|
|
||||||
visitor.Visit(*this);
|
|
||||||
input_->Accept(visitor);
|
|
||||||
visitor.PostVisit(*this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<Cursor> RemoveLabels::MakeCursor(GraphDbAccessor &db) {
|
std::unique_ptr<Cursor> RemoveLabels::MakeCursor(GraphDbAccessor &db) {
|
||||||
return std::make_unique<RemoveLabelsCursor>(*this, db);
|
return std::make_unique<RemoveLabelsCursor>(*this, db);
|
||||||
@ -824,6 +789,8 @@ bool RemoveLabels::RemoveLabelsCursor::Pull(Frame &frame,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RemoveLabels::RemoveLabelsCursor::Reset() { input_cursor_->Reset(); }
|
||||||
|
|
||||||
template <typename TAccessor>
|
template <typename TAccessor>
|
||||||
ExpandUniquenessFilter<TAccessor>::ExpandUniquenessFilter(
|
ExpandUniquenessFilter<TAccessor>::ExpandUniquenessFilter(
|
||||||
const std::shared_ptr<LogicalOperator> &input, Symbol expand_symbol,
|
const std::shared_ptr<LogicalOperator> &input, Symbol expand_symbol,
|
||||||
@ -833,14 +800,7 @@ ExpandUniquenessFilter<TAccessor>::ExpandUniquenessFilter(
|
|||||||
previous_symbols_(previous_symbols) {}
|
previous_symbols_(previous_symbols) {}
|
||||||
|
|
||||||
template <typename TAccessor>
|
template <typename TAccessor>
|
||||||
void ExpandUniquenessFilter<TAccessor>::Accept(
|
ACCEPT_WITH_INPUT(ExpandUniquenessFilter<TAccessor>)
|
||||||
LogicalOperatorVisitor &visitor) {
|
|
||||||
if (visitor.PreVisit(*this)) {
|
|
||||||
visitor.Visit(*this);
|
|
||||||
input_->Accept(visitor);
|
|
||||||
visitor.PostVisit(*this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename TAccessor>
|
template <typename TAccessor>
|
||||||
std::unique_ptr<Cursor> ExpandUniquenessFilter<TAccessor>::MakeCursor(
|
std::unique_ptr<Cursor> ExpandUniquenessFilter<TAccessor>::MakeCursor(
|
||||||
@ -873,6 +833,11 @@ bool ExpandUniquenessFilter<TAccessor>::ExpandUniquenessFilterCursor::Pull(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename TAccessor>
|
||||||
|
void ExpandUniquenessFilter<TAccessor>::ExpandUniquenessFilterCursor::Reset() {
|
||||||
|
input_cursor_->Reset();
|
||||||
|
}
|
||||||
|
|
||||||
// instantiations of the ExpandUniquenessFilter template class
|
// instantiations of the ExpandUniquenessFilter template class
|
||||||
// we only ever need these two
|
// we only ever need these two
|
||||||
template class ExpandUniquenessFilter<VertexAccessor>;
|
template class ExpandUniquenessFilter<VertexAccessor>;
|
||||||
@ -919,13 +884,8 @@ Accumulate::Accumulate(const std::shared_ptr<LogicalOperator> &input,
|
|||||||
const std::vector<Symbol> &symbols, bool advance_command)
|
const std::vector<Symbol> &symbols, bool advance_command)
|
||||||
: input_(input), symbols_(symbols), advance_command_(advance_command) {}
|
: input_(input), symbols_(symbols), advance_command_(advance_command) {}
|
||||||
|
|
||||||
void Accumulate::Accept(LogicalOperatorVisitor &visitor) {
|
ACCEPT_WITH_INPUT(Accumulate)
|
||||||
if (visitor.PreVisit(*this)) {
|
|
||||||
visitor.Visit(*this);
|
|
||||||
input_->Accept(visitor);
|
|
||||||
visitor.PostVisit(*this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
std::unique_ptr<Cursor> Accumulate::MakeCursor(GraphDbAccessor &db) {
|
std::unique_ptr<Cursor> Accumulate::MakeCursor(GraphDbAccessor &db) {
|
||||||
return std::make_unique<Accumulate::AccumulateCursor>(*this, db);
|
return std::make_unique<Accumulate::AccumulateCursor>(*this, db);
|
||||||
}
|
}
|
||||||
@ -960,6 +920,13 @@ bool Accumulate::AccumulateCursor::Pull(Frame &frame,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Accumulate::AccumulateCursor::Reset() {
|
||||||
|
input_cursor_->Reset();
|
||||||
|
cache_.clear();
|
||||||
|
cache_it_ = cache_.begin();
|
||||||
|
pulled_all_input_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
Aggregate::Aggregate(const std::shared_ptr<LogicalOperator> &input,
|
Aggregate::Aggregate(const std::shared_ptr<LogicalOperator> &input,
|
||||||
const std::vector<Aggregate::Element> &aggregations,
|
const std::vector<Aggregate::Element> &aggregations,
|
||||||
const std::vector<Expression *> &group_by,
|
const std::vector<Expression *> &group_by,
|
||||||
@ -969,13 +936,7 @@ Aggregate::Aggregate(const std::shared_ptr<LogicalOperator> &input,
|
|||||||
group_by_(group_by),
|
group_by_(group_by),
|
||||||
remember_(remember) {}
|
remember_(remember) {}
|
||||||
|
|
||||||
void Aggregate::Accept(LogicalOperatorVisitor &visitor) {
|
ACCEPT_WITH_INPUT(Aggregate)
|
||||||
if (visitor.PreVisit(*this)) {
|
|
||||||
visitor.Visit(*this);
|
|
||||||
input_->Accept(visitor);
|
|
||||||
visitor.PostVisit(*this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<Cursor> Aggregate::MakeCursor(GraphDbAccessor &db) {
|
std::unique_ptr<Cursor> Aggregate::MakeCursor(GraphDbAccessor &db) {
|
||||||
return std::make_unique<AggregateCursor>(*this, db);
|
return std::make_unique<AggregateCursor>(*this, db);
|
||||||
@ -1044,7 +1005,8 @@ void Aggregate::AggregateCursor::ProcessOne(Frame &frame,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Aggregate::AggregateCursor::EnsureInitialized(
|
void Aggregate::AggregateCursor::EnsureInitialized(
|
||||||
Frame &frame, Aggregate::AggregateCursor::AggregationValue &agg_value) {
|
Frame &frame,
|
||||||
|
Aggregate::AggregateCursor::AggregationValue &agg_value) const {
|
||||||
if (agg_value.values_.size() > 0) return;
|
if (agg_value.values_.size() > 0) return;
|
||||||
|
|
||||||
for (const auto &agg_elem : self_.aggregations_) {
|
for (const auto &agg_elem : self_.aggregations_) {
|
||||||
@ -1134,7 +1096,15 @@ void Aggregate::AggregateCursor::Update(
|
|||||||
} // end loop over all aggregations
|
} // end loop over all aggregations
|
||||||
}
|
}
|
||||||
|
|
||||||
void Aggregate::AggregateCursor::EnsureOkForMinMax(const TypedValue &value) {
|
void Aggregate::AggregateCursor::Reset() {
|
||||||
|
input_cursor_->Reset();
|
||||||
|
aggregation_.clear();
|
||||||
|
aggregation_it_ = aggregation_.begin();
|
||||||
|
pulled_all_input_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Aggregate::AggregateCursor::EnsureOkForMinMax(
|
||||||
|
const TypedValue &value) const {
|
||||||
switch (value.type()) {
|
switch (value.type()) {
|
||||||
case TypedValue::Type::Bool:
|
case TypedValue::Type::Bool:
|
||||||
case TypedValue::Type::Int:
|
case TypedValue::Type::Int:
|
||||||
@ -1148,7 +1118,8 @@ void Aggregate::AggregateCursor::EnsureOkForMinMax(const TypedValue &value) {
|
|||||||
"MIN and MAX aggregations");
|
"MIN and MAX aggregations");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Aggregate::AggregateCursor::EnsureOkForAvgSum(const TypedValue &value) {
|
void Aggregate::AggregateCursor::EnsureOkForAvgSum(
|
||||||
|
const TypedValue &value) const {
|
||||||
switch (value.type()) {
|
switch (value.type()) {
|
||||||
case TypedValue::Type::Int:
|
case TypedValue::Type::Int:
|
||||||
case TypedValue::Type::Double:
|
case TypedValue::Type::Double:
|
||||||
@ -1171,13 +1142,7 @@ Skip::Skip(const std::shared_ptr<LogicalOperator> &input,
|
|||||||
Expression *expression)
|
Expression *expression)
|
||||||
: input_(input), expression_(expression) {}
|
: input_(input), expression_(expression) {}
|
||||||
|
|
||||||
void Skip::Accept(LogicalOperatorVisitor &visitor) {
|
ACCEPT_WITH_INPUT(Skip)
|
||||||
if (visitor.PreVisit(*this)) {
|
|
||||||
visitor.Visit(*this);
|
|
||||||
input_->Accept(visitor);
|
|
||||||
visitor.PostVisit(*this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<Cursor> Skip::MakeCursor(GraphDbAccessor &db) {
|
std::unique_ptr<Cursor> Skip::MakeCursor(GraphDbAccessor &db) {
|
||||||
return std::make_unique<SkipCursor>(*this, db);
|
return std::make_unique<SkipCursor>(*this, db);
|
||||||
@ -1209,17 +1174,17 @@ bool Skip::SkipCursor::Pull(Frame &frame, const SymbolTable &symbol_table) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Skip::SkipCursor::Reset() {
|
||||||
|
input_cursor_->Reset();
|
||||||
|
to_skip_ = -1;
|
||||||
|
skipped_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
Limit::Limit(const std::shared_ptr<LogicalOperator> &input,
|
Limit::Limit(const std::shared_ptr<LogicalOperator> &input,
|
||||||
Expression *expression)
|
Expression *expression)
|
||||||
: input_(input), expression_(expression) {}
|
: input_(input), expression_(expression) {}
|
||||||
|
|
||||||
void Limit::Accept(LogicalOperatorVisitor &visitor) {
|
ACCEPT_WITH_INPUT(Limit)
|
||||||
if (visitor.PreVisit(*this)) {
|
|
||||||
visitor.Visit(*this);
|
|
||||||
input_->Accept(visitor);
|
|
||||||
visitor.PostVisit(*this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<Cursor> Limit::MakeCursor(GraphDbAccessor &db) {
|
std::unique_ptr<Cursor> Limit::MakeCursor(GraphDbAccessor &db) {
|
||||||
return std::make_unique<LimitCursor>(*this, db);
|
return std::make_unique<LimitCursor>(*this, db);
|
||||||
@ -1252,6 +1217,12 @@ bool Limit::LimitCursor::Pull(Frame &frame, const SymbolTable &symbol_table) {
|
|||||||
return input_cursor_->Pull(frame, symbol_table);
|
return input_cursor_->Pull(frame, symbol_table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Limit::LimitCursor::Reset() {
|
||||||
|
input_cursor_->Reset();
|
||||||
|
limit_ = -1;
|
||||||
|
pulled_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
OrderBy::OrderBy(const std::shared_ptr<LogicalOperator> &input,
|
OrderBy::OrderBy(const std::shared_ptr<LogicalOperator> &input,
|
||||||
const std::vector<std::pair<Ordering, Expression *>> order_by,
|
const std::vector<std::pair<Ordering, Expression *>> order_by,
|
||||||
const std::vector<Symbol> remember)
|
const std::vector<Symbol> remember)
|
||||||
@ -1267,13 +1238,7 @@ OrderBy::OrderBy(const std::shared_ptr<LogicalOperator> &input,
|
|||||||
compare_ = TypedValueListCompare(ordering);
|
compare_ = TypedValueListCompare(ordering);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OrderBy::Accept(LogicalOperatorVisitor &visitor) {
|
ACCEPT_WITH_INPUT(OrderBy)
|
||||||
if (visitor.PreVisit(*this)) {
|
|
||||||
visitor.Visit(*this);
|
|
||||||
input_->Accept(visitor);
|
|
||||||
visitor.PostVisit(*this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<Cursor> OrderBy::MakeCursor(GraphDbAccessor &db) {
|
std::unique_ptr<Cursor> OrderBy::MakeCursor(GraphDbAccessor &db) {
|
||||||
return std::make_unique<OrderByCursor>(*this, db);
|
return std::make_unique<OrderByCursor>(*this, db);
|
||||||
@ -1325,6 +1290,13 @@ bool OrderBy::OrderByCursor::Pull(Frame &frame,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OrderBy::OrderByCursor::Reset() {
|
||||||
|
input_cursor_->Reset();
|
||||||
|
did_pull_all_ = false;
|
||||||
|
cache_.clear();
|
||||||
|
cache_it_ = cache_.begin();
|
||||||
|
}
|
||||||
|
|
||||||
bool OrderBy::TypedValueCompare(const TypedValue &a, const TypedValue &b) {
|
bool OrderBy::TypedValueCompare(const TypedValue &a, const TypedValue &b) {
|
||||||
// in ordering null comes after everything else
|
// in ordering null comes after everything else
|
||||||
// at the same time Null is not less that null
|
// at the same time Null is not less that null
|
||||||
|
@ -40,6 +40,12 @@ class Cursor {
|
|||||||
* @param SymbolTable Used to get the position of symbols in frame.
|
* @param SymbolTable Used to get the position of symbols in frame.
|
||||||
*/
|
*/
|
||||||
virtual bool Pull(Frame &, const SymbolTable &) = 0;
|
virtual bool Pull(Frame &, const SymbolTable &) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the Cursor to it's initial state.
|
||||||
|
*/
|
||||||
|
virtual void Reset() = 0;
|
||||||
|
|
||||||
virtual ~Cursor() {}
|
virtual ~Cursor() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -105,6 +111,8 @@ class Once : public LogicalOperator {
|
|||||||
class OnceCursor : public Cursor {
|
class OnceCursor : public Cursor {
|
||||||
public:
|
public:
|
||||||
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
||||||
|
void Reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool did_pull_{false};
|
bool did_pull_{false};
|
||||||
};
|
};
|
||||||
@ -141,6 +149,7 @@ class CreateNode : public LogicalOperator {
|
|||||||
public:
|
public:
|
||||||
CreateNodeCursor(const CreateNode &self, GraphDbAccessor &db);
|
CreateNodeCursor(const CreateNode &self, GraphDbAccessor &db);
|
||||||
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
||||||
|
void Reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const CreateNode &self_;
|
const CreateNode &self_;
|
||||||
@ -205,6 +214,7 @@ class CreateExpand : public LogicalOperator {
|
|||||||
public:
|
public:
|
||||||
CreateExpandCursor(const CreateExpand &self, GraphDbAccessor &db);
|
CreateExpandCursor(const CreateExpand &self, GraphDbAccessor &db);
|
||||||
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
||||||
|
void Reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const CreateExpand &self_;
|
const CreateExpand &self_;
|
||||||
@ -255,6 +265,7 @@ class ScanAll : public LogicalOperator {
|
|||||||
public:
|
public:
|
||||||
ScanAllCursor(const ScanAll &self, GraphDbAccessor &db);
|
ScanAllCursor(const ScanAll &self, GraphDbAccessor &db);
|
||||||
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
||||||
|
void Reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const ScanAll &self_;
|
const ScanAll &self_;
|
||||||
@ -330,6 +341,7 @@ class Expand : public LogicalOperator {
|
|||||||
public:
|
public:
|
||||||
ExpandCursor(const Expand &self, GraphDbAccessor &db);
|
ExpandCursor(const Expand &self, GraphDbAccessor &db);
|
||||||
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
||||||
|
void Reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Expand &self_;
|
const Expand &self_;
|
||||||
@ -404,6 +416,7 @@ class NodeFilter : public LogicalOperator {
|
|||||||
public:
|
public:
|
||||||
NodeFilterCursor(const NodeFilter &self, GraphDbAccessor &db);
|
NodeFilterCursor(const NodeFilter &self, GraphDbAccessor &db);
|
||||||
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
||||||
|
void Reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const NodeFilter &self_;
|
const NodeFilter &self_;
|
||||||
@ -443,10 +456,11 @@ class EdgeFilter : public LogicalOperator {
|
|||||||
public:
|
public:
|
||||||
EdgeFilterCursor(const EdgeFilter &self, GraphDbAccessor &db);
|
EdgeFilterCursor(const EdgeFilter &self, GraphDbAccessor &db);
|
||||||
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
||||||
|
void Reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const EdgeFilter &self_;
|
const EdgeFilter &self_;
|
||||||
std::unique_ptr<Cursor> input_cursor_;
|
const std::unique_ptr<Cursor> input_cursor_;
|
||||||
|
|
||||||
/** Helper function for checking if the given edge satisfied
|
/** Helper function for checking if the given edge satisfied
|
||||||
* the criteria of this edge filter. */
|
* the criteria of this edge filter. */
|
||||||
@ -477,6 +491,7 @@ class Filter : public LogicalOperator {
|
|||||||
public:
|
public:
|
||||||
FilterCursor(const Filter &self, GraphDbAccessor &db);
|
FilterCursor(const Filter &self, GraphDbAccessor &db);
|
||||||
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
||||||
|
void Reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Filter &self_;
|
const Filter &self_;
|
||||||
@ -511,6 +526,7 @@ class Produce : public LogicalOperator {
|
|||||||
public:
|
public:
|
||||||
ProduceCursor(const Produce &self, GraphDbAccessor &db);
|
ProduceCursor(const Produce &self, GraphDbAccessor &db);
|
||||||
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
||||||
|
void Reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Produce &self_;
|
const Produce &self_;
|
||||||
@ -543,11 +559,12 @@ class Delete : public LogicalOperator {
|
|||||||
public:
|
public:
|
||||||
DeleteCursor(const Delete &self, GraphDbAccessor &db);
|
DeleteCursor(const Delete &self, GraphDbAccessor &db);
|
||||||
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
||||||
|
void Reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Delete &self_;
|
const Delete &self_;
|
||||||
GraphDbAccessor &db_;
|
GraphDbAccessor &db_;
|
||||||
std::unique_ptr<Cursor> input_cursor_;
|
const std::unique_ptr<Cursor> input_cursor_;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -573,10 +590,11 @@ class SetProperty : public LogicalOperator {
|
|||||||
public:
|
public:
|
||||||
SetPropertyCursor(const SetProperty &self, GraphDbAccessor &db);
|
SetPropertyCursor(const SetProperty &self, GraphDbAccessor &db);
|
||||||
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
||||||
|
void Reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const SetProperty &self_;
|
const SetProperty &self_;
|
||||||
std::unique_ptr<Cursor> input_cursor_;
|
const std::unique_ptr<Cursor> input_cursor_;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -616,6 +634,7 @@ class SetProperties : public LogicalOperator {
|
|||||||
public:
|
public:
|
||||||
SetPropertiesCursor(const SetProperties &self, GraphDbAccessor &db);
|
SetPropertiesCursor(const SetProperties &self, GraphDbAccessor &db);
|
||||||
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
||||||
|
void Reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const SetProperties &self_;
|
const SetProperties &self_;
|
||||||
@ -628,7 +647,7 @@ class SetProperties : public LogicalOperator {
|
|||||||
* RecordAccessor<Edge>
|
* RecordAccessor<Edge>
|
||||||
*/
|
*/
|
||||||
template <typename TRecordAccessor>
|
template <typename TRecordAccessor>
|
||||||
void Set(TRecordAccessor &record, const TypedValue &rhs);
|
void Set(TRecordAccessor &record, const TypedValue &rhs) const;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -654,10 +673,11 @@ class SetLabels : public LogicalOperator {
|
|||||||
public:
|
public:
|
||||||
SetLabelsCursor(const SetLabels &self, GraphDbAccessor &db);
|
SetLabelsCursor(const SetLabels &self, GraphDbAccessor &db);
|
||||||
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
||||||
|
void Reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const SetLabels &self_;
|
const SetLabels &self_;
|
||||||
std::unique_ptr<Cursor> input_cursor_;
|
const std::unique_ptr<Cursor> input_cursor_;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -680,10 +700,11 @@ class RemoveProperty : public LogicalOperator {
|
|||||||
public:
|
public:
|
||||||
RemovePropertyCursor(const RemoveProperty &self, GraphDbAccessor &db);
|
RemovePropertyCursor(const RemoveProperty &self, GraphDbAccessor &db);
|
||||||
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
||||||
|
void Reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const RemoveProperty &self_;
|
const RemoveProperty &self_;
|
||||||
std::unique_ptr<Cursor> input_cursor_;
|
const std::unique_ptr<Cursor> input_cursor_;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -710,10 +731,11 @@ class RemoveLabels : public LogicalOperator {
|
|||||||
public:
|
public:
|
||||||
RemoveLabelsCursor(const RemoveLabels &self, GraphDbAccessor &db);
|
RemoveLabelsCursor(const RemoveLabels &self, GraphDbAccessor &db);
|
||||||
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
||||||
|
void Reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const RemoveLabels &self_;
|
const RemoveLabels &self_;
|
||||||
std::unique_ptr<Cursor> input_cursor_;
|
const std::unique_ptr<Cursor> input_cursor_;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -757,10 +779,11 @@ class ExpandUniquenessFilter : public LogicalOperator {
|
|||||||
ExpandUniquenessFilterCursor(const ExpandUniquenessFilter &self,
|
ExpandUniquenessFilterCursor(const ExpandUniquenessFilter &self,
|
||||||
GraphDbAccessor &db);
|
GraphDbAccessor &db);
|
||||||
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
||||||
|
void Reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const ExpandUniquenessFilter &self_;
|
const ExpandUniquenessFilter &self_;
|
||||||
std::unique_ptr<Cursor> input_cursor_;
|
const std::unique_ptr<Cursor> input_cursor_;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -807,6 +830,7 @@ class Accumulate : public LogicalOperator {
|
|||||||
public:
|
public:
|
||||||
AccumulateCursor(const Accumulate &self, GraphDbAccessor &db);
|
AccumulateCursor(const Accumulate &self, GraphDbAccessor &db);
|
||||||
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
||||||
|
void Reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Accumulate &self_;
|
const Accumulate &self_;
|
||||||
@ -859,6 +883,7 @@ class Aggregate : public LogicalOperator {
|
|||||||
public:
|
public:
|
||||||
AggregateCursor(Aggregate &self, GraphDbAccessor &db);
|
AggregateCursor(Aggregate &self, GraphDbAccessor &db);
|
||||||
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
||||||
|
void Reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// custom equality function for the unordered map
|
// custom equality function for the unordered map
|
||||||
@ -883,8 +908,8 @@ class Aggregate : public LogicalOperator {
|
|||||||
std::vector<TypedValue> remember_;
|
std::vector<TypedValue> remember_;
|
||||||
};
|
};
|
||||||
|
|
||||||
Aggregate &self_;
|
const Aggregate &self_;
|
||||||
std::unique_ptr<Cursor> input_cursor_;
|
const std::unique_ptr<Cursor> input_cursor_;
|
||||||
// storage for aggregated data
|
// storage for aggregated data
|
||||||
// map key is the list of group-by values
|
// map key is the list of group-by values
|
||||||
// map value is an AggregationValue struct
|
// map value is an AggregationValue struct
|
||||||
@ -922,7 +947,7 @@ class Aggregate : public LogicalOperator {
|
|||||||
* that the value vectors are filled with an appropriate number of Nulls,
|
* that the value vectors are filled with an appropriate number of Nulls,
|
||||||
* counts are set to 0 and remember values are remembered.
|
* counts are set to 0 and remember values are remembered.
|
||||||
*/
|
*/
|
||||||
void EnsureInitialized(Frame &frame, AggregationValue &agg_value);
|
void EnsureInitialized(Frame &frame, AggregationValue &agg_value) const;
|
||||||
|
|
||||||
/** Updates the given AggregationValue with new data. Assumes that
|
/** Updates the given AggregationValue with new data. Assumes that
|
||||||
* the AggregationValue has been initialized */
|
* the AggregationValue has been initialized */
|
||||||
@ -931,11 +956,11 @@ class Aggregate : public LogicalOperator {
|
|||||||
|
|
||||||
/** Checks if the given TypedValue is legal in MIN and MAX. If not
|
/** Checks if the given TypedValue is legal in MIN and MAX. If not
|
||||||
* an appropriate exception is thrown. */
|
* an appropriate exception is thrown. */
|
||||||
void EnsureOkForMinMax(const TypedValue &value);
|
void EnsureOkForMinMax(const TypedValue &value) const;
|
||||||
|
|
||||||
/** Checks if the given TypedValue is legal in AVG and SUM. If not
|
/** Checks if the given TypedValue is legal in AVG and SUM. If not
|
||||||
* an appropriate exception is thrown. */
|
* an appropriate exception is thrown. */
|
||||||
void EnsureOkForAvgSum(const TypedValue &value);
|
void EnsureOkForAvgSum(const TypedValue &value) const;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -965,10 +990,11 @@ class Skip : public LogicalOperator {
|
|||||||
public:
|
public:
|
||||||
SkipCursor(Skip &self, GraphDbAccessor &db);
|
SkipCursor(Skip &self, GraphDbAccessor &db);
|
||||||
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
||||||
|
void Reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Skip &self_;
|
const Skip &self_;
|
||||||
std::unique_ptr<Cursor> input_cursor_;
|
const std::unique_ptr<Cursor> input_cursor_;
|
||||||
// init to_skip_ to -1, indicating
|
// init to_skip_ to -1, indicating
|
||||||
// that it's still unknown (input has not been Pulled yet)
|
// that it's still unknown (input has not been Pulled yet)
|
||||||
int to_skip_{-1};
|
int to_skip_{-1};
|
||||||
@ -1005,6 +1031,7 @@ class Limit : public LogicalOperator {
|
|||||||
public:
|
public:
|
||||||
LimitCursor(Limit &self, GraphDbAccessor &db);
|
LimitCursor(Limit &self, GraphDbAccessor &db);
|
||||||
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
||||||
|
void Reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Limit &self_;
|
Limit &self_;
|
||||||
@ -1068,10 +1095,11 @@ class OrderBy : public LogicalOperator {
|
|||||||
public:
|
public:
|
||||||
OrderByCursor(OrderBy &self, GraphDbAccessor &db);
|
OrderByCursor(OrderBy &self, GraphDbAccessor &db);
|
||||||
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
bool Pull(Frame &frame, const SymbolTable &symbol_table) override;
|
||||||
|
void Reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OrderBy &self_;
|
const OrderBy &self_;
|
||||||
std::unique_ptr<Cursor> input_cursor_;
|
const std::unique_ptr<Cursor> input_cursor_;
|
||||||
bool did_pull_all_{false};
|
bool did_pull_all_{false};
|
||||||
// a cache of elements pulled from the input
|
// a cache of elements pulled from the input
|
||||||
// first pair element is the order-by list
|
// first pair element is the order-by list
|
||||||
|
Loading…
Reference in New Issue
Block a user