greenplumn CDistributionSpecSingleton 源码

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

greenplumn CDistributionSpecSingleton 代码

文件路径:/src/backend/gporca/libgpopt/include/gpopt/base/CDistributionSpecSingleton.h

//---------------------------------------------------------------------------
//	Greenplum Database
//	Copyright (C) 2011 EMC Corp.
//
//	@filename:
//		CDistributionSpecSingleton.h
//
//	@doc:
//		Description of a singleton distribution;
//		Can be used as required or derived property;
//---------------------------------------------------------------------------
#ifndef GPOPT_CDistributionSpecSingleton_H
#define GPOPT_CDistributionSpecSingleton_H

#include "gpos/base.h"
#include "gpos/utils.h"

#include "gpopt/base/CDistributionSpec.h"

namespace gpopt
{
using namespace gpos;

//---------------------------------------------------------------------------
//	@class:
//		CDistributionSpecSingleton
//
//	@doc:
//		Class for representing singleton distribution specification.
//
//---------------------------------------------------------------------------
class CDistributionSpecSingleton : public CDistributionSpec
{
public:
	// type of segment
	enum ESegmentType
	{
		EstMaster,
		EstSegment,
		EstSentinel
	};

protected:
	// what type of segment is data distributed on
	ESegmentType m_est;

	// segment type name
	static const CHAR *m_szSegmentType[EstSentinel];

private:
public:
	CDistributionSpecSingleton(const CDistributionSpecSingleton &) = delete;

	// ctor
	explicit CDistributionSpecSingleton(ESegmentType esegtype);

	CDistributionSpecSingleton();

	// distribution type accessor
	EDistributionType
	Edt() const override
	{
		return CDistributionSpec::EdtSingleton;
	}

	// segment type accessor
	ESegmentType
	Est() const
	{
		return m_est;
	}

	// is this a master-only distribution
	BOOL
	FOnMaster() const
	{
		return EstMaster == m_est;
	}

	// return distribution partitioning type
	EDistributionPartitioningType
	Edpt() const override
	{
		return EdptNonPartitioned;
	}

	// does this distribution satisfy the given one
	BOOL FSatisfies(const CDistributionSpec *pds) const override;

	// hash function for singleton distribution spec
	ULONG
	HashValue() const override
	{
		ULONG ulEdt = (ULONG) Edt();
		BOOL fOnMaster = FOnMaster();

		return gpos::CombineHashes(gpos::HashValue<ULONG>(&ulEdt),
								   gpos::HashValue<BOOL>(&fOnMaster));
	}

	// match function for singleton distribution specs
	BOOL
	Matches(const CDistributionSpec *pds) const override
	{
		return Edt() == pds->Edt() &&
			   FOnMaster() ==
				   dynamic_cast<const CDistributionSpecSingleton *>(pds)
					   ->FOnMaster();
	}

	// append enforcers to dynamic array for the given plan properties
	void AppendEnforcers(CMemoryPool *mp, CExpressionHandle &exprhdl,
						 CReqdPropPlan *prpp, CExpressionArray *pdrgpexpr,
						 CExpression *pexpr) override;

	// print
	IOstream &OsPrint(IOstream &os) const override;

	// conversion function
	static CDistributionSpecSingleton *
	PdssConvert(CDistributionSpec *pds)
	{
		GPOS_ASSERT(nullptr != pds);
		GPOS_ASSERT(EdtSingleton == pds->Edt() ||
					EdtStrictSingleton == pds->Edt());

		return dynamic_cast<CDistributionSpecSingleton *>(pds);
	}

	// conversion function
	static const CDistributionSpecSingleton *
	PdssConvert(const CDistributionSpec *pds)
	{
		GPOS_ASSERT(nullptr != pds);
		GPOS_ASSERT(EdtSingleton == pds->Edt() ||
					EdtStrictSingleton == pds->Edt());

		return dynamic_cast<const CDistributionSpecSingleton *>(pds);
	}

};	// class CDistributionSpecSingleton

}  // namespace gpopt

#endif	// !GPOPT_CDistributionSpecSingleton_H

// EOF

相关信息

greenplumn 源码目录

相关文章

greenplumn CAutoOptCtxt 源码

greenplumn CCTEInfo 源码

greenplumn CCTEMap 源码

greenplumn CCTEReq 源码

greenplumn CCastUtils 源码

greenplumn CColConstraintsArrayMapper 源码

greenplumn CColConstraintsHashMapper 源码

greenplumn CColRef 源码

greenplumn CColRefComputed 源码

greenplumn CColRefSet 源码

0  赞