Ejemplo n.º 1
0
//---------------------------------------------------------------------------
//	@function:
//		CPartConstraint::CopyPartConstraints
//
//	@doc:
//		Copy the part constraints to the given destination part constraint map
//
//---------------------------------------------------------------------------
void
CPartConstraint::CopyPartConstraints
	(
	IMemoryPool *mp,
	UlongToPartConstraintMap *ppartcnstrmapDest,
	UlongToPartConstraintMap *ppartcnstrmapSource
	)
{
	GPOS_ASSERT(NULL != ppartcnstrmapDest);
	GPOS_ASSERT(NULL != ppartcnstrmapSource);

	UlongToPartConstraintMapIter pcmi(ppartcnstrmapSource);

	while (pcmi.Advance())
	{
		ULONG ulKey = *(pcmi.Key());
		CPartConstraint *ppartcnstrSource = const_cast<CPartConstraint *>(pcmi.Value());

		CPartConstraint *ppartcnstrDest = ppartcnstrmapDest->Find(&ulKey);
		GPOS_ASSERT_IMP(NULL != ppartcnstrDest, ppartcnstrDest->FEquivalent(ppartcnstrSource));

		if (NULL == ppartcnstrDest)
		{
			ppartcnstrSource->AddRef();

#ifdef GPOS_DEBUG
			BOOL result =
#endif // GPOS_DEBUG
				ppartcnstrmapDest->Insert(GPOS_NEW(mp) ULONG(ulKey), ppartcnstrSource);

			GPOS_ASSERT(result && "Duplicate part constraints");
		}
	}
}