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): better CSEP printer + shallow CSEP copy
This commit is contained in:
@ -201,6 +201,17 @@ std::string endlWithIndent(const size_t ident)
|
|||||||
return output.str();
|
return output.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CalpontSelectExecutionPlan::printSubCSEP(const size_t& ident, ostringstream& output,
|
||||||
|
CalpontSelectExecutionPlan*& plan) const
|
||||||
|
{
|
||||||
|
if (plan)
|
||||||
|
{
|
||||||
|
output << endlWithIndent(ident) << "{" << endlWithIndent(ident + 2) << plan->toString(ident + 2);
|
||||||
|
// remove last two spaces from the stream.
|
||||||
|
output.seekp(-2, std::ios::cur);
|
||||||
|
output << "}" << std::endl << endlWithIndent(ident);
|
||||||
|
}
|
||||||
|
}
|
||||||
string CalpontSelectExecutionPlan::toString(const size_t ident) const
|
string CalpontSelectExecutionPlan::toString(const size_t ident) const
|
||||||
{
|
{
|
||||||
ostringstream output;
|
ostringstream output;
|
||||||
@ -228,29 +239,26 @@ string CalpontSelectExecutionPlan::toString(const size_t ident) const
|
|||||||
// Returned Column
|
// Returned Column
|
||||||
CalpontSelectExecutionPlan::ReturnedColumnList retCols = returnedCols();
|
CalpontSelectExecutionPlan::ReturnedColumnList retCols = returnedCols();
|
||||||
output << ">>Returned Columns" << endlWithIndent(ident);
|
output << ">>Returned Columns" << endlWithIndent(ident);
|
||||||
output << std::string(ident, ' ');
|
|
||||||
|
|
||||||
uint32_t seq = 0;
|
uint32_t seq = 0;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < retCols.size(); i++)
|
for (unsigned int i = 0; i < retCols.size(); i++)
|
||||||
{
|
{
|
||||||
output << *retCols[i] << endlWithIndent(ident);
|
output << *retCols[i] << endlWithIndent(ident+2); // WIP replace with constant
|
||||||
|
|
||||||
if (retCols[i]->colSource() & SELECT_SUB)
|
if (retCols[i]->colSource() & SELECT_SUB)
|
||||||
{
|
{
|
||||||
output << "select sub -- " << endlWithIndent(ident);
|
output << "select sub -- " << endlWithIndent(ident + 2);
|
||||||
CalpontSelectExecutionPlan* plan =
|
CalpontSelectExecutionPlan* plan =
|
||||||
dynamic_cast<CalpontSelectExecutionPlan*>(fSelectSubList[seq++].get());
|
dynamic_cast<CalpontSelectExecutionPlan*>(fSelectSubList[seq++].get());
|
||||||
|
|
||||||
if (plan)
|
printSubCSEP(ident, output, plan);
|
||||||
output << "{" << plan->toString(ident + 2) << "}" << endlWithIndent(ident);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// From Clause
|
// From Clause
|
||||||
CalpontSelectExecutionPlan::TableList tables = tableList();
|
CalpontSelectExecutionPlan::TableList tables = tableList();
|
||||||
output << ">>From Tables" << endlWithIndent(ident);
|
output << ">>From Tables" << endlWithIndent(ident + 2);
|
||||||
output << std::string(ident, ' ');
|
|
||||||
seq = 0;
|
seq = 0;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < tables.size(); i++)
|
for (unsigned int i = 0; i < tables.size(); i++)
|
||||||
@ -258,34 +266,25 @@ string CalpontSelectExecutionPlan::toString(const size_t ident) const
|
|||||||
// derived table
|
// derived table
|
||||||
if (tables[i].schema.length() == 0 && tables[i].table.length() == 0)
|
if (tables[i].schema.length() == 0 && tables[i].table.length() == 0)
|
||||||
{
|
{
|
||||||
output << "derived table - " << tables[i].alias << endlWithIndent(ident);
|
output << "derived table - " << tables[i].alias << endlWithIndent(ident+2);
|
||||||
CalpontSelectExecutionPlan* plan =
|
CalpontSelectExecutionPlan* plan =
|
||||||
dynamic_cast<CalpontSelectExecutionPlan*>(fDerivedTableList[seq++].get());
|
dynamic_cast<CalpontSelectExecutionPlan*>(fDerivedTableList[seq++].get());
|
||||||
|
|
||||||
if (plan)
|
printSubCSEP(ident, output, plan);
|
||||||
{
|
|
||||||
output << "{" << plan->toString(ident + 2) << "}" << endlWithIndent(ident);
|
|
||||||
}
|
|
||||||
output << std::string(ident, ' ');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
output << tables[i] << endl;
|
output << tables[i] << endlWithIndent(ident+2);
|
||||||
output << std::string(ident, ' ');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filters
|
// Filters
|
||||||
output << ">>Filters" << endlWithIndent(ident);
|
output << ">>Filters" << endlWithIndent(ident);
|
||||||
output << std::string(ident, ' ');
|
|
||||||
|
|
||||||
|
|
||||||
if (filters() != nullptr)
|
if (filters() != nullptr)
|
||||||
filters()->walk(ParseTree::print, output);
|
filters()->walk(ParseTree::print, output);
|
||||||
else
|
else
|
||||||
output << "empty filter tree" << endlWithIndent(ident);
|
output << "empty filter tree" << endlWithIndent(ident);
|
||||||
output << std::string(ident, ' ');
|
|
||||||
|
|
||||||
// Group by columns
|
// Group by columns
|
||||||
const CalpontSelectExecutionPlan::GroupByColumnList& gbc = groupByCols();
|
const CalpontSelectExecutionPlan::GroupByColumnList& gbc = groupByCols();
|
||||||
@ -348,8 +347,7 @@ string CalpontSelectExecutionPlan::toString(const size_t ident) const
|
|||||||
{
|
{
|
||||||
CalpontSelectExecutionPlan* plan = dynamic_cast<CalpontSelectExecutionPlan*>(unionVec()[i].get());
|
CalpontSelectExecutionPlan* plan = dynamic_cast<CalpontSelectExecutionPlan*>(unionVec()[i].get());
|
||||||
|
|
||||||
if (plan)
|
printSubCSEP(ident, output, plan);
|
||||||
output << endlWithIndent(ident) << "{" << plan->toString(ident + 2) << "}\n" << endlWithIndent(ident);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return output.str();
|
return output.str();
|
||||||
@ -915,8 +913,8 @@ execplan::SCSEP CalpontSelectExecutionPlan::cloneWORecursiveSelects()
|
|||||||
newPlan->returnedCols(newReturnedCols);
|
newPlan->returnedCols(newReturnedCols);
|
||||||
|
|
||||||
// Deep copy of filters
|
// Deep copy of filters
|
||||||
if (fFilters)
|
// if (fFilters)
|
||||||
newPlan->filters(new ParseTree(*fFilters));
|
// newPlan->filters(new ParseTree(*fFilters));
|
||||||
|
|
||||||
// Deep copy of filter token list
|
// Deep copy of filter token list
|
||||||
newPlan->filterTokenList(fFilterTokenList);
|
newPlan->filterTokenList(fFilterTokenList);
|
||||||
|
@ -798,6 +798,7 @@ class CalpontSelectExecutionPlan : public CalpontExecutionPlan
|
|||||||
* Return a string rep of the CSEP
|
* Return a string rep of the CSEP
|
||||||
* @return a string
|
* @return a string
|
||||||
*/
|
*/
|
||||||
|
void printSubCSEP(const size_t& ident, ostringstream& output, CalpontSelectExecutionPlan*& plan) const;
|
||||||
virtual std::string toString(const size_t ident = 0) const;
|
virtual std::string toString(const size_t ident = 0) const;
|
||||||
|
|
||||||
/** @brief Is this an internal query?
|
/** @brief Is this an internal query?
|
||||||
|
Reference in New Issue
Block a user