1
0
Fork 0

Merge branch 'aql2' of https://github.com/triAGENS/ArangoDB into aql2

This commit is contained in:
Jan Steemann 2014-08-01 11:21:17 +02:00
commit af9dbdba85
6 changed files with 310 additions and 313 deletions

View File

@ -43,7 +43,7 @@ int ExecutionBlock::bind (std::map<std::string, struct TRI_json_s*>* params) {
}
////////////////////////////////////////////////////////////////////////////////
/// @brief functionality to walk an execution plan recursively
/// @brief functionality to walk an execution block recursively
////////////////////////////////////////////////////////////////////////////////
void ExecutionBlock::walk (WalkerWorker* worker) {
@ -60,7 +60,7 @@ void ExecutionBlock::walk (WalkerWorker* worker) {
(*it)->walk(worker);
}
// Now handle a subquery:
if (_exePlan->getType() == ExecutionPlan::SUBQUERY) {
if (_exePlan->getType() == ExecutionNode::SUBQUERY) {
// auto p = static_cast<SubqueryBlock*>(this);
if (worker->enterSubquery(this, nullptr)) { ; // p->_subquery
// p->_subquery->walk(worker);
@ -75,26 +75,26 @@ void ExecutionBlock::walk (WalkerWorker* worker) {
// --SECTION-- factory for instanciation of plans
// -----------------------------------------------------------------------------
ExecutionBlock* ExecutionBlock::instanciatePlan (ExecutionPlan const* ep) {
ExecutionBlock* ExecutionBlock::instanciatePlan (ExecutionNode const* ep) {
ExecutionBlock* eb;
switch (ep->getType()) {
case ExecutionPlan::SINGLETON: {
eb = new SingletonBlock(static_cast<SingletonPlan const*>(ep));
case ExecutionNode::SINGLETON: {
eb = new SingletonBlock(static_cast<SingletonNode const*>(ep));
break;
}
case ExecutionPlan::ENUMERATE_COLLECTION: {
eb = new EnumerateCollectionBlock(static_cast<EnumerateCollectionPlan const*>(ep));
case ExecutionNode::ENUMERATE_COLLECTION: {
eb = new EnumerateCollectionBlock(static_cast<EnumerateCollectionNode const*>(ep));
break;
}
case ExecutionPlan::ROOT: {
eb = new RootBlock(static_cast<RootPlan const*>(ep));
case ExecutionNode::ROOT: {
eb = new RootBlock(static_cast<RootNode const*>(ep));
break;
}
default: {
THROW_ARANGO_EXCEPTION(TRI_ERROR_NOT_IMPLEMENTED);
}
}
vector<ExecutionPlan*> deps = ep->getDependencies();
vector<ExecutionNode*> deps = ep->getDependencies();
for (auto it = deps.begin(); it != deps.end();++it) {
eb->addDependency(instanciatePlan(*it));
}

View File

@ -48,7 +48,7 @@ namespace triagens {
class ExecutionBlock {
public:
ExecutionBlock (ExecutionPlan const* ep)
ExecutionBlock (ExecutionNode const* ep)
: _exePlan(ep), _done(false), _depth(0) { }
virtual ~ExecutionBlock ();
@ -100,7 +100,7 @@ namespace triagens {
}
////////////////////////////////////////////////////////////////////////////////
/// @brief functionality to walk an execution plan recursively
/// @brief functionality to walk an execution block recursively
////////////////////////////////////////////////////////////////////////////////
class WalkerWorker {
@ -187,49 +187,49 @@ namespace triagens {
}
virtual void after (ExecutionBlock *eb) {
switch (eb->getPlan()->getType()) {
case ExecutionPlan::ENUMERATE_COLLECTION: {
switch (eb->getPlanNode()->getType()) {
case ExecutionNode::ENUMERATE_COLLECTION: {
depth++;
nrVarsHere.push_back(1);
nrVars.push_back(1 + nrVars.back());
auto ep = static_cast<EnumerateCollectionPlan const*>(eb->getPlan());
auto ep = static_cast<EnumerateCollectionNode const*>(eb->getPlanNode());
varInfo.insert(make_pair(ep->_outVariable->id,
VarInfo(depth, totalNrVars)));
totalNrVars++;
break;
}
case ExecutionPlan::ENUMERATE_LIST: {
case ExecutionNode::ENUMERATE_LIST: {
depth++;
nrVarsHere.push_back(1);
nrVars.push_back(1 + nrVars.back());
auto ep = static_cast<EnumerateListPlan const*>(eb->getPlan());
auto ep = static_cast<EnumerateListNode const*>(eb->getPlanNode());
varInfo.insert(make_pair(ep->_outVariable->id,
VarInfo(depth, totalNrVars)));
totalNrVars++;
break;
}
case ExecutionPlan::CALCULATION: {
case ExecutionNode::CALCULATION: {
nrVarsHere[depth]++;
nrVars[depth]++;
auto ep = static_cast<CalculationPlan const*>(eb->getPlan());
auto ep = static_cast<CalculationNode const*>(eb->getPlanNode());
varInfo.insert(make_pair(ep->_outVariable->id,
VarInfo(depth, totalNrVars)));
totalNrVars++;
break;
}
case ExecutionPlan::PROJECTION: {
case ExecutionNode::PROJECTION: {
nrVarsHere[depth]++;
nrVars[depth]++;
auto ep = static_cast<ProjectionPlan const*>(eb->getPlan());
auto ep = static_cast<ProjectionNode const*>(eb->getPlanNode());
varInfo.insert(make_pair(ep->_outVariable->id,
VarInfo(depth, totalNrVars)));
totalNrVars++;
break;
}
case ExecutionPlan::SUBQUERY: {
case ExecutionNode::SUBQUERY: {
nrVarsHere[depth]++;
nrVars[depth]++;
auto ep = static_cast<SubqueryPlan const*>(eb->getPlan());
auto ep = static_cast<SubqueryNode const*>(eb->getPlanNode());
varInfo.insert(make_pair(ep->_outVariable->id,
VarInfo(depth, totalNrVars)));
totalNrVars++;
@ -441,16 +441,16 @@ namespace triagens {
return 0;
}
ExecutionPlan const* getPlan () {
ExecutionNode const* getPlanNode () {
return _exePlan;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief our corresponding ExecutionPlan node
/// @brief our corresponding ExecutionNode node
////////////////////////////////////////////////////////////////////////////////
protected:
ExecutionPlan const* _exePlan;
ExecutionNode const* _exePlan;
////////////////////////////////////////////////////////////////////////////////
/// @brief our dependent nodes
@ -489,11 +489,11 @@ namespace triagens {
std::shared_ptr<VarOverview> _varOverview;
////////////////////////////////////////////////////////////////////////////////
/// @brief a static factory for ExecutionBlocks from ExecutionPlans
/// @brief a static factory for ExecutionBlocks from ExecutionNodes
////////////////////////////////////////////////////////////////////////////////
public:
static ExecutionBlock* instanciatePlan (ExecutionPlan const* ep);
static ExecutionBlock* instanciatePlan (ExecutionNode const* ep);
};
@ -509,7 +509,7 @@ namespace triagens {
/// @brief constructor
////////////////////////////////////////////////////////////////////////////////
SingletonBlock (SingletonPlan const* ep)
SingletonBlock (SingletonNode const* ep)
: ExecutionBlock(ep) {
}
@ -588,7 +588,7 @@ namespace triagens {
/// @brief constructor
////////////////////////////////////////////////////////////////////////////////
EnumerateCollectionBlock (EnumerateCollectionPlan const* ep)
EnumerateCollectionBlock (EnumerateCollectionNode const* ep)
: ExecutionBlock(ep), _posInAllDocs(0) {
}
@ -618,7 +618,7 @@ namespace triagens {
return res;
}
auto p = reinterpret_cast<EnumerateCollectionPlan const*>(_exePlan);
auto p = reinterpret_cast<EnumerateCollectionNode const*>(_exePlan);
V8ReadTransaction trx(p->_vocbase, p->_collname);
@ -793,7 +793,7 @@ namespace triagens {
public:
RootBlock (RootPlan const* ep)
RootBlock (RootNode const* ep)
: ExecutionBlock(ep) {
}
@ -811,7 +811,7 @@ namespace triagens {
// Let's steal the actual result and throw away the vars:
AqlItemBlock* stripped = new AqlItemBlock(1, 1);
auto ep = static_cast<RootPlan const*>(getPlan());
auto ep = static_cast<RootNode const*>(getPlanNode());
auto it = _varOverview->varInfo.find(ep->_inVariable->id);
TRI_ASSERT(it != _varOverview->varInfo.end());
unsigned int index = it->second.index;
@ -829,7 +829,7 @@ namespace triagens {
}
// Let's steal the actual result and throw away the vars:
auto ep = static_cast<RootPlan const*>(getPlan());
auto ep = static_cast<RootNode const*>(getPlanNode());
auto it = _varOverview->varInfo.find(ep->_inVariable->id);
TRI_ASSERT(it != _varOverview->varInfo.end());
unsigned int index = it->second.index;

View File

@ -31,15 +31,15 @@ using namespace triagens::basics;
using namespace triagens::aql;
// -----------------------------------------------------------------------------
// --SECTION-- methods of ExecutionPlan
// --SECTION-- methods of ExecutionNode
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief toJson, export an ExecutionPlan to JSON
/// @brief toJson, export an ExecutionNode to JSON
////////////////////////////////////////////////////////////////////////////////
Json ExecutionPlan::toJson (TRI_memory_zone_t* zone) {
std::map<ExecutionPlan*, int> indexTab;
Json ExecutionNode::toJson (TRI_memory_zone_t* zone) {
std::map<ExecutionNode*, int> indexTab;
Json json;
Json nodes;
try {
@ -58,7 +58,7 @@ Json ExecutionPlan::toJson (TRI_memory_zone_t* zone) {
/// @brief toJsonHelper, for a generic node
////////////////////////////////////////////////////////////////////////////////
Json ExecutionPlan::toJsonHelperGeneric (std::map<ExecutionPlan*, int>& indexTab,
Json ExecutionNode::toJsonHelperGeneric (std::map<ExecutionNode*, int>& indexTab,
triagens::basics::Json& nodes,
TRI_memory_zone_t* zone) {
auto iter = indexTab.find(this);
@ -98,7 +98,7 @@ static void someSpaces (std::string& st, int nr) {
}
}
void ExecutionPlan::appendAsString (std::string& st, int indent) {
void ExecutionNode::appendAsString (std::string& st, int indent) {
someSpaces(st, indent);
st.push_back('<');
st.append(getTypeString());
@ -121,7 +121,7 @@ void ExecutionPlan::appendAsString (std::string& st, int indent) {
/// @brief functionality to walk an execution plan recursively
////////////////////////////////////////////////////////////////////////////////
void ExecutionPlan::walk (WalkerWorker& worker) {
void ExecutionNode::walk (WalkerWorker& worker) {
worker.before(this);
for (auto it = _dependencies.begin();
it != _dependencies.end();
@ -129,7 +129,7 @@ void ExecutionPlan::walk (WalkerWorker& worker) {
(*it)->walk(worker);
}
if (getType() == SUBQUERY) {
auto p = static_cast<SubqueryPlan*>(this);
auto p = static_cast<SubqueryNode*>(this);
worker.enterSubquery(this, p->getSubquery());
p->getSubquery()->walk(worker);
worker.leaveSubquery(this, p->getSubquery());
@ -138,18 +138,18 @@ void ExecutionPlan::walk (WalkerWorker& worker) {
}
// -----------------------------------------------------------------------------
// --SECTION-- methods of SingletonPlan
// --SECTION-- methods of SingletonNode
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief toJson, for SingletonPlan
/// @brief toJson, for SingletonNode
////////////////////////////////////////////////////////////////////////////////
void SingletonPlan::toJsonHelper (
std::map<ExecutionPlan*, int>& indexTab,
void SingletonNode::toJsonHelper (
std::map<ExecutionNode*, int>& indexTab,
triagens::basics::Json& nodes,
TRI_memory_zone_t* zone) {
Json json(ExecutionPlan::toJsonHelperGeneric(indexTab, nodes, zone)); // call base class method
Json json(ExecutionNode::toJsonHelperGeneric(indexTab, nodes, zone)); // call base class method
if (json.isEmpty()) {
return;
}
@ -161,17 +161,17 @@ void SingletonPlan::toJsonHelper (
}
// -----------------------------------------------------------------------------
// --SECTION-- methods of EnumerateCollectionPlan
// --SECTION-- methods of EnumerateCollectionNode
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief toJson, for EnumerateCollectionPlan
/// @brief toJson, for EnumerateCollectionNode
////////////////////////////////////////////////////////////////////////////////
void EnumerateCollectionPlan::toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
void EnumerateCollectionNode::toJsonHelper (std::map<ExecutionNode*, int>& indexTab,
triagens::basics::Json& nodes,
TRI_memory_zone_t* zone) {
Json json(ExecutionPlan::toJsonHelperGeneric(indexTab, nodes, zone)); // call base class method
Json json(ExecutionNode::toJsonHelperGeneric(indexTab, nodes, zone)); // call base class method
if (json.isEmpty()) {
return;
}
@ -188,17 +188,17 @@ void EnumerateCollectionPlan::toJsonHelper (std::map<ExecutionPlan*, int>& index
}
// -----------------------------------------------------------------------------
// --SECTION-- methods of EnumerateListPlan
// --SECTION-- methods of EnumerateListNode
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief toJson, for EnumerateListPlan
/// @brief toJson, for EnumerateListNode
////////////////////////////////////////////////////////////////////////////////
void EnumerateListPlan::toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
void EnumerateListNode::toJsonHelper (std::map<ExecutionNode*, int>& indexTab,
triagens::basics::Json& nodes,
TRI_memory_zone_t* zone) {
Json json(ExecutionPlan::toJsonHelperGeneric(indexTab, nodes, zone)); // call base class method
Json json(ExecutionNode::toJsonHelperGeneric(indexTab, nodes, zone)); // call base class method
if (json.isEmpty()) {
return;
}
@ -212,17 +212,17 @@ void EnumerateListPlan::toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
}
// -----------------------------------------------------------------------------
// --SECTION-- methods of LimitPlan
// --SECTION-- methods of LimitNode
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief toJson, for LimitPlan
/// @brief toJson, for LimitNode
////////////////////////////////////////////////////////////////////////////////
void LimitPlan::toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
void LimitNode::toJsonHelper (std::map<ExecutionNode*, int>& indexTab,
triagens::basics::Json& nodes,
TRI_memory_zone_t* zone) {
Json json(ExecutionPlan::toJsonHelperGeneric(indexTab, nodes, zone)); // call base class method
Json json(ExecutionNode::toJsonHelperGeneric(indexTab, nodes, zone)); // call base class method
if (json.isEmpty()) {
return;
}
@ -237,17 +237,17 @@ void LimitPlan::toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
}
// -----------------------------------------------------------------------------
// --SECTION-- methods of CalculationPlan
// --SECTION-- methods of CalculationNode
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief toJson, for CalculationPlan
/// @brief toJson, for CalculationNode
////////////////////////////////////////////////////////////////////////////////
void CalculationPlan::toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
void CalculationNode::toJsonHelper (std::map<ExecutionNode*, int>& indexTab,
triagens::basics::Json& nodes,
TRI_memory_zone_t* zone) {
Json json(ExecutionPlan::toJsonHelperGeneric(indexTab, nodes, zone)); // call base class method
Json json(ExecutionNode::toJsonHelperGeneric(indexTab, nodes, zone)); // call base class method
if (json.isEmpty()) {
return;
}
@ -262,17 +262,17 @@ void CalculationPlan::toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
}
// -----------------------------------------------------------------------------
// --SECTION-- methods of SubqueryPlan
// --SECTION-- methods of SubqueryNode
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief toJson, for SubqueryPlan
/// @brief toJson, for SubqueryNode
////////////////////////////////////////////////////////////////////////////////
void SubqueryPlan::toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
void SubqueryNode::toJsonHelper (std::map<ExecutionNode*, int>& indexTab,
triagens::basics::Json& nodes,
TRI_memory_zone_t* zone) {
Json json(ExecutionPlan::toJsonHelperGeneric(indexTab, nodes, zone)); // call base class method
Json json(ExecutionNode::toJsonHelperGeneric(indexTab, nodes, zone)); // call base class method
if (json.isEmpty()) {
return;
}
@ -286,17 +286,17 @@ void SubqueryPlan::toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
}
// -----------------------------------------------------------------------------
// --SECTION-- methods of ProjectionPlan
// --SECTION-- methods of ProjectionNode
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief toJson, for ProjectionPlan
/// @brief toJson, for ProjectionNode
////////////////////////////////////////////////////////////////////////////////
void ProjectionPlan::toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
void ProjectionNode::toJsonHelper (std::map<ExecutionNode*, int>& indexTab,
triagens::basics::Json& nodes,
TRI_memory_zone_t* zone) {
Json json(ExecutionPlan::toJsonHelperGeneric(indexTab, nodes, zone)); // call base class method
Json json(ExecutionNode::toJsonHelperGeneric(indexTab, nodes, zone)); // call base class method
if (json.isEmpty()) {
return;
}
@ -316,17 +316,17 @@ void ProjectionPlan::toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
}
// -----------------------------------------------------------------------------
// --SECTION-- methods of FilterPlan
// --SECTION-- methods of FilterNode
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief toJson, for FilterPlan
/// @brief toJson, for FilterNode
////////////////////////////////////////////////////////////////////////////////
void FilterPlan::toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
void FilterNode::toJsonHelper (std::map<ExecutionNode*, int>& indexTab,
triagens::basics::Json& nodes,
TRI_memory_zone_t* zone) {
Json json(ExecutionPlan::toJsonHelperGeneric(indexTab, nodes, zone)); // call base class method
Json json(ExecutionNode::toJsonHelperGeneric(indexTab, nodes, zone)); // call base class method
if (json.isEmpty()) {
return;
}
@ -340,17 +340,17 @@ void FilterPlan::toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
}
// -----------------------------------------------------------------------------
// --SECTION-- methods of SortPlan
// --SECTION-- methods of SortNode
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief toJson, for SortPlan
/// @brief toJson, for SortNode
////////////////////////////////////////////////////////////////////////////////
void SortPlan::toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
void SortNode::toJsonHelper (std::map<ExecutionNode*, int>& indexTab,
triagens::basics::Json& nodes,
TRI_memory_zone_t* zone) {
Json json(ExecutionPlan::toJsonHelperGeneric(indexTab, nodes, zone)); // call base class method
Json json(ExecutionNode::toJsonHelperGeneric(indexTab, nodes, zone)); // call base class method
if (json.isEmpty()) {
return;
}
@ -370,17 +370,17 @@ void SortPlan::toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
}
// -----------------------------------------------------------------------------
// --SECTION-- methods of AggregateOnUnSortedPlan
// --SECTION-- methods of AggregateOnUnSortedNode
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief toJson, for AggregateOnUnSortedPlan
/// @brief toJson, for AggregateOnUnSortedNode
////////////////////////////////////////////////////////////////////////////////
void AggregateOnUnsortedPlan::toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
void AggregateOnUnsortedNode::toJsonHelper (std::map<ExecutionNode*, int>& indexTab,
triagens::basics::Json& nodes,
TRI_memory_zone_t* zone) {
Json json(ExecutionPlan::toJsonHelperGeneric(indexTab, nodes, zone)); // call base class method
Json json(ExecutionNode::toJsonHelperGeneric(indexTab, nodes, zone)); // call base class method
if (json.isEmpty()) {
return;
}
@ -406,17 +406,17 @@ void AggregateOnUnsortedPlan::toJsonHelper (std::map<ExecutionPlan*, int>& index
}
// -----------------------------------------------------------------------------
// --SECTION-- methods of RootPlan
// --SECTION-- methods of RootNode
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief toJson, for RootPlan
/// @brief toJson, for RootNode
////////////////////////////////////////////////////////////////////////////////
void RootPlan::toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
void RootNode::toJsonHelper (std::map<ExecutionNode*, int>& indexTab,
triagens::basics::Json& nodes,
TRI_memory_zone_t* zone) {
Json json(ExecutionPlan::toJsonHelperGeneric(indexTab, nodes, zone)); // call base class method
Json json(ExecutionNode::toJsonHelperGeneric(indexTab, nodes, zone)); // call base class method
if (json.isEmpty()) {
return;
}

View File

@ -25,8 +25,8 @@
/// @author Copyright 2014, triagens GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#ifndef ARANGODB_AQL_EXECUTION_PLAN_H
#define ARANGODB_AQL_EXECUTION_PLAN_H 1
#ifndef ARANGODB_AQL_EXECUTION_Plan_H
#define ARANGODB_AQL_EXECUTION_Plan_H 1
#include <Basics/Common.h>
@ -44,10 +44,10 @@ namespace triagens {
class ExecutionBlock;
////////////////////////////////////////////////////////////////////////////////
/// @brief class ExecutionPlan, abstract base class of all execution plans
/// @brief class ExecutionNode, abstract base class of all execution Nodes
////////////////////////////////////////////////////////////////////////////////
class ExecutionPlan {
class ExecutionNode {
////////////////////////////////////////////////////////////////////////////////
/// @brief node type
@ -93,14 +93,14 @@ namespace triagens {
/// @brief default constructor
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan () {
ExecutionNode () {
}
////////////////////////////////////////////////////////////////////////////////
/// @brief constructor with one dependency
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan (ExecutionPlan* ep) {
ExecutionNode (ExecutionNode* ep) {
_dependencies.push_back(ep);
}
@ -108,10 +108,7 @@ namespace triagens {
/// @brief destructor, free dependencies
////////////////////////////////////////////////////////////////////////////////
virtual ~ExecutionPlan () {
for (auto i = _dependencies.begin(); i != _dependencies.end(); ++i) {
delete *i;
}
virtual ~ExecutionNode () {
}
////////////////////////////////////////////////////////////////////////////////
@ -127,14 +124,14 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
virtual std::string getTypeString () const {
return std::string("ExecutionPlan (abstract)");
return std::string("ExecutionNode (abstract)");
}
////////////////////////////////////////////////////////////////////////////////
/// @brief add a dependency
////////////////////////////////////////////////////////////////////////////////
void addDependency (ExecutionPlan* ep) {
void addDependency (ExecutionNode* ep) {
_dependencies.push_back(ep);
}
@ -142,7 +139,7 @@ namespace triagens {
/// @brief get all dependencies
////////////////////////////////////////////////////////////////////////////////
vector<ExecutionPlan*> getDependencies () const {
vector<ExecutionNode*> getDependencies () const {
return _dependencies;
}
@ -151,7 +148,7 @@ namespace triagens {
/// removed, please note that this does not delete ep!
////////////////////////////////////////////////////////////////////////////////
bool removeDependency (ExecutionPlan* ep) {
bool removeDependency (ExecutionNode* ep) {
auto it = _dependencies.begin();
while (it != _dependencies.end()) {
if (*it == ep) {
@ -167,7 +164,7 @@ namespace triagens {
/// @brief access the pos-th dependency
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* operator[] (size_t pos) const {
ExecutionNode* operator[] (size_t pos) const {
if (pos > _dependencies.size()) {
return nullptr;
}
@ -177,16 +174,16 @@ namespace triagens {
}
////////////////////////////////////////////////////////////////////////////////
/// @brief clone execution plan recursively, this makes the class abstract
/// @brief clone execution Node recursively, this makes the class abstract
////////////////////////////////////////////////////////////////////////////////
virtual ExecutionPlan* clone () const = 0; // make class abstract
virtual ExecutionNode* clone () const = 0; // make class abstract
////////////////////////////////////////////////////////////////////////////////
/// @brief helper for cloning, use virtual clone methods for dependencies
////////////////////////////////////////////////////////////////////////////////
void cloneDependencies (ExecutionPlan* theClone) const {
void cloneDependencies (ExecutionNode* theClone) const {
auto it = _dependencies.begin();
while (it != _dependencies.end()) {
theClone->_dependencies.push_back((*it)->clone());
@ -209,11 +206,11 @@ namespace triagens {
protected:
triagens::basics::Json toJsonHelperGeneric (
std::map<ExecutionPlan*, int>& indexTab,
std::map<ExecutionNode*, int>& indexTab,
triagens::basics::Json& nodes,
TRI_memory_zone_t* zone);
virtual void toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
virtual void toJsonHelper (std::map<ExecutionNode*, int>& indexTab,
triagens::basics::Json& nodes,
TRI_memory_zone_t* zone = TRI_UNKNOWN_MEM_ZONE) = 0;
@ -234,12 +231,12 @@ namespace triagens {
public:
WalkerWorker () {};
virtual ~WalkerWorker () {};
virtual void before (ExecutionPlan* eb) {};
virtual void after (ExecutionPlan* eb) {};
virtual void enterSubquery (ExecutionPlan* super,
ExecutionPlan* sub) {};
virtual void leaveSubquery (ExecutionPlan* super,
ExecutionPlan* sub) {};
virtual void before (ExecutionNode* eb) {};
virtual void after (ExecutionNode* eb) {};
virtual void enterSubquery (ExecutionNode* super,
ExecutionNode* sub) {};
virtual void leaveSubquery (ExecutionNode* super,
ExecutionNode* sub) {};
};
void walk (WalkerWorker& worker);
@ -254,19 +251,19 @@ namespace triagens {
protected:
std::vector<ExecutionPlan*> _dependencies;
std::vector<ExecutionNode*> _dependencies;
};
// -----------------------------------------------------------------------------
// --SECTION-- class SingletonPlan
// --SECTION-- class SingletonNode
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief class SingletonPlan, derived from ExecutionPlan
/// @brief class SingletonNode, derived from ExecutionNode
////////////////////////////////////////////////////////////////////////////////
class SingletonPlan : public ExecutionPlan {
class SingletonNode : public ExecutionNode {
friend class ExecutionBlock;
friend class SingletonBlock;
@ -277,7 +274,7 @@ namespace triagens {
public:
SingletonPlan () : ExecutionPlan() {
SingletonNode () : ExecutionNode() {
}
////////////////////////////////////////////////////////////////////////////////
@ -293,38 +290,38 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
virtual std::string getTypeString () const {
return std::string("SingletonPlan");
return std::string("SingletonNode");
}
////////////////////////////////////////////////////////////////////////////////
/// @brief export to JSON
////////////////////////////////////////////////////////////////////////////////
virtual void toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
virtual void toJsonHelper (std::map<ExecutionNode*, int>& indexTab,
triagens::basics::Json& nodes,
TRI_memory_zone_t* zone = TRI_UNKNOWN_MEM_ZONE);
////////////////////////////////////////////////////////////////////////////////
/// @brief clone execution plan recursively
/// @brief clone ExecutionNode recursively
////////////////////////////////////////////////////////////////////////////////
virtual ExecutionPlan* clone () const {
auto c = new SingletonPlan();
virtual ExecutionNode* clone () const {
auto c = new SingletonNode();
cloneDependencies(c);
return static_cast<ExecutionPlan*>(c);
return static_cast<ExecutionNode*>(c);
}
};
// -----------------------------------------------------------------------------
// --SECTION-- class EnumerateCollectionPlan
// --SECTION-- class EnumerateCollectionNode
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief class EnumerateCollectionPlan, derived from ExecutionPlan
/// @brief class EnumerateCollectionNode, derived from ExecutionNode
////////////////////////////////////////////////////////////////////////////////
class EnumerateCollectionPlan : public ExecutionPlan {
class EnumerateCollectionNode : public ExecutionNode {
friend class ExecutionBlock;
friend class EnumerateCollectionBlock;
@ -335,10 +332,10 @@ namespace triagens {
public:
EnumerateCollectionPlan (TRI_vocbase_t* vocbase,
EnumerateCollectionNode (TRI_vocbase_t* vocbase,
std::string collname,
Variable const* outVariable)
: ExecutionPlan(), _vocbase(vocbase), _collname(collname),
: ExecutionNode(), _vocbase(vocbase), _collname(collname),
_outVariable(outVariable) {
TRI_ASSERT(_vocbase != nullptr);
@ -358,25 +355,25 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
virtual std::string getTypeString () const {
return std::string("EnumerateCollectionPlan");
return std::string("EnumerateCollectionNode");
}
////////////////////////////////////////////////////////////////////////////////
/// @brief export to JSON
////////////////////////////////////////////////////////////////////////////////
virtual void toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
virtual void toJsonHelper (std::map<ExecutionNode*, int>& indexTab,
triagens::basics::Json& nodes,
TRI_memory_zone_t* zone = TRI_UNKNOWN_MEM_ZONE);
////////////////////////////////////////////////////////////////////////////////
/// @brief clone execution plan recursively
/// @brief clone ExecutionNode recursively
////////////////////////////////////////////////////////////////////////////////
virtual ExecutionPlan* clone () const {
auto c = new EnumerateCollectionPlan(_vocbase, _collname, _outVariable);
virtual ExecutionNode* clone () const {
auto c = new EnumerateCollectionNode(_vocbase, _collname, _outVariable);
cloneDependencies(c);
return static_cast<ExecutionPlan*>(c);
return static_cast<ExecutionNode*>(c);
}
////////////////////////////////////////////////////////////////////////////////
@ -406,14 +403,14 @@ namespace triagens {
};
// -----------------------------------------------------------------------------
// --SECTION-- class EnumerateListPlan
// --SECTION-- class EnumerateListNode
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief class EnumerateListPlan, derived from ExecutionPlan
/// @brief class EnumerateListNode, derived from ExecutionNode
////////////////////////////////////////////////////////////////////////////////
class EnumerateListPlan : public ExecutionPlan {
class EnumerateListNode : public ExecutionNode {
friend class ExecutionBlock;
friend class EnumerateListBlock;
@ -424,9 +421,9 @@ namespace triagens {
public:
EnumerateListPlan (Variable const* inVariable,
EnumerateListNode (Variable const* inVariable,
Variable const* outVariable)
: ExecutionPlan(), _inVariable(inVariable), _outVariable(outVariable) {
: ExecutionNode(), _inVariable(inVariable), _outVariable(outVariable) {
TRI_ASSERT(_inVariable != nullptr);
TRI_ASSERT(_outVariable != nullptr);
@ -445,25 +442,25 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
virtual std::string getTypeString () const {
return std::string("EnumerateListPlan");
return std::string("EnumerateListNode");
}
////////////////////////////////////////////////////////////////////////////////
/// @brief export to JSON
////////////////////////////////////////////////////////////////////////////////
virtual void toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
virtual void toJsonHelper (std::map<ExecutionNode*, int>& indexTab,
triagens::basics::Json& nodes,
TRI_memory_zone_t* zone = TRI_UNKNOWN_MEM_ZONE);
////////////////////////////////////////////////////////////////////////////////
/// @brief clone execution plan recursively
/// @brief clone ExecutionNode recursively
////////////////////////////////////////////////////////////////////////////////
virtual ExecutionPlan* clone () const {
auto c = new EnumerateListPlan(_inVariable, _outVariable);
virtual ExecutionNode* clone () const {
auto c = new EnumerateListNode(_inVariable, _outVariable);
cloneDependencies(c);
return static_cast<ExecutionPlan*>(c);
return static_cast<ExecutionNode*>(c);
}
////////////////////////////////////////////////////////////////////////////////
@ -488,14 +485,14 @@ namespace triagens {
// -----------------------------------------------------------------------------
// --SECTION-- class LimitPlan
// --SECTION-- class LimitNode
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief class LimitPlan, derived from ExecutionPlan
/// @brief class LimitNode, derived from ExecutionNode
////////////////////////////////////////////////////////////////////////////////
class LimitPlan : public ExecutionPlan {
class LimitNode : public ExecutionNode {
friend class ExecutionBlock;
friend class LimitBlock;
@ -506,12 +503,12 @@ namespace triagens {
public:
LimitPlan (size_t o, size_t l)
: ExecutionPlan(), _offset(o), _limit(l) {
LimitNode (size_t o, size_t l)
: ExecutionNode(), _offset(o), _limit(l) {
}
LimitPlan (size_t l)
: ExecutionPlan(), _offset(0), _limit(l) {
LimitNode (size_t l)
: ExecutionNode(), _offset(0), _limit(l) {
}
////////////////////////////////////////////////////////////////////////////////
@ -527,25 +524,25 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
virtual std::string getTypeString () const {
return std::string("LimitPlan");
return std::string("LimitNode");
}
////////////////////////////////////////////////////////////////////////////////
/// @brief export to JSON
////////////////////////////////////////////////////////////////////////////////
virtual void toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
virtual void toJsonHelper (std::map<ExecutionNode*, int>& indexTab,
triagens::basics::Json& nodes,
TRI_memory_zone_t* zone = TRI_UNKNOWN_MEM_ZONE);
////////////////////////////////////////////////////////////////////////////////
/// @brief clone execution plan recursively
/// @brief clone ExecutionNode recursively
////////////////////////////////////////////////////////////////////////////////
virtual ExecutionPlan* clone () const {
auto c = new LimitPlan(_offset, _limit);
virtual ExecutionNode* clone () const {
auto c = new LimitNode(_offset, _limit);
cloneDependencies(c);
return static_cast<ExecutionPlan*>(c);
return static_cast<ExecutionNode*>(c);
}
////////////////////////////////////////////////////////////////////////////////
@ -560,14 +557,14 @@ namespace triagens {
};
// -----------------------------------------------------------------------------
// --SECTION-- class ProjectionPlan
// --SECTION-- class ProjectionNode
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief class ProjectionPlan, derived from ExecutionPlan
/// @brief class ProjectionNode, derived from ExecutionNode
////////////////////////////////////////////////////////////////////////////////
class ProjectionPlan : public ExecutionPlan {
class ProjectionNode : public ExecutionNode {
friend class ExecutionBlock;
friend class ProjectionBlock;
@ -578,10 +575,10 @@ namespace triagens {
public:
ProjectionPlan (Variable const* inVariable,
ProjectionNode (Variable const* inVariable,
Variable const* outVariable,
std::vector<std::string> keepAttributes)
: ExecutionPlan(), _inVariable(inVariable), _outVariable(outVariable),
: ExecutionNode(), _inVariable(inVariable), _outVariable(outVariable),
_keepAttributes(keepAttributes) {
TRI_ASSERT(inVariable != nullptr);
@ -601,25 +598,25 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
virtual std::string getTypeString () const {
return std::string("ProjectionPlan");
return std::string("ProjectionNode");
}
////////////////////////////////////////////////////////////////////////////////
/// @brief export to JSON
////////////////////////////////////////////////////////////////////////////////
virtual void toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
virtual void toJsonHelper (std::map<ExecutionNode*, int>& indexTab,
triagens::basics::Json& nodes,
TRI_memory_zone_t* zone = TRI_UNKNOWN_MEM_ZONE);
////////////////////////////////////////////////////////////////////////////////
/// @brief clone execution plan recursively
/// @brief clone ExecutionNode recursively
////////////////////////////////////////////////////////////////////////////////
virtual ExecutionPlan* clone () const {
auto c = new ProjectionPlan(_inVariable, _outVariable, _keepAttributes);
virtual ExecutionNode* clone () const {
auto c = new ProjectionNode(_inVariable, _outVariable, _keepAttributes);
cloneDependencies(c);
return static_cast<ExecutionPlan*>(c);
return static_cast<ExecutionNode*>(c);
}
////////////////////////////////////////////////////////////////////////////////
@ -649,14 +646,14 @@ namespace triagens {
};
// -----------------------------------------------------------------------------
// --SECTION-- class CalculationPlan
// --SECTION-- class CalculationNode
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief class CalculationPlan, derived from ExecutionPlan
/// @brief class CalculationNode, derived from ExecutionNode
////////////////////////////////////////////////////////////////////////////////
class CalculationPlan : public ExecutionPlan {
class CalculationNode : public ExecutionNode {
friend class ExecutionBlock;
friend class CalculationBlock;
@ -667,8 +664,8 @@ namespace triagens {
/// @brief constructor
////////////////////////////////////////////////////////////////////////////////
CalculationPlan (Expression* expr, Variable const* outVariable)
: ExecutionPlan(), _expression(expr), _outVariable(outVariable) {
CalculationNode (Expression* expr, Variable const* outVariable)
: ExecutionNode(), _expression(expr), _outVariable(outVariable) {
TRI_ASSERT(_expression != nullptr);
TRI_ASSERT(_outVariable != nullptr);
@ -678,7 +675,7 @@ namespace triagens {
/// @brief destructor
////////////////////////////////////////////////////////////////////////////////
~CalculationPlan () {
~CalculationNode () {
if (_expression != nullptr) {
delete _expression;
}
@ -697,25 +694,25 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
virtual std::string getTypeString () const {
return std::string("CalculationPlan");
return std::string("CalculationNode");
}
////////////////////////////////////////////////////////////////////////////////
/// @brief export to JSON
////////////////////////////////////////////////////////////////////////////////
virtual void toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
virtual void toJsonHelper (std::map<ExecutionNode*, int>& indexTab,
triagens::basics::Json& nodes,
TRI_memory_zone_t* zone = TRI_UNKNOWN_MEM_ZONE);
////////////////////////////////////////////////////////////////////////////////
/// @brief clone execution plan recursively
/// @brief clone ExecutionNode recursively
////////////////////////////////////////////////////////////////////////////////
virtual ExecutionPlan* clone () const {
auto c = new CalculationPlan(_expression->clone(), _outVariable);
virtual ExecutionNode* clone () const {
auto c = new CalculationNode(_expression->clone(), _outVariable);
cloneDependencies(c);
return static_cast<ExecutionPlan*>(c);
return static_cast<ExecutionNode*>(c);
}
////////////////////////////////////////////////////////////////////////////////
@ -747,14 +744,14 @@ namespace triagens {
};
// -----------------------------------------------------------------------------
// --SECTION-- class SubqueryPlan
// --SECTION-- class SubqueryNode
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief class SubqueryPlan, derived from ExecutionPlan
/// @brief class SubqueryNode, derived from ExecutionNode
////////////////////////////////////////////////////////////////////////////////
class SubqueryPlan : public ExecutionPlan {
class SubqueryNode : public ExecutionNode {
friend class ExecutionBlock;
friend class SubqueryBlock;
@ -765,8 +762,8 @@ namespace triagens {
public:
SubqueryPlan (ExecutionPlan* subquery, Variable const* outVariable)
: ExecutionPlan(), _subquery(subquery), _outVariable(outVariable) {
SubqueryNode (ExecutionNode* subquery, Variable const* outVariable)
: ExecutionNode(), _subquery(subquery), _outVariable(outVariable) {
TRI_ASSERT(_subquery != nullptr);
TRI_ASSERT(_outVariable != nullptr);
@ -785,32 +782,32 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
virtual std::string getTypeString () const {
return std::string("SubqueryPlan");
return std::string("SubqueryNode");
}
////////////////////////////////////////////////////////////////////////////////
/// @brief export to JSON
////////////////////////////////////////////////////////////////////////////////
virtual void toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
virtual void toJsonHelper (std::map<ExecutionNode*, int>& indexTab,
triagens::basics::Json& nodes,
TRI_memory_zone_t* zone = TRI_UNKNOWN_MEM_ZONE);
////////////////////////////////////////////////////////////////////////////////
/// @brief clone execution plan recursively
/// @brief clone ExecutionNode recursively
////////////////////////////////////////////////////////////////////////////////
virtual ExecutionPlan* clone () const {
auto c = new SubqueryPlan(_subquery->clone(), _outVariable);
virtual ExecutionNode* clone () const {
auto c = new SubqueryNode(_subquery->clone(), _outVariable);
cloneDependencies(c);
return static_cast<ExecutionPlan*>(c);
return static_cast<ExecutionNode*>(c);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief getter for subquery
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* getSubquery () {
ExecutionNode* getSubquery () {
return _subquery;
}
@ -824,7 +821,7 @@ namespace triagens {
/// @brief we need to have an expression and where to write the result
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* _subquery;
ExecutionNode* _subquery;
////////////////////////////////////////////////////////////////////////////////
/// @brief variable to write to
@ -835,14 +832,14 @@ namespace triagens {
};
// -----------------------------------------------------------------------------
// --SECTION-- class FilterPlan
// --SECTION-- class FilterNode
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief class FilterPlan, derived from ExecutionPlan
/// @brief class FilterNode, derived from ExecutionNode
////////////////////////////////////////////////////////////////////////////////
class FilterPlan : public ExecutionPlan {
class FilterNode : public ExecutionNode {
friend class ExecutionBlock;
friend class FilterBlock;
@ -853,8 +850,8 @@ namespace triagens {
public:
FilterPlan (Variable const* inVariable)
: ExecutionPlan(), _inVariable(inVariable) {
FilterNode (Variable const* inVariable)
: ExecutionNode(), _inVariable(inVariable) {
TRI_ASSERT(_inVariable != nullptr);
}
@ -872,25 +869,25 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
virtual std::string getTypeString () const {
return std::string("FilterPlan");
return std::string("FilterNode");
}
////////////////////////////////////////////////////////////////////////////////
/// @brief export to JSON
////////////////////////////////////////////////////////////////////////////////
virtual void toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
virtual void toJsonHelper (std::map<ExecutionNode*, int>& indexTab,
triagens::basics::Json& nodes,
TRI_memory_zone_t* zone = TRI_UNKNOWN_MEM_ZONE);
////////////////////////////////////////////////////////////////////////////////
/// @brief clone execution plan recursively
/// @brief clone ExecutionNode recursively
////////////////////////////////////////////////////////////////////////////////
virtual ExecutionPlan* clone () const {
auto c = new FilterPlan(_inVariable);
virtual ExecutionNode* clone () const {
auto c = new FilterNode(_inVariable);
cloneDependencies(c);
return static_cast<ExecutionPlan*>(c);
return static_cast<ExecutionNode*>(c);
}
////////////////////////////////////////////////////////////////////////////////
@ -908,14 +905,14 @@ namespace triagens {
};
// -----------------------------------------------------------------------------
// --SECTION-- class SortPlan
// --SECTION-- class SortNode
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief class SortPlan, derived from ExecutionPlan
/// @brief class SortNode, derived from ExecutionNode
////////////////////////////////////////////////////////////////////////////////
class SortPlan : public ExecutionPlan {
class SortNode : public ExecutionNode {
friend class ExecutionBlock;
friend class SortBlock;
@ -926,8 +923,8 @@ namespace triagens {
public:
SortPlan (std::vector<std::pair<Variable const*, bool>> elements)
: ExecutionPlan(), _elements(elements) {
SortNode (std::vector<std::pair<Variable const*, bool>> elements)
: ExecutionNode(), _elements(elements) {
}
////////////////////////////////////////////////////////////////////////////////
@ -943,25 +940,25 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
virtual std::string getTypeString () const {
return std::string("SortPlan");
return std::string("SortNode");
}
////////////////////////////////////////////////////////////////////////////////
/// @brief export to JSON
////////////////////////////////////////////////////////////////////////////////
virtual void toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
virtual void toJsonHelper (std::map<ExecutionNode*, int>& indexTab,
triagens::basics::Json& nodes,
TRI_memory_zone_t* zone = TRI_UNKNOWN_MEM_ZONE);
////////////////////////////////////////////////////////////////////////////////
/// @brief clone execution plan recursively
/// @brief clone ExecutionNode recursively
////////////////////////////////////////////////////////////////////////////////
virtual ExecutionPlan* clone () const {
auto c = new SortPlan(_elements);
virtual ExecutionNode* clone () const {
auto c = new SortNode(_elements);
cloneDependencies(c);
return static_cast<ExecutionPlan*>(c);
return static_cast<ExecutionNode*>(c);
}
////////////////////////////////////////////////////////////////////////////////
@ -981,14 +978,14 @@ namespace triagens {
// -----------------------------------------------------------------------------
// --SECTION-- class AggregateOnUnsortedPlan
// --SECTION-- class AggregateOnUnsortedNode
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief class AggregateOnUnsortedPlan, derived from ExecutionPlan
/// @brief class AggregateOnUnsortedNode, derived from ExecutionNode
////////////////////////////////////////////////////////////////////////////////
class AggregateOnUnsortedPlan : public ExecutionPlan {
class AggregateOnUnsortedNode : public ExecutionNode {
friend class ExecutionBlock;
friend class AggregateOnUnsortedBlock;
@ -999,9 +996,9 @@ namespace triagens {
public:
AggregateOnUnsortedPlan (std::vector<std::pair<Variable const*, Variable const*>> aggregateVariables,
AggregateOnUnsortedNode (std::vector<std::pair<Variable const*, Variable const*>> aggregateVariables,
Variable const* outVariable)
: ExecutionPlan(), _aggregateVariables(aggregateVariables), _outVariable(outVariable) {
: ExecutionNode(), _aggregateVariables(aggregateVariables), _outVariable(outVariable) {
}
////////////////////////////////////////////////////////////////////////////////
@ -1017,25 +1014,25 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
virtual std::string getTypeString () const {
return std::string("AggregateOnUnsortedPlan");
return std::string("AggregateOnUnsortedNode");
}
////////////////////////////////////////////////////////////////////////////////
/// @brief export to JSON
////////////////////////////////////////////////////////////////////////////////
virtual void toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
virtual void toJsonHelper (std::map<ExecutionNode*, int>& indexTab,
triagens::basics::Json& nodes,
TRI_memory_zone_t* zone = TRI_UNKNOWN_MEM_ZONE);
////////////////////////////////////////////////////////////////////////////////
/// @brief clone execution plan recursively
/// @brief clone ExecutionNode recursively
////////////////////////////////////////////////////////////////////////////////
virtual ExecutionPlan* clone () const {
auto c = new AggregateOnUnsortedPlan(_aggregateVariables, _outVariable);
virtual ExecutionNode* clone () const {
auto c = new AggregateOnUnsortedNode(_aggregateVariables, _outVariable);
cloneDependencies(c);
return static_cast<ExecutionPlan*>(c);
return static_cast<ExecutionNode*>(c);
}
////////////////////////////////////////////////////////////////////////////////
@ -1060,14 +1057,14 @@ namespace triagens {
// -----------------------------------------------------------------------------
// --SECTION-- class RootPlan
// --SECTION-- class RootNode
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief class RootPlan, derived from ExecutionPlan
/// @brief class RootNode, derived from ExecutionNode
////////////////////////////////////////////////////////////////////////////////
class RootPlan : public ExecutionPlan {
class RootNode : public ExecutionNode {
friend class ExecutionBlock;
friend class RootBlock;
@ -1078,8 +1075,8 @@ namespace triagens {
public:
RootPlan (Variable const* inVariable)
: ExecutionPlan(), _inVariable(inVariable) {
RootNode (Variable const* inVariable)
: ExecutionNode(), _inVariable(inVariable) {
TRI_ASSERT(_inVariable != nullptr);
}
@ -1097,25 +1094,25 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
virtual std::string getTypeString () const {
return std::string("RootPlan");
return std::string("RootNode");
}
////////////////////////////////////////////////////////////////////////////////
/// @brief export to JSON
////////////////////////////////////////////////////////////////////////////////
virtual void toJsonHelper (std::map<ExecutionPlan*, int>& indexTab,
virtual void toJsonHelper (std::map<ExecutionNode*, int>& indexTab,
triagens::basics::Json& nodes,
TRI_memory_zone_t* zone = TRI_UNKNOWN_MEM_ZONE);
////////////////////////////////////////////////////////////////////////////////
/// @brief clone execution plan recursively
/// @brief clone ExecutionNode recursively
////////////////////////////////////////////////////////////////////////////////
virtual ExecutionPlan* clone () const {
auto c = new RootPlan(_inVariable);
virtual ExecutionNode* clone () const {
auto c = new RootNode(_inVariable);
cloneDependencies(c);
return static_cast<ExecutionPlan*>(c);
return static_cast<ExecutionNode*>(c);
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -64,14 +64,14 @@ PlanGenerator::~PlanGenerator () {
/// @brief create an initial execution plan from an abstract syntax tree
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* PlanGenerator::fromAst (Ast const* ast) {
ExecutionNode* PlanGenerator::fromAst (Ast const* ast) {
TRI_ASSERT(ast != nullptr);
auto root = ast->root();
TRI_ASSERT(root != nullptr);
TRI_ASSERT(root->type == NODE_TYPE_ROOT);
ExecutionPlan* plan = fromNode(ast, root);
ExecutionNode* plan = fromNode(ast, root);
return plan;
}
@ -84,7 +84,7 @@ ExecutionPlan* PlanGenerator::fromAst (Ast const* ast) {
/// @brief creates a calculation node for an arbitrary expression
////////////////////////////////////////////////////////////////////////////////
CalculationPlan* PlanGenerator::createTemporaryCalculation (Ast const* ast,
CalculationNode* PlanGenerator::createTemporaryCalculation (Ast const* ast,
AstNode const* expression) {
// generate a temporary variable
auto out = ast->variables()->createTemporaryVariable();
@ -94,7 +94,7 @@ CalculationPlan* PlanGenerator::createTemporaryCalculation (Ast const* ast,
auto expr = new Expression(ast->query()->executor(), const_cast<AstNode*>(expression));
try {
return new CalculationPlan(expr, out);
return new CalculationNode(expr, out);
}
catch (...) {
// prevent memleak
@ -108,8 +108,8 @@ CalculationPlan* PlanGenerator::createTemporaryCalculation (Ast const* ast,
/// @brief adds "previous" as dependency to "plan", returns "plan"
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* PlanGenerator::addDependency (ExecutionPlan* previous,
ExecutionPlan* plan) {
ExecutionNode* PlanGenerator::addDependency (ExecutionNode* previous,
ExecutionNode* plan) {
TRI_ASSERT(previous != nullptr);
TRI_ASSERT(plan != nullptr);
@ -128,8 +128,8 @@ ExecutionPlan* PlanGenerator::addDependency (ExecutionPlan* previous,
/// @brief create an execution plan element from an AST FOR node
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* PlanGenerator::fromNodeFor (Ast const* ast,
ExecutionPlan* previous,
ExecutionNode* PlanGenerator::fromNodeFor (Ast const* ast,
ExecutionNode* previous,
AstNode const* node) {
TRI_ASSERT(node != nullptr && node->type == NODE_TYPE_FOR);
TRI_ASSERT(node->numMembers() == 2);
@ -142,26 +142,26 @@ ExecutionPlan* PlanGenerator::fromNodeFor (Ast const* ast,
auto v = static_cast<Variable*>(variable->getData());
TRI_ASSERT(v != nullptr);
ExecutionPlan* plan = nullptr;
ExecutionNode* plan = nullptr;
// peek at second operand
if (expression->type == NODE_TYPE_COLLECTION) {
// second operand is a collection
char const* collectionName = expression->getStringValue();
plan = new EnumerateCollectionPlan(ast->query()->vocbase(), std::string(collectionName), v);
plan = new EnumerateCollectionNode(ast->query()->vocbase(), std::string(collectionName), v);
}
else if (expression->type == NODE_TYPE_REFERENCE) {
// second operand is already a variable
auto inVariable = static_cast<Variable*>(variable->getData());
TRI_ASSERT(inVariable != nullptr);
plan = new EnumerateListPlan(inVariable, v);
plan = new EnumerateListNode(inVariable, v);
}
else {
// second operand is some misc. expression
auto calc = createTemporaryCalculation(ast, expression);
try {
plan = new EnumerateListPlan(calc->outVariable(), v);
plan = new EnumerateListNode(calc->outVariable(), v);
plan->addDependency(calc);
}
catch (...) {
@ -179,28 +179,28 @@ ExecutionPlan* PlanGenerator::fromNodeFor (Ast const* ast,
/// @brief create an execution plan element from an AST FILTER node
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* PlanGenerator::fromNodeFilter (Ast const* ast,
ExecutionPlan* previous,
ExecutionNode* PlanGenerator::fromNodeFilter (Ast const* ast,
ExecutionNode* previous,
AstNode const* node) {
TRI_ASSERT(node != nullptr && node->type == NODE_TYPE_FILTER);
TRI_ASSERT(node->numMembers() == 1);
auto expression = node->getMember(0);
ExecutionPlan* plan = nullptr;
ExecutionNode* plan = nullptr;
if (expression->type == NODE_TYPE_REFERENCE) {
// operand is already a variable
auto v = static_cast<Variable*>(expression->getData());
TRI_ASSERT(v != nullptr);
plan = new FilterPlan(v);
plan = new FilterNode(v);
}
else {
// operand is some misc expression
auto calc = createTemporaryCalculation(ast, expression);
try {
plan = new FilterPlan(calc->outVariable());
plan = new FilterNode(calc->outVariable());
plan->addDependency(calc);
}
catch (...) {
@ -216,8 +216,8 @@ ExecutionPlan* PlanGenerator::fromNodeFilter (Ast const* ast,
/// @brief create an execution plan element from an AST LET node
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* PlanGenerator::fromNodeLet (Ast const* ast,
ExecutionPlan* previous,
ExecutionNode* PlanGenerator::fromNodeLet (Ast const* ast,
ExecutionNode* previous,
AstNode const* node) {
TRI_ASSERT(node != nullptr && node->type == NODE_TYPE_LET);
TRI_ASSERT(node->numMembers() == 2);
@ -227,7 +227,7 @@ ExecutionPlan* PlanGenerator::fromNodeLet (Ast const* ast,
auto v = static_cast<Variable*>(variable->getData());
ExecutionPlan* plan = nullptr;
ExecutionNode* plan = nullptr;
if (expression->type == NODE_TYPE_SUBQUERY) {
// TODO: node might be a subquery. this is currently NOT handled
@ -238,7 +238,7 @@ ExecutionPlan* PlanGenerator::fromNodeLet (Ast const* ast,
auto expr = new Expression(ast->query()->executor(), const_cast<AstNode*>(expression));
try {
plan = new CalculationPlan(expr, v);
plan = new CalculationNode(expr, v);
}
catch (...) {
// prevent memleak
@ -254,8 +254,8 @@ ExecutionPlan* PlanGenerator::fromNodeLet (Ast const* ast,
/// @brief create an execution plan element from an AST SORT node
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* PlanGenerator::fromNodeSort (Ast const* ast,
ExecutionPlan* previous,
ExecutionNode* PlanGenerator::fromNodeSort (Ast const* ast,
ExecutionNode* previous,
AstNode const* node) {
TRI_ASSERT(node != nullptr && node->type == NODE_TYPE_SORT);
TRI_ASSERT(node->numMembers() == 1);
@ -264,7 +264,7 @@ ExecutionPlan* PlanGenerator::fromNodeSort (Ast const* ast,
TRI_ASSERT(list->type == NODE_TYPE_LIST);
std::vector<std::pair<Variable const*, bool>> elements;
std::vector<CalculationPlan*> temp;
std::vector<CalculationNode*> temp;
try {
size_t const n = list->numMembers();
@ -306,7 +306,7 @@ ExecutionPlan* PlanGenerator::fromNodeSort (Ast const* ast,
previous = (*it);
}
auto plan = new SortPlan(elements);
auto plan = new SortNode(elements);
return addDependency(previous, plan);
}
@ -315,8 +315,8 @@ ExecutionPlan* PlanGenerator::fromNodeSort (Ast const* ast,
/// @brief create an execution plan element from an AST COLLECT node
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* PlanGenerator::fromNodeCollect (Ast const* ast,
ExecutionPlan* previous,
ExecutionNode* PlanGenerator::fromNodeCollect (Ast const* ast,
ExecutionNode* previous,
AstNode const* node) {
TRI_ASSERT(node != nullptr && node->type == NODE_TYPE_COLLECT);
size_t const n = node->numMembers();
@ -333,8 +333,8 @@ ExecutionPlan* PlanGenerator::fromNodeCollect (Ast const* ast,
/// @brief create an execution plan element from an AST LIMIT node
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* PlanGenerator::fromNodeLimit (Ast const* ast,
ExecutionPlan* previous,
ExecutionNode* PlanGenerator::fromNodeLimit (Ast const* ast,
ExecutionNode* previous,
AstNode const* node) {
TRI_ASSERT(node != nullptr && node->type == NODE_TYPE_LIMIT);
TRI_ASSERT(node->numMembers() == 2);
@ -345,7 +345,7 @@ ExecutionPlan* PlanGenerator::fromNodeLimit (Ast const* ast,
TRI_ASSERT(offset->type == NODE_TYPE_VALUE);
TRI_ASSERT(count->type == NODE_TYPE_VALUE);
auto plan = new LimitPlan(static_cast<size_t>(offset->getIntValue()), static_cast<size_t>(count->getIntValue()));
auto plan = new LimitNode(static_cast<size_t>(offset->getIntValue()), static_cast<size_t>(count->getIntValue()));
return addDependency(previous, plan);
}
@ -354,28 +354,28 @@ ExecutionPlan* PlanGenerator::fromNodeLimit (Ast const* ast,
/// @brief create an execution plan element from an AST RETURN node
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* PlanGenerator::fromNodeReturn (Ast const* ast,
ExecutionPlan* previous,
ExecutionNode* PlanGenerator::fromNodeReturn (Ast const* ast,
ExecutionNode* previous,
AstNode const* node) {
TRI_ASSERT(node != nullptr && node->type == NODE_TYPE_RETURN);
TRI_ASSERT(node->numMembers() == 1);
auto expression = node->getMember(0);
ExecutionPlan* plan = nullptr;
ExecutionNode* plan = nullptr;
if (expression->type == NODE_TYPE_REFERENCE) {
// operand is already a variable
auto v = static_cast<Variable*>(expression->getData());
TRI_ASSERT(v != nullptr);
plan = new RootPlan(v);
plan = new RootNode(v);
}
else {
// operand is some misc expression
auto calc = createTemporaryCalculation(ast, expression);
try {
plan = new RootPlan(calc->outVariable());
plan = new RootNode(calc->outVariable());
plan->addDependency(calc);
}
catch (...) {
@ -391,8 +391,8 @@ ExecutionPlan* PlanGenerator::fromNodeReturn (Ast const* ast,
/// @brief create an execution plan element from an AST REMOVE node
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* PlanGenerator::fromNodeRemove (Ast const* ast,
ExecutionPlan* previous,
ExecutionNode* PlanGenerator::fromNodeRemove (Ast const* ast,
ExecutionNode* previous,
AstNode const* node) {
TRI_ASSERT(node != nullptr && node->type == NODE_TYPE_REMOVE);
@ -406,8 +406,8 @@ ExecutionPlan* PlanGenerator::fromNodeRemove (Ast const* ast,
/// @brief create an execution plan element from an AST INSERT node
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* PlanGenerator::fromNodeInsert (Ast const* ast,
ExecutionPlan* previous,
ExecutionNode* PlanGenerator::fromNodeInsert (Ast const* ast,
ExecutionNode* previous,
AstNode const* node) {
TRI_ASSERT(node != nullptr && node->type == NODE_TYPE_INSERT);
@ -421,8 +421,8 @@ ExecutionPlan* PlanGenerator::fromNodeInsert (Ast const* ast,
/// @brief create an execution plan element from an AST UPDATE node
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* PlanGenerator::fromNodeUpdate (Ast const* ast,
ExecutionPlan* previous,
ExecutionNode* PlanGenerator::fromNodeUpdate (Ast const* ast,
ExecutionNode* previous,
AstNode const* node) {
TRI_ASSERT(node != nullptr && node->type == NODE_TYPE_UPDATE);
@ -436,8 +436,8 @@ ExecutionPlan* PlanGenerator::fromNodeUpdate (Ast const* ast,
/// @brief create an execution plan element from an AST REPLACE node
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* PlanGenerator::fromNodeReplace (Ast const* ast,
ExecutionPlan* previous,
ExecutionNode* PlanGenerator::fromNodeReplace (Ast const* ast,
ExecutionNode* previous,
AstNode const* node) {
TRI_ASSERT(node != nullptr && node->type == NODE_TYPE_REPLACE);
@ -451,11 +451,11 @@ ExecutionPlan* PlanGenerator::fromNodeReplace (Ast const* ast,
/// @brief create an execution plan from an abstract syntax tree node
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* PlanGenerator::fromNode (Ast const* ast,
ExecutionNode* PlanGenerator::fromNode (Ast const* ast,
AstNode const* node) {
TRI_ASSERT(node != nullptr);
ExecutionPlan* plan = new SingletonPlan();
ExecutionNode* plan = new SingletonNode();
try {
size_t const n = node->numMembers();

View File

@ -37,8 +37,8 @@ namespace triagens {
class Ast;
struct AstNode;
class CalculationPlan;
class ExecutionPlan;
class CalculationNode;
class ExecutionNode;
// -----------------------------------------------------------------------------
// --SECTION-- class PlanGenerator
@ -74,7 +74,7 @@ namespace triagens {
/// @brief create an initial execution plan from an abstract syntax tree
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* fromAst (Ast const*);
ExecutionNode* fromAst (Ast const*);
// -----------------------------------------------------------------------------
// --SECTION-- private methods
@ -86,109 +86,109 @@ namespace triagens {
/// @brief creates a calculation node for an arbitrary expression
////////////////////////////////////////////////////////////////////////////////
CalculationPlan* createTemporaryCalculation (Ast const*,
CalculationNode* createTemporaryCalculation (Ast const*,
AstNode const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief adds "previous" as dependency to "plan", returns "plan"
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* addDependency (ExecutionPlan*,
ExecutionPlan*);
ExecutionNode* addDependency (ExecutionNode*,
ExecutionNode*);
////////////////////////////////////////////////////////////////////////////////
/// @brief create an execution plan element from an AST FOR node
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* fromNodeFor (Ast const*,
ExecutionPlan*,
ExecutionNode* fromNodeFor (Ast const*,
ExecutionNode*,
AstNode const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief create an execution plan element from an AST FILTER node
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* fromNodeFilter (Ast const*,
ExecutionPlan*,
ExecutionNode* fromNodeFilter (Ast const*,
ExecutionNode*,
AstNode const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief create an execution plan element from an AST LET node
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* fromNodeLet (Ast const*,
ExecutionPlan*,
ExecutionNode* fromNodeLet (Ast const*,
ExecutionNode*,
AstNode const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief create an execution plan element from an AST SORT node
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* fromNodeSort (Ast const*,
ExecutionPlan*,
ExecutionNode* fromNodeSort (Ast const*,
ExecutionNode*,
AstNode const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief create an execution plan element from an AST COLLECT node
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* fromNodeCollect (Ast const*,
ExecutionPlan*,
ExecutionNode* fromNodeCollect (Ast const*,
ExecutionNode*,
AstNode const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief create an execution plan element from an AST LIMIT node
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* fromNodeLimit (Ast const*,
ExecutionPlan*,
ExecutionNode* fromNodeLimit (Ast const*,
ExecutionNode*,
AstNode const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief create an execution plan element from an AST RETURN node
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* fromNodeReturn (Ast const*,
ExecutionPlan*,
ExecutionNode* fromNodeReturn (Ast const*,
ExecutionNode*,
AstNode const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief create an execution plan element from an AST REMOVE node
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* fromNodeRemove (Ast const*,
ExecutionPlan*,
ExecutionNode* fromNodeRemove (Ast const*,
ExecutionNode*,
AstNode const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief create an execution plan element from an AST INSERT node
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* fromNodeInsert (Ast const*,
ExecutionPlan*,
ExecutionNode* fromNodeInsert (Ast const*,
ExecutionNode*,
AstNode const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief create an execution plan element from an AST UPDATE node
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* fromNodeUpdate (Ast const*,
ExecutionPlan*,
ExecutionNode* fromNodeUpdate (Ast const*,
ExecutionNode*,
AstNode const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief create an execution plan element from an AST REPLACE node
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* fromNodeReplace (Ast const*,
ExecutionPlan*,
ExecutionNode* fromNodeReplace (Ast const*,
ExecutionNode*,
AstNode const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief create an execution plan from an abstract syntax tree node
////////////////////////////////////////////////////////////////////////////////
ExecutionPlan* fromNode (Ast const*,
ExecutionNode* fromNode (Ast const*,
AstNode const*);
// -----------------------------------------------------------------------------