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


C++ COperator::FPattern方法代码示例

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


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

示例1: GPOS_NEW

//---------------------------------------------------------------------------
//	@function:
//		CBinding::PexprExtract
//
//	@doc:
//		Extract a binding according to a given pattern;
//		Keep root node fixed;
//
//---------------------------------------------------------------------------
CExpression *
CBinding::PexprExtract
	(
	IMemoryPool *pmp,
	CGroupExpression *pgexpr,
	CExpression *pexprPattern,
	CExpression *pexprLast
	)
{
	GPOS_CHECK_ABORT;

	if (!pexprPattern->FMatchPattern(pgexpr))
	{
		// shallow matching fails
		return NULL;
	}
	
	// the previously extracted pattern must have the same root
	GPOS_ASSERT_IMP(NULL != pexprLast, pexprLast->Pgexpr() == pgexpr);

	COperator *popPattern = pexprPattern->Pop();
	if (popPattern->FPattern() && CPattern::PopConvert(popPattern)->FLeaf())
	{
		// return immediately; no deep extraction for leaf patterns
		pgexpr->Pop()->AddRef();
		return GPOS_NEW(pmp) CExpression(pmp, pgexpr->Pop(), pgexpr);
	}

	DrgPexpr *pdrgpexpr = NULL;
	ULONG ulArity = pgexpr->UlArity();
	if (0 == ulArity && NULL != pexprLast)
	{
		// no more bindings
		return NULL;
	}
	else
	{
		// attempt binding to children
		pdrgpexpr = GPOS_NEW(pmp) DrgPexpr(pmp);
		if (!FExtractChildren(pmp, pgexpr, pexprPattern, pexprLast, pdrgpexpr))
		{
			pdrgpexpr->Release();
			return NULL;
		}
	}					

	CExpression *pexpr = PexprFinalize(pmp, pgexpr, pdrgpexpr);
	GPOS_ASSERT(NULL != pexpr);
	
	return pexpr;
}
开发者ID:HanumathRao,项目名称:gporca,代码行数:60,代码来源:CBinding.cpp

示例2: PexprExtract

//---------------------------------------------------------------------------
//	@function:
//		CBinding::PexprExtract
//
//	@doc:
//		Extract a binding according to a given pattern;
//		If no appropriate child pattern can be matched advance the root node
//		until group is exhausted;
//
//---------------------------------------------------------------------------
CExpression *
CBinding::PexprExtract
	(
	IMemoryPool *pmp,
	CGroup *pgroup,
	CExpression *pexprPattern,
	CExpression *pexprLast
	)
{
	GPOS_CHECK_STACK_SIZE;
	GPOS_CHECK_ABORT;

	GPOS_ASSERT(NULL != pgroup);
	GPOS_ASSERT(NULL != pexprPattern);

	CGroupExpression *pgexpr = NULL;
	if (NULL != pexprLast)
	{
		pgexpr = pexprLast->Pgexpr();
	}
	else
	{
		// init cursor
		pgexpr = PgexprNext(pgroup, NULL);
	}
	GPOS_ASSERT(NULL != pgexpr);
	
	COperator *popPattern = pexprPattern->Pop();
	if (popPattern->FPattern() && CPattern::PopConvert(popPattern)->FLeaf())
	{
		// for leaf patterns, we do not iterate on group expressions
		if (NULL != pexprLast)
		{
			// if a leaf was extracted before, then group is exhausted
			return NULL;
		}

		return PexprExtract(pmp, pgexpr, pexprPattern, pexprLast);
	}

	// start position for next binding
	CExpression *pexprStart = pexprLast;
	do 
	{
		if (pexprPattern->FMatchPattern(pgexpr))
		{
			CExpression *pexprResult =
				PexprExtract(pmp, pgexpr, pexprPattern, pexprStart);
			if (NULL != pexprResult)
			{
				return pexprResult;
			}
		}
		
		// move cursor and reset start position
		pgexpr = PgexprNext(pgroup, pgexpr);
		pexprStart = NULL;

		GPOS_CHECK_ABORT;
	}
	while (NULL != pgexpr);

	// group exhausted
	return NULL;
}
开发者ID:HanumathRao,项目名称:gporca,代码行数:75,代码来源:CBinding.cpp


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