gooderp18绿色标准版
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

103 lines
3.4KB

  1. /*
  2. * brin_tuple.h
  3. * Declarations for dealing with BRIN-specific tuples.
  4. *
  5. * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
  6. * Portions Copyright (c) 1994, Regents of the University of California
  7. *
  8. * IDENTIFICATION
  9. * src/include/access/brin_tuple.h
  10. */
  11. #ifndef BRIN_TUPLE_H
  12. #define BRIN_TUPLE_H
  13. #include "access/brin_internal.h"
  14. #include "access/tupdesc.h"
  15. /*
  16. * A BRIN index stores one index tuple per page range. Each index tuple
  17. * has one BrinValues struct for each indexed column; in turn, each BrinValues
  18. * has (besides the null flags) an array of Datum whose size is determined by
  19. * the opclass.
  20. */
  21. typedef struct BrinValues
  22. {
  23. AttrNumber bv_attno; /* index attribute number */
  24. bool bv_hasnulls; /* are there any nulls in the page range? */
  25. bool bv_allnulls; /* are all values nulls in the page range? */
  26. Datum *bv_values; /* current accumulated values */
  27. } BrinValues;
  28. /*
  29. * This struct is used to represent an in-memory index tuple. The values can
  30. * only be meaningfully decoded with an appropriate BrinDesc.
  31. */
  32. typedef struct BrinMemTuple
  33. {
  34. bool bt_placeholder; /* this is a placeholder tuple */
  35. BlockNumber bt_blkno; /* heap blkno that the tuple is for */
  36. MemoryContext bt_context; /* memcxt holding the bt_columns values */
  37. /* output arrays for brin_deform_tuple: */
  38. Datum *bt_values; /* values array */
  39. bool *bt_allnulls; /* allnulls array */
  40. bool *bt_hasnulls; /* hasnulls array */
  41. /* not an output array, but must be last */
  42. BrinValues bt_columns[FLEXIBLE_ARRAY_MEMBER];
  43. } BrinMemTuple;
  44. /*
  45. * An on-disk BRIN tuple. This is possibly followed by a nulls bitmask, with
  46. * room for 2 null bits (two bits for each indexed column); an opclass-defined
  47. * number of Datum values for each column follow.
  48. */
  49. typedef struct BrinTuple
  50. {
  51. /* heap block number that the tuple is for */
  52. BlockNumber bt_blkno;
  53. /* ---------------
  54. * bt_info is laid out in the following fashion:
  55. *
  56. * 7th (high) bit: has nulls
  57. * 6th bit: is placeholder tuple
  58. * 5th bit: unused
  59. * 4-0 bit: offset of data
  60. * ---------------
  61. */
  62. uint8 bt_info;
  63. } BrinTuple;
  64. #define SizeOfBrinTuple (offsetof(BrinTuple, bt_info) + sizeof(uint8))
  65. /*
  66. * bt_info manipulation macros
  67. */
  68. #define BRIN_OFFSET_MASK 0x1F
  69. /* bit 0x20 is not used at present */
  70. #define BRIN_PLACEHOLDER_MASK 0x40
  71. #define BRIN_NULLS_MASK 0x80
  72. #define BrinTupleDataOffset(tup) ((Size) (((BrinTuple *) (tup))->bt_info & BRIN_OFFSET_MASK))
  73. #define BrinTupleHasNulls(tup) (((((BrinTuple *) (tup))->bt_info & BRIN_NULLS_MASK)) != 0)
  74. #define BrinTupleIsPlaceholder(tup) (((((BrinTuple *) (tup))->bt_info & BRIN_PLACEHOLDER_MASK)) != 0)
  75. extern BrinTuple *brin_form_tuple(BrinDesc *brdesc, BlockNumber blkno,
  76. BrinMemTuple *tuple, Size *size);
  77. extern BrinTuple *brin_form_placeholder_tuple(BrinDesc *brdesc,
  78. BlockNumber blkno, Size *size);
  79. extern void brin_free_tuple(BrinTuple *tuple);
  80. extern BrinTuple *brin_copy_tuple(BrinTuple *tuple, Size len,
  81. BrinTuple *dest, Size *destsz);
  82. extern bool brin_tuples_equal(const BrinTuple *a, Size alen,
  83. const BrinTuple *b, Size blen);
  84. extern BrinMemTuple *brin_new_memtuple(BrinDesc *brdesc);
  85. extern BrinMemTuple *brin_memtuple_initialize(BrinMemTuple *dtuple,
  86. BrinDesc *brdesc);
  87. extern BrinMemTuple *brin_deform_tuple(BrinDesc *brdesc,
  88. BrinTuple *tuple, BrinMemTuple *dMemtuple);
  89. #endif /* BRIN_TUPLE_H */
上海开阖软件有限公司 沪ICP备12045867号-1