tidbitmap.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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-2016, PostgreSQL Global Development Group
  17. *
  18. * src/include/nodes/tidbitmap.h
  19. *
  20. *-------------------------------------------------------------------------
  21. */
  22. #ifndef TIDBITMAP_H
  23. #define TIDBITMAP_H
  24. #include "storage/itemptr.h"
  25. /*
  26. * Actual bitmap representation is private to tidbitmap.c. Callers can
  27. * do IsA(x, TIDBitmap) on it, but nothing else.
  28. */
  29. typedef struct TIDBitmap TIDBitmap;
  30. /* Likewise, TBMIterator is private */
  31. typedef struct TBMIterator TBMIterator;
  32. /* Result structure for tbm_iterate */
  33. typedef struct
  34. {
  35. BlockNumber blockno; /* page number containing tuples */
  36. int ntuples; /* -1 indicates lossy result */
  37. bool recheck; /* should the tuples be rechecked? */
  38. /* Note: recheck is always true if ntuples < 0 */
  39. OffsetNumber offsets[FLEXIBLE_ARRAY_MEMBER];
  40. } TBMIterateResult;
  41. /* function prototypes in nodes/tidbitmap.c */
  42. extern TIDBitmap *tbm_create(long maxbytes);
  43. extern void tbm_free(TIDBitmap *tbm);
  44. extern void tbm_add_tuples(TIDBitmap *tbm,
  45. const ItemPointer tids, int ntids,
  46. bool recheck);
  47. extern void tbm_add_page(TIDBitmap *tbm, BlockNumber pageno);
  48. extern void tbm_union(TIDBitmap *a, const TIDBitmap *b);
  49. extern void tbm_intersect(TIDBitmap *a, const TIDBitmap *b);
  50. extern bool tbm_is_empty(const TIDBitmap *tbm);
  51. extern TBMIterator *tbm_begin_iterate(TIDBitmap *tbm);
  52. extern TBMIterateResult *tbm_iterate(TBMIterator *iterator);
  53. extern void tbm_end_iterate(TBMIterator *iterator);
  54. #endif /* TIDBITMAP_H */