本文整理汇总了C++中CExpression::PdpDerive方法的典型用法代码示例。如果您正苦于以下问题:C++ CExpression::PdpDerive方法的具体用法?C++ CExpression::PdpDerive怎么用?C++ CExpression::PdpDerive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CExpression
的用法示例。
在下文中一共展示了CExpression::PdpDerive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//---------------------------------------------------------------------------
// @function:
// CXformTest::PexprStarJoinTree
//
// @doc:
// Generate a randomized star join tree
//
//---------------------------------------------------------------------------
CExpression *
CXformTest::PexprStarJoinTree
(
IMemoryPool *pmp,
ULONG ulTabs
)
{
CExpression *pexprLeft = CTestUtils::PexprLogicalGet(pmp);
for (ULONG ul = 1; ul < ulTabs; ul++)
{
CDrvdPropRelational *pdprelLeft = CDrvdPropRelational::Pdprel(pexprLeft->PdpDerive());
CColRef *pcrLeft = pdprelLeft->PcrsOutput()->PcrAny();
CExpression *pexprRight = CTestUtils::PexprLogicalGet(pmp);
CDrvdPropRelational *pdprelRight = CDrvdPropRelational::Pdprel(pexprRight->PdpDerive());
CColRef *pcrRight = pdprelRight->PcrsOutput()->PcrAny();
CExpression *pexprPred = CUtils::PexprScalarEqCmp(pmp, pcrLeft, pcrRight);
pexprLeft = CUtils::PexprLogicalJoin<CLogicalInnerJoin>(pmp, pexprLeft, pexprRight, pexprPred);
}
return pexprLeft;
}
示例2: CColRefSet
//---------------------------------------------------------------------------
// @function:
// CXformLeftSemiJoin2InnerJoin::Transform
//
// @doc:
// actual transformation
//
//---------------------------------------------------------------------------
void
CXformLeftSemiJoin2InnerJoin::Transform
(
CXformContext *pxfctxt,
CXformResult *pxfres,
CExpression *pexpr
)
const
{
GPOS_ASSERT(NULL != pxfctxt);
GPOS_ASSERT(FPromising(pxfctxt->Pmp(), this, pexpr));
GPOS_ASSERT(FCheckPattern(pexpr));
IMemoryPool *mp = pxfctxt->Pmp();
// extract components
CExpression *pexprOuter = (*pexpr)[0];
CExpression *pexprInner = (*pexpr)[1];
CExpression *pexprScalar = (*pexpr)[2];
pexprOuter->AddRef();
pexprInner->AddRef();
pexprScalar->AddRef();
// construct grouping columns by collecting used columns in the join predicate
// that come from join's inner child
CColRefSet *pcrsOuterOutput = CDrvdPropRelational::GetRelationalProperties(pexprOuter->PdpDerive())->PcrsOutput();
CColRefSet *pcrsUsed = CDrvdPropScalar::GetDrvdScalarProps(pexprScalar->PdpDerive())->PcrsUsed();
CColRefSet *pcrsGb = GPOS_NEW(mp) CColRefSet(mp);
pcrsGb->Include(pcrsUsed);
pcrsGb->Difference(pcrsOuterOutput);
GPOS_ASSERT(0 < pcrsGb->Size());
CKeyCollection *pkc = CDrvdPropRelational::GetRelationalProperties(pexprInner->PdpDerive())->Pkc();
if (NULL == pkc ||
(NULL != pkc && !pkc->FKey(pcrsGb, false /*fExactMatch*/)))
{
// grouping columns do not cover a key on the inner side,
// we need to create a group by on inner side
CColRefArray *colref_array = pcrsGb->Pdrgpcr(mp);
CExpression *pexprGb =
GPOS_NEW(mp) CExpression
(
mp,
GPOS_NEW(mp) CLogicalGbAgg(mp, colref_array, COperator::EgbaggtypeGlobal /*egbaggtype*/),
pexprInner,
GPOS_NEW(mp) CExpression(mp, GPOS_NEW(mp) CScalarProjectList(mp))
);
pexprInner = pexprGb;
}
CExpression *pexprInnerJoin =
CUtils::PexprLogicalJoin<CLogicalInnerJoin>(mp, pexprOuter, pexprInner, pexprScalar);
pcrsGb->Release();
pxfres->Add(pexprInnerJoin);
}
示例3: CColRefSet
//---------------------------------------------------------------------------
// @function:
// CDecorrelator::FProcessGbAgg
//
// @doc:
// Decorrelate GbAgg operator
//
//---------------------------------------------------------------------------
BOOL
CDecorrelator::FProcessGbAgg
(
IMemoryPool *pmp,
CExpression *pexpr,
BOOL, // fEqualityOnly
CExpression **ppexprDecorrelated,
DrgPexpr *pdrgpexprCorrelations
)
{
CLogicalGbAgg *popAggOriginal = CLogicalGbAgg::PopConvert(pexpr->Pop());
// fail if agg has outer references
if (CUtils::FHasOuterRefs(pexpr) && !CUtils::FHasOuterRefs((*pexpr)[0]))
{
return false;
}
// TODO: 12/20/2012 - ; check for strictness of agg function
// decorrelate relational child
CExpression *pexprRelational = NULL;
if (!FProcess(pmp, (*pexpr)[0], true /*fEqualityOnly*/, &pexprRelational, pdrgpexprCorrelations))
{
GPOS_ASSERT(NULL == pexprRelational);
return false;
}
// get the output columns of decorrelated child
CColRefSet *pcrsOutput = CDrvdPropRelational::Pdprel(pexprRelational->PdpDerive())->PcrsOutput();
// create temp expression of correlations to determine inner columns
pdrgpexprCorrelations->AddRef();
CExpression *pexprTemp = CPredicateUtils::PexprConjunction(pmp, pdrgpexprCorrelations);
CColRefSet *pcrs =
GPOS_NEW(pmp) CColRefSet(pmp,
*(CDrvdPropScalar::Pdpscalar(pexprTemp->PdpDerive())->PcrsUsed()));
pcrs->Intersection(pcrsOutput);
pexprTemp->Release();
// add grouping columns from original agg
pcrs->Include(popAggOriginal->Pdrgpcr());
// assemble grouping columns
DrgPcr *pdrgpcr = pcrs->Pdrgpcr(pmp);
pcrs->Release();
// assemble agg
CExpression *pexprProjList = (*pexpr)[1];
pexprProjList->AddRef();
CLogicalGbAgg *popAgg = GPOS_NEW(pmp) CLogicalGbAgg(pmp, pdrgpcr, popAggOriginal->Egbaggtype());
*ppexprDecorrelated = GPOS_NEW(pmp) CExpression(pmp, popAgg, pexprRelational, pexprProjList);
return true;
}
示例4: at
//---------------------------------------------------------------------------
// @function:
// COptimizer::PrintQuery
//
// @doc:
// Helper function to print query expression
//
//---------------------------------------------------------------------------
void
COptimizer::PrintQuery
(
IMemoryPool *pmp,
CExpression *pexprTranslated,
CQueryContext *pqc
)
{
CAutoTrace at(pmp);
at.Os() << std::endl << "Algebrized query: " << std::endl << *pexprTranslated;
DrgPexpr *pdrgpexpr = COptCtxt::PoctxtFromTLS()->Pcteinfo()->PdrgPexpr(pmp);
const ULONG ulCTEs = pdrgpexpr->UlLength();
if (0 < ulCTEs)
{
at.Os() << std::endl << "Common Table Expressions: ";
for (ULONG ul = 0; ul < ulCTEs; ul++)
{
at.Os() << std::endl << *(*pdrgpexpr)[ul];
}
}
pdrgpexpr->Release();
CExpression *pexprPreprocessed = pqc->Pexpr();
(void) pexprPreprocessed->PdpDerive();
at.Os() << std::endl << "Algebrized preprocessed query: " << std::endl << *pexprPreprocessed;
}
示例5: exprhdl
//---------------------------------------------------------------------------
// @function:
// CDecorrelator::FProcessProject
//
// @doc:
// Decorrelate project/sequence project
//
//---------------------------------------------------------------------------
BOOL
CDecorrelator::FProcessProject
(
IMemoryPool *pmp,
CExpression *pexpr,
BOOL fEqualityOnly,
CExpression **ppexprDecorrelated,
DrgPexpr *pdrgpexprCorrelations
)
{
COperator::EOperatorId eopid = pexpr->Pop()->Eopid();
GPOS_ASSERT(COperator::EopLogicalProject == eopid ||
COperator::EopLogicalSequenceProject == eopid);
CExpression *pexprPrjList = (*pexpr)[1];
// fail if project elements have outer references
CColRefSet *pcrsOutput = CDrvdPropRelational::Pdprel((*pexpr)[0]->PdpDerive())->PcrsOutput();
CColRefSet *pcrsUsed = CDrvdPropScalar::Pdpscalar(pexprPrjList->PdpDerive())->PcrsUsed();
if (!pcrsOutput->FSubset(pcrsUsed))
{
return false;
}
if (COperator::EopLogicalSequenceProject == eopid)
{
(void) pexpr->PdpDerive();
CExpressionHandle exprhdl(pmp);
exprhdl.Attach(pexpr);
exprhdl.DeriveProps(NULL /*pdpctxt*/);
if (CLogicalSequenceProject::PopConvert(pexpr->Pop())->FHasLocalOuterRefs(exprhdl))
{
// fail if a SequenceProject has local outer references
return false;
}
}
// decorrelate relational child
CExpression *pexprRelational = NULL;
if (!FProcess(pmp, (*pexpr)[0], fEqualityOnly, &pexprRelational, pdrgpexprCorrelations))
{
GPOS_ASSERT(NULL == pexprRelational);
return false;
}
// assemble new project
COperator *pop = pexpr->Pop();
pop->AddRef();
pexprPrjList->AddRef();
*ppexprDecorrelated = GPOS_NEW(pmp) CExpression(pmp, pop, pexprRelational, pexprPrjList);
return true;
}
示例6: CColRefSet
//---------------------------------------------------------------------------
// @function:
// CXformSimplifyGbAgg::FDropGbAgg
//
// @doc:
// Return true if GbAgg operator can be dropped because grouping
// columns include a key
//
//---------------------------------------------------------------------------
BOOL
CXformSimplifyGbAgg::FDropGbAgg
(
IMemoryPool *pmp,
CExpression *pexpr,
CXformResult *pxfres
)
{
CLogicalGbAgg *popAgg = CLogicalGbAgg::PopConvert(pexpr->Pop());
CExpression *pexprRelational = (*pexpr)[0];
CExpression *pexprProjectList = (*pexpr)[1];
if (0 < pexprProjectList->UlArity())
{
// GbAgg cannot be dropped if Agg functions are computed
return false;
}
CKeyCollection *pkc = CDrvdPropRelational::Pdprel(pexprRelational->PdpDerive())->Pkc();
if (NULL == pkc)
{
// relational child does not have key
return false;
}
const ULONG ulKeys = pkc->UlKeys();
BOOL fDrop = false;
for (ULONG ul = 0; !fDrop && ul < ulKeys; ul++)
{
DrgPcr *pdrgpcrKey = pkc->PdrgpcrKey(pmp, ul);
CColRefSet *pcrs = GPOS_NEW(pmp) CColRefSet(pmp, pdrgpcrKey);
pdrgpcrKey->Release();
CColRefSet *pcrsGrpCols = GPOS_NEW(pmp) CColRefSet(pmp);
pcrsGrpCols->Include(popAgg->Pdrgpcr());
BOOL fGrpColsHasKey = pcrsGrpCols->FSubset(pcrs);
pcrs->Release();
pcrsGrpCols->Release();
if (fGrpColsHasKey)
{
// Gb operator can be dropped
pexprRelational->AddRef();
CExpression *pexprResult =
CUtils::PexprLogicalSelect(pmp, pexprRelational, CPredicateUtils::PexprConjunction(pmp, NULL));
pxfres->Add(pexprResult);
fDrop = true;
}
}
return fDrop;
}
示例7: CLogicalInnerJoin
//---------------------------------------------------------------------------
// @function:
// CNormalizer::FSimplifySelectOnOuterJoin
//
// @doc:
// A SELECT on top of LOJ, where SELECT's predicate is NULL-filtering and
// uses columns from LOJ's inner child, is simplified as Inner-Join
//
// Example:
//
// select * from (select * from R left join S on r1=s1) as foo where foo.s1>0;
//
// is converted to:
//
// select * from R inner join S on r1=s1 and s1>0;
//
//
//
//---------------------------------------------------------------------------
BOOL
CNormalizer::FSimplifySelectOnOuterJoin
(
IMemoryPool *pmp,
CExpression *pexprOuterJoin,
CExpression *pexprPred, // selection predicate
CExpression **ppexprResult
)
{
GPOS_ASSERT(NULL != pmp);
GPOS_ASSERT(COperator::EopLogicalLeftOuterJoin == pexprOuterJoin->Pop()->Eopid());
GPOS_ASSERT(pexprPred->Pop()->FScalar());
GPOS_ASSERT(NULL != ppexprResult);
if (0 == pexprOuterJoin->UlArity())
{
// exit early for leaf patterns extracted from memo
*ppexprResult = NULL;
return false;
}
CExpression *pexprOuterJoinOuterChild = (*pexprOuterJoin)[0];
CExpression *pexprOuterJoinInnerChild = (*pexprOuterJoin)[1];
CExpression *pexprOuterJoinPred = (*pexprOuterJoin)[2];
CColRefSet *pcrsOutput = CDrvdPropRelational::Pdprel(pexprOuterJoinInnerChild->PdpDerive())->PcrsOutput();
if (!GPOS_FTRACE(EopttraceDisableOuterJoin2InnerJoinRewrite) &&
CPredicateUtils::FNullRejecting(pmp, pexprPred, pcrsOutput))
{
// we have a predicate on top of LOJ that uses LOJ's inner child,
// if the predicate filters-out nulls, we can add it to the join
// predicate and turn LOJ into Inner-Join
pexprOuterJoinOuterChild->AddRef();
pexprOuterJoinInnerChild->AddRef();
*ppexprResult = GPOS_NEW(pmp) CExpression
(
pmp,
GPOS_NEW(pmp) CLogicalInnerJoin(pmp),
pexprOuterJoinOuterChild,
pexprOuterJoinInnerChild,
CPredicateUtils::PexprConjunction(pmp, pexprPred, pexprOuterJoinPred)
);
return true;
}
// failed to convert LOJ to inner-join
return false;
}
示例8: GPOS_NEW
//---------------------------------------------------------------------------
// @function:
// CXformGbAggWithMDQA2Join::PexprMDQAs2Join
//
// @doc:
// Converts GbAgg with multiple distinct aggregates into a join of single
// distinct aggregates,
//
// distinct aggregates that share the same argument are grouped together
// in one leaf of the generated join expression,
//
// non-distinct aggregates are also grouped together in one leaf of the
// generated join expression
//
//---------------------------------------------------------------------------
CExpression *
CXformGbAggWithMDQA2Join::PexprMDQAs2Join
(
IMemoryPool *pmp,
CExpression *pexpr
)
{
GPOS_ASSERT(NULL != pexpr);
GPOS_ASSERT(COperator::EopLogicalGbAgg == pexpr->Pop()->Eopid());
GPOS_ASSERT(CDrvdPropScalar::Pdpscalar((*pexpr)[1]->PdpDerive())->FHasMultipleDistinctAggs());
// extract components
CExpression *pexprChild = (*pexpr)[0];
CColRefSet *pcrsChildOutput = CDrvdPropRelational::Pdprel(pexprChild->PdpDerive())->PcrsOutput();
DrgPcr *pdrgpcrChildOutput = pcrsChildOutput->Pdrgpcr(pmp);
// create a CTE producer based on child expression
CCTEInfo *pcteinfo = COptCtxt::PoctxtFromTLS()->Pcteinfo();
const ULONG ulCTEId = pcteinfo->UlNextId();
(void) CXformUtils::PexprAddCTEProducer(pmp, ulCTEId, pdrgpcrChildOutput, pexprChild);
// create a CTE consumer with child output columns
CExpression *pexprConsumer =
GPOS_NEW(pmp) CExpression
(
pmp,
GPOS_NEW(pmp) CLogicalCTEConsumer(pmp, ulCTEId, pdrgpcrChildOutput)
);
pcteinfo->IncrementConsumers(ulCTEId);
// finalize GbAgg expression by replacing its child with CTE consumer
pexpr->Pop()->AddRef();
(*pexpr)[1]->AddRef();
CExpression *pexprGbAggWithConsumer = GPOS_NEW(pmp) CExpression(pmp, pexpr->Pop(), pexprConsumer, (*pexpr)[1]);
CExpression *pexprJoinDQAs = CXformUtils::PexprGbAggOnCTEConsumer2Join(pmp, pexprGbAggWithConsumer);
GPOS_ASSERT(NULL != pexprJoinDQAs);
pexprGbAggWithConsumer->Release();
return GPOS_NEW(pmp) CExpression
(
pmp,
GPOS_NEW(pmp) CLogicalCTEAnchor(pmp, ulCTEId),
pexprJoinDQAs
);
}
示例9: GPOS_NEW
//---------------------------------------------------------------------------
// @function:
// CStatsPredUtils::PstatspredConj
//
// @doc:
// Create conjunctive statistics filter composed of the extracted
// components of the conjunction
//---------------------------------------------------------------------------
CStatsPred *
CStatsPredUtils::PstatspredConj
(
IMemoryPool *pmp,
CExpression *pexprScalar,
CColRefSet *pcrsOuterRefs
)
{
GPOS_ASSERT(NULL != pexprScalar);
DrgPexpr *pdrgpexprConjuncts = CPredicateUtils::PdrgpexprConjuncts(pmp, pexprScalar);
const ULONG ulLen = pdrgpexprConjuncts->UlLength();
DrgPstatspred *pdrgpstatspred = GPOS_NEW(pmp) DrgPstatspred(pmp);
for (ULONG ul = 0; ul < ulLen; ul++)
{
CExpression *pexprPred = (*pdrgpexprConjuncts)[ul];
CColRefSet *pcrsUsed = CDrvdPropScalar::Pdpscalar(pexprPred->PdpDerive())->PcrsUsed();
if (NULL != pcrsOuterRefs && pcrsOuterRefs->FSubset(pcrsUsed))
{
// skip predicate with outer references
continue;
}
if (CPredicateUtils::FOr(pexprPred))
{
CStatsPred *pstatspredDisj = PstatspredDisj(pmp, pexprPred, pcrsOuterRefs);
if (NULL != pstatspredDisj)
{
pdrgpstatspred->Append(pstatspredDisj);
}
}
else
{
AddSupportedStatsFilters(pmp, pdrgpstatspred, pexprPred, pcrsOuterRefs);
}
}
pdrgpexprConjuncts->Release();
if (0 < pdrgpstatspred->UlLength())
{
return GPOS_NEW(pmp) CStatsPredConj(pdrgpstatspred);
}
pdrgpstatspred->Release();
return NULL;
}
示例10: PpartinfoCombine
//---------------------------------------------------------------------------
// @function:
// CLogicalCTEAnchor::PpartinfoDerive
//
// @doc:
// Derive part consumer
//
//---------------------------------------------------------------------------
CPartInfo *
CLogicalCTEAnchor::PpartinfoDerive
(
IMemoryPool *pmp,
CExpressionHandle &exprhdl
)
const
{
CPartInfo *ppartinfoChild = exprhdl.Pdprel(0 /*ulChildIndex*/)->Ppartinfo();
GPOS_ASSERT(NULL != ppartinfoChild);
CExpression *pexprProducer = COptCtxt::PoctxtFromTLS()->Pcteinfo()->PexprCTEProducer(m_ulId);
GPOS_ASSERT(NULL != pexprProducer);
CPartInfo *ppartinfoCTEProducer = CDrvdPropRelational::Pdprel(pexprProducer->PdpDerive())->Ppartinfo();
return CPartInfo::PpartinfoCombine(pmp, ppartinfoChild, ppartinfoCTEProducer);
}
示例11: DrgPdp
//---------------------------------------------------------------------------
// @function:
// CExpressionHandle::DeriveProps
//
// @doc:
// Recursive property derivation
//
//---------------------------------------------------------------------------
void
CExpressionHandle::DeriveProps
(
CDrvdPropCtxt *pdpctxt
)
{
GPOS_ASSERT(NULL == m_pdrgpdp);
GPOS_ASSERT(NULL == m_pdp);
GPOS_CHECK_ABORT;
if (NULL != m_pgexpr)
{
CopyGroupProps();
return;
}
GPOS_ASSERT(NULL != m_pexpr);
// check if expression already has derived props
if (NULL != m_pexpr->Pdp(m_pexpr->Ept()))
{
CopyExprProps();
return;
}
// copy stats of attached expression
CopyStats();
// extract children's properties
m_pdrgpdp = GPOS_NEW(m_pmp) DrgPdp(m_pmp);
const ULONG ulArity = m_pexpr->UlArity();
for (ULONG ul = 0; ul < ulArity; ul++)
{
CExpression *pexprChild = (*m_pexpr)[ul];
CDrvdProp *pdp = pexprChild->PdpDerive(pdpctxt);
pdp->AddRef();
m_pdrgpdp->Append(pdp);
// add child props to derivation context
CDrvdPropCtxt::AddDerivedProps(pdp, pdpctxt);
}
// create/derive local properties
m_pdp = Pop()->PdpCreate(m_pmp);
m_pdp->Derive(m_pmp, *this, pdpctxt);
}
示例12: CLogicalConstTableGet
//---------------------------------------------------------------------------
// @function:
// CXformSimplifyLeftOuterJoin::Transform
//
// @doc:
// Actual transformation to simplify left outer join
//
//---------------------------------------------------------------------------
void
CXformSimplifyLeftOuterJoin::Transform
(
CXformContext *pxfctxt,
CXformResult *pxfres,
CExpression *pexpr
)
const
{
GPOS_ASSERT(NULL != pxfctxt);
GPOS_ASSERT(NULL != pxfres);
GPOS_ASSERT(FPromising(pxfctxt->Pmp(), this, pexpr));
GPOS_ASSERT(FCheckPattern(pexpr));
IMemoryPool *pmp = pxfctxt->Pmp();
// extract components
CExpression *pexprOuter = (*pexpr)[0];
CExpression *pexprInner = (*pexpr)[1];
CExpression *pexprScalar = (*pexpr)[2];
pexprOuter->AddRef();
pexprScalar->AddRef();
CExpression *pexprResult = NULL;
// inner child of LOJ can be replaced with empty table
GPOS_ASSERT(CUtils::FScalarConstFalse(pexprScalar));
// extract output columns of inner child
DrgPcr *pdrgpcr = CDrvdPropRelational::Pdprel(pexprInner->PdpDerive())->PcrsOutput()->Pdrgpcr(pmp);
// generate empty constant table with the same columns
COperator *popCTG = GPOS_NEW(pmp) CLogicalConstTableGet(pmp, pdrgpcr, GPOS_NEW(pmp) DrgPdrgPdatum(pmp));
pexprResult =
GPOS_NEW(pmp) CExpression
(
pmp,
GPOS_NEW(pmp) CLogicalLeftOuterJoin(pmp),
pexprOuter,
GPOS_NEW(pmp) CExpression(pmp, popCTG),
pexprScalar
);
pxfres->Add(pexprResult);
}
示例13: DrgPexpr
//---------------------------------------------------------------------------
// @function:
// CPartitionPropagationSpec::PdrgpexprPredicatesOnKey
//
// @doc:
// Returns an array of predicates on the given partitioning key given
// an array of predicates on all keys
//
//---------------------------------------------------------------------------
DrgPexpr *
CPartitionPropagationSpec::PdrgpexprPredicatesOnKey
(
IMemoryPool *pmp,
DrgPexpr *pdrgpexpr,
CColRef *pcr,
CColRefSet *pcrsKeys,
CBitSet **ppbs
)
{
GPOS_ASSERT(NULL != pdrgpexpr);
GPOS_ASSERT(NULL != pcr);
GPOS_ASSERT(NULL != ppbs);
GPOS_ASSERT(NULL != *ppbs);
DrgPexpr *pdrgpexprResult = GPOS_NEW(pmp) DrgPexpr(pmp);
const ULONG ulLen = pdrgpexpr->UlLength();
for (ULONG ul = 0; ul < ulLen; ul++)
{
if ((*ppbs)->FBit(ul))
{
// this expression has already been added for another column
continue;
}
CExpression *pexpr = (*pdrgpexpr)[ul];
GPOS_ASSERT(pexpr->Pop()->FScalar());
CColRefSet *pcrsUsed = CDrvdPropScalar::Pdpscalar(pexpr->PdpDerive())->PcrsUsed();
CColRefSet *pcrsUsedKeys = GPOS_NEW(pmp) CColRefSet(pmp, *pcrsUsed);
pcrsUsedKeys->Intersection(pcrsKeys);
if (1 == pcrsUsedKeys->CElements() && pcrsUsedKeys->FMember(pcr))
{
pexpr->AddRef();
pdrgpexprResult->Append(pexpr);
(*ppbs)->FExchangeSet(ul);
}
pcrsUsedKeys->Release();
}
return pdrgpexprResult;
}
示例14: CExpressionArray
//---------------------------------------------------------------------------
// @function:
// CPartitionPropagationSpec::PdrgpexprPredicatesOnKey
//
// @doc:
// Returns an array of predicates on the given partitioning key given
// an array of predicates on all keys
//
//---------------------------------------------------------------------------
CExpressionArray *
CPartitionPropagationSpec::PdrgpexprPredicatesOnKey
(
IMemoryPool *mp,
CExpressionArray *pdrgpexpr,
CColRef *colref,
CColRefSet *pcrsKeys,
CBitSet **ppbs
)
{
GPOS_ASSERT(NULL != pdrgpexpr);
GPOS_ASSERT(NULL != colref);
GPOS_ASSERT(NULL != ppbs);
GPOS_ASSERT(NULL != *ppbs);
CExpressionArray *pdrgpexprResult = GPOS_NEW(mp) CExpressionArray(mp);
const ULONG length = pdrgpexpr->Size();
for (ULONG ul = 0; ul < length; ul++)
{
if ((*ppbs)->Get(ul))
{
// this expression has already been added for another column
continue;
}
CExpression *pexpr = (*pdrgpexpr)[ul];
GPOS_ASSERT(pexpr->Pop()->FScalar());
CColRefSet *pcrsUsed = CDrvdPropScalar::GetDrvdScalarProps(pexpr->PdpDerive())->PcrsUsed();
CColRefSet *pcrsUsedKeys = GPOS_NEW(mp) CColRefSet(mp, *pcrsUsed);
pcrsUsedKeys->Intersection(pcrsKeys);
if (1 == pcrsUsedKeys->Size() && pcrsUsedKeys->FMember(colref))
{
pexpr->AddRef();
pdrgpexprResult->Append(pexpr);
(*ppbs)->ExchangeSet(ul);
}
pcrsUsedKeys->Release();
}
return pdrgpexprResult;
}
示例15:
//---------------------------------------------------------------------------
// @function:
// CDecorrelator::FProcessAssert
//
// @doc:
// Decorrelate assert operator
//
//---------------------------------------------------------------------------
BOOL
CDecorrelator::FProcessAssert
(
IMemoryPool *pmp,
CExpression *pexpr,
BOOL fEqualityOnly,
CExpression **ppexprDecorrelated,
DrgPexpr *pdrgpexprCorrelations
)
{
GPOS_ASSERT(NULL != pexpr);
COperator *pop = pexpr->Pop();
GPOS_ASSERT(COperator::EopLogicalAssert == pop->Eopid());
CExpression *pexprScalar = (*pexpr)[1];
// fail if assert expression has outer references
CColRefSet *pcrsOutput = CDrvdPropRelational::Pdprel((*pexpr)[0]->PdpDerive())->PcrsOutput();
CColRefSet *pcrsUsed = CDrvdPropScalar::Pdpscalar(pexprScalar->PdpDerive())->PcrsUsed();
if (!pcrsOutput->FSubset(pcrsUsed))
{
return false;
}
// decorrelate relational child
CExpression *pexprRelational = NULL;
if (!FProcess(pmp, (*pexpr)[0], fEqualityOnly, &pexprRelational, pdrgpexprCorrelations))
{
GPOS_ASSERT(NULL == pexprRelational);
return false;
}
// assemble new project
pop->AddRef();
pexprScalar->AddRef();
*ppexprDecorrelated = GPOS_NEW(pmp) CExpression(pmp, pop, pexprRelational, pexprScalar);
return true;
}