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.
|
|
|
|
*
|
|
|
|
*
|
2024-01-04 02:49:05 +01:00
|
|
|
* Copyright (c) 2003-2024, PostgreSQL Global Development Group
|
2005-04-18 00:24:02 +02:00
|
|
|
*
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/include/nodes/tidbitmap.h
|
2005-04-18 00:24:02 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef TIDBITMAP_H
|
|
|
|
#define TIDBITMAP_H
|
|
|
|
|
|
|
|
#include "storage/itemptr.h"
|
2017-03-08 14:02:03 +01:00
|
|
|
#include "utils/dsa.h"
|
2005-04-18 00:24:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Actual bitmap representation is private to tidbitmap.c. Callers can
|
|
|
|
* do IsA(x, TIDBitmap) on it, but nothing else.
|
|
|
|
*/
|
|
|
|
typedef struct TIDBitmap TIDBitmap;
|
|
|
|
|
2009-01-10 22:08:36 +01:00
|
|
|
/* Likewise, TBMIterator is private */
|
|
|
|
typedef struct TBMIterator TBMIterator;
|
2017-03-08 14:02:03 +01:00
|
|
|
typedef struct TBMSharedIterator TBMSharedIterator;
|
2009-01-10 22:08:36 +01:00
|
|
|
|
2005-04-18 00:24:02 +02:00
|
|
|
/* Result structure for tbm_iterate */
|
2019-04-01 02:51:49 +02:00
|
|
|
typedef struct TBMIterateResult
|
2005-04-18 00:24:02 +02:00
|
|
|
{
|
|
|
|
BlockNumber blockno; /* page number containing tuples */
|
|
|
|
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 */
|
2015-02-20 06:11:42 +01:00
|
|
|
OffsetNumber offsets[FLEXIBLE_ARRAY_MEMBER];
|
|
|
|
} TBMIterateResult;
|
2005-04-18 00:24:02 +02:00
|
|
|
|
|
|
|
/* function prototypes in nodes/tidbitmap.c */
|
|
|
|
|
2017-03-08 14:02:03 +01:00
|
|
|
extern TIDBitmap *tbm_create(long maxbytes, dsa_area *dsa);
|
2005-04-18 00:24:02 +02:00
|
|
|
extern void tbm_free(TIDBitmap *tbm);
|
2017-03-08 14:02:03 +01:00
|
|
|
extern void tbm_free_shared_area(dsa_area *dsa, dsa_pointer dp);
|
2005-04-18 00:24:02 +02:00
|
|
|
|
2008-04-11 00:25:26 +02:00
|
|
|
extern void tbm_add_tuples(TIDBitmap *tbm,
|
|
|
|
const ItemPointer tids, int ntids,
|
|
|
|
bool recheck);
|
2009-03-24 21:17:18 +01:00
|
|
|
extern void tbm_add_page(TIDBitmap *tbm, BlockNumber pageno);
|
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);
|
|
|
|
|
2009-01-10 22:08:36 +01:00
|
|
|
extern TBMIterator *tbm_begin_iterate(TIDBitmap *tbm);
|
2017-03-08 14:02:03 +01:00
|
|
|
extern dsa_pointer tbm_prepare_shared_iterate(TIDBitmap *tbm);
|
2009-01-10 22:08:36 +01:00
|
|
|
extern TBMIterateResult *tbm_iterate(TBMIterator *iterator);
|
2017-03-08 14:02:03 +01:00
|
|
|
extern TBMIterateResult *tbm_shared_iterate(TBMSharedIterator *iterator);
|
2009-01-10 22:08:36 +01:00
|
|
|
extern void tbm_end_iterate(TBMIterator *iterator);
|
2017-03-08 14:02:03 +01:00
|
|
|
extern void tbm_end_shared_iterate(TBMSharedIterator *iterator);
|
|
|
|
extern TBMSharedIterator *tbm_attach_shared_iterate(dsa_area *dsa,
|
|
|
|
dsa_pointer dp);
|
2017-11-10 22:50:50 +01:00
|
|
|
extern long tbm_calculate_entries(double maxbytes);
|
2005-04-18 00:24:02 +02:00
|
|
|
|
|
|
|
#endif /* TIDBITMAP_H */
|