greenplumn CColumnFactoryTest 源码

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

greenplumn CColumnFactoryTest 代码

文件路径:/src/backend/gporca/server/src/unittest/gpopt/base/CColumnFactoryTest.cpp

//---------------------------------------------------------------------------
//	Greenplum Database
//	Copyright (C) 2008, 2009 Greenplum, Inc.
//
//	@filename:
//		CColumnFactoryTest.cpp
//
//	@doc:
//		Test for CColumnFactory
//---------------------------------------------------------------------------

#include "unittest/gpopt/base/CColumnFactoryTest.h"

#include "gpos/base.h"
#include "gpos/memory/CAutoMemoryPool.h"
#include "gpos/test/CUnittest.h"

#include "gpopt/base/CColumnFactory.h"
#include "gpopt/base/COptCtxt.h"
#include "gpopt/base/CQueryContext.h"
#include "gpopt/mdcache/CMDAccessor.h"
#include "gpopt/mdcache/CMDCache.h"
#include "naucrates/md/CMDProviderMemory.h"
#include "naucrates/md/IMDTypeInt4.h"

#include "unittest/gpopt/CTestUtils.h"
#include "unittest/gpopt/translate/CTranslatorExprToDXLTest.h"

using namespace gpopt;

//---------------------------------------------------------------------------
//	@function:
//		CColumnFactoryTest::EresUnittest
//
//	@doc:
//		Unittest for column factory
//
//---------------------------------------------------------------------------
GPOS_RESULT
CColumnFactoryTest::EresUnittest()
{
	CUnittest rgut[] = {
		GPOS_UNITTEST_FUNC(CColumnFactoryTest::EresUnittest_Basic)};

	return CUnittest::EresExecute(rgut, GPOS_ARRAY_SIZE(rgut));
}


//---------------------------------------------------------------------------
//	@function:
//		CColumnFactoryTest::EresUnittest_Basic
//
//	@doc:
//		Basic array allocation test
//
//---------------------------------------------------------------------------
GPOS_RESULT
CColumnFactoryTest::EresUnittest_Basic()
{
	CAutoMemoryPool amp;
	CMemoryPool *mp = amp.Pmp();

	CMDProviderMemory *pmdp = CTestUtils::m_pmdpf;
	pmdp->AddRef();
	CMDAccessor mda(mp, CMDCache::Pcache());
	mda.RegisterProvider(CTestUtils::m_sysidDefault, pmdp);

	const IMDTypeInt4 *pmdtypeint4 = mda.PtMDType<IMDTypeInt4>();

	CColumnFactory cf;

	// typed colref
	CColRef *pcrOne = cf.PcrCreate(pmdtypeint4, default_type_modifier);
	GPOS_ASSERT(pcrOne == cf.LookupColRef(pcrOne->m_id));
	cf.Destroy(pcrOne);

	// typed/named colref
	CWStringConst strName(GPOS_WSZ_LIT("C_CustKey"));
	CColRef *pcrTwo =
		cf.PcrCreate(pmdtypeint4, default_type_modifier, CName(&strName));
	GPOS_ASSERT(pcrTwo == cf.LookupColRef(pcrTwo->m_id));

	// clone previous colref
	CColRef *pcrThree = cf.PcrCreate(pcrTwo);
	GPOS_ASSERT(pcrThree != cf.LookupColRef(pcrTwo->m_id));
	GPOS_ASSERT(!pcrThree->Name().Equals(pcrTwo->Name()));
	cf.Destroy(pcrThree);

	cf.Destroy(pcrTwo);

	return GPOS_OK;
}


// EOF

相关信息

greenplumn 源码目录

相关文章

greenplumn CColRefSetIterTest 源码

greenplumn CColRefSetTest 源码

greenplumn CConstraintTest 源码

greenplumn CDistributionSpecTest 源码

greenplumn CEquivalenceClassesTest 源码

greenplumn CFunctionalDependencyTest 源码

greenplumn CGroupTest 源码

greenplumn CKeyCollectionTest 源码

greenplumn CMaxCardTest 源码

greenplumn COrderSpecTest 源码

0  赞