You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-11-02 06:13:16 +03:00
chore(format): apply clang-format
This commit is contained in:
@@ -978,8 +978,8 @@ extern "C"
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l > TraceSize)
|
if (l > TraceSize * 100)
|
||||||
l = TraceSize;
|
l = TraceSize * 100;
|
||||||
|
|
||||||
*length = l;
|
*length = l;
|
||||||
return out->c_str();
|
return out->c_str();
|
||||||
|
|||||||
@@ -129,7 +129,6 @@ static void store_query_plan(execplan::SCSEP& csep, PlanType planType)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void store_applied_rules(const std::string rboRules)
|
static void store_applied_rules(const std::string rboRules)
|
||||||
{
|
{
|
||||||
cal_connection_info* ci = ensure_conn_info();
|
cal_connection_info* ci = ensure_conn_info();
|
||||||
|
|||||||
@@ -79,8 +79,8 @@ bool someForeignTablesHasStatisticsAndMbIndex(execplan::CalpontSelectExecutionPl
|
|||||||
[&ctx](const auto& table)
|
[&ctx](const auto& table)
|
||||||
{
|
{
|
||||||
cal_impl_if::SchemaAndTableName schemaAndTableName = {table.schema, table.table};
|
cal_impl_if::SchemaAndTableName schemaAndTableName = {table.schema, table.table};
|
||||||
return (!table.isColumnstore() &&
|
return (!table.isColumnstore() && ctx.getGwi().tableStatisticsMap.find(schemaAndTableName) !=
|
||||||
ctx.getGwi().tableStatisticsMap.find(schemaAndTableName) != ctx.getGwi().tableStatisticsMap.end());
|
ctx.getGwi().tableStatisticsMap.end());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,9 +29,10 @@
|
|||||||
namespace optimizer
|
namespace optimizer
|
||||||
{
|
{
|
||||||
|
|
||||||
using DerivedToFiltersMap = std::map<std::string, execplan::ParseTree*>;
|
using DerivedToFiltersMap = std::map<std::string, execplan::ParseTree*>;
|
||||||
|
|
||||||
bool predicatePushdownFilter(execplan::CalpontSelectExecutionPlan& csep, optimizer::RBOptimizerContext& /*ctx*/)
|
bool predicatePushdownFilter(execplan::CalpontSelectExecutionPlan& csep,
|
||||||
|
optimizer::RBOptimizerContext& /*ctx*/)
|
||||||
{
|
{
|
||||||
// The original rule match contains questionable decision to filter out
|
// The original rule match contains questionable decision to filter out
|
||||||
// queries that contains any UNION UNIT with only derived tables.
|
// queries that contains any UNION UNIT with only derived tables.
|
||||||
@@ -40,7 +41,6 @@ bool predicatePushdownFilter(execplan::CalpontSelectExecutionPlan& csep, optimiz
|
|||||||
return !csep.tableList().empty();
|
return !csep.tableList().empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void setDerivedTable(execplan::ParseTree* n)
|
void setDerivedTable(execplan::ParseTree* n)
|
||||||
{
|
{
|
||||||
execplan::ParseTree* lhs = n->left();
|
execplan::ParseTree* lhs = n->left();
|
||||||
@@ -75,8 +75,9 @@ void setDerivedTable(execplan::ParseTree* n)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
execplan::ParseTree* setDerivedFilter(cal_impl_if::gp_walk_info* gwip, execplan::ParseTree*& n, DerivedToFiltersMap& filterMap,
|
execplan::ParseTree* setDerivedFilter(cal_impl_if::gp_walk_info* gwip, execplan::ParseTree*& n,
|
||||||
const execplan::CalpontSelectExecutionPlan::SelectList& derivedTbList)
|
DerivedToFiltersMap& filterMap,
|
||||||
|
const execplan::CalpontSelectExecutionPlan::SelectList& derivedTbList)
|
||||||
{
|
{
|
||||||
if (!(n->derivedTable().empty()))
|
if (!(n->derivedTable().empty()))
|
||||||
{
|
{
|
||||||
@@ -86,7 +87,8 @@ execplan::ParseTree* setDerivedFilter(cal_impl_if::gp_walk_info* gwip, execplan:
|
|||||||
|
|
||||||
for (uint i = 0; i < derivedTbList.size(); i++)
|
for (uint i = 0; i < derivedTbList.size(); i++)
|
||||||
{
|
{
|
||||||
execplan::CalpontSelectExecutionPlan* plan = dynamic_cast<execplan::CalpontSelectExecutionPlan*>(derivedTbList[i].get());
|
execplan::CalpontSelectExecutionPlan* plan =
|
||||||
|
dynamic_cast<execplan::CalpontSelectExecutionPlan*>(derivedTbList[i].get());
|
||||||
|
|
||||||
if (plan->derivedTbAlias() == n->derivedTable())
|
if (plan->derivedTbAlias() == n->derivedTable())
|
||||||
{
|
{
|
||||||
@@ -159,82 +161,83 @@ bool applyPredicatePushdown(execplan::CalpontSelectExecutionPlan& csep, RBOptimi
|
|||||||
* that OR involving derived table are emptied and null candidate of each
|
* that OR involving derived table are emptied and null candidate of each
|
||||||
* stacked filter needs to be reset (not null)
|
* stacked filter needs to be reset (not null)
|
||||||
*/
|
*/
|
||||||
execplan::ParseTree* pt = csep.filters();
|
execplan::ParseTree* pt = csep.filters();
|
||||||
DerivedToFiltersMap derivedTbFilterMap;
|
DerivedToFiltersMap derivedTbFilterMap;
|
||||||
auto& derivedTbList = csep.derivedTableList();
|
auto& derivedTbList = csep.derivedTableList();
|
||||||
bool hasBeenApplied = false;
|
bool hasBeenApplied = false;
|
||||||
|
|
||||||
if (pt)
|
if (pt)
|
||||||
{
|
{
|
||||||
pt->walk(setDerivedTable);
|
pt->walk(setDerivedTable);
|
||||||
setDerivedFilter(&ctx.getGwi(), pt, derivedTbFilterMap, derivedTbList);
|
setDerivedFilter(&ctx.getGwi(), pt, derivedTbFilterMap, derivedTbList);
|
||||||
csep.filters(pt);
|
csep.filters(pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// AND the filters of individual stack to the derived table filter tree
|
// AND the filters of individual stack to the derived table filter tree
|
||||||
// @todo union filters.
|
// @todo union filters.
|
||||||
// @todo outer join complication
|
// @todo outer join complication
|
||||||
for (uint i = 0; i < derivedTbList.size(); i++)
|
for (uint i = 0; i < derivedTbList.size(); i++)
|
||||||
{
|
{
|
||||||
execplan::CalpontSelectExecutionPlan* plan = dynamic_cast<execplan::CalpontSelectExecutionPlan*>(derivedTbList[i].get());
|
execplan::CalpontSelectExecutionPlan* plan =
|
||||||
execplan::CalpontSelectExecutionPlan::ReturnedColumnList derivedColList = plan->returnedCols();
|
dynamic_cast<execplan::CalpontSelectExecutionPlan*>(derivedTbList[i].get());
|
||||||
auto mapIt = derivedTbFilterMap.find(plan->derivedTbAlias());
|
execplan::CalpontSelectExecutionPlan::ReturnedColumnList derivedColList = plan->returnedCols();
|
||||||
|
auto mapIt = derivedTbFilterMap.find(plan->derivedTbAlias());
|
||||||
if (mapIt != derivedTbFilterMap.end())
|
|
||||||
{
|
if (mapIt != derivedTbFilterMap.end())
|
||||||
// replace all derived column of this filter with real column from
|
{
|
||||||
// derived table projection list.
|
// replace all derived column of this filter with real column from
|
||||||
execplan::ParseTree* mainFilter = new execplan::ParseTree();
|
// derived table projection list.
|
||||||
mainFilter->copyTree(*(mapIt->second));
|
execplan::ParseTree* mainFilter = new execplan::ParseTree();
|
||||||
replaceRefCol(mainFilter, derivedColList);
|
mainFilter->copyTree(*(mapIt->second));
|
||||||
execplan::ParseTree* derivedFilter = plan->filters();
|
replaceRefCol(mainFilter, derivedColList);
|
||||||
|
execplan::ParseTree* derivedFilter = plan->filters();
|
||||||
if (derivedFilter)
|
|
||||||
{
|
if (derivedFilter)
|
||||||
execplan::LogicOperator* op = new execplan::LogicOperator("and");
|
{
|
||||||
execplan::ParseTree* filter = new execplan::ParseTree(op);
|
execplan::LogicOperator* op = new execplan::LogicOperator("and");
|
||||||
filter->left(derivedFilter);
|
execplan::ParseTree* filter = new execplan::ParseTree(op);
|
||||||
filter->right(mainFilter);
|
filter->left(derivedFilter);
|
||||||
plan->filters(filter);
|
filter->right(mainFilter);
|
||||||
}
|
plan->filters(filter);
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
plan->filters(mainFilter);
|
{
|
||||||
}
|
plan->filters(mainFilter);
|
||||||
|
}
|
||||||
// union filter handling
|
|
||||||
for (uint j = 0; j < plan->unionVec().size(); j++)
|
// union filter handling
|
||||||
{
|
for (uint j = 0; j < plan->unionVec().size(); j++)
|
||||||
execplan::CalpontSelectExecutionPlan* unionPlan =
|
{
|
||||||
reinterpret_cast<execplan::CalpontSelectExecutionPlan*>(plan->unionVec()[j].get());
|
execplan::CalpontSelectExecutionPlan* unionPlan =
|
||||||
execplan::CalpontSelectExecutionPlan::ReturnedColumnList unionColList = unionPlan->returnedCols();
|
reinterpret_cast<execplan::CalpontSelectExecutionPlan*>(plan->unionVec()[j].get());
|
||||||
execplan::ParseTree* mainFilterForUnion = new execplan::ParseTree();
|
execplan::CalpontSelectExecutionPlan::ReturnedColumnList unionColList = unionPlan->returnedCols();
|
||||||
mainFilterForUnion->copyTree(*(mapIt->second));
|
execplan::ParseTree* mainFilterForUnion = new execplan::ParseTree();
|
||||||
replaceRefCol(mainFilterForUnion, unionColList);
|
mainFilterForUnion->copyTree(*(mapIt->second));
|
||||||
execplan::ParseTree* unionFilter = unionPlan->filters();
|
replaceRefCol(mainFilterForUnion, unionColList);
|
||||||
|
execplan::ParseTree* unionFilter = unionPlan->filters();
|
||||||
if (unionFilter)
|
|
||||||
{
|
if (unionFilter)
|
||||||
execplan::LogicOperator* op = new execplan::LogicOperator("and");
|
{
|
||||||
execplan::ParseTree* filter = new execplan::ParseTree(op);
|
execplan::LogicOperator* op = new execplan::LogicOperator("and");
|
||||||
filter->left(unionFilter);
|
execplan::ParseTree* filter = new execplan::ParseTree(op);
|
||||||
filter->right(mainFilterForUnion);
|
filter->left(unionFilter);
|
||||||
unionPlan->filters(filter);
|
filter->right(mainFilterForUnion);
|
||||||
}
|
unionPlan->filters(filter);
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
unionPlan->filters(mainFilterForUnion);
|
{
|
||||||
}
|
unionPlan->filters(mainFilterForUnion);
|
||||||
}
|
}
|
||||||
hasBeenApplied = true;
|
}
|
||||||
}
|
hasBeenApplied = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// clean derivedTbFilterMap because all the filters are copied
|
|
||||||
for (auto mapIt = derivedTbFilterMap.begin(); mapIt != derivedTbFilterMap.end(); ++mapIt)
|
// clean derivedTbFilterMap because all the filters are copied
|
||||||
{
|
for (auto mapIt = derivedTbFilterMap.begin(); mapIt != derivedTbFilterMap.end(); ++mapIt)
|
||||||
|
{
|
||||||
delete (*mapIt).second;
|
delete (*mapIt).second;
|
||||||
}
|
}
|
||||||
|
|
||||||
return hasBeenApplied;
|
return hasBeenApplied;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,29 +35,61 @@ class RBOptimizerContext
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RBOptimizerContext() = delete;
|
RBOptimizerContext() = delete;
|
||||||
RBOptimizerContext(cal_impl_if::gp_walk_info& walk_info, THD& thd, bool logRules, uint cesOptimizationParallelFactor = 50)
|
RBOptimizerContext(cal_impl_if::gp_walk_info& walk_info, THD& thd, bool logRules,
|
||||||
: gwi_(walk_info), thd_(thd), logRules_(logRules), cesOptimizationParallelFactor_(cesOptimizationParallelFactor)
|
uint cesOptimizationParallelFactor = 50)
|
||||||
|
: gwi_(walk_info)
|
||||||
|
, thd_(thd)
|
||||||
|
, logRules_(logRules)
|
||||||
|
, cesOptimizationParallelFactor_(cesOptimizationParallelFactor)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
cal_impl_if::gp_walk_info& getGwi() { return gwi_; }
|
cal_impl_if::gp_walk_info& getGwi()
|
||||||
THD& getThd() { return thd_; }
|
{
|
||||||
uint64_t getUniqueId() const { return uniqueId_; }
|
return gwi_;
|
||||||
void incrementUniqueId() { ++uniqueId_; }
|
}
|
||||||
bool logRulesEnabled() const { return logRules_; }
|
THD& getThd()
|
||||||
uint getCesOptimizationParallelFactor() const { return cesOptimizationParallelFactor_; }
|
{
|
||||||
|
return thd_;
|
||||||
|
}
|
||||||
|
uint64_t getUniqueId() const
|
||||||
|
{
|
||||||
|
return uniqueId_;
|
||||||
|
}
|
||||||
|
void incrementUniqueId()
|
||||||
|
{
|
||||||
|
++uniqueId_;
|
||||||
|
}
|
||||||
|
bool logRulesEnabled() const
|
||||||
|
{
|
||||||
|
return logRules_;
|
||||||
|
}
|
||||||
|
uint getCesOptimizationParallelFactor() const
|
||||||
|
{
|
||||||
|
return cesOptimizationParallelFactor_;
|
||||||
|
}
|
||||||
|
|
||||||
// Applied rules API
|
// Applied rules API
|
||||||
void addAppliedRule(const std::string& name) { appliedRules_.push_back(name); }
|
void addAppliedRule(const std::string& name)
|
||||||
const std::vector<std::string>& getAppliedRules() const { return appliedRules_; }
|
{
|
||||||
bool hasAppliedRules() const { return !appliedRules_.empty(); }
|
appliedRules_.push_back(name);
|
||||||
|
}
|
||||||
|
const std::vector<std::string>& getAppliedRules() const
|
||||||
|
{
|
||||||
|
return appliedRules_;
|
||||||
|
}
|
||||||
|
bool hasAppliedRules() const
|
||||||
|
{
|
||||||
|
return !appliedRules_.empty();
|
||||||
|
}
|
||||||
std::string serializeAppliedRules() const
|
std::string serializeAppliedRules() const
|
||||||
{
|
{
|
||||||
std::string out;
|
std::string out;
|
||||||
for (size_t i = 0; i < appliedRules_.size(); ++i)
|
for (size_t i = 0; i < appliedRules_.size(); ++i)
|
||||||
{
|
{
|
||||||
if (i) out += ",";
|
if (i)
|
||||||
|
out += ",";
|
||||||
out += appliedRules_[i];
|
out += appliedRules_[i];
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
|
|||||||
Reference in New Issue
Block a user