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
Reformat all code to coding standard
This commit is contained in:
@ -49,91 +49,103 @@ extern "C" void init_demangler(int, int, int);
|
||||
|
||||
using namespace execplan;
|
||||
|
||||
class ExecPlanTest : public CppUnit::TestFixture {
|
||||
class ExecPlanTest : public CppUnit::TestFixture
|
||||
{
|
||||
|
||||
CPPUNIT_TEST_SUITE( ExecPlanTest );
|
||||
CPPUNIT_TEST_SUITE( ExecPlanTest );
|
||||
|
||||
CPPUNIT_TEST( selectExecutionPlan_13 );
|
||||
CPPUNIT_TEST( selectExecutionPlan_13 );
|
||||
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
public:
|
||||
|
||||
static void walkfnString(const ParseTree* n)
|
||||
{
|
||||
char *r;
|
||||
static bool is_init = false;
|
||||
const char* mname = typeid(*(n->data())).name();
|
||||
if (!is_init)
|
||||
{
|
||||
::init_demangler(0, 0, 0);
|
||||
is_init = true;
|
||||
}
|
||||
r = ::cplus_demangle_with_style(mname, 7, 27);
|
||||
if (r != 0)
|
||||
{
|
||||
//cout << "mangle: " << mname << " demangle: " << r << endl;
|
||||
::free(r);
|
||||
}
|
||||
if (typeid(*(n->data())) == typeid(SimpleFilter))
|
||||
{
|
||||
cout << "SimpleFilter: " << endl;
|
||||
const SimpleFilter* sf = dynamic_cast<SimpleFilter*>(n->data());
|
||||
const ReturnedColumn* lhs = sf->lhs();
|
||||
const ReturnedColumn* rhs = sf->rhs();
|
||||
const Operator* op = sf->op();
|
||||
cout << '\t' << lhs->data() << ' ' << op->data() << ' ' << rhs->data();
|
||||
cout << endl << "\t\t";
|
||||
if (typeid(*lhs) == typeid(SimpleColumn))
|
||||
{
|
||||
cout << "SimpleColumn: " << lhs->data() << " / ";
|
||||
}
|
||||
else if (typeid(*lhs) == typeid(ConstantColumn))
|
||||
{
|
||||
cout << "ConstantColumn: " << lhs->data() << " / ";
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "UNK: " << lhs->data() << " / ";
|
||||
}
|
||||
cout << "Operator: " << op->data() << " / ";
|
||||
if (typeid(*rhs) == typeid(SimpleColumn))
|
||||
{
|
||||
cout << "SimpleColumn: " << rhs->data();
|
||||
}
|
||||
else if (typeid(*rhs) == typeid(ConstantColumn))
|
||||
{
|
||||
cout << "ConstantColumn: " << rhs->data();
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "UNK: " << rhs->data();
|
||||
}
|
||||
}
|
||||
else if (typeid(*(n->data())) == typeid(Operator))
|
||||
{
|
||||
cout << "Operator: ";
|
||||
const Operator* op = dynamic_cast<Operator*>(n->data());
|
||||
cout << '\t' << op->data();
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << mname << " -x-: ";
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
static void walkfnString(const ParseTree* n)
|
||||
{
|
||||
char* r;
|
||||
static bool is_init = false;
|
||||
const char* mname = typeid(*(n->data())).name();
|
||||
|
||||
void setUp() {
|
||||
}
|
||||
|
||||
void tearDown() {
|
||||
}
|
||||
|
||||
void selectExecutionPlan_13() {
|
||||
if (!is_init)
|
||||
{
|
||||
::init_demangler(0, 0, 0);
|
||||
is_init = true;
|
||||
}
|
||||
|
||||
cout <<
|
||||
"SQL: \
|
||||
r = ::cplus_demangle_with_style(mname, 7, 27);
|
||||
|
||||
if (r != 0)
|
||||
{
|
||||
//cout << "mangle: " << mname << " demangle: " << r << endl;
|
||||
::free(r);
|
||||
}
|
||||
|
||||
if (typeid(*(n->data())) == typeid(SimpleFilter))
|
||||
{
|
||||
cout << "SimpleFilter: " << endl;
|
||||
const SimpleFilter* sf = dynamic_cast<SimpleFilter*>(n->data());
|
||||
const ReturnedColumn* lhs = sf->lhs();
|
||||
const ReturnedColumn* rhs = sf->rhs();
|
||||
const Operator* op = sf->op();
|
||||
cout << '\t' << lhs->data() << ' ' << op->data() << ' ' << rhs->data();
|
||||
cout << endl << "\t\t";
|
||||
|
||||
if (typeid(*lhs) == typeid(SimpleColumn))
|
||||
{
|
||||
cout << "SimpleColumn: " << lhs->data() << " / ";
|
||||
}
|
||||
else if (typeid(*lhs) == typeid(ConstantColumn))
|
||||
{
|
||||
cout << "ConstantColumn: " << lhs->data() << " / ";
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "UNK: " << lhs->data() << " / ";
|
||||
}
|
||||
|
||||
cout << "Operator: " << op->data() << " / ";
|
||||
|
||||
if (typeid(*rhs) == typeid(SimpleColumn))
|
||||
{
|
||||
cout << "SimpleColumn: " << rhs->data();
|
||||
}
|
||||
else if (typeid(*rhs) == typeid(ConstantColumn))
|
||||
{
|
||||
cout << "ConstantColumn: " << rhs->data();
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "UNK: " << rhs->data();
|
||||
}
|
||||
}
|
||||
else if (typeid(*(n->data())) == typeid(Operator))
|
||||
{
|
||||
cout << "Operator: ";
|
||||
const Operator* op = dynamic_cast<Operator*>(n->data());
|
||||
cout << '\t' << op->data();
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << mname << " -x-: ";
|
||||
}
|
||||
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
void selectExecutionPlan_13()
|
||||
{
|
||||
|
||||
cout <<
|
||||
"SQL: \
|
||||
select \
|
||||
c_count, \
|
||||
count(*) as custdist \
|
||||
@ -154,123 +166,123 @@ group by \
|
||||
order by \
|
||||
custdist desc,\
|
||||
c_count desc;"
|
||||
<< endl;
|
||||
<< endl;
|
||||
|
||||
//x ------------The create view statement is being re-written as an inline view ----- x/
|
||||
//x ------------The create view statement is being re-written as an inline view ----- x/
|
||||
|
||||
//This is the main query body for query 16
|
||||
CalpontSelectExecutionPlan* csep = new CalpontSelectExecutionPlan();
|
||||
|
||||
//This is the main query body for query 16
|
||||
CalpontSelectExecutionPlan *csep = new CalpontSelectExecutionPlan();
|
||||
|
||||
// Create the Projection (returned columns)
|
||||
CalpontSelectExecutionPlan::ReturnedColumnList colList;
|
||||
SimpleColumn *c1 = new SimpleColumn("calpont.FROMTABLE.c_count");
|
||||
SimpleColumn* c1 = new SimpleColumn("calpont.FROMTABLE.c_count");
|
||||
c1->tableAlias("c_orders");
|
||||
colList.push_back(c1);
|
||||
ArithmeticColumn *c2 = new ArithmeticColumn("count(ALL)");
|
||||
ArithmeticColumn* c2 = new ArithmeticColumn("count(ALL)");
|
||||
c2->alias("custdist");
|
||||
colList.push_back(c2);
|
||||
|
||||
|
||||
csep->returnedCols(colList); // set Projection columns
|
||||
|
||||
// Filter columns (Not needed for outer query)
|
||||
//CalpontSelectExecutionPlan::FilterTokenList csep_filterlist;
|
||||
// Filter columns (Not needed for outer query)
|
||||
//CalpontSelectExecutionPlan::FilterTokenList csep_filterlist;
|
||||
|
||||
/* --------------- sub select begins here ---------------- */
|
||||
//Sub select filter
|
||||
CalpontSelectExecutionPlan *subcsep =
|
||||
/* --------------- sub select begins here ---------------- */
|
||||
//Sub select filter
|
||||
CalpontSelectExecutionPlan* subcsep =
|
||||
new CalpontSelectExecutionPlan(CalpontSelectExecutionPlan::FROM);
|
||||
|
||||
//subselect return column(s)
|
||||
CalpontSelectExecutionPlan::ReturnedColumnList subColList;
|
||||
CalpontSelectExecutionPlan::ReturnedColumnList subColList;
|
||||
|
||||
SimpleColumn *sc1 = new SimpleColumn ("tpch.customer.c_custkey");
|
||||
subColList.push_back(sc1);
|
||||
ArithmeticColumn *sc2 = new ArithmeticColumn ("count(tpch.orders.o_orderkey)");
|
||||
sc2->alias("c_count");
|
||||
subColList.push_back(sc2);
|
||||
// Append returned columns to subselect
|
||||
subcsep->returnedCols(subColList);
|
||||
SimpleColumn* sc1 = new SimpleColumn ("tpch.customer.c_custkey");
|
||||
subColList.push_back(sc1);
|
||||
ArithmeticColumn* sc2 = new ArithmeticColumn ("count(tpch.orders.o_orderkey)");
|
||||
sc2->alias("c_count");
|
||||
subColList.push_back(sc2);
|
||||
// Append returned columns to subselect
|
||||
subcsep->returnedCols(subColList);
|
||||
|
||||
//subselect Filters
|
||||
CalpontSelectExecutionPlan::FilterTokenList subcsep_filterlist;
|
||||
SimpleFilter *sf1 = new SimpleFilter ( new Operator("="),
|
||||
new SimpleColumn ("tpch.customer.c_custkey"),
|
||||
new SimpleColumn ("tpch.orders.o_custkey"));
|
||||
subcsep_filterlist.push_back(sf1);
|
||||
//subselect Filters
|
||||
CalpontSelectExecutionPlan::FilterTokenList subcsep_filterlist;
|
||||
SimpleFilter* sf1 = new SimpleFilter ( new Operator("="),
|
||||
new SimpleColumn ("tpch.customer.c_custkey"),
|
||||
new SimpleColumn ("tpch.orders.o_custkey"));
|
||||
subcsep_filterlist.push_back(sf1);
|
||||
|
||||
subcsep_filterlist.push_back(new Operator("and"));
|
||||
|
||||
SimpleFilter *sf2 = new SimpleFilter ( new Operator("NOT LIKE"),
|
||||
new SimpleColumn ("tpch.orders.o_comment"),
|
||||
new ConstantColumn("%:1%:2%"));
|
||||
subcsep_filterlist.push_back(sf2);
|
||||
SimpleFilter* sf2 = new SimpleFilter ( new Operator("NOT LIKE"),
|
||||
new SimpleColumn ("tpch.orders.o_comment"),
|
||||
new ConstantColumn("%:1%:2%"));
|
||||
subcsep_filterlist.push_back(sf2);
|
||||
|
||||
subcsep->filterTokenList(subcsep_filterlist); //Set Filter Columns
|
||||
|
||||
// sub Group By List
|
||||
// sub Group By List
|
||||
CalpontSelectExecutionPlan::GroupByColumnList subcsep_groupbyList;
|
||||
SimpleColumn *sg1 = new SimpleColumn("tpch.customer.c_custkey");
|
||||
SimpleColumn* sg1 = new SimpleColumn("tpch.customer.c_custkey");
|
||||
subcsep_groupbyList.push_back(sg1);
|
||||
subcsep->groupByCols(subcsep_groupbyList); //Set GroupBy columns
|
||||
subcsep->tableAlias("c_orders");
|
||||
subcsep->groupByCols(subcsep_groupbyList); //Set GroupBy columns
|
||||
subcsep->tableAlias("c_orders");
|
||||
|
||||
// Draw the subselect tree.
|
||||
ParseTree *pt = const_cast<ParseTree*>(subcsep->filters());
|
||||
// Draw the subselect tree.
|
||||
ParseTree* pt = const_cast<ParseTree*>(subcsep->filters());
|
||||
pt->drawTree("selectExecutionPlan_13_subquery.dot");
|
||||
|
||||
// x --------------- sub select begins here ---------------- x/
|
||||
|
||||
CalpontSelectExecutionPlan::SelectList subselectlist;
|
||||
subselectlist.push_back(subcsep);
|
||||
csep->subSelects(subselectlist);
|
||||
// x --------------- sub select begins here ---------------- x/
|
||||
|
||||
CalpontSelectExecutionPlan::SelectList subselectlist;
|
||||
subselectlist.push_back(subcsep);
|
||||
csep->subSelects(subselectlist);
|
||||
|
||||
|
||||
// Build Group By List
|
||||
// Build Group By List
|
||||
CalpontSelectExecutionPlan::GroupByColumnList csep_groupbyList;
|
||||
//SimpleColumn *g1 = new SimpleColumn("calpont.FROMTABLE.c_count");
|
||||
SimpleColumn *g1 = new SimpleColumn(*c1);
|
||||
SimpleColumn* g1 = new SimpleColumn(*c1);
|
||||
g1->alias("c_count");
|
||||
cout<< "\n I am testing \n\n" << "g1=" << *g1 << "\n end of data\n" << endl;
|
||||
cout << "\n I am testing \n\n" << "g1=" << *g1 << "\n end of data\n" << endl;
|
||||
csep_groupbyList.push_back(g1);
|
||||
csep->groupByCols(csep_groupbyList); //Set GroupBy columns
|
||||
csep->groupByCols(csep_groupbyList); //Set GroupBy columns
|
||||
|
||||
// Order By List
|
||||
// Order By List
|
||||
CalpontSelectExecutionPlan::OrderByColumnList csep_orderbyList;
|
||||
//ArithmeticColumn *o1 = new ArithmeticColumn("count(ALL)");
|
||||
ArithmeticColumn *o1 = new ArithmeticColumn(*c2);
|
||||
//ArithmeticColumn *o1 = new ArithmeticColumn("count(ALL)");
|
||||
ArithmeticColumn* o1 = new ArithmeticColumn(*c2);
|
||||
o1->alias("custdist");
|
||||
o1->asc(false);
|
||||
csep_orderbyList.push_back(o1);
|
||||
SimpleColumn *o2 = new SimpleColumn(*c1);
|
||||
SimpleColumn* o2 = new SimpleColumn(*c1);
|
||||
o2->alias("c_count");
|
||||
o2->asc(false);
|
||||
csep_orderbyList.push_back(o2);
|
||||
csep->orderByCols(csep_orderbyList); //Set OrderBy columns
|
||||
|
||||
//SimpleColumn *abc = new SimpleColumn(*c1);
|
||||
csep->orderByCols(csep_orderbyList); //Set OrderBy columns
|
||||
|
||||
//filterList->walk(walkfnString); ??
|
||||
//SimpleColumn *abc = new SimpleColumn(*c1);
|
||||
|
||||
//filterList->walk(walkfnString); ??
|
||||
|
||||
cout << "\nCalpont Execution Plan:" << endl;
|
||||
cout << *csep << endl;
|
||||
cout << " --- end of test 13 ---" << endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( ExecPlanTest );
|
||||
|
||||
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
|
||||
int main( int argc, char **argv)
|
||||
int main( int argc, char** argv)
|
||||
{
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
|
||||
runner.addTest( registry.makeTest() );
|
||||
bool wasSuccessful = runner.run( "", false );
|
||||
return (wasSuccessful ? 0 : 1);
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry();
|
||||
runner.addTest( registry.makeTest() );
|
||||
bool wasSuccessful = runner.run( "", false );
|
||||
return (wasSuccessful ? 0 : 1);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user