//--------------------------------------------------------------------------- // @function: // CPartInfo::CPartInfoEntry::PpartinfoentryAddRemappedKeys // // @doc: // Create a copy of the current object, and add a set of remapped // part keys to this entry, using the existing keys and the given hashmap // //--------------------------------------------------------------------------- CPartInfo::CPartInfoEntry * CPartInfo::CPartInfoEntry::PpartinfoentryAddRemappedKeys ( IMemoryPool *pmp, CColRefSet *pcrs, HMUlCr *phmulcr ) { GPOS_ASSERT(NULL != pcrs); GPOS_ASSERT(NULL != phmulcr); DrgPpartkeys *pdrgppartkeys = CPartKeys::PdrgppartkeysCopy(pmp, m_pdrgppartkeys); const ULONG ulSize = m_pdrgppartkeys->UlLength(); for (ULONG ul = 0; ul < ulSize; ul++) { CPartKeys *ppartkeys = (*m_pdrgppartkeys)[ul]; if (ppartkeys->FOverlap(pcrs)) { pdrgppartkeys->Append(ppartkeys->PpartkeysRemap(pmp, phmulcr)); break; } } m_pmdid->AddRef(); CPartConstraint *ppartcnstrRel = m_ppartcnstrRel->PpartcnstrCopyWithRemappedColumns(pmp, phmulcr, false /*fMustExist*/); return GPOS_NEW(pmp) CPartInfoEntry(m_ulScanId, m_pmdid, pdrgppartkeys, ppartcnstrRel); }
//--------------------------------------------------------------------------- // @function: // CPhysicalScan::PpimDeriveFromDynamicScan // // @doc: // Derive partition index map from a dynamic scan operator // //--------------------------------------------------------------------------- CPartIndexMap * CPhysicalScan::PpimDeriveFromDynamicScan ( IMemoryPool *pmp, ULONG ulPartIndexId, IMDId *pmdidRel, DrgDrgPcr *pdrgpdrgpcrPart, ULONG ulSecondaryPartIndexId, CPartConstraint *ppartcnstr, CPartConstraint *ppartcnstrRel, ULONG ulExpectedPropagators ) { CPartIndexMap *ppim = GPOS_NEW(pmp) CPartIndexMap(pmp); PartCnstrMap *ppartcnstrmap = GPOS_NEW(pmp) PartCnstrMap(pmp); (void) ppartcnstrmap->FInsert(GPOS_NEW(pmp) ULONG(ulSecondaryPartIndexId), ppartcnstr); DrgPpartkeys *pdrgppartkeys = GPOS_NEW(pmp) DrgPpartkeys(pmp); pdrgppartkeys->Append(GPOS_NEW(pmp) CPartKeys(pdrgpdrgpcrPart)); ppim->Insert(ulPartIndexId, ppartcnstrmap, CPartIndexMap::EpimConsumer, ulExpectedPropagators, pmdidRel, pdrgppartkeys, ppartcnstrRel); return ppim; }
//--------------------------------------------------------------------------- // @function: // CPhysicalPartitionSelector::PpimDerive // // @doc: // Derive partition index map // //--------------------------------------------------------------------------- CPartIndexMap * CPhysicalPartitionSelector::PpimDerive ( IMemoryPool *pmp, CExpressionHandle &exprhdl, CDrvdPropCtxt *pdpctxt ) const { GPOS_ASSERT(NULL != pdpctxt); CDrvdPropPlan *pdpplan = exprhdl.Pdpplan(0 /*ulChildIndex*/); CPartIndexMap *ppimInput = pdpplan->Ppim(); GPOS_ASSERT(NULL != ppimInput); ULONG ulExpectedPartitionSelectors = CDrvdPropCtxtPlan::PdpctxtplanConvert(pdpctxt)->UlExpectedPartitionSelectors(); CPartIndexMap *ppim = ppimInput->PpimPartitionSelector(pmp, m_ulScanId, ulExpectedPartitionSelectors); if (!ppim->FContains(m_ulScanId)) { // the consumer of this scan id does not come from the child, i.e. it // is on the other side of a join Pmdid()->AddRef(); m_pdrgpdrgpcr->AddRef(); m_ppartcnstrmap->AddRef(); m_ppartcnstr->AddRef(); DrgPpartkeys *pdrgppartkeys = GPOS_NEW(pmp) DrgPpartkeys(pmp); pdrgppartkeys->Append(GPOS_NEW(pmp) CPartKeys(m_pdrgpdrgpcr)); ppim->Insert(m_ulScanId, m_ppartcnstrmap, CPartIndexMap::EpimPropagator, 0 /*ulExpectedPropagators*/, Pmdid(), pdrgppartkeys, m_ppartcnstr); } return ppim; }
//--------------------------------------------------------------------------- // @function: // CPartInfo::AddPartConsumer // // @doc: // Add part table consumer // //--------------------------------------------------------------------------- void CPartInfo::AddPartConsumer ( IMemoryPool *pmp, ULONG ulScanId, IMDId *pmdid, DrgDrgPcr *pdrgpdrgpcrPart, CPartConstraint *ppartcnstrRel ) { DrgPpartkeys *pdrgppartkeys = GPOS_NEW(pmp) DrgPpartkeys(pmp); pdrgppartkeys->Append(GPOS_NEW(pmp) CPartKeys(pdrgpdrgpcrPart)); m_pdrgppartentries->Append(GPOS_NEW(pmp) CPartInfoEntry(ulScanId, pmdid, pdrgppartkeys, ppartcnstrRel)); }
//--------------------------------------------------------------------------- // @function: // CPartKeys::PdrgppartkeysCopy // // @doc: // Copy array of part keys into given memory pool // //--------------------------------------------------------------------------- DrgPpartkeys * CPartKeys::PdrgppartkeysCopy ( IMemoryPool *pmp, const DrgPpartkeys *pdrgppartkeys ) { GPOS_ASSERT(NULL != pdrgppartkeys); DrgPpartkeys *pdrgppartkeysCopy = GPOS_NEW(pmp) DrgPpartkeys(pmp); const ULONG ulLength = pdrgppartkeys->UlLength(); for (ULONG ul = 0; ul < ulLength; ul++) { pdrgppartkeysCopy->Append((*pdrgppartkeys)[ul]->PpartkeysCopy(pmp)); } return pdrgppartkeysCopy; }