本文整理汇总了C++中DrgPexpr类的典型用法代码示例。如果您正苦于以下问题:C++ DrgPexpr类的具体用法?C++ DrgPexpr怎么用?C++ DrgPexpr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DrgPexpr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GPOS_NEW
//---------------------------------------------------------------------------
// @function:
// CConstraint::PexprScalarConjDisj
//
// @doc:
// Construct a conjunction or disjunction scalar expression from an
// array of constraints
//
//---------------------------------------------------------------------------
CExpression *
CConstraint::PexprScalarConjDisj
(
IMemoryPool *pmp,
DrgPcnstr *pdrgpcnstr,
BOOL fConj
)
const
{
DrgPexpr *pdrgpexpr = GPOS_NEW(pmp) DrgPexpr(pmp);
const ULONG ulLen = pdrgpcnstr->UlLength();
for (ULONG ul = 0; ul < ulLen; ul++)
{
CExpression *pexpr = (*pdrgpcnstr)[ul]->PexprScalar(pmp);
pexpr->AddRef();
pdrgpexpr->Append(pexpr);
}
if (fConj)
{
return CPredicateUtils::PexprConjunction(pmp, pdrgpexpr);
}
return CPredicateUtils::PexprDisjunction(pmp, pdrgpexpr);
}
示例2: GPOS_NEW
//---------------------------------------------------------------------------
// @function:
// CDistributionSpecHashed::PdsCopyWithRemappedColumns
//
// @doc:
// Return a copy of the distribution spec with remapped columns
//
//---------------------------------------------------------------------------
CDistributionSpec *
CDistributionSpecHashed::PdsCopyWithRemappedColumns
(
IMemoryPool *pmp,
HMUlCr *phmulcr,
BOOL fMustExist
)
{
DrgPexpr *pdrgpexpr = GPOS_NEW(pmp) DrgPexpr(pmp);
const ULONG ulLen = m_pdrgpexpr->UlLength();
for (ULONG ul = 0; ul < ulLen; ul++)
{
CExpression *pexpr = (*m_pdrgpexpr)[ul];
pdrgpexpr->Append(pexpr->PexprCopyWithRemappedColumns(pmp, phmulcr, fMustExist));
}
if (NULL == m_pdshashedEquiv)
{
return GPOS_NEW(pmp) CDistributionSpecHashed(pdrgpexpr, m_fNullsColocated);
}
// copy equivalent distribution
CDistributionSpec *pds = m_pdshashedEquiv->PdsCopyWithRemappedColumns(pmp, phmulcr, fMustExist);
CDistributionSpecHashed *pdshashed = CDistributionSpecHashed::PdsConvert(pds);
return GPOS_NEW(pmp) CDistributionSpecHashed(pdrgpexpr, m_fNullsColocated, pdshashed);
}
示例3: GPOS_ASSERT
//---------------------------------------------------------------------------
// @function:
// CPhysicalUnionAll::PdsMatching
//
// @doc:
// Compute output hashed distribution based on the outer child's
// hashed distribution
//---------------------------------------------------------------------------
CDistributionSpecHashed *
CPhysicalUnionAll::PdsMatching
(
IMemoryPool *pmp,
const DrgPul *pdrgpulOuter
)
const
{
GPOS_ASSERT(NULL != pdrgpulOuter);
const ULONG ulCols = pdrgpulOuter->UlLength();
GPOS_ASSERT(ulCols <= m_pdrgpcrOutput->UlLength());
DrgPexpr *pdrgpexpr = GPOS_NEW(pmp) DrgPexpr(pmp);
for (ULONG ulCol = 0; ulCol < ulCols; ulCol++)
{
ULONG ulIdx = *(*pdrgpulOuter)[ulCol];
CExpression *pexpr = CUtils::PexprScalarIdent(pmp, (*m_pdrgpcrOutput)[ulIdx]);
pdrgpexpr->Append(pexpr);
}
GPOS_ASSERT(0 < pdrgpexpr->UlLength());
return GPOS_NEW(pmp) CDistributionSpecHashed(pdrgpexpr, true /*fNullsColocated*/);
}
示例4: GPOS_ASSERT
//---------------------------------------------------------------------------
// @function:
// CCNFConverter::Pdrgpdrgpexpr
//
// @doc:
// Create an array of arrays each holding the children of an expression
// from the given array
//
//
//---------------------------------------------------------------------------
DrgPdrgPexpr *
CCNFConverter::Pdrgpdrgpexpr
(
IMemoryPool *pmp,
DrgPexpr *pdrgpexpr
)
{
GPOS_ASSERT(NULL != pmp);
GPOS_ASSERT(NULL != pdrgpexpr);
DrgPdrgPexpr *pdrgpdrgpexpr = GPOS_NEW(pmp) DrgPdrgPexpr(pmp);
const ULONG ulArity = pdrgpexpr->UlLength();
for (ULONG ul = 0; ul < ulArity; ul++)
{
CExpression *pexpr = (*pdrgpexpr)[ul];
DrgPexpr *pdrgpexprChild = NULL;
if (CPredicateUtils::FAnd(pexpr))
{
pdrgpexprChild = pexpr->PdrgPexpr();
pdrgpexprChild->AddRef();
}
else
{
pdrgpexprChild = GPOS_NEW(pmp) DrgPexpr(pmp);
pexpr->AddRef();
pdrgpexprChild->Append(pexpr);
}
pdrgpdrgpexpr->Append(pdrgpexprChild);
}
return pdrgpdrgpexpr;
}
示例5: DrgPds
CHashedDistributions::CHashedDistributions
(
IMemoryPool *pmp,
DrgPcr *pdrgpcrOutput,
DrgDrgPcr *pdrgpdrgpcrInput
)
:
DrgPds(pmp)
{
const ULONG ulCols = pdrgpcrOutput->UlLength();
const ULONG ulArity = pdrgpdrgpcrInput->UlLength();
for (ULONG ulChild = 0; ulChild < ulArity; ulChild++)
{
DrgPcr *pdrgpcr = (*pdrgpdrgpcrInput)[ulChild];
DrgPexpr *pdrgpexpr = GPOS_NEW(pmp) DrgPexpr(pmp);
for (ULONG ulCol = 0; ulCol < ulCols; ulCol++)
{
CColRef *pcr = (*pdrgpcr)[ulCol];
CExpression *pexpr = CUtils::PexprScalarIdent(pmp, pcr);
pdrgpexpr->Append(pexpr);
}
// create a hashed distribution on input columns of the current child
BOOL fNullsColocated = true;
CDistributionSpec *pdshashed = GPOS_NEW(pmp) CDistributionSpecHashed(pdrgpexpr, fNullsColocated);
Append(pdshashed);
}
}
示例6: GPOS_ASSERT
//---------------------------------------------------------------------------
// @function:
// CNormalizer::PushThruSetOp
//
// @doc:
// Push a conjunct through set operation
//
//---------------------------------------------------------------------------
void
CNormalizer::PushThruSetOp
(
IMemoryPool *pmp,
CExpression *pexprSetOp,
CExpression *pexprConj,
CExpression **ppexprResult
)
{
GPOS_ASSERT(NULL != pexprSetOp);
GPOS_ASSERT(CUtils::FLogicalSetOp(pexprSetOp->Pop()));
GPOS_ASSERT(NULL != pexprConj);
GPOS_ASSERT(NULL != ppexprResult);
CLogicalSetOp *popSetOp = CLogicalSetOp::PopConvert(pexprSetOp->Pop());
DrgPcr *pdrgpcrOutput = popSetOp->PdrgpcrOutput();
CColRefSet *pcrsOutput = GPOS_NEW(pmp) CColRefSet(pmp, pdrgpcrOutput);
DrgDrgPcr *pdrgpdrgpcrInput = popSetOp->PdrgpdrgpcrInput();
DrgPexpr *pdrgpexprNewChildren = GPOS_NEW(pmp) DrgPexpr(pmp);
const ULONG ulArity = pexprSetOp->UlArity();
for (ULONG ul = 0; ul < ulArity; ul++)
{
CExpression *pexprChild = (*pexprSetOp)[ul];
DrgPcr *pdrgpcrChild = (*pdrgpdrgpcrInput)[ul];
CColRefSet *pcrsChild = GPOS_NEW(pmp) CColRefSet(pmp, pdrgpcrChild);
pexprConj->AddRef();
CExpression *pexprRemappedConj = pexprConj;
if (!pcrsChild->FEqual(pcrsOutput))
{
// child columns are different from SetOp output columns,
// we need to fix conjunct by mapping output columns to child columns,
// columns that are not in the output of SetOp child need also to be re-mapped
// to new columns,
//
// for example, if the conjunct looks like 'x > (select max(y) from T)'
// and the SetOp child produces only column x, we need to create a new
// conjunct that looks like 'x1 > (select max(y1) from T)'
// where x1 is a copy of x, and y1 is a copy of y
//
// this is achieved by passing (fMustExist = True) flag below, which enforces
// creating column copies for columns not already in the given map
HMUlCr *phmulcr = CUtils::PhmulcrMapping(pmp, pdrgpcrOutput, pdrgpcrChild);
pexprRemappedConj->Release();
pexprRemappedConj = pexprConj->PexprCopyWithRemappedColumns(pmp, phmulcr, true /*fMustExist*/);
phmulcr->Release();
}
CExpression *pexprNewChild = NULL;
PushThru(pmp, pexprChild, pexprRemappedConj, &pexprNewChild);
pdrgpexprNewChildren->Append(pexprNewChild);
pexprRemappedConj->Release();
pcrsChild->Release();
}
pcrsOutput->Release();
popSetOp->AddRef();
*ppexprResult = GPOS_NEW(pmp) CExpression(pmp, popSetOp, pdrgpexprNewChildren);
}
示例7: GPOS_ASSERT
//---------------------------------------------------------------------------
// @function:
// CXformGbAggWithMDQA2Join::PexprTransform
//
// @doc:
// Main transformation driver
//
//---------------------------------------------------------------------------
CExpression *
CXformGbAggWithMDQA2Join::PexprTransform
(
IMemoryPool *pmp,
CExpression *pexpr
)
{
// protect against stack overflow during recursion
GPOS_CHECK_STACK_SIZE;
GPOS_ASSERT(NULL != pmp);
GPOS_ASSERT(NULL != pexpr);
COperator *pop = pexpr->Pop();
if (COperator::EopLogicalGbAgg == pop->Eopid())
{
CExpression *pexprResult = PexprExpandMDQAs(pmp, pexpr);
if (NULL != pexprResult)
{
return pexprResult;
}
}
// recursively process child expressions
const ULONG ulArity = pexpr->UlArity();
DrgPexpr *pdrgpexprChildren = GPOS_NEW(pmp) DrgPexpr(pmp);
for (ULONG ul = 0; ul < ulArity; ul++)
{
CExpression *pexprChild = PexprTransform(pmp, (*pexpr)[ul]);
pdrgpexprChildren->Append(pexprChild);
}
pop->AddRef();
return GPOS_NEW(pmp) CExpression(pmp, pop, pdrgpexprChildren);
}
示例8: 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;
}
示例9: CDistributionSpecHashedNoOp
void
CDistributionSpecHashedNoOp::AppendEnforcers
(
IMemoryPool *pmp,
CExpressionHandle &exprhdl,
CReqdPropPlan *,
DrgPexpr *pdrgpexpr,
CExpression *pexpr
)
{
CDrvdProp *pdp = exprhdl.Pdp();
CDistributionSpec *pdsChild = CDrvdPropPlan::Pdpplan(pdp)->Pds();
CDistributionSpecHashed *pdsChildHashed = dynamic_cast<CDistributionSpecHashed *>(pdsChild);
if (NULL == pdsChildHashed)
{
return;
}
DrgPexpr *pdrgpexprNoOpRedistributionColumns = pdsChildHashed->Pdrgpexpr();
pdrgpexprNoOpRedistributionColumns->AddRef();
CDistributionSpecHashedNoOp* pdsNoOp = GPOS_NEW(pmp) CDistributionSpecHashedNoOp(pdrgpexprNoOpRedistributionColumns);
pexpr->AddRef();
CExpression *pexprMotion = GPOS_NEW(pmp) CExpression
(
pmp,
GPOS_NEW(pmp) CPhysicalMotionHashDistribute(pmp, pdsNoOp),
pexpr
);
pdrgpexpr->Append(pexprMotion);
}
示例10: GPOS_NEW
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::PexprCombinedPartPred
//
// @doc:
// Return a single combined partition selection predicate
//
//---------------------------------------------------------------------------
CExpression *
CPhysicalPartitionSelector::PexprCombinedPartPred
(
IMemoryPool *pmp
)
const
{
DrgPexpr *pdrgpexpr = GPOS_NEW(pmp) DrgPexpr(pmp);
const ULONG ulLevels = UlPartLevels();
for (ULONG ul = 0; ul < ulLevels; ul++)
{
CExpression *pexpr = PexprPartPred(pmp, ul);
if (NULL != pexpr)
{
pdrgpexpr->Append(pexpr);
}
}
if (NULL != m_pexprResidual)
{
m_pexprResidual->AddRef();
pdrgpexpr->Append(m_pexprResidual);
}
return CPredicateUtils::PexprConjunction(pmp, pdrgpexpr);
}
示例11: GPOS_ASSERT_IMP
//---------------------------------------------------------------------------
// @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;
}
示例12: GPOS_ASSERT
//---------------------------------------------------------------------------
// @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);
}
示例13: GPOS_NEW
//---------------------------------------------------------------------------
// @function:
// CJoinOrderDP::PexprBuildPred
//
// @doc:
// Build predicate connecting the two given sets
//
//---------------------------------------------------------------------------
CExpression *
CJoinOrderDP::PexprBuildPred
(
CBitSet *pbsFst,
CBitSet *pbsSnd
)
{
// collect edges connecting the given sets
CBitSet *pbsEdges = GPOS_NEW(m_pmp) CBitSet(m_pmp);
CBitSet *pbs = GPOS_NEW(m_pmp) CBitSet(m_pmp, *pbsFst);
pbs->Union(pbsSnd);
for (ULONG ul = 0; ul < m_ulEdges; ul++)
{
SEdge *pedge = m_rgpedge[ul];
if (
pbs->FSubset(pedge->m_pbs) &&
!pbsFst->FDisjoint(pedge->m_pbs) &&
!pbsSnd->FDisjoint(pedge->m_pbs)
)
{
#ifdef GPOS_DEBUG
BOOL fSet =
#endif // GPOS_DEBUG
pbsEdges->FExchangeSet(ul);
GPOS_ASSERT(!fSet);
}
}
pbs->Release();
CExpression *pexprPred = NULL;
if (0 < pbsEdges->CElements())
{
DrgPexpr *pdrgpexpr = GPOS_NEW(m_pmp) DrgPexpr(m_pmp);
CBitSetIter bsi(*pbsEdges);
while (bsi.FAdvance())
{
ULONG ul = bsi.UlBit();
SEdge *pedge = m_rgpedge[ul];
pedge->m_pexpr->AddRef();
pdrgpexpr->Append(pedge->m_pexpr);
}
pexprPred = CPredicateUtils::PexprConjunction(m_pmp, pdrgpexpr);
}
pbsEdges->Release();
return pexprPred;
}
示例14: GPOS_ASSERT
//---------------------------------------------------------------------------
// @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());
}
示例15: GPOS_ASSERT
//---------------------------------------------------------------------------
// @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;
}