1/*-------------------------------------------------------------------------
4 * PostgreSQL tuple-id (TID) bitmap package
6 * This module provides bitmap data structures that are spiritually
7 * similar to Bitmapsets, but are specially adapted to store sets of
8 * tuple identifiers (TIDs), or ItemPointers. In particular, the division
9 * of an ItemPointer into BlockNumber and OffsetNumber is catered for.
10 * Also, since we wish to be able to store very large tuple sets in
11 * memory with this data structure, we support "lossy" storage, in which
12 * we no longer remember individual tuple offsets on a page but only the
13 * fact that a particular page needs to be visited.
16 * Copyright (c) 2003-2025, PostgreSQL Global Development Group
18 * src/include/nodes/tidbitmap.h
20 *-------------------------------------------------------------------------
29 * The maximum number of tuples per page is not large (typically 256 with
30 * 8K pages, or 1024 with 32K pages). So there's not much point in making
31 * the per-page bitmaps variable size. We just legislate that the size
34 #define TBM_MAX_TUPLES_PER_PAGE MaxHeapTuplesPerPage
37 * Actual bitmap representation is private to tidbitmap.c. Callers can
38 * do IsA(x, TIDBitmap) on it, but nothing else.
42/* Likewise, TBMPrivateIterator is private */
47 * Callers with both private and shared implementations can use this unified
60/* Result structure for tbm_iterate */
68 * Whether or not the tuples should be rechecked. This is always true if
69 * the page is lossy but may also be true if the query requires recheck.
74 * Pointer to the page containing the bitmap for this block. It is a void *
75 * to avoid exposing the details of the tidbitmap PagetableEntry to API
81/* function prototypes in nodes/tidbitmap.c */
121 * It doesn't matter if we check the private or shared iterator here. If
122 * tbm_end_iterate() was called, they will be NULL
127#endif /* TIDBITMAP_H */
TBMSharedIterator * shared_iterator
union TBMIterator::@111 i
TBMPrivateIterator * private_iterator
void tbm_free(TIDBitmap *tbm)
struct TBMIterateResult TBMIterateResult
bool tbm_iterate(TBMIterator *iterator, TBMIterateResult *tbmres)
bool tbm_shared_iterate(TBMSharedIterator *iterator, TBMIterateResult *tbmres)
void tbm_add_tuples(TIDBitmap *tbm, const ItemPointer tids, int ntids, bool recheck)
bool tbm_is_empty(const TIDBitmap *tbm)
void tbm_end_iterate(TBMIterator *iterator)
void tbm_end_shared_iterate(TBMSharedIterator *iterator)
struct TBMIterator TBMIterator
dsa_pointer tbm_prepare_shared_iterate(TIDBitmap *tbm)
void tbm_intersect(TIDBitmap *a, const TIDBitmap *b)
void tbm_free_shared_area(dsa_area *dsa, dsa_pointer dp)
bool tbm_private_iterate(TBMPrivateIterator *iterator, TBMIterateResult *tbmres)
void tbm_add_page(TIDBitmap *tbm, BlockNumber pageno)
TBMSharedIterator * tbm_attach_shared_iterate(dsa_area *dsa, dsa_pointer dp)
TBMIterator tbm_begin_iterate(TIDBitmap *tbm, dsa_area *dsa, dsa_pointer dsp)
int tbm_extract_page_tuple(TBMIterateResult *iteritem, OffsetNumber *offsets, uint32 max_offsets)
void tbm_union(TIDBitmap *a, const TIDBitmap *b)
void tbm_end_private_iterate(TBMPrivateIterator *iterator)
TIDBitmap * tbm_create(Size maxbytes, dsa_area *dsa)
TBMPrivateIterator * tbm_begin_private_iterate(TIDBitmap *tbm)
int tbm_calculate_entries(Size maxbytes)
static bool tbm_exhausted(TBMIterator *iterator)