MCPcopy Create free account
hub / github.com/apache/cloudberry / findbitmappage

Function findbitmappage

src/backend/access/bitmap/bitmapinsert.c:1014–1066  ·  view source on GitHub ↗

* findbitmappage() -- find the bitmap page that contains * the given tid location, and obtain the first tid location * in this page. * * We assume that this tid location is not in bm_last_compword or * bm_last_word of its LOVItem. * * We will have write lock on the bitmap page we find. */

Source from the content-addressed store, hash-verified

1012 * We will have write lock on the bitmap page we find.
1013 */
1014static void
1015findbitmappage(Relation rel, BMLOVItem lovitem,
1016 uint64 tidnum,
1017 Buffer* bitmapBufferP, uint64* firstTidNumberP)
1018{
1019 BlockNumber nextBlockNo = lovitem->bm_lov_head;
1020
1021 *firstTidNumberP = 1;
1022
1023 while (BlockNumberIsValid(nextBlockNo))
1024 {
1025 Page bitmapPage;
1026 BMBitmapOpaque bitmapOpaque;
1027
1028 CHECK_FOR_INTERRUPTS();
1029
1030 *bitmapBufferP = _bitmap_getbuf(rel, nextBlockNo, BM_WRITE);
1031 bitmapPage = BufferGetPage(*bitmapBufferP);
1032 bitmapOpaque = (BMBitmapOpaque)
1033 PageGetSpecialPointer(bitmapPage);
1034
1035 if (bitmapOpaque->bm_last_tid_location >= tidnum)
1036 return; /* find the page */
1037
1038 (*firstTidNumberP) = bitmapOpaque->bm_last_tid_location + 1;
1039 nextBlockNo = bitmapOpaque->bm_bitmap_next;
1040
1041 _bitmap_relbuf(*bitmapBufferP);
1042 }
1043
1044 /*
1045 * We can't find such a page. This should not happen.
1046 * So we error out.
1047 */
1048 ereport(ERROR,
1049 (errcode(ERRCODE_INDEX_CORRUPTED),
1050 errmsg("could not find bitmap page containing tid " INT64_FORMAT
1051 " in bitmap index %u (relfilenode %u/%u/%u"
1052 ", next block %d, LOV head %d, LOV tail %d"
1053 ", firstTidNumber " INT64_FORMAT
1054 ", bm_last_tid_location " INT64_FORMAT
1055 ", bm_last_setbit " INT64_FORMAT
1056 ", bm_last_compword " INT64_FORMAT
1057 ", bm_last_word " INT64_FORMAT
1058 ", lov_words_header %d)",
1059 tidnum, RelationGetRelid(rel),
1060 rel->rd_node.spcNode, rel->rd_node.dbNode, rel->rd_node.relNode,
1061 nextBlockNo, lovitem->bm_lov_head,
1062 lovitem->bm_lov_tail, *firstTidNumberP, lovitem->bm_last_tid_location,
1063 lovitem->bm_last_setbit, lovitem->bm_last_compword,
1064 lovitem->bm_last_word, lovitem->lov_words_header),
1065 errhint("Reindex bitmap index \"%s\".", RelationGetRelationName(rel))));
1066}
1067
1068/*
1069 * verify_bitmappages() -- verify if the bm_last_tid_location values

Callers 1

updatesetbitFunction · 0.85

Calls 5

_bitmap_getbufFunction · 0.85
_bitmap_relbufFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50
errhintFunction · 0.50

Tested by

no test coverage detected