greenplumn init 源码

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

greenplumn init 代码

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

//---------------------------------------------------------------------------
//	Greenplum Database
//	Copyright (C) 2011 Greenplum, Inc.
//
//	@filename:
//		init.cpp
//
//	@doc:
//		Implementation of initialization and termination functions for
//		libgpopt.
//---------------------------------------------------------------------------

#include "gpopt/init.h"

#include "gpos/_api.h"
#include "gpos/memory/CAutoMemoryPool.h"
#include "gpos/task/CWorker.h"

#include "gpopt/exception.h"
#include "gpopt/mdcache/CMDCache.h"
#include "gpopt/xforms/CXformFactory.h"
#include "naucrates/init.h"

using namespace gpos;
using namespace gpopt;

static CMemoryPool *mp = nullptr;


//---------------------------------------------------------------------------
//      @function:
//              gpopt_init
//
//      @doc:
//              Initialize gpopt library. To enable memory allocations
//              via a custom allocator, pass in non-NULL fnAlloc/fnFree
//              allocation/deallocation functions. If either of the parameters
//              are NULL, gpopt with be initialized with the default allocator.
//
//---------------------------------------------------------------------------
void
gpopt_init()
{
	{
		CAutoMemoryPool amp;
		mp = amp.Pmp();

		// add standard exception messages
		(void) gpopt::EresExceptionInit(mp);

		// detach safety
		(void) amp.Detach();
	}

	if (GPOS_OK != gpopt::CXformFactory::Init())
	{
		return;
	}
}

//---------------------------------------------------------------------------
//      @function:
//              gpopt_terminate
//
//      @doc:
//              Destroy the memory pool
//
//---------------------------------------------------------------------------
void
gpopt_terminate()
{
#ifdef GPOS_DEBUG
	CMDCache::Shutdown();

	CMemoryPoolManager::GetMemoryPoolMgr()->Destroy(mp);

	CXformFactory::Shutdown();
#endif	// GPOS_DEBUG
}

// EOF

相关信息

greenplumn 源码目录

相关文章

greenplumn exception 源码

0  赞