greenplumn CLogicalApply 源码

  • 2022-08-18
  • 浏览 (212)

greenplumn CLogicalApply 代码

文件路径:/src/backend/gporca/libgpopt/src/operators/CLogicalApply.cpp

//---------------------------------------------------------------------------
//	Greenplum Database
//	Copyright (C) 2012 EMC Corp.
//
//	@filename:
//		CLogicalApply.cpp
//
//	@doc:
//		Implementation of apply operator
//---------------------------------------------------------------------------

#include "gpopt/operators/CLogicalApply.h"

#include "gpos/base.h"

#include "gpopt/operators/CExpressionHandle.h"


using namespace gpopt;


//---------------------------------------------------------------------------
//	@function:
//		CLogicalApply::CLogicalApply
//
//	@doc:
//		Ctor
//
//---------------------------------------------------------------------------
CLogicalApply::CLogicalApply(CMemoryPool *mp)
	: CLogical(mp),
	  m_pdrgpcrInner(nullptr),
	  m_eopidOriginSubq(COperator::EopSentinel)
{
}


//---------------------------------------------------------------------------
//	@function:
//		CLogicalApply::CLogicalApply
//
//	@doc:
//		Ctor
//
//---------------------------------------------------------------------------
CLogicalApply::CLogicalApply(CMemoryPool *mp, CColRefArray *pdrgpcrInner,
							 EOperatorId eopidOriginSubq)
	: CLogical(mp),
	  m_pdrgpcrInner(pdrgpcrInner),
	  m_eopidOriginSubq(eopidOriginSubq)
{
	GPOS_ASSERT(nullptr != pdrgpcrInner);
}

//---------------------------------------------------------------------------
//	@function:
//		CLogicalApply::~CLogicalApply
//
//	@doc:
//		Dtor
//
//---------------------------------------------------------------------------
CLogicalApply::~CLogicalApply()
{
	CRefCount::SafeRelease(m_pdrgpcrInner);
}


//---------------------------------------------------------------------------
//	@function:
//		CLogicalApply::PcrsStat
//
//	@doc:
//		Compute required stat columns of the n-th child
//
//---------------------------------------------------------------------------
CColRefSet *
CLogicalApply::PcrsStat(CMemoryPool *mp, CExpressionHandle &exprhdl,
						CColRefSet *pcrsInput, ULONG child_index) const
{
	GPOS_ASSERT(3 == exprhdl.Arity());

	CColRefSet *pcrsUsed = GPOS_NEW(mp) CColRefSet(mp);
	// add columns used by scalar child
	pcrsUsed->Union(exprhdl.DeriveUsedColumns(2));

	if (0 == child_index)
	{
		// add outer references coming from inner child
		pcrsUsed->Union(exprhdl.DeriveOuterReferences(1));
	}

	CColRefSet *pcrsStat =
		PcrsReqdChildStats(mp, exprhdl, pcrsInput, pcrsUsed, child_index);
	pcrsUsed->Release();

	return pcrsStat;
}

//---------------------------------------------------------------------------
//	@function:
//		CLogicalApply::Matches
//
//	@doc:
//		Match function
//
//---------------------------------------------------------------------------
BOOL
CLogicalApply::Matches(COperator *pop) const
{
	if (pop->Eopid() == Eopid())
	{
		CColRefArray *pdrgpcrInner =
			CLogicalApply::PopConvert(pop)->PdrgPcrInner();
		if (nullptr == m_pdrgpcrInner || nullptr == pdrgpcrInner)
		{
			return (nullptr == m_pdrgpcrInner && nullptr == pdrgpcrInner);
		}

		return m_pdrgpcrInner->Equals(pdrgpcrInner);
	}

	return false;
}

//---------------------------------------------------------------------------
//	@function:
//		CLogicalApply::OsPrint
//
//	@doc:
//		debug print
//
//---------------------------------------------------------------------------
IOstream &
CLogicalApply::OsPrint(IOstream &os) const
{
	os << this->SzId();
	if (nullptr != m_pdrgpcrInner)
	{
		os << " (Reqd Inner Cols: ";
		(void) CUtils::OsPrintDrgPcr(os, m_pdrgpcrInner);
		os << ")";
	}

	return os;
}


// EOF

相关信息

greenplumn 源码目录

相关文章

greenplumn CExpression 源码

greenplumn CExpressionFactorizer 源码

greenplumn CExpressionHandle 源码

greenplumn CExpressionPreprocessor 源码

greenplumn CExpressionUtils 源码

greenplumn CHashedDistributions 源码

greenplumn CLogical 源码

greenplumn CLogicalAssert 源码

greenplumn CLogicalBitmapTableGet 源码

greenplumn CLogicalCTEAnchor 源码

0  赞