//--------------------------------------------------------------------------- // @function: // CLogicalGet::OsPrint // // @doc: // debug print // //--------------------------------------------------------------------------- IOstream & CLogicalGet::OsPrint ( IOstream &os ) const { if (m_fPattern) { return COperator::OsPrint(os); } else { os << SzId() << " "; // alias of table as referenced in the query m_pnameAlias->OsPrint(os); // actual name of table in catalog and columns os << " ("; m_ptabdesc->Name().OsPrint(os); os << "), Columns: ["; CUtils::OsPrintDrgPcr(os, m_pdrgpcrOutput); os << "] Key sets: {"; const ULONG ulColumns = m_pdrgpcrOutput->UlLength(); const DrgPbs *pdrgpbsKeys = m_ptabdesc->PdrgpbsKeys(); for (ULONG ul = 0; ul < pdrgpbsKeys->UlLength(); ul++) { CBitSet *pbs = (*pdrgpbsKeys)[ul]; if (0 < ul) { os << ", "; } os << "["; ULONG ulPrintedKeys = 0; for (ULONG ulKey = 0; ulKey < ulColumns; ulKey++) { if (pbs->FBit(ulKey)) { if (0 < ulPrintedKeys) { os << ","; } os << ulKey; ulPrintedKeys++; } } os << "]"; } os << "}"; } return os; }
//--------------------------------------------------------------------------- // @function: // CBitSetTest::EresUnittest_Basics // // @doc: // Testing ctors/dtor // //--------------------------------------------------------------------------- GPOS_RESULT CBitSetTest::EresUnittest_Basics() { // create memory pool CAutoMemoryPool amp; IMemoryPool *pmp = amp.Pmp(); ULONG cSizeBits = 32; CBitSet *pbs = GPOS_NEW(pmp) CBitSet(pmp, cSizeBits); ULONG cInserts = 10; for (ULONG i = 0; i < cInserts; i += 2) { // forces addition of new link pbs->FExchangeSet(i * cSizeBits); } GPOS_ASSERT(cInserts / 2 == pbs->CElements()); for (ULONG i = 1; i < cInserts; i += 2) { // new link between existing links pbs->FExchangeSet(i * cSizeBits); } GPOS_ASSERT(cInserts == pbs->CElements()); CBitSet *pbsCopy = GPOS_NEW(pmp) CBitSet(pmp, *pbs); GPOS_ASSERT(pbsCopy->FEqual(pbs)); // delete old bitset to make sure we're not accidentally // using any of its memory pbs->Release(); for (ULONG i = 0; i < cInserts; i++) { GPOS_ASSERT(pbsCopy->FBit(i * cSizeBits)); } CWStringDynamic str(pmp); COstreamString os(&str); os << *pbsCopy << std::endl; GPOS_TRACE(str.Wsz()); pbsCopy->Release(); return GPOS_OK; }
//--------------------------------------------------------------------------- // @function: // CTranslatorDXLToQuery::MarkUnusedColumns // // @doc: // Mark unused target list entries in the setop child // //--------------------------------------------------------------------------- void CTranslatorDXLToQuery::MarkUnusedColumns ( Query *pquery, RangeTblRef *prtref, CStateDXLToQuery *pstatedxltoquery, const DrgPul *pdrgpulColids ) { const ULONG ulRTIndex = prtref->rtindex; RangeTblEntry *prte = (RangeTblEntry*) gpdb::PvListNth(pquery->rtable, ulRTIndex -1); GPOS_ASSERT(RTE_SUBQUERY == prte->rtekind); Query *pqueryDerTbl = prte->subquery; // maintain the list of used columns in a bit set CBitSet *pds = New(m_pmp) CBitSet(m_pmp); const ULONG ulLen = pdrgpulColids->UlLength(); for (ULONG ul = 0; ul < ulLen; ul++) { ULONG ulValue = *((*pdrgpulColids)[ul]); (void) pds->FExchangeSet(ulValue); } // Mark all columns that are not in the list of required input columns as being unused const ULONG ulSize = pstatedxltoquery->UlLength(); for (ULONG ul = 0; ul < ulSize; ul++) { ULONG ulColId = pstatedxltoquery->UlColId(ul); BOOL fSet = pds->FBit(ulColId); if (!fSet) { // mark the column as unused in the query TargetEntry *pte2 = (TargetEntry*) gpdb::PvListNth(pqueryDerTbl->targetList, ul); pte2->resjunk = true; // mark the column as unused in the state TargetEntry *pte = pstatedxltoquery->PteColumn(ul); pte->resjunk = true; } } pds->Release(); }
//--------------------------------------------------------------------------- // @function: // CConfigParamMapping::PbsPack // // @doc: // Pack the GPDB config params into a bitset // //--------------------------------------------------------------------------- CBitSet * CConfigParamMapping::PbsPack ( IMemoryPool *pmp, ULONG ulXforms // number of available xforms ) { CBitSet *pbs = New(pmp) CBitSet(pmp, EopttraceSentinel); for (ULONG ul = 0; ul < GPOS_ARRAY_SIZE(m_elem); ul++) { SConfigMappingElem elem = m_elem[ul]; GPOS_ASSERT(!pbs->FBit((ULONG) elem.m_etf) && "trace flag already set"); BOOL fVal = *elem.m_pfParam; if (elem.m_fNegate) { // negate the value of config param fVal = !fVal; } if (fVal) { #ifdef GPOS_DEBUG BOOL fSet = #endif // GPOS_DEBUG pbs->FExchangeSet((ULONG) elem.m_etf); GPOS_ASSERT(!fSet); } } // pack disable flags of xforms for (ULONG ul = 0; ul < ulXforms; ul++) { GPOS_ASSERT(!pbs->FBit(EopttraceDisableXformBase + ul) && "xform trace flag already set"); if (optimizer_xforms[ul]) { #ifdef GPOS_DEBUG BOOL fSet = #endif // GPOS_DEBUG pbs->FExchangeSet(EopttraceDisableXformBase + ul); GPOS_ASSERT(!fSet); } } // disable index-join if the corresponding GUC is turned off if (!optimizer_enable_indexjoin) { CBitSet *pbsIndexJoin = CXform::PbsIndexJoinXforms(pmp); pbs->Union(pbsIndexJoin); pbsIndexJoin->Release(); } // disable bitmap scan if the corresponding GUC is turned off if (!optimizer_enable_bitmapscan) { CBitSet *pbsBitmapScan = CXform::PbsBitmapIndexXforms(pmp); pbs->Union(pbsBitmapScan); pbsBitmapScan->Release(); } // disable outerjoin to unionall transformation if GUC is turned off if (!optimizer_enable_outerjoin_to_unionall_rewrite) { pbs->FExchangeSet(GPOPT_DISABLE_XFORM_TF(CXform::ExfLeftOuter2InnerUnionAllLeftAntiSemiJoin)); } // disable Assert MaxOneRow plans if GUC is turned off if (!optimizer_enable_assert_maxonerow) { pbs->FExchangeSet(GPOPT_DISABLE_XFORM_TF(CXform::ExfMaxOneRow2Assert)); } if (!optimizer_enable_partial_index) { CBitSet *pbsHeterogeneousIndex = CXform::PbsHeterogeneousIndexXforms(pmp); pbs->Union(pbsHeterogeneousIndex); pbsHeterogeneousIndex->Release(); } return pbs; }