Query::Plan - WITH API
Reviewers: teon.banek, buda Reviewed By: teon.banek Differential Revision: https://phabricator.memgraph.io/D224
This commit is contained in:
parent
b33b671505
commit
263749508c
@ -550,6 +550,27 @@ class Return : public Clause {
|
||||
Return(int uid) : Clause(uid) {}
|
||||
};
|
||||
|
||||
class With : public Clause {
|
||||
friend class AstTreeStorage;
|
||||
|
||||
public:
|
||||
void Accept(TreeVisitorBase &visitor) override {
|
||||
visitor.Visit(*this);
|
||||
for (auto &expr : named_expressions_) {
|
||||
expr->Accept(visitor);
|
||||
}
|
||||
if (where_) where_->Accept(visitor);
|
||||
visitor.PostVisit(*this);
|
||||
}
|
||||
|
||||
bool distinct_{false};
|
||||
std::vector<NamedExpression *> named_expressions_;
|
||||
Where *where_ = nullptr;
|
||||
|
||||
protected:
|
||||
With(int uid) : Clause(uid) {}
|
||||
};
|
||||
|
||||
class Delete : public Clause {
|
||||
friend class AstTreeStorage;
|
||||
|
||||
|
@ -12,6 +12,7 @@ class PropertyLookup;
|
||||
class Create;
|
||||
class Match;
|
||||
class Return;
|
||||
class With;
|
||||
class Pattern;
|
||||
class NodeAtom;
|
||||
class EdgeAtom;
|
||||
@ -47,6 +48,6 @@ using TreeVisitorBase = ::utils::Visitor<
|
||||
DivisionOperator, ModOperator, NotEqualOperator, EqualOperator,
|
||||
LessOperator, GreaterOperator, LessEqualOperator, GreaterEqualOperator,
|
||||
UnaryPlusOperator, UnaryMinusOperator, Identifier, Literal, PropertyLookup,
|
||||
Create, Match, Return, Pattern, NodeAtom, EdgeAtom, Delete, Where,
|
||||
Create, Match, Return, With, Pattern, NodeAtom, EdgeAtom, Delete, Where,
|
||||
SetProperty, SetProperties, SetLabels, RemoveProperty, RemoveLabels>;
|
||||
}
|
||||
|
@ -835,5 +835,28 @@ bool ExpandUniquenessFilter<TAccessor>::ExpandUniquenessFilterCursor::Pull(
|
||||
template class ExpandUniquenessFilter<VertexAccessor>;
|
||||
template class ExpandUniquenessFilter<EdgeAccessor>;
|
||||
|
||||
Accumulate::Accumulate(std::shared_ptr<LogicalOperator> input, const std::vector<Symbol> &symbols) :
|
||||
input_(input), symbols_(symbols) {}
|
||||
|
||||
void Accumulate::Accept(LogicalOperatorVisitor &visitor) {
|
||||
visitor.Visit(*this);
|
||||
input_->Accept(visitor);
|
||||
visitor.PostVisit(*this);
|
||||
}
|
||||
std::unique_ptr<Cursor> Accumulate::MakeCursor(GraphDbAccessor &db) {
|
||||
return std::unique_ptr<Cursor>();
|
||||
}
|
||||
|
||||
AdvanceCommand::AdvanceCommand(std::shared_ptr<LogicalOperator> input) : input_(input) {}
|
||||
|
||||
void AdvanceCommand::Accept(LogicalOperatorVisitor &visitor) {
|
||||
visitor.Visit(*this);
|
||||
input_->Accept(visitor);
|
||||
visitor.PostVisit(*this);
|
||||
}
|
||||
std::unique_ptr<Cursor> AdvanceCommand::MakeCursor(GraphDbAccessor &db) {
|
||||
return std::unique_ptr<Cursor>();
|
||||
}
|
||||
|
||||
} // namespace plan
|
||||
} // namespace query
|
||||
|
@ -54,14 +54,15 @@ class RemoveProperty;
|
||||
class RemoveLabels;
|
||||
template <typename TAccessor>
|
||||
class ExpandUniquenessFilter;
|
||||
class Accumulate;
|
||||
class AdvanceCommand;
|
||||
|
||||
/** @brief Base class for visitors of @c LogicalOperator class hierarchy. */
|
||||
using LogicalOperatorVisitor =
|
||||
::utils::Visitor<CreateNode, CreateExpand, ScanAll, Expand, NodeFilter,
|
||||
EdgeFilter, Filter, Produce, Delete, SetProperty,
|
||||
SetProperties, SetLabels, RemoveProperty, RemoveLabels,
|
||||
ExpandUniquenessFilter<VertexAccessor>,
|
||||
ExpandUniquenessFilter<EdgeAccessor>>;
|
||||
using LogicalOperatorVisitor = ::utils::Visitor<
|
||||
CreateNode, CreateExpand, ScanAll, Expand, NodeFilter, EdgeFilter, Filter,
|
||||
Produce, Delete, SetProperty, SetProperties, SetLabels, RemoveProperty,
|
||||
RemoveLabels, ExpandUniquenessFilter<VertexAccessor>,
|
||||
ExpandUniquenessFilter<EdgeAccessor>, Accumulate, AdvanceCommand>;
|
||||
|
||||
/** @brief Base class for logical operators.
|
||||
*
|
||||
@ -741,5 +742,26 @@ class ExpandUniquenessFilter : public LogicalOperator {
|
||||
};
|
||||
};
|
||||
|
||||
class Accumulate : public LogicalOperator {
|
||||
public:
|
||||
Accumulate(std::shared_ptr<LogicalOperator> input, const std::vector<Symbol> &symbols);
|
||||
void Accept(LogicalOperatorVisitor &visitor) override;
|
||||
std::unique_ptr<Cursor> MakeCursor(GraphDbAccessor &db) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<LogicalOperator> input_;
|
||||
const std::vector<Symbol> symbols_;
|
||||
};
|
||||
|
||||
class AdvanceCommand : public LogicalOperator {
|
||||
public:
|
||||
AdvanceCommand(std::shared_ptr<LogicalOperator> input);
|
||||
void Accept(LogicalOperatorVisitor &visitor) override;
|
||||
std::unique_ptr<Cursor> MakeCursor(GraphDbAccessor &db) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<LogicalOperator> input_;
|
||||
};
|
||||
|
||||
} // namespace plan
|
||||
} // namespace query
|
||||
|
Loading…
Reference in New Issue
Block a user