greenplumn CLogicalInnerJoin 源码
greenplumn CLogicalInnerJoin 代码
文件路径:/src/backend/gporca/libgpopt/src/operators/CLogicalInnerJoin.cpp
//---------------------------------------------------------------------------
// Greenplum Database
// Copyright (C) 2009 Greenplum, Inc.
//
// @filename:
// CLogicalInnerJoin.cpp
//
// @doc:
// Implementation of inner join operator
//---------------------------------------------------------------------------
#include "gpopt/operators/CLogicalInnerJoin.h"
#include "gpos/base.h"
#include "gpopt/base/CColRefSet.h"
#include "gpopt/base/CColRefSetIter.h"
#include "gpopt/operators/CExpression.h"
#include "gpopt/operators/CExpressionHandle.h"
#include "gpopt/operators/CPredicateUtils.h"
using namespace gpopt;
//---------------------------------------------------------------------------
// @function:
// CLogicalInnerJoin::CLogicalInnerJoin
//
// @doc:
// ctor
// Note: 04/09/2009 - ; so far inner join doesn't have any specific
// members, hence, no need for a separate pattern ctor
//
//---------------------------------------------------------------------------
CLogicalInnerJoin::CLogicalInnerJoin(CMemoryPool *mp,
CXform::EXformId origin_xform)
: CLogicalJoin(mp, origin_xform)
{
GPOS_ASSERT(nullptr != mp);
}
//---------------------------------------------------------------------------
// @function:
// CLogicalInnerJoin::DeriveMaxCard
//
// @doc:
// Derive max card
//
//---------------------------------------------------------------------------
CMaxCard
CLogicalInnerJoin::DeriveMaxCard(CMemoryPool *, // mp
CExpressionHandle &exprhdl) const
{
return CLogical::Maxcard(exprhdl, 2 /*ulScalarIndex*/, MaxcardDef(exprhdl));
}
//---------------------------------------------------------------------------
// @function:
// CLogicalInnerJoin::PxfsCandidates
//
// @doc:
// Get candidate xforms
//
//---------------------------------------------------------------------------
CXformSet *
CLogicalInnerJoin::PxfsCandidates(CMemoryPool *mp) const
{
CXformSet *xform_set = GPOS_NEW(mp) CXformSet(mp);
(void) xform_set->ExchangeSet(CXform::ExfImplementInnerJoin);
(void) xform_set->ExchangeSet(CXform::ExfSubqJoin2Apply);
(void) xform_set->ExchangeSet(CXform::ExfJoin2BitmapIndexGetApply);
(void) xform_set->ExchangeSet(CXform::ExfJoin2IndexGetApply);
(void) xform_set->ExchangeSet(CXform::ExfJoinCommutativity);
(void) xform_set->ExchangeSet(CXform::ExfJoinAssociativity);
(void) xform_set->ExchangeSet(CXform::ExfInnerJoinSemiJoinSwap);
(void) xform_set->ExchangeSet(CXform::ExfInnerJoinAntiSemiJoinSwap);
(void) xform_set->ExchangeSet(CXform::ExfInnerJoinAntiSemiJoinNotInSwap);
return xform_set;
}
//---------------------------------------------------------------------------
// @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(CMemoryPool *mp, CGroupExpression *pgexprFst,
CGroupExpression *pgexprSnd)
{
if (nullptr == pgexprFst || nullptr == 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());
CExpressionArray *pdrgpexprConjFst = CPredicateUtils::PdrgpexprConjuncts(
mp, pgroupScalarFst->PexprScalarRep());
CExpressionArray *pdrgpexprConjSnd = CPredicateUtils::PdrgpexprConjuncts(
mp, pgroupScalarSnd->PexprScalarRep());
ULONG ulConjFst = pdrgpexprConjFst->Size();
ULONG ulConjSnd = pdrgpexprConjSnd->Size();
pdrgpexprConjFst->Release();
pdrgpexprConjSnd->Release();
return ulConjFst < ulConjSnd;
}
// EOF
相关信息
相关文章
greenplumn CExpressionFactorizer 源码
greenplumn CExpressionHandle 源码
greenplumn CExpressionPreprocessor 源码
greenplumn CExpressionUtils 源码
0
赞
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦