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-2008, PostgreSQL Global Development Group
20 *-------------------------------------------------------------------------
25 #include "storage/itemptr.h"
29 * Actual bitmap representation is private to tidbitmap.c. Callers can
30 * do IsA(x, TIDBitmap) on it, but nothing else.
32 typedef struct TIDBitmap TIDBitmap
;
34 /* Result structure for tbm_iterate */
37 BlockNumber blockno
; /* page number containing tuples */
38 int ntuples
; /* -1 indicates lossy result */
39 bool recheck
; /* should the tuples be rechecked? */
40 /* Note: recheck is always true if ntuples < 0 */
41 OffsetNumber offsets
[1]; /* VARIABLE LENGTH ARRAY */
42 } TBMIterateResult
; /* VARIABLE LENGTH STRUCT */
44 /* function prototypes in nodes/tidbitmap.c */
46 extern TIDBitmap
*tbm_create(long maxbytes
);
47 extern void tbm_free(TIDBitmap
*tbm
);
49 extern void tbm_add_tuples(TIDBitmap
*tbm
,
50 const ItemPointer tids
, int ntids
,
53 extern void tbm_union(TIDBitmap
*a
, const TIDBitmap
*b
);
54 extern void tbm_intersect(TIDBitmap
*a
, const TIDBitmap
*b
);
56 extern bool tbm_is_empty(const TIDBitmap
*tbm
);
58 extern void tbm_begin_iterate(TIDBitmap
*tbm
);
59 extern TBMIterateResult
*tbm_iterate(TIDBitmap
*tbm
);
61 #endif /* TIDBITMAP_H */