codekingpro/portable-devtools
115k
1/*-------------------------------------------------------------------------2 *3 * tidbitmap.h4 * PostgreSQL tuple-id (TID) bitmap package5 *6 * This module provides bitmap data structures that are spiritually7 * similar to Bitmapsets, but are specially adapted to store sets of8 * tuple identifiers (TIDs), or ItemPointers. In particular, the division9 * of an ItemPointer into BlockNumber and OffsetNumber is catered for.10 * Also, since we wish to be able to store very large tuple sets in11 * memory with this data structure, we support "lossy" storage, in which12 * we no longer remember individual tuple offsets on a page but only the13 * fact that a particular page needs to be visited.14 *15 *16 * Copyright (c) 2003-2023, PostgreSQL Global Development Group17 *18 * src/include/nodes/tidbitmap.h19 *20 *-------------------------------------------------------------------------21 */22#ifndef TIDBITMAP_H23#define TIDBITMAP_H24 25#include "storage/itemptr.h"26#include "utils/dsa.h"27 28 29/*30 * Actual bitmap representation is private to tidbitmap.c. Callers can31 * do IsA(x, TIDBitmap) on it, but nothing else.32 */33typedef struct TIDBitmap TIDBitmap;34 35/* Likewise, TBMIterator is private */36typedef struct TBMIterator TBMIterator;37typedef struct TBMSharedIterator TBMSharedIterator;38 39/* Result structure for tbm_iterate */40typedef struct TBMIterateResult41{42 BlockNumber blockno; /* page number containing tuples */43 int ntuples; /* -1 indicates lossy result */44 bool recheck; /* should the tuples be rechecked? */45 /* Note: recheck is always true if ntuples < 0 */46 OffsetNumber offsets[FLEXIBLE_ARRAY_MEMBER];47} TBMIterateResult;48 49/* function prototypes in nodes/tidbitmap.c */50 51extern TIDBitmap *tbm_create(long maxbytes, dsa_area *dsa);52extern void tbm_free(TIDBitmap *tbm);53extern void tbm_free_shared_area(dsa_area *dsa, dsa_pointer dp);54 55extern void tbm_add_tuples(TIDBitmap *tbm,56 const ItemPointer tids, int ntids,57 bool recheck);58extern void tbm_add_page(TIDBitmap *tbm, BlockNumber pageno);59 60extern void tbm_union(TIDBitmap *a, const TIDBitmap *b);61extern void tbm_intersect(TIDBitmap *a, const TIDBitmap *b);62 63extern bool tbm_is_empty(const TIDBitmap *tbm);64 65extern TBMIterator *tbm_begin_iterate(TIDBitmap *tbm);66extern dsa_pointer tbm_prepare_shared_iterate(TIDBitmap *tbm);67extern TBMIterateResult *tbm_iterate(TBMIterator *iterator);68extern TBMIterateResult *tbm_shared_iterate(TBMSharedIterator *iterator);69extern void tbm_end_iterate(TBMIterator *iterator);70extern void tbm_end_shared_iterate(TBMSharedIterator *iterator);71extern TBMSharedIterator *tbm_attach_shared_iterate(dsa_area *dsa,72 dsa_pointer dp);73extern long tbm_calculate_entries(double maxbytes);74 75#endif /* TIDBITMAP_H */76 