greenplumn CUpperBoundNDVs 源码

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

greenplumn CUpperBoundNDVs 代码

文件路径:/src/backend/gporca/libnaucrates/include/naucrates/statistics/CUpperBoundNDVs.h

//---------------------------------------------------------------------------
//      Greenplum Database
//      Copyright (C) 2014 VMware, Inc. or its affiliates.
//
//      @filename:
//              CUpperBoundNDVs.h
//
//      @doc:
//              Upper bound on the number of distinct values for a given set of columns
//---------------------------------------------------------------------------

#ifndef GPNAUCRATES_CUpperBoundNDVs_H
#define GPNAUCRATES_CUpperBoundNDVs_H

#include "gpos/base.h"

#include "gpopt/base/CColRefSet.h"

namespace gpnaucrates
{
using namespace gpos;
using namespace gpmd;

// forward decl
class CUpperBoundNDVs;

// dynamic array of upper bound ndvs
using CUpperBoundNDVPtrArray = CDynamicPtrArray<CUpperBoundNDVs, CleanupDelete>;

//---------------------------------------------------------------------------
//      @class:
//              CUpperBoundNDVs
//
//      @doc:
//              Upper bound on the number of distinct values for a given set of columns
//
//---------------------------------------------------------------------------

class CUpperBoundNDVs
{
private:
	// set of column references
	CColRefSet *m_column_refset;

	// upper bound of ndvs
	CDouble m_upper_bound_ndv;

public:
	CUpperBoundNDVs(const CUpperBoundNDVs &) = delete;

	// ctor
	CUpperBoundNDVs(CColRefSet *column_refset, CDouble upper_bound_ndv)
		: m_column_refset(column_refset), m_upper_bound_ndv(upper_bound_ndv)
	{
		GPOS_ASSERT(nullptr != m_column_refset);
	}

	// dtor
	~CUpperBoundNDVs()
	{
		m_column_refset->Release();
	}

	// return the upper bound of ndvs
	CDouble
	UpperBoundNDVs() const
	{
		return m_upper_bound_ndv;
	}

	// check if the column is present
	BOOL
	IsPresent(const CColRef *column_ref) const
	{
		return m_column_refset->FMember(column_ref);
	}

	// copy upper bound ndvs
	CUpperBoundNDVs *CopyUpperBoundNDVs(CMemoryPool *mp) const;
	CUpperBoundNDVs *CopyUpperBoundNDVs(CMemoryPool *mp,
										CDouble upper_bound_ndv) const;

	// copy upper bound ndvs with remapped column id; function will
	// return null if there is no mapping found for any of the columns
	CUpperBoundNDVs *CopyUpperBoundNDVWithRemap(
		CMemoryPool *mp, UlongToColRefMap *colid_to_colref_map) const;

	// print function
	IOstream &OsPrint(IOstream &os) const;
};
}  // namespace gpnaucrates

#endif	// !GPNAUCRATES_CUpperBoundNDVs_H

// EOF

相关信息

greenplumn 源码目录

相关文章

greenplumn CBucket 源码

greenplumn CFilterStatsProcessor 源码

greenplumn CGroupByStatsProcessor 源码

greenplumn CHistogram 源码

greenplumn CInnerJoinStatsProcessor 源码

greenplumn CJoinStatsProcessor 源码

greenplumn CLeftAntiSemiJoinStatsProcessor 源码

greenplumn CLeftOuterJoinStatsProcessor 源码

greenplumn CLeftSemiJoinStatsProcessor 源码

greenplumn CLimitStatsProcessor 源码

0  赞