1
0
Fork 0

remove filters which are always true

This commit is contained in:
Jan Steemann 2014-08-18 17:03:08 +02:00
parent b923e660e8
commit 36430620fa
1 changed files with 8 additions and 1 deletions

View File

@ -44,6 +44,7 @@ int triagens::aql::removeUnnecessaryFiltersRule (Optimizer* opt,
bool& keep) {
keep = true;
std::unordered_set<ExecutionNode*> toRemove;
std::vector<ExecutionNode*> nodes = plan->findNodesOfType(triagens::aql::ExecutionNode::FILTER);
for (auto n : nodes) {
@ -65,7 +66,7 @@ int triagens::aql::removeUnnecessaryFiltersRule (Optimizer* opt,
// the expression is a constant value
if (root->toBoolean()) {
// TODO: remove filter node and merge with following node
std::cout << "FOUND A CONSTANT FILTER WHICH IS ALWAYS TRUE. TODO: optimize it away!\n";
toRemove.insert(n);
}
else {
// TODO: remove filter node plus all dependencies
@ -75,6 +76,12 @@ int triagens::aql::removeUnnecessaryFiltersRule (Optimizer* opt,
}
}
if (! toRemove.empty()) {
std::cout << "Removing " << toRemove.size() << " unnecessary "
"FilterNodes..." << std::endl;
plan->removeNodes(toRemove);
}
return TRI_ERROR_NO_ERROR;
}