greenplumn CXformJoinCommutativity 源码
greenplumn CXformJoinCommutativity 代码
文件路径:/src/backend/gporca/libgpopt/src/xforms/CXformJoinCommutativity.cpp
//---------------------------------------------------------------------------
// Greenplum Database
// Copyright (C) 2011 EMC Corp.
//
// @filename:
// CXformJoinCommutativity.cpp
//
// @doc:
// Implementation of commutativity transform
//---------------------------------------------------------------------------
#include "gpopt/xforms/CXformJoinCommutativity.h"
#include "gpos/base.h"
#include "gpopt/metadata/CTableDescriptor.h"
#include "gpopt/operators/CLogicalInnerJoin.h"
#include "gpopt/operators/CPatternLeaf.h"
using namespace gpopt;
//---------------------------------------------------------------------------
// @function:
// CXformJoinCommutativity::CXformJoinCommutativity
//
// @doc:
// Ctor
//
//---------------------------------------------------------------------------
CXformJoinCommutativity::CXformJoinCommutativity(CMemoryPool *mp)
: CXformExploration(
// pattern
GPOS_NEW(mp) CExpression(
mp, GPOS_NEW(mp) CLogicalInnerJoin(mp),
GPOS_NEW(mp)
CExpression(mp, GPOS_NEW(mp) CPatternLeaf(mp)), // left child
GPOS_NEW(mp) CExpression(
mp, GPOS_NEW(mp) CPatternLeaf(mp)), // right child
GPOS_NEW(mp)
CExpression(mp, GPOS_NEW(mp) CPatternLeaf(mp))) // predicate
)
{
}
//---------------------------------------------------------------------------
// @function:
// CXformJoinCommutativity::FCompatible
//
// @doc:
// Compatibility function for join commutativity
//
//---------------------------------------------------------------------------
BOOL
CXformJoinCommutativity::FCompatible(CXform::EXformId exfid)
{
BOOL fCompatible = true;
switch (exfid)
{
case CXform::ExfJoinCommutativity:
fCompatible = false;
break;
default:
fCompatible = true;
}
return fCompatible;
}
//---------------------------------------------------------------------------
// @function:
// CXformJoinCommutativity::Transform
//
// @doc:
// Actual transformation
//
//---------------------------------------------------------------------------
void
CXformJoinCommutativity::Transform(CXformContext *pxfctxt, CXformResult *pxfres,
CExpression *pexpr) const
{
GPOS_ASSERT(nullptr != pxfctxt);
GPOS_ASSERT(FPromising(pxfctxt->Pmp(), this, pexpr));
GPOS_ASSERT(FCheckPattern(pexpr));
CMemoryPool *mp = pxfctxt->Pmp();
// extract components
CExpression *pexprLeft = (*pexpr)[0];
CExpression *pexprRight = (*pexpr)[1];
CExpression *pexprScalar = (*pexpr)[2];
// addref children
pexprLeft->AddRef();
pexprRight->AddRef();
pexprScalar->AddRef();
// assemble transformed expression
CExpression *pexprAlt = CUtils::PexprLogicalJoin<CLogicalInnerJoin>(
mp, pexprRight, pexprLeft, pexprScalar);
// add alternative to transformation result
pxfres->Add(pexprAlt);
}
// EOF
相关信息
相关文章
greenplumn CJoinOrderGreedy 源码
greenplumn CJoinOrderMinCard 源码
greenplumn CSubqueryHandler 源码
0
赞
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
7、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦