You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
feat(optimizer): stack-based filters walker
This commit is contained in:
@ -18,6 +18,7 @@
|
||||
#include "constantcolumn.h"
|
||||
#include "execplan/calpontselectexecutionplan.h"
|
||||
#include "execplan/simplecolumn.h"
|
||||
#include "existsfilter.h"
|
||||
#include "logicoperator.h"
|
||||
#include "operator.h"
|
||||
#include "predicateoperator.h"
|
||||
@ -95,6 +96,37 @@ bool Rule::walk(execplan::CalpontSelectExecutionPlan& csep) const
|
||||
rewrite |= walk(unionUnitLocal);
|
||||
}
|
||||
|
||||
if (csep.filters() != nullptr)
|
||||
{
|
||||
bool rewriteLocal = false;
|
||||
std::vector<execplan::ParseTree*> stack;
|
||||
stack.push_back(csep.filters());
|
||||
while (!stack.empty())
|
||||
{
|
||||
execplan::ParseTree* node = stack.back();
|
||||
stack.pop_back();
|
||||
if (node == nullptr)
|
||||
continue;
|
||||
|
||||
auto* existsFilter = dynamic_cast<execplan::ExistsFilter*>(node->data());
|
||||
if (existsFilter)
|
||||
{
|
||||
if (matchRule(*existsFilter->sub()))
|
||||
{
|
||||
applyRule(*existsFilter->sub());
|
||||
rewriteLocal = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (node->right())
|
||||
stack.push_back(node->right());
|
||||
if (node->left())
|
||||
stack.push_back(node->left());
|
||||
}
|
||||
if (rewriteLocal)
|
||||
rewrite |= rewriteLocal;
|
||||
}
|
||||
|
||||
if (matchRule(csep))
|
||||
{
|
||||
applyRule(csep);
|
||||
|
Reference in New Issue
Block a user