//--------------------------------------------------------------------------- // @function: // CConstraintConjunction::PcnstrCopyWithRemappedColumns // // @doc: // Return a copy of the constraint with remapped columns. If must_exist is // set to true, then every column reference in this constraint must be in // the hashmap in order to be replace. Otherwise, some columns may not be // in the mapping, and hence will not be replaced // //--------------------------------------------------------------------------- CConstraint * CConstraintConjunction::PcnstrCopyWithRemappedColumns ( IMemoryPool *mp, UlongToColRefMap *colref_mapping, BOOL must_exist ) { CConstraintArray *pdrgpcnstr = GPOS_NEW(mp) CConstraintArray(mp); const ULONG length = m_pdrgpcnstr->Size(); for (ULONG ul = 0; ul < length; ul++) { CConstraint *pcnstr = (*m_pdrgpcnstr)[ul]; CConstraint *pcnstrCopy = pcnstr->PcnstrCopyWithRemappedColumns(mp, colref_mapping, must_exist); pdrgpcnstr->Append(pcnstrCopy); } return GPOS_NEW(mp) CConstraintConjunction(mp, pdrgpcnstr); }
//--------------------------------------------------------------------------- // @function: // CPartConstraint::PpartcnstrCopyWithRemappedColumns // // @doc: // Return a copy of the part constraint with remapped columns // //--------------------------------------------------------------------------- CPartConstraint * CPartConstraint::PpartcnstrCopyWithRemappedColumns ( IMemoryPool *mp, UlongToColRefMap *colref_mapping, BOOL must_exist ) { if (m_fUninterpreted) { return GPOS_NEW(mp) CPartConstraint(true /*m_fUninterpreted*/); } UlongToConstraintMap *phmulcnstr = GPOS_NEW(mp) UlongToConstraintMap(mp); CColRef2dArray *pdrgpdrgpcr = GPOS_NEW(mp) CColRef2dArray(mp); for (ULONG ul = 0; ul < m_num_of_part_levels; ul++) { CColRefArray *colref_array = (*m_pdrgpdrgpcr)[ul]; CColRefArray *pdrgpcrMapped = CUtils::PdrgpcrRemap(mp, colref_array, colref_mapping, must_exist); pdrgpdrgpcr->Append(pdrgpcrMapped); CConstraint *pcnstr = Pcnstr(ul); if (NULL != pcnstr) { CConstraint *pcnstrRemapped = pcnstr->PcnstrCopyWithRemappedColumns(mp, colref_mapping, must_exist); #ifdef GPOS_DEBUG BOOL result = #endif // GPOS_DEBUG phmulcnstr->Insert(GPOS_NEW(mp) ULONG(ul), pcnstrRemapped); GPOS_ASSERT(result); } } m_pbsDefaultParts->AddRef(); return GPOS_NEW(mp) CPartConstraint(mp, phmulcnstr, m_pbsDefaultParts, m_is_unbounded, pdrgpdrgpcr); }