/* * tbm_add_page - add a whole page to a TIDBitmap * * This causes the whole page to be reported (with the recheck flag) * when the TIDBitmap is scanned. */ void tbm_add_page(TIDBitmap *tbm, BlockNumber pageno) { /* Enter the page in the bitmap, or mark it lossy if already present */ tbm_mark_page_lossy(tbm, pageno); /* If we went over the memory limit, lossify some more pages */ if (tbm->nentries > tbm->maxentries) tbm_lossify(tbm); }
/* * tbm_add_tuples - add some tuple IDs to a HashBitmap */ void tbm_add_tuples(HashBitmap *tbm, const ItemPointer tids, int ntids) { int i; Assert(!tbm->iterating); for (i = 0; i < ntids; i++) { BlockNumber blk = ItemPointerGetBlockNumber(tids + i); OffsetNumber off = ItemPointerGetOffsetNumber(tids + i); PagetableEntry *page; int wordnum, bitnum; /* safety check to ensure we don't overrun bit array bounds */ /* UNDONE: Turn this off until we convert this module to AO TIDs. */ #if 0 if (off < 1 || off > MAX_TUPLES_PER_PAGE) elog(ERROR, "tuple offset out of range: %u", off); #endif if (tbm_page_is_lossy(tbm, blk)) continue; /* whole page is already marked */ page = tbm_get_pageentry(tbm, blk); if (page->ischunk) { /* The page is a lossy chunk header, set bit for itself */ wordnum = bitnum = 0; } else { /* Page is exact, so set bit for individual tuple */ wordnum = WORDNUM(off - 1); bitnum = BITNUM(off - 1); } page->words[wordnum] |= ((tbm_bitmapword) 1 << bitnum); if (tbm->nentries > tbm->maxentries) tbm_lossify(tbm); } }