Header And Logo

PostgreSQL
| The world's most advanced open source database.

tidbitmap.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * tidbitmap.h
00004  *    PostgreSQL tuple-id (TID) bitmap package
00005  *
00006  * This module provides bitmap data structures that are spiritually
00007  * similar to Bitmapsets, but are specially adapted to store sets of
00008  * tuple identifiers (TIDs), or ItemPointers.  In particular, the division
00009  * of an ItemPointer into BlockNumber and OffsetNumber is catered for.
00010  * Also, since we wish to be able to store very large tuple sets in
00011  * memory with this data structure, we support "lossy" storage, in which
00012  * we no longer remember individual tuple offsets on a page but only the
00013  * fact that a particular page needs to be visited.
00014  *
00015  *
00016  * Copyright (c) 2003-2013, PostgreSQL Global Development Group
00017  *
00018  * src/include/nodes/tidbitmap.h
00019  *
00020  *-------------------------------------------------------------------------
00021  */
00022 #ifndef TIDBITMAP_H
00023 #define TIDBITMAP_H
00024 
00025 #include "storage/itemptr.h"
00026 
00027 
00028 /*
00029  * Actual bitmap representation is private to tidbitmap.c.  Callers can
00030  * do IsA(x, TIDBitmap) on it, but nothing else.
00031  */
00032 typedef struct TIDBitmap TIDBitmap;
00033 
00034 /* Likewise, TBMIterator is private */
00035 typedef struct TBMIterator TBMIterator;
00036 
00037 /* Result structure for tbm_iterate */
00038 typedef struct
00039 {
00040     BlockNumber blockno;        /* page number containing tuples */
00041     int         ntuples;        /* -1 indicates lossy result */
00042     bool        recheck;        /* should the tuples be rechecked? */
00043     /* Note: recheck is always true if ntuples < 0 */
00044     OffsetNumber offsets[1];    /* VARIABLE LENGTH ARRAY */
00045 } TBMIterateResult;             /* VARIABLE LENGTH STRUCT */
00046 
00047 /* function prototypes in nodes/tidbitmap.c */
00048 
00049 extern TIDBitmap *tbm_create(long maxbytes);
00050 extern void tbm_free(TIDBitmap *tbm);
00051 
00052 extern void tbm_add_tuples(TIDBitmap *tbm,
00053                const ItemPointer tids, int ntids,
00054                bool recheck);
00055 extern void tbm_add_page(TIDBitmap *tbm, BlockNumber pageno);
00056 
00057 extern void tbm_union(TIDBitmap *a, const TIDBitmap *b);
00058 extern void tbm_intersect(TIDBitmap *a, const TIDBitmap *b);
00059 
00060 extern bool tbm_is_empty(const TIDBitmap *tbm);
00061 
00062 extern TBMIterator *tbm_begin_iterate(TIDBitmap *tbm);
00063 extern TBMIterateResult *tbm_iterate(TBMIterator *iterator);
00064 extern void tbm_end_iterate(TBMIterator *iterator);
00065 
00066 #endif   /* TIDBITMAP_H */