PostgreSQL Source Code  git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
tidbitmap.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * tidbitmap.h
4  * PostgreSQL tuple-id (TID) bitmap package
5  *
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.
14  *
15  *
16  * Copyright (c) 2003-2024, PostgreSQL Global Development Group
17  *
18  * src/include/nodes/tidbitmap.h
19  *
20  *-------------------------------------------------------------------------
21  */
22 #ifndef TIDBITMAP_H
23 #define TIDBITMAP_H
24 
25 #include "storage/itemptr.h"
26 #include "utils/dsa.h"
27 
28 
29 /*
30  * Actual bitmap representation is private to tidbitmap.c. Callers can
31  * do IsA(x, TIDBitmap) on it, but nothing else.
32  */
33 typedef struct TIDBitmap TIDBitmap;
34 
35 /* Likewise, TBMIterator is private */
36 typedef struct TBMIterator TBMIterator;
38 
39 /* Result structure for tbm_iterate */
40 typedef struct TBMIterateResult
41 {
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 */
48 
49 /* function prototypes in nodes/tidbitmap.c */
50 
51 extern TIDBitmap *tbm_create(long maxbytes, dsa_area *dsa);
52 extern void tbm_free(TIDBitmap *tbm);
53 extern void tbm_free_shared_area(dsa_area *dsa, dsa_pointer dp);
54 
55 extern void tbm_add_tuples(TIDBitmap *tbm,
56  const ItemPointer tids, int ntids,
57  bool recheck);
58 extern void tbm_add_page(TIDBitmap *tbm, BlockNumber pageno);
59 
60 extern void tbm_union(TIDBitmap *a, const TIDBitmap *b);
61 extern void tbm_intersect(TIDBitmap *a, const TIDBitmap *b);
62 
63 extern bool tbm_is_empty(const TIDBitmap *tbm);
64 
67 extern TBMIterateResult *tbm_iterate(TBMIterator *iterator);
69 extern void tbm_end_iterate(TBMIterator *iterator);
70 extern void tbm_end_shared_iterate(TBMSharedIterator *iterator);
72  dsa_pointer dp);
73 extern long tbm_calculate_entries(double maxbytes);
74 
75 #endif /* TIDBITMAP_H */
uint32 BlockNumber
Definition: block.h:31
#define FLEXIBLE_ARRAY_MEMBER
Definition: c.h:413
uint64 dsa_pointer
Definition: dsa.h:62
int b
Definition: isn.c:69
int a
Definition: isn.c:68
uint16 OffsetNumber
Definition: off.h:24
OffsetNumber offsets[FLEXIBLE_ARRAY_MEMBER]
Definition: tidbitmap.h:46
BlockNumber blockno
Definition: tidbitmap.h:42
Definition: dsa.c:348
void tbm_free(TIDBitmap *tbm)
Definition: tidbitmap.c:322
TBMIterator * tbm_begin_iterate(TIDBitmap *tbm)
Definition: tidbitmap.c:689
struct TBMIterateResult TBMIterateResult
void tbm_add_tuples(TIDBitmap *tbm, const ItemPointer tids, int ntids, bool recheck)
Definition: tidbitmap.c:377
bool tbm_is_empty(const TIDBitmap *tbm)
Definition: tidbitmap.c:670
void tbm_end_iterate(TBMIterator *iterator)
Definition: tidbitmap.c:1146
long tbm_calculate_entries(double maxbytes)
Definition: tidbitmap.c:1542
void tbm_end_shared_iterate(TBMSharedIterator *iterator)
Definition: tidbitmap.c:1158
TBMSharedIterator * tbm_attach_shared_iterate(dsa_area *dsa, dsa_pointer dp)
Definition: tidbitmap.c:1461
dsa_pointer tbm_prepare_shared_iterate(TIDBitmap *tbm)
Definition: tidbitmap.c:766
void tbm_intersect(TIDBitmap *a, const TIDBitmap *b)
Definition: tidbitmap.c:540
void tbm_free_shared_area(dsa_area *dsa, dsa_pointer dp)
Definition: tidbitmap.c:341
void tbm_add_page(TIDBitmap *tbm, BlockNumber pageno)
Definition: tidbitmap.c:443
TIDBitmap * tbm_create(long maxbytes, dsa_area *dsa)
Definition: tidbitmap.c:266
void tbm_union(TIDBitmap *a, const TIDBitmap *b)
Definition: tidbitmap.c:458
TBMIterateResult * tbm_shared_iterate(TBMSharedIterator *iterator)
Definition: tidbitmap.c:1052
TBMIterateResult * tbm_iterate(TBMIterator *iterator)
Definition: tidbitmap.c:971