From 89d5abe4f0b945d07645ac7ead252c8aafe09331 Mon Sep 17 00:00:00 2001 From: John Naylor Date: Fri, 5 Apr 2024 17:06:55 +0700 Subject: [PATCH v83 2/3] pgindent --- src/backend/access/common/tidstore.c | 99 ++++++++++++++-------------- 1 file changed, 51 insertions(+), 48 deletions(-) diff --git a/src/backend/access/common/tidstore.c b/src/backend/access/common/tidstore.c index 4eb5d46951..26eb52948b 100644 --- a/src/backend/access/common/tidstore.c +++ b/src/backend/access/common/tidstore.c @@ -45,7 +45,10 @@ typedef struct BlocktableEntry { uint16 nwords; - /* We can store a small number of offsets here to avoid wasting space with a sparse bitmap. */ + /* + * We can store a small number of offsets here to avoid wasting space with + * a sparse bitmap. + */ OffsetNumber full_offsets[NUM_FULL_OFFSETS]; bitmapword words[FLEXIBLE_ARRAY_MEMBER]; @@ -342,35 +345,35 @@ TidStoreSetBlockOffsets(TidStore *ts, BlockNumber blkno, OffsetNumber *offsets, } else { - for (wordnum = 0, next_word_threshold = BITS_PER_BITMAPWORD; - wordnum <= WORDNUM(offsets[num_offsets - 1]); - wordnum++, next_word_threshold += BITS_PER_BITMAPWORD) - { - word = 0; - - while (idx < num_offsets) + for (wordnum = 0, next_word_threshold = BITS_PER_BITMAPWORD; + wordnum <= WORDNUM(offsets[num_offsets - 1]); + wordnum++, next_word_threshold += BITS_PER_BITMAPWORD) { - OffsetNumber off = offsets[idx]; + word = 0; - /* safety check to ensure we don't overrun bit array bounds */ - if (!OffsetNumberIsValid(off)) - elog(ERROR, "tuple offset out of range: %u", off); + while (idx < num_offsets) + { + OffsetNumber off = offsets[idx]; + + /* safety check to ensure we don't overrun bit array bounds */ + if (!OffsetNumberIsValid(off)) + elog(ERROR, "tuple offset out of range: %u", off); - if (off >= next_word_threshold) - break; + if (off >= next_word_threshold) + break; - word |= ((bitmapword) 1 << BITNUM(off)); - idx++; + word |= ((bitmapword) 1 << BITNUM(off)); + idx++; + } + + /* write out offset bitmap for this wordnum */ + page->words[wordnum] = word; } - /* write out offset bitmap for this wordnum */ - page->words[wordnum] = word; + page->nwords = wordnum; + Assert(page->nwords == WORDS_PER_PAGE(offsets[num_offsets - 1])); } - page->nwords = wordnum; - Assert(page->nwords == WORDS_PER_PAGE(offsets[num_offsets - 1])); -} - if (TidStoreIsShared(ts)) shared_ts_set(ts->tree.shared, blkno, page); else @@ -408,15 +411,15 @@ TidStoreIsMember(TidStore *ts, ItemPointer tid) } else { - wordnum = WORDNUM(off); - bitnum = BITNUM(off); + wordnum = WORDNUM(off); + bitnum = BITNUM(off); - /* no bitmap for the off */ - if (wordnum >= page->nwords) - return false; + /* no bitmap for the off */ + if (wordnum >= page->nwords) + return false; - return (page->words[wordnum] & ((bitmapword) 1 << bitnum)) != 0; -} + return (page->words[wordnum] & ((bitmapword) 1 << bitnum)) != 0; + } } /* @@ -547,26 +550,26 @@ tidstore_iter_extract_tids(TidStoreIter *iter, BlockNumber blkno, } else { - for (wordnum = 0; wordnum < page->nwords; wordnum++) - { - bitmapword w = page->words[wordnum]; - int off = wordnum * BITS_PER_BITMAPWORD; - - /* Make sure there is enough space to add offsets */ - if ((result->num_offsets + BITS_PER_BITMAPWORD) > result->max_offset) + for (wordnum = 0; wordnum < page->nwords; wordnum++) { - result->max_offset *= 2; - result->offsets = repalloc(result->offsets, - sizeof(OffsetNumber) * result->max_offset); - } - - while (w != 0) - { - if (w & 1) - result->offsets[result->num_offsets++] = (OffsetNumber) off; - off++; - w >>= 1; + bitmapword w = page->words[wordnum]; + int off = wordnum * BITS_PER_BITMAPWORD; + + /* Make sure there is enough space to add offsets */ + if ((result->num_offsets + BITS_PER_BITMAPWORD) > result->max_offset) + { + result->max_offset *= 2; + result->offsets = repalloc(result->offsets, + sizeof(OffsetNumber) * result->max_offset); + } + + while (w != 0) + { + if (w & 1) + result->offsets[result->num_offsets++] = (OffsetNumber) off; + off++; + w >>= 1; + } } } } -} -- 2.44.0