本文整理汇总了C++中DrgPexpr::UlLength方法的典型用法代码示例。如果您正苦于以下问题:C++ DrgPexpr::UlLength方法的具体用法?C++ DrgPexpr::UlLength怎么用?C++ DrgPexpr::UlLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DrgPexpr
的用法示例。
在下文中一共展示了DrgPexpr::UlLength方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GPOS_NEW
//---------------------------------------------------------------------------
// @function:
// CPhysicalUnionAll::PdshashedPassThru
//
// @doc:
// Compute required hashed distribution of the n-th child
//
//---------------------------------------------------------------------------
CDistributionSpecHashed *
CPhysicalUnionAll::PdshashedPassThru
(
IMemoryPool *pmp,
CDistributionSpecHashed *pdshashedRequired,
ULONG ulChildIndex
)
const
{
DrgPexpr *pdrgpexprRequired = pdshashedRequired->Pdrgpexpr();
DrgPcr *pdrgpcrChild = (*m_pdrgpdrgpcrInput)[ulChildIndex];
const ULONG ulExprs = pdrgpexprRequired->UlLength();
const ULONG ulOutputCols = m_pdrgpcrOutput->UlLength();
DrgPexpr *pdrgpexprChildRequired = GPOS_NEW(pmp) DrgPexpr(pmp);
for (ULONG ulExpr = 0; ulExpr < ulExprs; ulExpr++)
{
CExpression *pexpr = (*pdrgpexprRequired)[ulExpr];
if (COperator::EopScalarIdent != pexpr->Pop()->Eopid())
{
// skip expressions that are not in form of scalar identifiers
continue;
}
const CColRef *pcrHashed = CScalarIdent::PopConvert(pexpr->Pop())->Pcr();
const IMDType *pmdtype = pcrHashed->Pmdtype();
if (!pmdtype->FHashable())
{
// skip non-hashable columns
continue;
}
for (ULONG ulCol = 0; ulCol < ulOutputCols; ulCol++)
{
const CColRef *pcrOutput = (*m_pdrgpcrOutput)[ulCol];
if (pcrOutput == pcrHashed)
{
const CColRef *pcrInput = (*pdrgpcrChild)[ulCol];
pdrgpexprChildRequired->Append(CUtils::PexprScalarIdent(pmp, pcrInput));
}
}
}
if (0 < pdrgpexprChildRequired->UlLength())
{
return GPOS_NEW(pmp) CDistributionSpecHashed(pdrgpexprChildRequired, true /* fNullsCollocated */);
}
// failed to create a matching hashed distribution
pdrgpexprChildRequired->Release();
if (NULL != pdshashedRequired->PdshashedEquiv())
{
// try again with equivalent distribution
return PdshashedPassThru(pmp, pdshashedRequired->PdshashedEquiv(), ulChildIndex);
}
// failed to create hashed distribution
return NULL;
}
示例2: if
//---------------------------------------------------------------------------
// @function:
// CStatsPredUtils::PdrgpstatsjoinExtract
//
// @doc:
// Helper function to extract array of statistics join filter
// from an array of join predicates
//
//---------------------------------------------------------------------------
DrgPstatsjoin *
CStatsPredUtils::PdrgpstatsjoinExtract
(
IMemoryPool *pmp,
CExpression *pexprScalar,
DrgPcrs *pdrgpcrsOutput, // array of output columns of join's relational inputs
CColRefSet *pcrsOuterRefs,
CStatsPred **ppstatspredUnsupported
)
{
GPOS_ASSERT(NULL != pexprScalar);
GPOS_ASSERT(NULL != pdrgpcrsOutput);
DrgPstatsjoin *pdrgpstatsjoin = GPOS_NEW(pmp) DrgPstatsjoin(pmp);
DrgPexpr *pdrgpexprUnsupported = GPOS_NEW(pmp) DrgPexpr(pmp);
// extract all the conjuncts
DrgPexpr *pdrgpexprConjuncts = CPredicateUtils::PdrgpexprConjuncts(pmp, pexprScalar);
const ULONG ulSize = pdrgpexprConjuncts->UlLength();
for (ULONG ul = 0; ul < ulSize; ul++)
{
CExpression *pexprPred = (*pdrgpexprConjuncts) [ul];
CStatisticsJoin *pstatsjoin = PstatsjoinExtract
(
pmp,
pexprPred,
pdrgpcrsOutput,
pcrsOuterRefs,
pdrgpexprUnsupported
);
if (NULL != pstatsjoin)
{
pdrgpstatsjoin->Append(pstatsjoin);
}
}
const ULONG ulUnsupported = pdrgpexprUnsupported->UlLength();
if (1 == ulUnsupported)
{
*ppstatspredUnsupported = CStatsPredUtils::PstatspredExtract(pmp, (*pdrgpexprUnsupported)[0], pcrsOuterRefs);
}
else if (1 < ulUnsupported)
{
pdrgpexprUnsupported->AddRef();
CExpression *pexprConj = CPredicateUtils::PexprConjDisj(pmp, pdrgpexprUnsupported, true /* fConjunction */);
*ppstatspredUnsupported = CStatsPredUtils::PstatspredExtract(pmp, pexprConj, pcrsOuterRefs);
pexprConj->Release();
}
// clean up
pdrgpexprUnsupported->Release();
pdrgpexprConjuncts->Release();
return pdrgpstatsjoin;
}
示例3:
//---------------------------------------------------------------------------
// @function:
// CNormalizer::SplitConjunctForSeqPrj
//
// @doc:
// Split the given conjunct into pushable and unpushable predicates
// for a sequence project expression
//
//---------------------------------------------------------------------------
void
CNormalizer::SplitConjunctForSeqPrj
(
IMemoryPool *pmp,
CExpression *pexprSeqPrj,
CExpression *pexprConj,
DrgPexpr **ppdrgpexprPushable,
DrgPexpr **ppdrgpexprUnpushable
)
{
GPOS_ASSERT(NULL != pexprSeqPrj);
GPOS_ASSERT(NULL != pexprConj);
GPOS_ASSERT(NULL != ppdrgpexprPushable);
GPOS_ASSERT(NULL != ppdrgpexprUnpushable);
*ppdrgpexprPushable = GPOS_NEW(pmp) DrgPexpr(pmp);
*ppdrgpexprUnpushable = GPOS_NEW(pmp) DrgPexpr(pmp);
DrgPexpr *pdrgpexprPreds = CPredicateUtils::PdrgpexprConjuncts(pmp, pexprConj);
const ULONG ulPreds = pdrgpexprPreds->UlLength();
for (ULONG ul = 0; ul < ulPreds; ul++)
{
CExpression *pexprPred = (*pdrgpexprPreds)[ul];
pexprPred->AddRef();
if (FPushableThruSeqPrjChild(pexprSeqPrj, pexprPred))
{
(*ppdrgpexprPushable)->Append(pexprPred);
}
else
{
(*ppdrgpexprUnpushable)->Append(pexprPred);
}
}
pdrgpexprPreds->Release();
}
示例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:
//---------------------------------------------------------------------------
// @function:
// CStatsPredUtils::FConjunction
//
// @doc:
// Is the condition a conjunctive predicate
//---------------------------------------------------------------------------
BOOL
CStatsPredUtils::FConjunction
(
IMemoryPool *pmp,
CExpression *pexprPred
)
{
GPOS_ASSERT(NULL != pexprPred);
DrgPexpr *pdrgpexprConjuncts = CPredicateUtils::PdrgpexprConjuncts(pmp, pexprPred);
const ULONG ulLen = pdrgpexprConjuncts->UlLength();
pdrgpexprConjuncts->Release();
return (1 < ulLen);
}
示例6:
//---------------------------------------------------------------------------
// @function:
// CLogicalInnerJoin::FFewerConj
//
// @doc:
// Compare two innerJoin group expressions, test whether the first one
// has less join predicates than the second one. This is used to
// prioritize innerJoin with less predicates for stats derivation
//
//---------------------------------------------------------------------------
BOOL
CLogicalInnerJoin::FFewerConj
(
IMemoryPool *pmp,
CGroupExpression *pgexprFst,
CGroupExpression *pgexprSnd
)
{
if (NULL == pgexprFst || NULL == pgexprSnd)
{
return false;
}
if (COperator::EopLogicalInnerJoin != pgexprFst->Pop()->Eopid() ||
COperator::EopLogicalInnerJoin != pgexprSnd->Pop()->Eopid())
{
return false;
}
// third child must be the group for join conditions
CGroup *pgroupScalarFst = (*pgexprFst)[2];
CGroup *pgroupScalarSnd = (*pgexprSnd)[2];
GPOS_ASSERT(pgroupScalarFst->FScalar());
GPOS_ASSERT(pgroupScalarSnd->FScalar());
DrgPexpr *pdrgpexprConjFst = CPredicateUtils::PdrgpexprConjuncts(pmp, pgroupScalarFst->PexprScalar());
DrgPexpr *pdrgpexprConjSnd = CPredicateUtils::PdrgpexprConjuncts(pmp, pgroupScalarSnd->PexprScalar());
ULONG ulConjFst = pdrgpexprConjFst->UlLength();
ULONG ulConjSnd = pdrgpexprConjSnd->UlLength();
pdrgpexprConjFst->Release();
pdrgpexprConjSnd->Release();
return ulConjFst < ulConjSnd;
}
示例7: 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;
}
示例8:
//---------------------------------------------------------------------------
// @function:
// CPhysicalJoin::FHashJoinPossible
//
// @doc:
// Check if predicate is hashjoin-able and extract arrays of hash keys
//
//---------------------------------------------------------------------------
BOOL
CPhysicalJoin::FHashJoinPossible
(
IMemoryPool *pmp,
CExpression *pexpr,
DrgPexpr *pdrgpexprOuter,
DrgPexpr *pdrgpexprInner,
CExpression **ppexprResult // output : join expression to be transformed to hash join
)
{
GPOS_ASSERT(COperator::EopLogicalNAryJoin != pexpr->Pop()->Eopid() &&
CUtils::FLogicalJoin(pexpr->Pop()));
// we should not be here if there are outer references
GPOS_ASSERT(!CUtils::FHasOuterRefs(pexpr));
GPOS_ASSERT(NULL != ppexprResult);
// introduce explicit casting, if needed
DrgPexpr *pdrgpexpr = CPredicateUtils::PdrgpexprCastEquality(pmp, (*pexpr)[2]);
// identify hashkeys
ULONG ulPreds = pdrgpexpr->UlLength();
for (ULONG ul = 0; ul < ulPreds; ul++)
{
CExpression *pexprPred = (*pdrgpexpr)[ul];
if (FHashJoinCompatible(pexprPred, (*pexpr)[0], (*pexpr)[1]))
{
AddHashKeys(pexprPred, (*pexpr)[0], (*pexpr)[1], pdrgpexprOuter, pdrgpexprInner);
}
}
// construct output join expression
pexpr->Pop()->AddRef();
(*pexpr)[0]->AddRef();
(*pexpr)[1]->AddRef();
*ppexprResult =
GPOS_NEW(pmp) CExpression
(
pmp,
pexpr->Pop(),
(*pexpr)[0],
(*pexpr)[1],
CPredicateUtils::PexprConjunction(pmp, pdrgpexpr)
);
return (0 != pdrgpexprInner->UlLength());
}
示例9: PexprNormalize
//---------------------------------------------------------------------------
// @function:
// CNormalizer::PushThruSeqPrj
//
// @doc:
// Push a conjunct through a sequence project expression
//
//---------------------------------------------------------------------------
void
CNormalizer::PushThruSeqPrj
(
IMemoryPool *pmp,
CExpression *pexprSeqPrj,
CExpression *pexprConj,
CExpression **ppexprResult
)
{
GPOS_ASSERT(NULL != pexprSeqPrj);
GPOS_ASSERT(CLogical::EopLogicalSequenceProject == pexprSeqPrj->Pop()->Eopid());
GPOS_ASSERT(NULL != pexprConj);
GPOS_ASSERT(NULL != ppexprResult);
// get logical and scalar children
CExpression *pexprLogicalChild = (*pexprSeqPrj)[0];
CExpression *pexprScalarChild = (*pexprSeqPrj)[1];
// break scalar expression to pushable and unpushable conjuncts
DrgPexpr *pdrgpexprPushable = NULL;
DrgPexpr *pdrgpexprUnpushable = NULL;
SplitConjunctForSeqPrj(pmp, pexprSeqPrj, pexprConj, &pdrgpexprPushable, &pdrgpexprUnpushable);
CExpression *pexprNewLogicalChild = NULL;
if (0 < pdrgpexprPushable->UlLength())
{
CExpression *pexprPushableConj = CPredicateUtils::PexprConjunction(pmp, pdrgpexprPushable);
PushThru(pmp, pexprLogicalChild, pexprPushableConj, &pexprNewLogicalChild);
pexprPushableConj->Release();
}
else
{
// no pushable predicates on top of sequence project,
// we still need to process child recursively to push-down child's own predicates
pdrgpexprPushable->Release();
pexprNewLogicalChild = PexprNormalize(pmp, pexprLogicalChild);
}
// create a new logical expression based on recursion results
COperator *pop = pexprSeqPrj->Pop();
pop->AddRef();
pexprScalarChild->AddRef();
CExpression *pexprNewLogical = GPOS_NEW(pmp) CExpression(pmp, pop, pexprNewLogicalChild, pexprScalarChild);
// create a select node for remaining predicates, if any
*ppexprResult = PexprSelect(pmp, pexprNewLogical, pdrgpexprUnpushable);
}
示例10: DrgPds
//---------------------------------------------------------------------------
// @function:
// CPhysicalHashJoin::CreateHashRedistributeRequests
//
// @doc:
// Create the set of redistribute requests to send to first
// hash join child
//
//---------------------------------------------------------------------------
void
CPhysicalHashJoin::CreateHashRedistributeRequests
(
IMemoryPool *pmp
)
{
GPOS_ASSERT(NULL == m_pdrgpdsRedistributeRequests);
GPOS_ASSERT(NULL != m_pdrgpexprOuterKeys);
GPOS_ASSERT(NULL != m_pdrgpexprInnerKeys);
DrgPexpr *pdrgpexpr = NULL;
if (EceoRightToLeft == Eceo())
{
pdrgpexpr = m_pdrgpexprInnerKeys;
}
else
{
pdrgpexpr = m_pdrgpexprOuterKeys;
}
m_pdrgpdsRedistributeRequests = GPOS_NEW(pmp) DrgPds(pmp);
const ULONG ulExprs = std::min((ULONG) GPOPT_MAX_HASH_DIST_REQUESTS, pdrgpexpr->UlLength());
if (1 < ulExprs)
{
for (ULONG ul = 0; ul < ulExprs; ul++)
{
DrgPexpr *pdrgpexprCurrent = GPOS_NEW(pmp) DrgPexpr(pmp);
CExpression *pexpr = (*pdrgpexpr)[ul];
pexpr->AddRef();
pdrgpexprCurrent->Append(pexpr);
// add a separate request for each hash join key
// TODO: - Dec 30, 2011; change fNullsColocated to false when our
// distribution matching can handle differences in NULL colocation
CDistributionSpecHashed *pdshashedCurrent = GPOS_NEW(pmp) CDistributionSpecHashed(pdrgpexprCurrent, true /* fNullsCollocated */);
m_pdrgpdsRedistributeRequests->Append(pdshashedCurrent);
}
}
// add a request that contains all hash join keys
pdrgpexpr->AddRef();
CDistributionSpecHashed *pdshashed = GPOS_NEW(pmp) CDistributionSpecHashed(pdrgpexpr, true /* fNullsCollocated */);
m_pdrgpdsRedistributeRequests->Append(pdshashed);
}
示例11: DrgPexpr
//---------------------------------------------------------------------------
// @function:
// CCNFConverter::Expand
//
// @doc:
// Recursively compute cross product over input array of arrays;
// convert each cross product result to a conjunct and store it in
// output array
//
//---------------------------------------------------------------------------
void
CCNFConverter::Expand
(
IMemoryPool *pmp,
DrgPdrgPexpr *pdrgpdrgpexprInput, // input array of arrays
DrgPexpr *pdrgpexprOutput, // output array
DrgPexpr *pdrgpexprToExpand, // a cross product result to be expanded
ULONG ulCurrent // index of current array to be used for expanding a cross product result
)
{
GPOS_CHECK_STACK_SIZE;
GPOS_ASSERT(ulCurrent <= pdrgpdrgpexprInput->UlLength());
if (ulCurrent == pdrgpdrgpexprInput->UlLength())
{
// exhausted input, add a new conjunct to output array
pdrgpexprOutput->Append(CPredicateUtils::PexprDisjunction(pmp, pdrgpexprToExpand));
return;
}
DrgPexpr *pdrgpexprCurrent = (*pdrgpdrgpexprInput)[ulCurrent];
const ULONG ulArity = pdrgpexprCurrent->UlLength();
for (ULONG ul = 0; ul < ulArity; ul++)
{
// append accumulated expressions to a new array
DrgPexpr *pdrgpexpr = GPOS_NEW(pmp) DrgPexpr(pmp);
CUtils::AddRefAppend<CExpression, CleanupRelease>(pdrgpexpr, pdrgpexprToExpand);
// add an expression from current input array only if it's not equal to an existing one
if (!CUtils::FEqualAny((*pdrgpexprCurrent)[ul], pdrgpexpr))
{
CExpression *pexpr = (*pdrgpexprCurrent)[ul];
pexpr->AddRef();
pdrgpexpr->Append(pexpr);
}
// recursively expand the resulting array
Expand(pmp, pdrgpdrgpexprInput, pdrgpexprOutput, pdrgpexpr, ulCurrent + 1);
}
pdrgpexprToExpand->Release();
}
示例12: GPOS_NEW
//---------------------------------------------------------------------------
// @function:
// CDistributionSpecHashed::PdshashedExcludeColumns
//
// @doc:
// Return a copy of the distribution spec after excluding the given
// columns, return NULL if all distribution expressions are excluded
//
//---------------------------------------------------------------------------
CDistributionSpecHashed *
CDistributionSpecHashed::PdshashedExcludeColumns
(
IMemoryPool *pmp,
CColRefSet *pcrs
)
{
GPOS_ASSERT(NULL != pcrs);
DrgPexpr *pdrgpexprNew = GPOS_NEW(pmp) DrgPexpr(pmp);
const ULONG ulExprs = m_pdrgpexpr->UlLength();
for (ULONG ul = 0; ul < ulExprs; ul++)
{
CExpression *pexpr = (*m_pdrgpexpr)[ul];
COperator *pop = pexpr->Pop();
if (COperator::EopScalarIdent == pop->Eopid())
{
// we only care here about column identifiers,
// any more complicated expressions are copied to output
const CColRef *pcr = CScalarIdent::PopConvert(pop)->Pcr();
if (pcrs->FMember(pcr))
{
continue;
}
}
pexpr->AddRef();
pdrgpexprNew->Append(pexpr);
}
if (0 == pdrgpexprNew->UlLength())
{
pdrgpexprNew->Release();
return NULL;
}
return GPOS_NEW(pmp) CDistributionSpecHashed(pdrgpexprNew, m_fNullsColocated);
}
示例13: DrgDrgPcr
//---------------------------------------------------------------------------
// @function:
// CXformSelect2PartialDynamicIndexGet::CreatePartialIndexGetPlan
//
// @doc:
// Create a plan as a union of the given partial index get candidates and
// possibly a dynamic table scan
//
//---------------------------------------------------------------------------
void
CXformSelect2PartialDynamicIndexGet::CreatePartialIndexGetPlan
(
IMemoryPool *pmp,
CExpression *pexpr,
DrgPpartdig *pdrgppartdig,
const IMDRelation *pmdrel,
CXformResult *pxfres
)
const
{
CExpression *pexprRelational = (*pexpr)[0];
CExpression *pexprScalar = (*pexpr)[1];
CLogicalDynamicGet *popGet = CLogicalDynamicGet::PopConvert(pexprRelational->Pop());
DrgPcr *pdrgpcrGet = popGet->PdrgpcrOutput();
const ULONG ulPartialIndexes = pdrgppartdig->UlLength();
DrgDrgPcr *pdrgpdrgpcrInput = GPOS_NEW(pmp) DrgDrgPcr(pmp);
DrgPexpr *pdrgpexprInput = GPOS_NEW(pmp) DrgPexpr(pmp);
for (ULONG ul = 0; ul < ulPartialIndexes; ul++)
{
SPartDynamicIndexGetInfo *ppartdig = (*pdrgppartdig)[ul];
const IMDIndex *pmdindex = ppartdig->m_pmdindex;
CPartConstraint *ppartcnstr = ppartdig->m_ppartcnstr;
DrgPexpr *pdrgpexprIndex = ppartdig->m_pdrgpexprIndex;
DrgPexpr *pdrgpexprResidual = ppartdig->m_pdrgpexprResidual;
DrgPcr *pdrgpcrNew = pdrgpcrGet;
if (0 < ul)
{
pdrgpcrNew = CUtils::PdrgpcrCopy(pmp, pdrgpcrGet);
}
else
{
pdrgpcrNew->AddRef();
}
CExpression *pexprDynamicScan = NULL;
if (NULL != pmdindex)
{
pexprDynamicScan = CXformUtils::PexprPartialDynamicIndexGet
(
pmp,
popGet,
pexpr->Pop()->UlOpId(),
pdrgpexprIndex,
pdrgpexprResidual,
pdrgpcrNew,
pmdindex,
pmdrel,
ppartcnstr,
NULL, // pcrsAcceptedOuterRefs
NULL, // pdrgpcrOuter
NULL // pdrgpcrNewOuter
);
}
else
{
pexprDynamicScan = PexprSelectOverDynamicGet
(
pmp,
popGet,
pexprScalar,
pdrgpcrNew,
ppartcnstr
);
}
GPOS_ASSERT(NULL != pexprDynamicScan);
pdrgpdrgpcrInput->Append(pdrgpcrNew);
pdrgpexprInput->Append(pexprDynamicScan);
}
ULONG ulInput = pdrgpexprInput->UlLength();
if (0 < ulInput)
{
CExpression *pexprResult = NULL;
if (1 < ulInput)
{
pdrgpcrGet->AddRef();
DrgPcr *pdrgpcrOuter = pdrgpcrGet;
// construct a new union all operator
pexprResult = GPOS_NEW(pmp) CExpression
(
pmp,
GPOS_NEW(pmp) CLogicalUnionAll(pmp, pdrgpcrOuter, pdrgpdrgpcrInput, popGet->UlScanId()),
//.........这里部分代码省略.........
示例14: CBitSet
//---------------------------------------------------------------------------
// @function:
// CPartitionPropagationSpec::SplitPartPredicates
//
// @doc:
// Split the partition elimination predicates over the various levels
// as well as the residual predicate and add them to the appropriate
// hashmaps. These are to be used when creating the partition selector
//
//---------------------------------------------------------------------------
void
CPartitionPropagationSpec::SplitPartPredicates
(
IMemoryPool *pmp,
CExpression *pexprScalar,
DrgDrgPcr *pdrgpdrgpcrKeys,
HMUlExpr *phmulexprEqFilter, // output
HMUlExpr *phmulexprFilter, // output
CExpression **ppexprResidual // output
)
{
GPOS_ASSERT(NULL != pexprScalar);
GPOS_ASSERT(NULL != pdrgpdrgpcrKeys);
GPOS_ASSERT(NULL != phmulexprEqFilter);
GPOS_ASSERT(NULL != phmulexprFilter);
GPOS_ASSERT(NULL != ppexprResidual);
GPOS_ASSERT(NULL == *ppexprResidual);
DrgPexpr *pdrgpexprConjuncts = CPredicateUtils::PdrgpexprConjuncts(pmp, pexprScalar);
CBitSet *pbsUsed = GPOS_NEW(pmp) CBitSet(pmp);
CColRefSet *pcrsKeys = PcrsKeys(pmp, pdrgpdrgpcrKeys);
const ULONG ulLevels = pdrgpdrgpcrKeys->UlLength();
for (ULONG ul = 0; ul < ulLevels; ul++)
{
CColRef *pcr = CUtils::PcrExtractPartKey(pdrgpdrgpcrKeys, ul);
// find conjuncts for this key and mark their positions
DrgPexpr *pdrgpexprKey = PdrgpexprPredicatesOnKey(pmp, pdrgpexprConjuncts, pcr, pcrsKeys, &pbsUsed);
const ULONG ulLen = pdrgpexprKey->UlLength();
if (0 == ulLen)
{
// no predicates on this key
pdrgpexprKey->Release();
continue;
}
if (1 < ulLen || (!CPredicateUtils::FEquality((*pdrgpexprKey)[0])))
{
// more than one predicate on this key or one non-equality predicate
#ifdef GPOS_DEBUG
BOOL fResult =
#endif // GPOS_DEBUG
phmulexprFilter->FInsert(GPOS_NEW(pmp) ULONG(ul), CPredicateUtils::PexprConjunction(pmp, pdrgpexprKey));
GPOS_ASSERT(fResult);
continue;
}
// one equality predicate (key = expr); take out the expression
// and add it to the equality filters map
CExpression *pexprPartKey = NULL;
CExpression *pexprOther = NULL;
IMDType::ECmpType ecmpt = IMDType::EcmptOther;
CPredicateUtils::ExtractComponents((*pdrgpexprKey)[0], pcr, &pexprPartKey, &pexprOther, &ecmpt);
GPOS_ASSERT(NULL != pexprOther);
pexprOther->AddRef();
#ifdef GPOS_DEBUG
BOOL fResult =
#endif // GPOS_DEBUG
phmulexprEqFilter->FInsert(GPOS_NEW(pmp) ULONG(ul), pexprOther);
GPOS_ASSERT(fResult);
pdrgpexprKey->Release();
}
(*ppexprResidual) = PexprResidualFilter(pmp, pdrgpexprConjuncts, pbsUsed);
pcrsKeys->Release();
pdrgpexprConjuncts->Release();
pbsUsed->Release();
}
示例15: DrgPexpr
//---------------------------------------------------------------------------
// @function:
// CDecorrelator::FProcessPredicate
//
// @doc:
// Decorrelate predicate
//
//---------------------------------------------------------------------------
BOOL
CDecorrelator::FProcessPredicate
(
IMemoryPool *pmp,
CExpression *pexprLogical, // logical parent of predicate tree
CExpression *pexprScalar,
BOOL fEqualityOnly,
CColRefSet *pcrsOutput,
CExpression **ppexprDecorrelated,
DrgPexpr *pdrgpexprCorrelations
)
{
GPOS_ASSERT(pexprLogical->Pop()->FLogical());
GPOS_ASSERT(pexprScalar->Pop()->FScalar());
*ppexprDecorrelated = NULL;
DrgPexpr *pdrgpexprConj = CPredicateUtils::PdrgpexprConjuncts(pmp, pexprScalar);
DrgPexpr *pdrgpexprResiduals = GPOS_NEW(pmp) DrgPexpr(pmp);
BOOL fSuccess = true;
// divvy up the predicates in residuals (w/ no outer ref) and correlations (w/ outer refs)
ULONG ulLength = pdrgpexprConj->UlLength();
for(ULONG ul = 0; ul < ulLength && fSuccess; ul++)
{
CExpression *pexprConj = (*pdrgpexprConj)[ul];
CColRefSet *pcrsUsed = CDrvdPropScalar::Pdpscalar(pexprConj->PdpDerive())->PcrsUsed();
if (pcrsOutput->FSubset(pcrsUsed))
{
// no outer ref
pexprConj->AddRef();
pdrgpexprResiduals->Append(pexprConj);
continue;
}
fSuccess = FDelayable(pexprLogical, pexprConj, fEqualityOnly);
if (fSuccess)
{
pexprConj->AddRef();
pdrgpexprCorrelations->Append(pexprConj);
}
}
pdrgpexprConj->Release();
if (!fSuccess || 0 == pdrgpexprResiduals->UlLength())
{
// clean up
pdrgpexprResiduals->Release();
}
else
{
// residuals become new predicate
*ppexprDecorrelated = CPredicateUtils::PexprConjunction(pmp, pdrgpexprResiduals);
}
return fSuccess;
}