PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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 
27 
28 /*
29  * Actual bitmap representation is private to tidbitmap.c. Callers can
30  * do IsA(x, TIDBitmap) on it, but nothing else.
31  */
32 typedef struct TIDBitmap TIDBitmap;
33 
34 /* Likewise, TBMIterator is private */
35 typedef struct TBMIterator TBMIterator;
36 
37 /* Result structure for tbm_iterate */
38 typedef struct
39 {
40  BlockNumber blockno; /* page number containing tuples */
41  int ntuples; /* -1 indicates lossy result */
42  bool recheck; /* should the tuples be rechecked? */
43  /* Note: recheck is always true if ntuples < 0 */
44  OffsetNumber offsets[FLEXIBLE_ARRAY_MEMBER];
46 
47 /* function prototypes in nodes/tidbitmap.c */
48 
49 extern TIDBitmap *tbm_create(long maxbytes);
50 extern void tbm_free(TIDBitmap *tbm);
51 
52 extern void tbm_add_tuples(TIDBitmap *tbm,
53  const ItemPointer tids, int ntids,
54  bool recheck);
55 extern void tbm_add_page(TIDBitmap *tbm, BlockNumber pageno);
56 
57 extern void tbm_union(TIDBitmap *a, const TIDBitmap *b);
58 extern void tbm_intersect(TIDBitmap *a, const TIDBitmap *b);
59 
60 extern bool tbm_is_empty(const TIDBitmap *tbm);
61 
63 extern TBMIterateResult *tbm_iterate(TBMIterator *iterator);
64 extern void tbm_end_iterate(TBMIterator *iterator);
65 
66 #endif /* TIDBITMAP_H */
bool tbm_is_empty(const TIDBitmap *tbm)
Definition: tidbitmap.c:583
void tbm_free(TIDBitmap *tbm)
Definition: tidbitmap.c:272
TBMIterateResult * tbm_iterate(TBMIterator *iterator)
Definition: tidbitmap.c:680
uint32 BlockNumber
Definition: block.h:31
void tbm_end_iterate(TBMIterator *iterator)
Definition: tidbitmap.c:787
uint16 OffsetNumber
Definition: off.h:24
TBMIterator * tbm_begin_iterate(TIDBitmap *tbm)
Definition: tidbitmap.c:602
BlockNumber blockno
Definition: tidbitmap.h:40
TIDBitmap * tbm_create(long maxbytes)
Definition: tidbitmap.c:210
void tbm_add_page(TIDBitmap *tbm, BlockNumber pageno)
Definition: tidbitmap.c:356
TIDBitmap * tbm
Definition: tidbitmap.c:152
void tbm_intersect(TIDBitmap *a, const TIDBitmap *b)
Definition: tidbitmap.c:453
void tbm_add_tuples(TIDBitmap *tbm, const ItemPointer tids, int ntids, bool recheck)
Definition: tidbitmap.c:290
void tbm_union(TIDBitmap *a, const TIDBitmap *b)
Definition: tidbitmap.c:371