当前位置: 首页>>代码示例>>C++>>正文


C++ ParseTree::copyTree方法代码示例

本文整理汇总了C++中ParseTree::copyTree方法的典型用法代码示例。如果您正苦于以下问题:C++ ParseTree::copyTree方法的具体用法?C++ ParseTree::copyTree怎么用?C++ ParseTree::copyTree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ParseTree的用法示例。


在下文中一共展示了ParseTree::copyTree方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: copyTree

 void copyTree()
 {
     //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))");
     ArithmeticColumn a(exp);
     ParseTree* pt = const_cast<ParseTree*>(a.expression());
     
     ParseTree* newTree = new ParseTree();
     
     // copy 1st time
     newTree->copyTree(*pt);        
     
     // copy 2nd time, see if the existing tree is deleted.
     newTree->copyTree (*pt);
     
     // explicitly delete the 2nd copied tree
     delete newTree;
 }    
开发者ID:hans511002,项目名称:erydb,代码行数:18,代码来源:tdriver.cpp

示例2: addExpression

void SubAdapterStep::addExpression(const JobStepVector& exps, JobInfo& jobInfo)
{
	// maps key to the index in the RG
	map<uint32_t, uint32_t> keyToIndexMap;
	const vector<uint32_t>& keys = fRowGroupIn.getKeys();
	for (size_t i = 0; i < keys.size(); i++)
		keyToIndexMap[keys[i]] = i;

	// combine the expression to one parse tree
	ParseTree* filter = NULL;
	for (JobStepVector::const_iterator it = exps.begin(); it != exps.end(); it++)
	{
		ExpressionStep* e = dynamic_cast<ExpressionStep*>(it->get());
		idbassert(e);

		e->updateInputIndex(keyToIndexMap, jobInfo);
		if (filter != NULL)
		{
			ParseTree* left = filter;
			ParseTree* right = new ParseTree();
			right->copyTree(*(e->expressionFilter()));
			filter = new ParseTree(new LogicOperator("and"));
			filter->left(left);
			filter->right(right);
		}
		else
		{
			filter = new ParseTree();
			filter->copyTree(*(e->expressionFilter()));
		}
	}

	// add to the expression wrapper
	if (fExpression.get() == NULL)
		fExpression.reset(new funcexp::FuncExpWrapper());
	fExpression->addFilter(boost::shared_ptr<execplan::ParseTree>(filter));
}
开发者ID:coderplay,项目名称:infinidb,代码行数:37,代码来源:subquerystep.cpp

示例3: derivedTableOptimization


//.........这里部分代码省略.........
			}

			// 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
			// derived table projection list.
			ParseTree *mainFilter = new ParseTree();
			mainFilter->copyTree(*(mapIt->second));
			replaceRefCol(mainFilter, derivedColList);
			ParseTree* derivedFilter = plan->filters();
			if (derivedFilter)
			{
				LogicOperator *op = new LogicOperator("and");
				ParseTree *filter = new ParseTree(op);
				filter->left(derivedFilter);
				filter->right(mainFilter);
				plan->filters(filter);
			}
			else
			{
				plan->filters(mainFilter);
			}

			// union filter handling
			for (uint j = 0; j < plan->unionVec().size(); j++)
			{
				erydbSelectExecutionPlan *unionPlan =
				  dynamic_cast<erydbSelectExecutionPlan*>(plan->unionVec()[j].get());
				erydbSelectExecutionPlan::ReturnedColumnList unionColList = unionPlan->returnedCols();
				ParseTree* mainFilterForUnion = new ParseTree();
				mainFilterForUnion->copyTree(*(mapIt->second));
				replaceRefCol(mainFilterForUnion, unionColList);
				ParseTree *unionFilter = unionPlan->filters();
				if (unionFilter)
				{
					LogicOperator *op = new LogicOperator("and");
					ParseTree *filter = new ParseTree(op);
					filter->left(unionFilter);
					filter->right(mainFilterForUnion);
					unionPlan->filters(filter);
				}
				else
				{
					unionPlan->filters(mainFilterForUnion);
				}
			}
		}
	}

	// clean derivedTbFilterMap because all the filters are copied
	for( mapIt = derivedTbFilterMap.begin(); mapIt != derivedTbFilterMap.end(); ++mapIt )
		delete (*mapIt).second;

	// recursively process the nested derived table
	for (uint i = 0; i < csep->subSelectList().size(); i++)
	{
		SCSEP subselect(boost::dynamic_pointer_cast<erydbSelectExecutionPlan>(csep->subSelectList()[i]));
		derivedTableOptimization(subselect);
	}
}
开发者ID:hans511002,项目名称:erydb,代码行数:101,代码来源:ha_from_sub.cpp


注:本文中的ParseTree::copyTree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。