1
0
Fork 0

fixing distribute in cluster optimizer rule.

This commit is contained in:
James 2014-10-21 11:04:38 +01:00
parent 12ac3b8bdd
commit dc357b96bf
1 changed files with 17 additions and 9 deletions

View File

@ -1638,15 +1638,12 @@ int triagens::aql::scatterInCluster (Optimizer* opt,
auto parents = node->getParents(); auto parents = node->getParents();
auto deps = node->getDependencies(); auto deps = node->getDependencies();
TRI_ASSERT(deps.size() == 1); TRI_ASSERT(deps.size() == 1);
// unlink the node
bool const isRootNode = plan->isRoot(node); bool const isRootNode = plan->isRoot(node);
if (isRootNode) { // don't do this if we are already distributing!
if (deps[0]->getType() == ExecutionNode::REMOTE && if (deps[0]->getType() == ExecutionNode::REMOTE &&
deps[0]->getDependencies()[0]->getType() == ExecutionNode::DISTRIBUTE){ deps[0]->getDependencies()[0]->getType() == ExecutionNode::DISTRIBUTE){
continue; continue;
} }
}
plan->unlinkNode(node, isRootNode); plan->unlinkNode(node, isRootNode);
auto const nodeType = node->getType(); auto const nodeType = node->getType();
@ -1782,8 +1779,19 @@ int triagens::aql::distributeInCluster (Optimizer* opt,
// re-link with the remote node // re-link with the remote node
node->addDependency(remoteNode); node->addDependency(remoteNode);
// make node the root again // insert another remote node
plan->root(node); remoteNode = new RemoteNode(plan, plan->nextId(), vocbase, collection, "", "", "");
plan->registerNode(remoteNode);
remoteNode->addDependency(node);
// insert a gather node
ExecutionNode* gatherNode = new GatherNode(plan, plan->nextId(), vocbase,
collection);
plan->registerNode(gatherNode);
gatherNode->addDependency(remoteNode);
// we replaced the root node, set a new root node
plan->root(gatherNode);
wasModified = true; wasModified = true;
} }