1
0
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:
Andrew Hutchings
2017-10-26 17:18:17 +01:00
parent 4985f3456e
commit 01446d1e22
1296 changed files with 403852 additions and 353747 deletions

View File

@ -45,25 +45,29 @@ using namespace messageqcpp;
using namespace execplan;
class TPCH_EXECPLAN : public CppUnit::TestFixture {
class TPCH_EXECPLAN : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( TPCH_EXECPLAN );
CPPUNIT_TEST_SUITE( TPCH_EXECPLAN );
CPPUNIT_TEST( Q1 );
CPPUNIT_TEST( Q1 );
CPPUNIT_TEST_SUITE_END();
CPPUNIT_TEST_SUITE_END();
private:
public:
void setUp() {
void setUp()
{
}
void tearDown() {
void tearDown()
{
}
void Q1() {
string sql = "\
void Q1()
{
string sql = "\
select\
o_year,\
sum(decode(nation, ':1', volumn, 0)) / sum(volume) as mkt_share\
@ -98,118 +102,118 @@ group by\
o_year\
order by\
o_year;";
CalpontSelectExecutionPlan csep;
// Returned columns
CalpontSelectExecutionPlan::ReturnedColumnList returnedColumnList;
// these columns are from the temp table of FROM clause.
// these columns are from the temp table of FROM clause.
// I hereby give schema name "calpont", table name "FROMTABLE",
SimpleColumn *c1 = new SimpleColumn("calpont.FROMTABLE.o_year");
SimpleColumn* c1 = new SimpleColumn("calpont.FROMTABLE.o_year");
returnedColumnList.push_back(c1);
ArithmeticColumn *c2 = new ArithmeticColumn("sum(decode(calpont.FROMTABLE.nation, ':1', calpont.FROMTABLE.volumn, 0))/sum(tpch.FROMTABLE.volumn)");
ArithmeticColumn* c2 = new ArithmeticColumn("sum(decode(calpont.FROMTABLE.nation, ':1', calpont.FROMTABLE.volumn, 0))/sum(tpch.FROMTABLE.volumn)");
returnedColumnList.push_back(c2);
csep.returnedCols(returnedColumnList);
// subselect in FROM clause
CalpontSelectExecutionPlan *subsep =
new CalpontSelectExecutionPlan(CalpontSelectExecutionPlan::FROM);
// subselect in FROM clause
CalpontSelectExecutionPlan* subsep =
new CalpontSelectExecutionPlan(CalpontSelectExecutionPlan::FROM);
// subselect returned columns
CalpontSelectExecutionPlan::ReturnedColumnList subReturnedColList;
ArithmeticColumn *sc1 = new ArithmeticColumn("extract(year from tpch.orders.o_orderdate)");
ArithmeticColumn* sc1 = new ArithmeticColumn("extract(year from tpch.orders.o_orderdate)");
sc1->alias ("o_year");
subReturnedColList.push_back(sc1);
ArithmeticColumn *sc2 = new ArithmeticColumn("tpch.lineitem.l_extendeprice * (1-tpch.lineitem.l_discount)");
ArithmeticColumn* sc2 = new ArithmeticColumn("tpch.lineitem.l_extendeprice * (1-tpch.lineitem.l_discount)");
sc2->alias("volume");
subReturnedColList.push_back(sc2);
SimpleColumn *sc3 = new SimpleColumn("tpch.nation.n_name");
SimpleColumn* sc3 = new SimpleColumn("tpch.nation.n_name");
sc3->tableAlias("n2");
subReturnedColList.push_back(sc3);
subsep->returnedCols(subReturnedColList);
// subselect filters
CalpontSelectExecutionPlan::FilterTokenList subFilterTokenList;
SimpleFilter *sf1 = new SimpleFilter (new Operator("="),
new SimpleColumn("tpch.part.p_partkey"),
new SimpleColumn("tpch.lineitem.l_partkey"));
SimpleFilter* sf1 = new SimpleFilter (new Operator("="),
new SimpleColumn("tpch.part.p_partkey"),
new SimpleColumn("tpch.lineitem.l_partkey"));
subFilterTokenList.push_back(sf1);
subFilterTokenList.push_back(new Operator("and"));
SimpleFilter *sf2 = new SimpleFilter (new Operator("="),
new SimpleColumn("tpch.supplier.s_suppkey"),
new SimpleColumn("tpch.lineitem.l_suppkey"));
SimpleFilter* sf2 = new SimpleFilter (new Operator("="),
new SimpleColumn("tpch.supplier.s_suppkey"),
new SimpleColumn("tpch.lineitem.l_suppkey"));
subFilterTokenList.push_back(sf2);
subFilterTokenList.push_back(new Operator("and"));
SimpleFilter *sf3 = new SimpleFilter (new Operator("="),
new SimpleColumn("tpch.lineitem.l_ordertkey"),
new SimpleColumn("tpch.orders.o_orderkey"));
SimpleFilter* sf3 = new SimpleFilter (new Operator("="),
new SimpleColumn("tpch.lineitem.l_ordertkey"),
new SimpleColumn("tpch.orders.o_orderkey"));
subFilterTokenList.push_back(sf3);
subFilterTokenList.push_back(new Operator("and"));
SimpleFilter *sf4 = new SimpleFilter (new Operator("="),
new SimpleColumn("tpch.orders.o_custkey"),
new SimpleColumn("tpch.customer.c_custkey"));
subFilterTokenList.push_back(sf4);
subFilterTokenList.push_back(new Operator("and"));
SimpleColumn *n1_nationkey = new SimpleColumn("tpch.nation.n_nationkey");
n1_nationkey->tableAlias("n1");
SimpleFilter *sf5 = new SimpleFilter (new Operator("="),
new SimpleColumn("tpch.customer.c_nationkey"),
n1_nationkey);
subFilterTokenList.push_back(sf5);
subFilterTokenList.push_back(new Operator("and"));
SimpleColumn *n1_regionkey = new SimpleColumn("tpch.nation.n_regionkey");
SimpleFilter* sf4 = new SimpleFilter (new Operator("="),
new SimpleColumn("tpch.orders.o_custkey"),
new SimpleColumn("tpch.customer.c_custkey"));
subFilterTokenList.push_back(sf4);
subFilterTokenList.push_back(new Operator("and"));
SimpleColumn* n1_nationkey = new SimpleColumn("tpch.nation.n_nationkey");
n1_nationkey->tableAlias("n1");
SimpleFilter* sf5 = new SimpleFilter (new Operator("="),
new SimpleColumn("tpch.customer.c_nationkey"),
n1_nationkey);
subFilterTokenList.push_back(sf5);
subFilterTokenList.push_back(new Operator("and"));
SimpleColumn* n1_regionkey = new SimpleColumn("tpch.nation.n_regionkey");
n1_regionkey->tableAlias ("n1");
SimpleFilter *sf6 = new SimpleFilter ( new Operator("="),
n1_regionkey,
new SimpleColumn("tpch.region.r_regionkey"));
SimpleFilter* sf6 = new SimpleFilter ( new Operator("="),
n1_regionkey,
new SimpleColumn("tpch.region.r_regionkey"));
subFilterTokenList.push_back(sf6);
subFilterTokenList.push_back(new Operator("and"));
SimpleFilter *sf7 = new SimpleFilter ( new Operator("="),
new SimpleColumn("tpch.region.r_name"),
new ConstantColumn (":2"));
SimpleFilter* sf7 = new SimpleFilter ( new Operator("="),
new SimpleColumn("tpch.region.r_name"),
new ConstantColumn (":2"));
subFilterTokenList.push_back(sf7);
subFilterTokenList.push_back(new Operator("and"));
SimpleColumn *n2_nationkey = new SimpleColumn("tpch.nation.n_nationkey");
subFilterTokenList.push_back(new Operator("and"));
SimpleColumn* n2_nationkey = new SimpleColumn("tpch.nation.n_nationkey");
n2_nationkey->tableAlias("n2");
SimpleFilter *sf9 = new SimpleFilter ( new Operator("="),
new SimpleColumn("tpch.supplier.s_nationkey"),
n2_nationkey);
subFilterTokenList.push_back(sf9);
subFilterTokenList.push_back(new Operator("and"));
SimpleFilter *sf10 = new SimpleFilter (new Operator (">="),
SimpleFilter* sf9 = new SimpleFilter ( new Operator("="),
new SimpleColumn("tpch.supplier.s_nationkey"),
n2_nationkey);
subFilterTokenList.push_back(sf9);
subFilterTokenList.push_back(new Operator("and"));
SimpleFilter* sf10 = new SimpleFilter (new Operator (">="),
new SimpleColumn ("tpch.orders.o_orderdate"),
new ConstantColumn ("1995-01-01"));
new ConstantColumn ("1995-01-01"));
subFilterTokenList.push_back(sf10);
subFilterTokenList.push_back(new Operator("and"));
SimpleFilter *sf11 = new SimpleFilter (new Operator ("<="),
SimpleFilter* sf11 = new SimpleFilter (new Operator ("<="),
new SimpleColumn ("tpch.orders.o_orderdate"),
new ConstantColumn ("1995-01-06"));
new ConstantColumn ("1995-01-06"));
subFilterTokenList.push_back(sf11);
subFilterTokenList.push_back(new Operator("and"));
SimpleFilter *sf12 = new SimpleFilter (new Operator ("="),
SimpleFilter* sf12 = new SimpleFilter (new Operator ("="),
new SimpleColumn ("tpch.part.p_type"),
new ConstantColumn ("3"));
new ConstantColumn ("3"));
subFilterTokenList.push_back(sf12);
subsep->filterTokenList(subFilterTokenList);
subsep->filterTokenList(subFilterTokenList);
subsep->tableAlias("all_nations");
// end of subselect in FROM. push FROM subselect to selectList
// NOTE: only FROM subselect needs to be pushed into selectList.
// Subselects in WHERE or HAVING clause are in where or having
@ -218,42 +222,42 @@ order by\
CalpontSelectExecutionPlan::SelectList fromSubSelectList;
fromSubSelectList.push_back(subsep);
csep.subSelects(fromSubSelectList);
ParseTree* pt = const_cast<ParseTree*>(subsep->filters());
pt->drawTree("q8.dot");
// Group by
CalpontSelectExecutionPlan::GroupByColumnList groupByList;
SimpleColumn *g1 = new SimpleColumn (*c1);
groupByList.push_back (g1);
csep.groupByCols(groupByList);
// Order by
CalpontSelectExecutionPlan::OrderByColumnList orderByList;
SimpleColumn *o1 = new SimpleColumn(*c1);
orderByList.push_back(o1);
csep.orderByCols(orderByList);
cout << csep;
}
};
ParseTree* pt = const_cast<ParseTree*>(subsep->filters());
pt->drawTree("q8.dot");
// Group by
CalpontSelectExecutionPlan::GroupByColumnList groupByList;
SimpleColumn* g1 = new SimpleColumn (*c1);
groupByList.push_back (g1);
csep.groupByCols(groupByList);
// Order by
CalpontSelectExecutionPlan::OrderByColumnList orderByList;
SimpleColumn* o1 = new SimpleColumn(*c1);
orderByList.push_back(o1);
csep.orderByCols(orderByList);
cout << csep;
}
};
CPPUNIT_TEST_SUITE_REGISTRATION( TPCH_EXECPLAN );
#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 &registry = 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);
}