mirror of https://gitee.com/bigwinds/arangodb
added assertions
This commit is contained in:
parent
467f260400
commit
84fbc98081
|
@ -89,7 +89,10 @@ class ExecutionBlock {
|
|||
void throwIfKilled();
|
||||
|
||||
/// @brief add a dependency
|
||||
void addDependency(ExecutionBlock* ep) { _dependencies.emplace_back(ep); }
|
||||
void addDependency(ExecutionBlock* ep) {
|
||||
TRI_ASSERT(ep != nullptr);
|
||||
_dependencies.emplace_back(ep);
|
||||
}
|
||||
|
||||
/// @brief get all dependencies
|
||||
std::vector<ExecutionBlock*> getDependencies() const { return _dependencies; }
|
||||
|
|
|
@ -239,6 +239,7 @@ struct Instanciator final : public WalkerWorker<ExecutionNode> {
|
|||
for (auto const& it : en->getDependencies()) {
|
||||
auto it2 = cache.find(it);
|
||||
TRI_ASSERT(it2 != cache.end());
|
||||
TRI_ASSERT(it2->second != nullptr);
|
||||
block->addDependency(it2->second);
|
||||
}
|
||||
|
||||
|
@ -670,6 +671,7 @@ struct CoordinatorInstanciator : public WalkerWorker<ExecutionNode> {
|
|||
|
||||
if (d != cache.end()) {
|
||||
// add regular dependencies
|
||||
TRI_ASSERT((*d).second != nullptr);
|
||||
eb->addDependency((*d).second);
|
||||
}
|
||||
}
|
||||
|
@ -713,6 +715,7 @@ struct CoordinatorInstanciator : public WalkerWorker<ExecutionNode> {
|
|||
throw;
|
||||
}
|
||||
|
||||
TRI_ASSERT(r != nullptr);
|
||||
eb->addDependency(r);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -437,6 +437,7 @@ void ExecutionNode::cloneDependencies(ExecutionPlan* plan,
|
|||
auto c = (*it)->clone(plan, true, withProperties);
|
||||
try {
|
||||
c->_parents.emplace_back(theClone);
|
||||
TRI_ASSERT(c != nullptr);
|
||||
theClone->_dependencies.emplace_back(c);
|
||||
} catch (...) {
|
||||
delete c;
|
||||
|
|
|
@ -126,6 +126,7 @@ class ExecutionNode {
|
|||
|
||||
/// @brief add a dependency
|
||||
void addDependency(ExecutionNode* ep) {
|
||||
TRI_ASSERT(ep != nullptr);
|
||||
_dependencies.emplace_back(ep);
|
||||
ep->_parents.emplace_back(this);
|
||||
}
|
||||
|
|
|
@ -403,6 +403,7 @@ ExecutionNode* ExecutionPlan::createCalculation(
|
|||
// DISTINCT expression is implemented by creating an anonymous COLLECT node
|
||||
auto collectNode = createAnonymousCollect(en);
|
||||
|
||||
TRI_ASSERT(en != nullptr);
|
||||
collectNode->addDependency(en);
|
||||
|
||||
return collectNode;
|
||||
|
@ -974,6 +975,7 @@ ExecutionNode* ExecutionPlan::fromNodeSort(ExecutionNode* previous,
|
|||
|
||||
// properly link the temporary calculations in the plan
|
||||
for (auto it = temp.begin(); it != temp.end(); ++it) {
|
||||
TRI_ASSERT(previous != nullptr);
|
||||
(*it)->addDependency(previous);
|
||||
previous = (*it);
|
||||
}
|
||||
|
@ -1804,6 +1806,7 @@ void ExecutionPlan::unlinkNode(ExecutionNode* node, bool allowUnlinkingRoot) {
|
|||
p->removeDependency(node);
|
||||
|
||||
for (auto* x : dep) {
|
||||
TRI_ASSERT(x != nullptr);
|
||||
p->addDependency(x);
|
||||
}
|
||||
}
|
||||
|
@ -1828,6 +1831,7 @@ void ExecutionPlan::replaceNode(ExecutionNode* oldNode,
|
|||
std::vector<ExecutionNode*> deps = oldNode->getDependencies();
|
||||
|
||||
for (auto* x : deps) {
|
||||
TRI_ASSERT(x != nullptr);
|
||||
newNode->addDependency(x);
|
||||
oldNode->removeDependency(x);
|
||||
}
|
||||
|
@ -1856,6 +1860,7 @@ void ExecutionPlan::insertDependency(ExecutionNode* oldNode,
|
|||
TRI_ASSERT(oldNode->getDependencies().size() == 1);
|
||||
|
||||
auto oldDeps = oldNode->getDependencies(); // Intentional copy
|
||||
TRI_ASSERT(!oldDeps.empty());
|
||||
|
||||
if (!oldNode->replaceDependency(oldDeps[0], newNode)) {
|
||||
THROW_ARANGO_EXCEPTION_MESSAGE(
|
||||
|
@ -1863,6 +1868,7 @@ void ExecutionPlan::insertDependency(ExecutionNode* oldNode,
|
|||
}
|
||||
|
||||
newNode->removeDependencies();
|
||||
TRI_ASSERT(oldDeps[0] != nullptr);
|
||||
newNode->addDependency(oldDeps[0]);
|
||||
_varUsageComputed = false;
|
||||
}
|
||||
|
|
|
@ -194,6 +194,7 @@ void arangodb::aql::sortInValuesRule(Optimizer* opt, ExecutionPlan* plan,
|
|||
plan->registerNode(calculationNode);
|
||||
|
||||
// make the new node a parent of the original calculation node
|
||||
TRI_ASSERT(setter != nullptr);
|
||||
calculationNode->addDependency(setter);
|
||||
auto oldParent = setter->getFirstParent();
|
||||
TRI_ASSERT(oldParent != nullptr);
|
||||
|
@ -1079,6 +1080,7 @@ void arangodb::aql::specializeCollectRule(Optimizer* opt, ExecutionPlan* plan,
|
|||
|
||||
TRI_ASSERT(collectNode->hasDependency());
|
||||
auto dep = collectNode->getFirstDependency();
|
||||
TRI_ASSERT(dep != nullptr);
|
||||
sortNode->addDependency(dep);
|
||||
collectNode->replaceDependency(dep, sortNode);
|
||||
|
||||
|
@ -2340,12 +2342,14 @@ void arangodb::aql::scatterInClusterRule(Optimizer* opt, ExecutionPlan* plan,
|
|||
ExecutionNode* scatterNode =
|
||||
new ScatterNode(plan, plan->nextId(), vocbase, collection);
|
||||
plan->registerNode(scatterNode);
|
||||
TRI_ASSERT(!deps.empty());
|
||||
scatterNode->addDependency(deps[0]);
|
||||
|
||||
// insert a remote node
|
||||
ExecutionNode* remoteNode =
|
||||
new RemoteNode(plan, plan->nextId(), vocbase, collection, "", "", "");
|
||||
plan->registerNode(remoteNode);
|
||||
TRI_ASSERT(scatterNode);
|
||||
remoteNode->addDependency(scatterNode);
|
||||
|
||||
// re-link with the remote node
|
||||
|
@ -2355,12 +2359,14 @@ void arangodb::aql::scatterInClusterRule(Optimizer* opt, ExecutionPlan* plan,
|
|||
remoteNode =
|
||||
new RemoteNode(plan, plan->nextId(), vocbase, collection, "", "", "");
|
||||
plan->registerNode(remoteNode);
|
||||
TRI_ASSERT(node);
|
||||
remoteNode->addDependency(node);
|
||||
|
||||
// insert a gather node
|
||||
ExecutionNode* gatherNode =
|
||||
new GatherNode(plan, plan->nextId(), vocbase, collection);
|
||||
plan->registerNode(gatherNode);
|
||||
TRI_ASSERT(remoteNode);
|
||||
gatherNode->addDependency(remoteNode);
|
||||
|
||||
// and now link the gather node with the rest of the plan
|
||||
|
@ -2565,6 +2571,7 @@ void arangodb::aql::distributeInClusterRule(Optimizer* opt, ExecutionPlan* plan,
|
|||
|
||||
if (originalParent != nullptr) {
|
||||
// we did not replace the root node
|
||||
TRI_ASSERT(gatherNode);
|
||||
originalParent->addDependency(gatherNode);
|
||||
} else {
|
||||
// we replaced the root node, set a new root node
|
||||
|
@ -3801,6 +3808,7 @@ void arangodb::aql::inlineSubqueriesRule(Optimizer* opt,
|
|||
if (it != returnNode) {
|
||||
// we skip over the subquery's return node. we don't need it anymore
|
||||
insert->removeDependencies();
|
||||
TRI_ASSERT(it != nullptr);
|
||||
insert->addDependency(it);
|
||||
insert = it;
|
||||
|
||||
|
|
Loading…
Reference in New Issue