//--------------------------------------------------------------------------- // @function: // CPartConstraint::FDisjunctionPossible // // @doc: // Check if it is possible to produce a disjunction of the two given part // constraints. This is possible if the first ulLevels-1 have the same // constraints and default flags for both part constraints // //--------------------------------------------------------------------------- BOOL CPartConstraint::FDisjunctionPossible ( CPartConstraint *ppartcnstrFst, CPartConstraint *ppartcnstrSnd ) { GPOS_ASSERT(NULL != ppartcnstrFst); GPOS_ASSERT(NULL != ppartcnstrSnd); GPOS_ASSERT(ppartcnstrFst->m_num_of_part_levels == ppartcnstrSnd->m_num_of_part_levels); const ULONG ulLevels = ppartcnstrFst->m_num_of_part_levels; BOOL fSuccess = true; for (ULONG ul = 0; fSuccess && ul < ulLevels - 1; ul++) { CConstraint *pcnstrFst = ppartcnstrFst->Pcnstr(ul); CConstraint *pcnstrSnd = ppartcnstrSnd->Pcnstr(ul); fSuccess = (NULL != pcnstrFst && NULL != pcnstrSnd && pcnstrFst->Equals(pcnstrSnd) && ppartcnstrFst->IsDefaultPartition(ul) == ppartcnstrSnd->IsDefaultPartition(ul)); } // last level constraints cannot be NULL as well fSuccess = (fSuccess && NULL != ppartcnstrFst->Pcnstr(ulLevels - 1) && NULL != ppartcnstrSnd->Pcnstr(ulLevels - 1)); return fSuccess; }
//--------------------------------------------------------------------------- // @function: // CPartConstraint::FEqualConstrMaps // // @doc: // Check if two constaint maps have the same constraints // //--------------------------------------------------------------------------- BOOL CPartConstraint::FEqualConstrMaps ( UlongToConstraintMap *phmulcnstrFst, UlongToConstraintMap *phmulcnstrSnd, ULONG ulLevels ) { if (phmulcnstrFst->Size() != phmulcnstrSnd->Size()) { return false; } for (ULONG ul = 0; ul < ulLevels; ul++) { CConstraint *pcnstrFst = phmulcnstrFst->Find(&ul); CConstraint *pcnstrSnd = phmulcnstrSnd->Find(&ul); if ((NULL == pcnstrFst || NULL == pcnstrSnd) && pcnstrFst != pcnstrSnd) { return false; } if (NULL != pcnstrFst && !pcnstrFst->Equals(pcnstrSnd)) { return false; } } return true; }