예제 #1
0
//---------------------------------------------------------------------------
//	@function:
//		CXformTest::EresUnittest_Mapping
//
//	@doc:
//		Test name -> xform mapping
//
//---------------------------------------------------------------------------
GPOS_RESULT
CXformTest::EresUnittest_Mapping()
{
	for (ULONG ul = 0; ul < CXform::ExfSentinel; ul++)
	{
		CXform::EXformId exfid = (CXform::EXformId) ul;
		CXform *pxform = CXformFactory::Pxff()->Pxf(exfid);
		CXform *pxformMapped = CXformFactory::Pxff()->Pxf(pxform->SzId());
		GPOS_ASSERT(pxform == pxformMapped);
	}

	return GPOS_OK;
}
예제 #2
0
//---------------------------------------------------------------------------
//	@function:
//		CXformTest::ApplyExprXforms
//
//	@doc:
//		Apply different xforms for the given expression
//
//---------------------------------------------------------------------------
void
CXformTest::ApplyExprXforms
	(
	IMemoryPool *pmp,
	IOstream &os,
	CExpression *pexpr
	)
{
	os << std::endl << "EXPR:" << std::endl;
	(void) pexpr->OsPrint(os);

	for (ULONG ulXformId = 0; ulXformId < CXform::ExfSentinel; ulXformId++)
	{
		CXform *pxform = CXformFactory::Pxff()->Pxf((CXform::EXformId) ulXformId);
		os << std::endl <<"XFORM " << pxform->SzId() << ":" << std::endl;

		CXformContext *pxfctxt = GPOS_NEW(pmp) CXformContext(pmp);
		CXformResult *pxfres = GPOS_NEW(pmp) CXformResult(pmp);

#ifdef GPOS_DEBUG
		if (pxform->FCheckPattern(pexpr) && CXform::FPromising(pmp, pxform, pexpr))
		{
			if (CXform::ExfExpandNAryJoinMinCard == pxform->Exfid())
			{
				GPOS_ASSERT(COperator::EopLogicalNAryJoin == pexpr->Pop()->Eopid());

				// derive stats on NAry join expression
				CExpressionHandle exprhdl(pmp);
				exprhdl.Attach(pexpr);
				exprhdl.DeriveStats(pmp, pmp, NULL /*prprel*/, NULL /*pdrgpstatCtxt*/);
			}

			pxform->Transform(pxfctxt, pxfres, pexpr);

			CExpression *pexprResult = pxfres->PexprNext();
			while (NULL != pexprResult)
			{
				GPOS_ASSERT(pexprResult->FMatchDebug(pexprResult));

				pexprResult = pxfres->PexprNext();
			}
			(void) pxfres->OsPrint(os);
		}
#endif // GPOS_DEBUG

		pxfres->Release();
		pxfctxt->Release();
	}
}