示例#1
0
//---------------------------------------------------------------------------
//	@function:
//		CMDFunctionGPDB::PstrOutArgTypes
//
//	@doc:
//		Serialize the array of output argument types into a comma-separated string
//
//---------------------------------------------------------------------------
CWStringDynamic *
CMDFunctionGPDB::PstrOutArgTypes() const
{
	GPOS_ASSERT(NULL != m_pdrgpmdidTypes);
	CWStringDynamic *pstr = GPOS_NEW(m_pmp) CWStringDynamic(m_pmp);

	const ULONG ulLen = m_pdrgpmdidTypes->UlLength();
	for (ULONG ul = 0; ul < ulLen; ul++)
	{
		IMDId *pmdid = (*m_pdrgpmdidTypes)[ul];
		if (ul == ulLen - 1)
		{
			// last element: do not print a comma
			pstr->AppendFormat(GPOS_WSZ_LIT("%ls"), pmdid->Wsz());
		}
		else
		{
			pstr->AppendFormat(GPOS_WSZ_LIT("%ls%ls"), pmdid->Wsz(), CDXLTokens::PstrToken(EdxltokenComma)->Wsz());
		}
	}

	return pstr;
}
示例#2
0
//---------------------------------------------------------------------------
//	@function:
//		CMDProviderMemory::LoadMetadataObjectsFromArray
//
//	@doc:
//		Loads the metadata objects from the given file
//
//---------------------------------------------------------------------------
void
CMDProviderMemory::LoadMetadataObjectsFromArray
	(
	IMemoryPool *pmp,
	DrgPimdobj *pdrgpmdobj
	)
{
	GPOS_ASSERT(NULL != pdrgpmdobj);

	// load metadata objects from the file
	CAutoRef<MDMap> a_pmdmap;
	m_pmdmap = GPOS_NEW(pmp) MDMap(pmp);
	a_pmdmap = m_pmdmap;

	const ULONG ulSize = pdrgpmdobj->UlLength();

	// load objects into the hash map
	for (ULONG ul = 0; ul < ulSize; ul++)
	{
		GPOS_CHECK_ABORT;

		IMDCacheObject *pmdobj = (*pdrgpmdobj)[ul];
		IMDId *pmdidKey = pmdobj->Pmdid();
		pmdidKey->AddRef();
		CAutoRef<IMDId> a_pmdidKey;
		a_pmdidKey = pmdidKey;
		
		CAutoP<CWStringDynamic> a_pstr;
		a_pstr = CDXLUtils::PstrSerializeMDObj(pmp, pmdobj, true /*fSerializeHeaders*/, false /*findent*/);
		
		GPOS_CHECK_ABORT;
		BOOL fInserted = m_pmdmap->FInsert(pmdidKey, a_pstr.Pt());
		if (!fInserted)
		{
			
			GPOS_RAISE(gpdxl::ExmaMD, gpdxl::ExmiMDCacheEntryDuplicate, pmdidKey->Wsz());
		}
		(void) a_pmdidKey.PtReset();
		(void) a_pstr.PtReset();
	}
	
	// safely completed loading
	(void) a_pmdmap.PtReset();
}