PostgreSQL Source Code  git master
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-2017, 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
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 */
46  OffsetNumber offsets[FLEXIBLE_ARRAY_MEMBER];
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 */
bool tbm_is_empty(const TIDBitmap *tbm)
Definition: tidbitmap.c:669
void tbm_free(TIDBitmap *tbm)
Definition: tidbitmap.c:321
TBMIterateResult * tbm_iterate(TBMIterator *iterator)
Definition: tidbitmap.c:970
void tbm_free_shared_area(dsa_area *dsa, dsa_pointer dp)
Definition: tidbitmap.c:340
TBMIterateResult * tbm_shared_iterate(TBMSharedIterator *iterator)
Definition: tidbitmap.c:1051
void tbm_end_shared_iterate(TBMSharedIterator *iterator)
Definition: tidbitmap.c:1157
uint32 BlockNumber
Definition: block.h:31
void tbm_end_iterate(TBMIterator *iterator)
Definition: tidbitmap.c:1145
uint64 dsa_pointer
Definition: dsa.h:62
uint16 OffsetNumber
Definition: off.h:24
TBMIterator * tbm_begin_iterate(TIDBitmap *tbm)
Definition: tidbitmap.c:688
BlockNumber blockno
Definition: tidbitmap.h:42
void tbm_add_page(TIDBitmap *tbm, BlockNumber pageno)
Definition: tidbitmap.c:442
long tbm_calculate_entries(double maxbytes)
Definition: tidbitmap.c:1545
void tbm_intersect(TIDBitmap *a, const TIDBitmap *b)
Definition: tidbitmap.c:539
dsa_pointer tbm_prepare_shared_iterate(TIDBitmap *tbm)
Definition: tidbitmap.c:765
TBMSharedIterator * tbm_attach_shared_iterate(dsa_area *dsa, dsa_pointer dp)
Definition: tidbitmap.c:1464
void tbm_add_tuples(TIDBitmap *tbm, const ItemPointer tids, int ntids, bool recheck)
Definition: tidbitmap.c:376
Definition: dsa.c:354
void tbm_union(TIDBitmap *a, const TIDBitmap *b)
Definition: tidbitmap.c:457
TIDBitmap * tbm_create(long maxbytes, dsa_area *dsa)
Definition: tidbitmap.c:265