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 13:59:10 +02:00
commit c9f104cdd6
1 changed files with 15 additions and 10 deletions

View File

@ -49,7 +49,7 @@ namespace triagens {
class ExecutionBlock { class ExecutionBlock {
public: public:
ExecutionBlock (ExecutionNode const* ep) ExecutionBlock (ExecutionNode const* ep)
: _exePlan(ep), _done(false), _depth(0) { } : _exePlan(ep), _done(false), _depth(0), _varOverview(nullptr) { }
virtual ~ExecutionBlock (); virtual ~ExecutionBlock ();
@ -163,19 +163,22 @@ namespace triagens {
unsigned int totalNrVars; unsigned int totalNrVars;
// This is used to tell all Blocks and share a pointer to ourselves // This is used to tell all Blocks and share a pointer to ourselves
shared_ptr<VarOverview> me; shared_ptr<VarOverview>* me;
VarOverview () VarOverview ()
: depth(0), totalNrVars(0) { : depth(0), totalNrVars(0), me(nullptr) {
nrVarsHere.push_back(0); nrVarsHere.push_back(0);
nrVars.push_back(0); nrVars.push_back(0);
me.reset(this);
}; };
void setSharedPtr (shared_ptr<VarOverview>* shared) {
me = shared;
}
// Copy constructor used for a subquery: // Copy constructor used for a subquery:
VarOverview (VarOverview const& v) VarOverview (VarOverview const& v)
: varInfo(v.varInfo), nrVarsHere(v.nrVars), nrVars(v.nrVars), : varInfo(v.varInfo), nrVarsHere(v.nrVars), nrVars(v.nrVars),
depth(v.depth+1), totalNrVars(v.totalNrVars) { depth(v.depth+1), totalNrVars(v.totalNrVars), me(nullptr) {
nrVarsHere.push_back(0); nrVarsHere.push_back(0);
nrVars.push_back(0); nrVars.push_back(0);
} }
@ -184,8 +187,9 @@ namespace triagens {
virtual bool enterSubquery (ExecutionBlock* super, virtual bool enterSubquery (ExecutionBlock* super,
ExecutionBlock* sub) { ExecutionBlock* sub) {
auto vv = new VarOverview(*this); shared_ptr<VarOverview> vv(new VarOverview(*this));
sub->walk(vv); vv->setSharedPtr(&vv);
sub->walk(vv.get());
vv->reset(); vv->reset();
return false; // do not walk into subquery return false; // do not walk into subquery
} }
@ -244,14 +248,15 @@ namespace triagens {
break; break;
} }
eb->_depth = depth; eb->_depth = depth;
eb->_varOverview = me; eb->_varOverview = *me;
} }
}; };
void staticAnalysis () { void staticAnalysis () {
auto v = new VarOverview(); shared_ptr<VarOverview> v(new VarOverview());
walk(v); v->setSharedPtr(&v);
walk(v.get());
v->reset(); v->reset();
} }