2005-04-18 00:24:02 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* tidbitmap.h
|
|
|
|
* PostgreSQL tuple-id (TID) bitmap package
|
|
|
|
*
|
|
|
|
* This module provides bitmap data structures that are spiritually
|
|
|
|
* similar to Bitmapsets, but are specially adapted to store sets of
|
|
|
|
* tuple identifiers (TIDs), or ItemPointers. In particular, the division
|
|
|
|
* of an ItemPointer into BlockNumber and OffsetNumber is catered for.
|
|
|
|
* Also, since we wish to be able to store very large tuple sets in
|
|
|
|
* memory with this data structure, we support "lossy" storage, in which
|
|
|
|
* we no longer remember individual tuple offsets on a page but only the
|
|
|
|
* fact that a particular page needs to be visited.
|
|
|
|
*
|
|
|
|
*
|
2008-01-01 20:46:01 +01:00
|
|
|
* Copyright (c) 2003-2008, PostgreSQL Global Development Group
|
2005-04-18 00:24:02 +02:00
|
|
|
*
|
2008-04-11 00:25:26 +02:00
|
|
|
* $PostgreSQL: pgsql/src/include/nodes/tidbitmap.h,v 1.7 2008/04/10 22:25:26 tgl Exp $
|
2005-04-18 00:24:02 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef TIDBITMAP_H
|
|
|
|
#define TIDBITMAP_H
|
|
|
|
|
|
|
|
#include "storage/itemptr.h"
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* Actual bitmap representation is private to tidbitmap.c. Callers can
|
2005-04-18 00:24:02 +02:00
|
|
|
* do IsA(x, TIDBitmap) on it, but nothing else.
|
|
|
|
*/
|
|
|
|
typedef struct TIDBitmap TIDBitmap;
|
|
|
|
|
|
|
|
/* Result structure for tbm_iterate */
|
|
|
|
typedef struct
|
|
|
|
{
|
2005-10-15 04:49:52 +02:00
|
|
|
BlockNumber blockno; /* page number containing tuples */
|
2005-04-18 00:24:02 +02:00
|
|
|
int ntuples; /* -1 indicates lossy result */
|
2008-04-11 00:25:26 +02:00
|
|
|
bool recheck; /* should the tuples be rechecked? */
|
|
|
|
/* Note: recheck is always true if ntuples < 0 */
|
2005-04-18 00:24:02 +02:00
|
|
|
OffsetNumber offsets[1]; /* VARIABLE LENGTH ARRAY */
|
|
|
|
} TBMIterateResult; /* VARIABLE LENGTH STRUCT */
|
|
|
|
|
|
|
|
/* function prototypes in nodes/tidbitmap.c */
|
|
|
|
|
|
|
|
extern TIDBitmap *tbm_create(long maxbytes);
|
|
|
|
extern void tbm_free(TIDBitmap *tbm);
|
|
|
|
|
2008-04-11 00:25:26 +02:00
|
|
|
extern void tbm_add_tuples(TIDBitmap *tbm,
|
|
|
|
const ItemPointer tids, int ntids,
|
|
|
|
bool recheck);
|
2005-04-18 00:24:02 +02:00
|
|
|
|
|
|
|
extern void tbm_union(TIDBitmap *a, const TIDBitmap *b);
|
|
|
|
extern void tbm_intersect(TIDBitmap *a, const TIDBitmap *b);
|
|
|
|
|
2005-08-29 00:47:20 +02:00
|
|
|
extern bool tbm_is_empty(const TIDBitmap *tbm);
|
|
|
|
|
2005-04-18 00:24:02 +02:00
|
|
|
extern void tbm_begin_iterate(TIDBitmap *tbm);
|
|
|
|
extern TBMIterateResult *tbm_iterate(TIDBitmap *tbm);
|
|
|
|
|
|
|
|
#endif /* TIDBITMAP_H */
|