本文整理汇总了C++中ParseTree::walk方法的典型用法代码示例。如果您正苦于以下问题:C++ ParseTree::walk方法的具体用法?C++ ParseTree::walk怎么用?C++ ParseTree::walk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParseTree
的用法示例。
在下文中一共展示了ParseTree::walk方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exp
void arithmeticExpression_1()
{
cout << "\narithmetic expression: " << endl;
string exp("substr(a)+ 100.00 * sum(tpch.part.p_type) / sum(tpch.lineitem.l_extendedprice *(1-tpch.lineitem.l_discount))");
cout << exp << endl;
ArithmeticColumn a(exp, 0);
ParseTree* pt = const_cast<ParseTree*>(a.expression());
if (pt != NULL)
{
pt->walk(walkfnString);
pt->drawTree("arithmeticExpression_1.dot");
}
cout << " --- end of test 6 ---" << endl;
}
示例2: derivedTableOptimization
void derivedTableOptimization(SCSEP& csep)
{
// @bug5634. replace the unused column with ConstantColumn from derived table column list,
// ExeMgr will not project ConstantColumn. Only count for local derived column.
// subquery may carry main query derived table list for column reference, those
// derived tables are not checked for optimization in this scope.
erydbSelectExecutionPlan::SelectList derivedTbList = csep->derivedTableList();
// @bug6156. Skip horizontal optimization for no table union.
bool horizontalOptimization = true;
for (uint i = 0; i < derivedTbList.size(); i++)
{
erydbSelectExecutionPlan *plan = dynamic_cast<erydbSelectExecutionPlan*>(derivedTbList[i].get());
erydbSelectExecutionPlan::ReturnedColumnList cols = plan->returnedCols();
vector<erydbSelectExecutionPlan::ReturnedColumnList> unionColVec;
// only do vertical optimization for union all
// @bug6134. Also skip the vertical optimization for select distinct
// because all columns need to be projected to check the distinctness.
bool verticalOptimization = false;
if (plan->distinctUnionNum() == 0 && !plan->distinct())
{
verticalOptimization = true;
for (uint j = 0; j < plan->unionVec().size(); j++)
{
unionColVec.push_back(
dynamic_cast<erydbSelectExecutionPlan*>(plan->unionVec()[j].get())->returnedCols());
}
}
if (plan->tableList().empty())
horizontalOptimization = false;
for (uint j = 0; j < plan->unionVec().size(); j++)
{
if (dynamic_cast<erydbSelectExecutionPlan*>(plan->unionVec()[j].get())->tableList().empty())
{
horizontalOptimization = false;
break;
}
}
if (verticalOptimization)
{
int64_t val = 1;
for (uint i = 0; i < cols.size(); i++)
{
//if (cols[i]->derivedTable().empty())
if (cols[i]->refCount() == 0)
{
if (cols[i]->derivedRefCol())
cols[i]->derivedRefCol()->decRefCount();
cols[i].reset(new ConstantColumn(val));
for (uint j = 0; j < unionColVec.size(); j++)
unionColVec[j][i].reset(new ConstantColumn(val));
}
}
// set back
plan->returnedCols(cols);
for (uint j = 0; j < unionColVec.size(); j++)
dynamic_cast<erydbSelectExecutionPlan*>(plan->unionVec()[j].get())->returnedCols(unionColVec[j]);
}
}
/*
* @bug5635. Move filters that only belongs to a derived table to inside the derived table.
* 1. parse tree walk to populate derivedTableFilterMap and set null candidate on the tree.
* 2. remove the null filters
* 3. and the filters of derivedTableFilterMap and append to the WHERE filter of the derived table
*
* Note:
* 1. Subquery filters is ignored because derived table can not be in subquery
* 2. While walking tree, whenever a single derive simplefilter is encountered,
* this filter is pushed to the corresponding stack
* 2. Whenever an OR operator is encountered, all the filter stack of
* that OR involving derived table are emptied and null candidate of each
* stacked filter needs to be reset (not null)
*/
ParseTree* pt = csep->filters();
map<string, ParseTree*> derivedTbFilterMap;
if (horizontalOptimization && pt)
{
pt->walk(setDerivedTable);
setDerivedFilter(pt, derivedTbFilterMap, derivedTbList);
csep->filters(pt);
}
// AND the filters of individual stack to the derived table filter tree
// @todo union filters.
// @todo outer join complication
map<string, ParseTree*>::iterator mapIt;
for (uint i = 0; i < derivedTbList.size(); i++)
{
erydbSelectExecutionPlan *plan = dynamic_cast<erydbSelectExecutionPlan*>(derivedTbList[i].get());
erydbSelectExecutionPlan::ReturnedColumnList derivedColList = plan->returnedCols();
mapIt = derivedTbFilterMap.find(plan->derivedTbAlias());
if (mapIt != derivedTbFilterMap.end())
{
// replace all derived column of this filter with real column from
//.........这里部分代码省略.........
示例3: r_regionkey
void selectExecutionPlan_1() {
cout << "SQL: select r_regionkey from region, nation where n_regionkey = r_regionkey and n_regionkey = 2;" << endl;
CalpontSelectExecutionPlan csep;
CalpontSelectExecutionPlan::ReturnedColumnList colList;
ParseTree* filterList;
// returned columns
SimpleColumn r_regionkey("tpch.region.r_regionkey");
SimpleColumn n_regionkey("tpch.nation.n_regionkey");
SimpleColumn p_partkey("tpch.part.p_partkey");
SimpleColumn n_name("tpch.nation.n_name");
SimpleColumn c_custkey("tpch.customer.c_custkey");
colList.push_back(new SimpleColumn(r_regionkey));
// filters
CalpontSelectExecutionPlan::Parser parser;
std::vector<Token> tokens;
//tokens.push_back(Token(new Operator("(")));
//tokens.push_back(Token(new Operator(")")));
tokens.push_back(Token(new SimpleFilter(new Operator("="),
new SimpleColumn(r_regionkey),
new SimpleColumn(n_regionkey))));
tokens.push_back(Token(new Operator("and")));
tokens.push_back(Token(new SimpleFilter(new Operator("="),
new SimpleColumn(r_regionkey),
new SimpleColumn(c_custkey))));
tokens.push_back(Token(new Operator("and")));
tokens.push_back(Token(new Operator("(")));
tokens.push_back(Token(new SimpleFilter(new Operator("="),
new SimpleColumn(n_regionkey),
new ConstantColumn("779"))));
tokens.push_back(Token(new Operator("or")));
tokens.push_back(Token(new SimpleFilter(new Operator("!="),
new SimpleColumn(n_name),
new ConstantColumn("'ASIA'"))));
tokens.push_back(Token(new Operator(")")));
tokens.push_back(Token(new Operator ("and")));
tokens.push_back(Token(new Operator("(")));
tokens.push_back(Token(new SimpleFilter(new Operator("<"),
new SimpleColumn(n_regionkey),
new ConstantColumn("77"))));
tokens.push_back(Token(new Operator("or")));
tokens.push_back(Token(new SimpleFilter(new Operator(">"),
new SimpleColumn(p_partkey),
new ConstantColumn("7007"))));
tokens.push_back(Token(new Operator(")")));
filterList = parser.parse(tokens.begin(), tokens.end());
// draw filterList tree
filterList->drawTree("selectExecutionPlan_1.dot");
// calpont execution plan
csep.returnedCols (colList);
csep.filters (filterList);
cout << "\nCalpont Execution Plan:" << endl;
cout << csep << endl;
cout << " --- end of test 1 ---" << endl;
filterList->walk(walkfnString);
}