PostgreSQL Source Code  git master
blutils.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * blutils.c
4  * Bloom index utilities.
5  *
6  * Portions Copyright (c) 2016-2020, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1990-1993, Regents of the University of California
8  *
9  * IDENTIFICATION
10  * contrib/bloom/blutils.c
11  *
12  *-------------------------------------------------------------------------
13  */
14 #include "postgres.h"
15 
16 #include "access/amapi.h"
17 #include "access/generic_xlog.h"
18 #include "access/reloptions.h"
19 #include "bloom.h"
20 #include "catalog/index.h"
21 #include "commands/vacuum.h"
22 #include "miscadmin.h"
23 #include "storage/bufmgr.h"
24 #include "storage/freespace.h"
25 #include "storage/indexfsm.h"
26 #include "storage/lmgr.h"
27 #include "utils/memutils.h"
28 
29 /* Signature dealing macros - note i is assumed to be of type int */
30 #define GETWORD(x,i) ( *( (BloomSignatureWord *)(x) + ( (i) / SIGNWORDBITS ) ) )
31 #define CLRBIT(x,i) GETWORD(x,i) &= ~( 0x01 << ( (i) % SIGNWORDBITS ) )
32 #define SETBIT(x,i) GETWORD(x,i) |= ( 0x01 << ( (i) % SIGNWORDBITS ) )
33 #define GETBIT(x,i) ( (GETWORD(x,i) >> ( (i) % SIGNWORDBITS )) & 0x01 )
34 
36 
37 /* Kind of relation options for bloom index */
39 
40 /* parse table for fillRelOptions */
42 
43 static int32 myRand(void);
44 static void mySrand(uint32 seed);
45 
46 /*
47  * Module initialize function: initialize info about Bloom relation options.
48  *
49  * Note: keep this in sync with makeDefaultBloomOptions().
50  */
51 void
52 _PG_init(void)
53 {
54  int i;
55  char buf[16];
56 
58 
59  /* Option for length of signature */
61  "Length of signature in bits",
64  bl_relopt_tab[0].optname = "length";
65  bl_relopt_tab[0].opttype = RELOPT_TYPE_INT;
66  bl_relopt_tab[0].offset = offsetof(BloomOptions, bloomLength);
67 
68  /* Number of bits for each possible index column: col1, col2, ... */
69  for (i = 0; i < INDEX_MAX_KEYS; i++)
70  {
71  snprintf(buf, sizeof(buf), "col%d", i + 1);
73  "Number of bits generated for each index column",
76  bl_relopt_tab[i + 1].optname = MemoryContextStrdup(TopMemoryContext,
77  buf);
78  bl_relopt_tab[i + 1].opttype = RELOPT_TYPE_INT;
79  bl_relopt_tab[i + 1].offset = offsetof(BloomOptions, bitSize[0]) + sizeof(int) * i;
80  }
81 }
82 
83 /*
84  * Construct a default set of Bloom options.
85  */
86 static BloomOptions *
88 {
89  BloomOptions *opts;
90  int i;
91 
92  opts = (BloomOptions *) palloc0(sizeof(BloomOptions));
93  /* Convert DEFAULT_BLOOM_LENGTH from # of bits to # of words */
95  for (i = 0; i < INDEX_MAX_KEYS; i++)
96  opts->bitSize[i] = DEFAULT_BLOOM_BITS;
97  SET_VARSIZE(opts, sizeof(BloomOptions));
98  return opts;
99 }
100 
101 /*
102  * Bloom handler function: return IndexAmRoutine with access method parameters
103  * and callbacks.
104  */
105 Datum
107 {
108  IndexAmRoutine *amroutine = makeNode(IndexAmRoutine);
109 
110  amroutine->amstrategies = BLOOM_NSTRATEGIES;
111  amroutine->amsupport = BLOOM_NPROC;
112  amroutine->amoptsprocnum = BLOOM_OPTIONS_PROC;
113  amroutine->amcanorder = false;
114  amroutine->amcanorderbyop = false;
115  amroutine->amcanbackward = false;
116  amroutine->amcanunique = false;
117  amroutine->amcanmulticol = true;
118  amroutine->amoptionalkey = true;
119  amroutine->amsearcharray = false;
120  amroutine->amsearchnulls = false;
121  amroutine->amstorage = false;
122  amroutine->amclusterable = false;
123  amroutine->ampredlocks = false;
124  amroutine->amcanparallel = false;
125  amroutine->amcaninclude = false;
126  amroutine->amusemaintenanceworkmem = false;
127  amroutine->amparallelvacuumoptions =
129  amroutine->amkeytype = InvalidOid;
130 
131  amroutine->ambuild = blbuild;
132  amroutine->ambuildempty = blbuildempty;
133  amroutine->aminsert = blinsert;
134  amroutine->ambulkdelete = blbulkdelete;
135  amroutine->amvacuumcleanup = blvacuumcleanup;
136  amroutine->amcanreturn = NULL;
137  amroutine->amcostestimate = blcostestimate;
138  amroutine->amoptions = bloptions;
139  amroutine->amproperty = NULL;
140  amroutine->ambuildphasename = NULL;
141  amroutine->amvalidate = blvalidate;
142  amroutine->ambeginscan = blbeginscan;
143  amroutine->amrescan = blrescan;
144  amroutine->amgettuple = NULL;
145  amroutine->amgetbitmap = blgetbitmap;
146  amroutine->amendscan = blendscan;
147  amroutine->ammarkpos = NULL;
148  amroutine->amrestrpos = NULL;
149  amroutine->amestimateparallelscan = NULL;
150  amroutine->aminitparallelscan = NULL;
151  amroutine->amparallelrescan = NULL;
152 
153  PG_RETURN_POINTER(amroutine);
154 }
155 
156 /*
157  * Fill BloomState structure for particular index.
158  */
159 void
161 {
162  int i;
163 
164  state->nColumns = index->rd_att->natts;
165 
166  /* Initialize hash function for each attribute */
167  for (i = 0; i < index->rd_att->natts; i++)
168  {
169  fmgr_info_copy(&(state->hashFn[i]),
170  index_getprocinfo(index, i + 1, BLOOM_HASH_PROC),
172  state->collations[i] = index->rd_indcollation[i];
173  }
174 
175  /* Initialize amcache if needed with options from metapage */
176  if (!index->rd_amcache)
177  {
178  Buffer buffer;
179  Page page;
180  BloomMetaPageData *meta;
181  BloomOptions *opts;
182 
183  opts = MemoryContextAlloc(index->rd_indexcxt, sizeof(BloomOptions));
184 
185  buffer = ReadBuffer(index, BLOOM_METAPAGE_BLKNO);
186  LockBuffer(buffer, BUFFER_LOCK_SHARE);
187 
188  page = BufferGetPage(buffer);
189 
190  if (!BloomPageIsMeta(page))
191  elog(ERROR, "Relation is not a bloom index");
192  meta = BloomPageGetMeta(BufferGetPage(buffer));
193 
194  if (meta->magickNumber != BLOOM_MAGICK_NUMBER)
195  elog(ERROR, "Relation is not a bloom index");
196 
197  *opts = meta->opts;
198 
199  UnlockReleaseBuffer(buffer);
200 
201  index->rd_amcache = (void *) opts;
202  }
203 
204  memcpy(&state->opts, index->rd_amcache, sizeof(state->opts));
206  sizeof(BloomSignatureWord) * state->opts.bloomLength;
207 }
208 
209 /*
210  * Random generator copied from FreeBSD. Using own random generator here for
211  * two reasons:
212  *
213  * 1) In this case random numbers are used for on-disk storage. Usage of
214  * PostgreSQL number generator would obstruct it from all possible changes.
215  * 2) Changing seed of PostgreSQL random generator would be undesirable side
216  * effect.
217  */
218 static int32 next;
219 
220 static int32
221 myRand(void)
222 {
223  /*----------
224  * Compute x = (7^5 * x) mod (2^31 - 1)
225  * without overflowing 31 bits:
226  * (2^31 - 1) = 127773 * (7^5) + 2836
227  * From "Random number generators: good ones are hard to find",
228  * Park and Miller, Communications of the ACM, vol. 31, no. 10,
229  * October 1988, p. 1195.
230  *----------
231  */
232  int32 hi,
233  lo,
234  x;
235 
236  /* Must be in [1, 0x7ffffffe] range at this point. */
237  hi = next / 127773;
238  lo = next % 127773;
239  x = 16807 * lo - 2836 * hi;
240  if (x < 0)
241  x += 0x7fffffff;
242  next = x;
243  /* Transform to [0, 0x7ffffffd] range. */
244  return (x - 1);
245 }
246 
247 static void
249 {
250  next = seed;
251  /* Transform to [1, 0x7ffffffe] range. */
252  next = (next % 0x7ffffffe) + 1;
253 }
254 
255 /*
256  * Add bits of given value to the signature.
257  */
258 void
260 {
261  uint32 hashVal;
262  int nBit,
263  j;
264 
265  /*
266  * init generator with "column's" number to get "hashed" seed for new
267  * value. We don't want to map the same numbers from different columns
268  * into the same bits!
269  */
270  mySrand(attno);
271 
272  /*
273  * Init hash sequence to map our value into bits. the same values in
274  * different columns will be mapped into different bits because of step
275  * above
276  */
277  hashVal = DatumGetInt32(FunctionCall1Coll(&state->hashFn[attno], state->collations[attno], value));
278  mySrand(hashVal ^ myRand());
279 
280  for (j = 0; j < state->opts.bitSize[attno]; j++)
281  {
282  /* prevent multiple evaluation in SETBIT macro */
283  nBit = myRand() % (state->opts.bloomLength * SIGNWORDBITS);
284  SETBIT(sign, nBit);
285  }
286 }
287 
288 /*
289  * Make bloom tuple from values.
290  */
291 BloomTuple *
293 {
294  int i;
295  BloomTuple *res = (BloomTuple *) palloc0(state->sizeOfBloomTuple);
296 
297  res->heapPtr = *iptr;
298 
299  /* Blooming each column */
300  for (i = 0; i < state->nColumns; i++)
301  {
302  /* skip nulls */
303  if (isnull[i])
304  continue;
305 
306  signValue(state, res->sign, values[i], i);
307  }
308 
309  return res;
310 }
311 
312 /*
313  * Add new bloom tuple to the page. Returns true if new tuple was successfully
314  * added to the page. Returns false if it doesn't fit on the page.
315  */
316 bool
318 {
319  BloomTuple *itup;
320  BloomPageOpaque opaque;
321  Pointer ptr;
322 
323  /* We shouldn't be pointed to an invalid page */
324  Assert(!PageIsNew(page) && !BloomPageIsDeleted(page));
325 
326  /* Does new tuple fit on the page? */
327  if (BloomPageGetFreeSpace(state, page) < state->sizeOfBloomTuple)
328  return false;
329 
330  /* Copy new tuple to the end of page */
331  opaque = BloomPageGetOpaque(page);
332  itup = BloomPageGetTuple(state, page, opaque->maxoff + 1);
333  memcpy((Pointer) itup, (Pointer) tuple, state->sizeOfBloomTuple);
334 
335  /* Adjust maxoff and pd_lower */
336  opaque->maxoff++;
337  ptr = (Pointer) BloomPageGetTuple(state, page, opaque->maxoff + 1);
338  ((PageHeader) page)->pd_lower = ptr - page;
339 
340  /* Assert we didn't overrun available space */
341  Assert(((PageHeader) page)->pd_lower <= ((PageHeader) page)->pd_upper);
342 
343  return true;
344 }
345 
346 /*
347  * Allocate a new page (either by recycling, or by extending the index file)
348  * The returned buffer is already pinned and exclusive-locked
349  * Caller is responsible for initializing the page by calling BloomInitPage
350  */
351 Buffer
353 {
354  Buffer buffer;
355  bool needLock;
356 
357  /* First, try to get a page from FSM */
358  for (;;)
359  {
360  BlockNumber blkno = GetFreeIndexPage(index);
361 
362  if (blkno == InvalidBlockNumber)
363  break;
364 
365  buffer = ReadBuffer(index, blkno);
366 
367  /*
368  * We have to guard against the possibility that someone else already
369  * recycled this page; the buffer may be locked if so.
370  */
371  if (ConditionalLockBuffer(buffer))
372  {
373  Page page = BufferGetPage(buffer);
374 
375  if (PageIsNew(page))
376  return buffer; /* OK to use, if never initialized */
377 
378  if (BloomPageIsDeleted(page))
379  return buffer; /* OK to use */
380 
382  }
383 
384  /* Can't use it, so release buffer and try again */
385  ReleaseBuffer(buffer);
386  }
387 
388  /* Must extend the file */
389  needLock = !RELATION_IS_LOCAL(index);
390  if (needLock)
392 
393  buffer = ReadBuffer(index, P_NEW);
395 
396  if (needLock)
398 
399  return buffer;
400 }
401 
402 /*
403  * Initialize any page of a bloom index.
404  */
405 void
407 {
408  BloomPageOpaque opaque;
409 
410  PageInit(page, BLCKSZ, sizeof(BloomPageOpaqueData));
411 
412  opaque = BloomPageGetOpaque(page);
413  memset(opaque, 0, sizeof(BloomPageOpaqueData));
414  opaque->flags = flags;
415  opaque->bloom_page_id = BLOOM_PAGE_ID;
416 }
417 
418 /*
419  * Fill in metapage for bloom index.
420  */
421 void
423 {
424  BloomOptions *opts;
425  BloomMetaPageData *metadata;
426 
427  /*
428  * Choose the index's options. If reloptions have been assigned, use
429  * those, otherwise create default options.
430  */
431  opts = (BloomOptions *) index->rd_options;
432  if (!opts)
433  opts = makeDefaultBloomOptions();
434 
435  /*
436  * Initialize contents of meta page, including a copy of the options,
437  * which are now frozen for the life of the index.
438  */
439  BloomInitPage(metaPage, BLOOM_META);
440  metadata = BloomPageGetMeta(metaPage);
441  memset(metadata, 0, sizeof(BloomMetaPageData));
442  metadata->magickNumber = BLOOM_MAGICK_NUMBER;
443  metadata->opts = *opts;
444  ((PageHeader) metaPage)->pd_lower += sizeof(BloomMetaPageData);
445 
446  /* If this fails, probably FreeBlockNumberArray size calc is wrong: */
447  Assert(((PageHeader) metaPage)->pd_lower <= ((PageHeader) metaPage)->pd_upper);
448 }
449 
450 /*
451  * Initialize metapage for bloom index.
452  */
453 void
455 {
456  Buffer metaBuffer;
457  Page metaPage;
459 
460  /*
461  * Make a new page; since it is first page it should be associated with
462  * block number 0 (BLOOM_METAPAGE_BLKNO).
463  */
464  metaBuffer = BloomNewBuffer(index);
466 
467  /* Initialize contents of meta page */
468  state = GenericXLogStart(index);
469  metaPage = GenericXLogRegisterBuffer(state, metaBuffer,
471  BloomFillMetapage(index, metaPage);
472  GenericXLogFinish(state);
473 
474  UnlockReleaseBuffer(metaBuffer);
475 }
476 
477 /*
478  * Parse reloptions for bloom index, producing a BloomOptions struct.
479  */
480 bytea *
481 bloptions(Datum reloptions, bool validate)
482 {
483  BloomOptions *rdopts;
484 
485  /* Parse the user-given reloptions */
486  rdopts = (BloomOptions *) build_reloptions(reloptions, validate,
488  sizeof(BloomOptions),
490  lengthof(bl_relopt_tab));
491 
492  /* Convert signature length from # of bits to # to words, rounding up */
493  if (rdopts)
494  rdopts->bloomLength = (rdopts->bloomLength + SIGNWORDBITS - 1) / SIGNWORDBITS;
495 
496  return (bytea *) rdopts;
497 }
ambeginscan_function ambeginscan
Definition: amapi.h:227
uint8 amparallelvacuumoptions
Definition: amapi.h:205
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:360
#define BLOOM_METAPAGE_BLKNO
Definition: bloom.h:78
#define BUFFER_LOCK_UNLOCK
Definition: bufmgr.h:96
#define SETBIT(x, i)
Definition: blutils.c:32
#define BloomPageIsDeleted(page)
Definition: bloom.h:64
ambulkdelete_function ambulkdelete
Definition: amapi.h:219
relopt_type opttype
Definition: reloptions.h:153
bool amcanmulticol
Definition: amapi.h:185
#define MAX_BLOOM_LENGTH
Definition: bloom.h:92
uint16 amsupport
Definition: amapi.h:173
IndexBuildResult * blbuild(Relation heap, Relation index, IndexInfo *indexInfo)
Definition: blinsert.c:122
BloomOptions opts
Definition: bloom.h:142
#define BLOOM_PAGE_ID
Definition: bloom.h:57
static int32 next
Definition: blutils.c:218
FmgrInfo * index_getprocinfo(Relation irel, AttrNumber attnum, uint16 procnum)
Definition: indexam.c:800
amgettuple_function amgettuple
Definition: amapi.h:229
#define DatumGetInt32(X)
Definition: postgres.h:472
bool amcanorderbyop
Definition: amapi.h:179
amproperty_function amproperty
Definition: amapi.h:224
#define ExclusiveLock
Definition: lockdefs.h:44
static BloomOptions * makeDefaultBloomOptions(void)
Definition: blutils.c:87
#define RELATION_IS_LOCAL(relation)
Definition: rel.h:583
#define BloomPageIsMeta(page)
Definition: bloom.h:62
FmgrInfo hashFn[INDEX_MAX_KEYS]
Definition: bloom.h:140
amparallelrescan_function amparallelrescan
Definition: amapi.h:238
#define BLOOM_NPROC
Definition: bloom.h:26
bool amstorage
Definition: amapi.h:193
#define DEFAULT_BLOOM_BITS
Definition: bloom.h:97
bool ampredlocks
Definition: amapi.h:197
uint32 BlockNumber
Definition: block.h:31
void ReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3483
#define P_NEW
Definition: bufmgr.h:91
OffsetNumber maxoff
Definition: bloom.h:35
aminsert_function aminsert
Definition: amapi.h:218
#define lengthof(array)
Definition: c.h:668
#define BUFFER_LOCK_EXCLUSIVE
Definition: bufmgr.h:98
PG_FUNCTION_INFO_V1(blhandler)
void add_int_reloption(bits32 kinds, const char *name, const char *desc, int default_val, int min_val, int max_val, LOCKMODE lockmode)
Definition: reloptions.c:877
Oid amkeytype
Definition: amapi.h:207
int bitSize[INDEX_MAX_KEYS]
Definition: bloom.h:105
Oid collations[INDEX_MAX_KEYS]
Definition: bloom.h:141
void blcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, double *indexCorrelation, double *indexPages)
Definition: blcost.c:23
bool amoptionalkey
Definition: amapi.h:187
Page GenericXLogRegisterBuffer(GenericXLogState *state, Buffer buffer, int flags)
Definition: generic_xlog.c:295
amvalidate_function amvalidate
Definition: amapi.h:226
uint16 bloom_page_id
Definition: bloom.h:40
void _PG_init(void)
Definition: blutils.c:52
signed int int32
Definition: c.h:355
IndexBulkDeleteResult * blvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
Definition: blvacuum.c:169
uint16 flags
Definition: bloom.h:36
void * build_reloptions(Datum reloptions, bool validate, relopt_kind kind, Size relopt_struct_size, const relopt_parse_elt *relopt_elems, int num_relopt_elems)
Definition: reloptions.c:1887
#define DEFAULT_BLOOM_LENGTH
Definition: bloom.h:91
Buffer BloomNewBuffer(Relation index)
Definition: blutils.c:352
bool blvalidate(Oid opclassoid)
Definition: blvalidate.c:32
Definition: type.h:89
void blendscan(IndexScanDesc scan)
Definition: blscan.c:68
uint16 BloomSignatureWord
Definition: bloom.h:84
unsigned short uint16
Definition: c.h:366
char * Pointer
Definition: c.h:344
amgetbitmap_function amgetbitmap
Definition: amapi.h:230
void UnlockReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3506
#define BloomPageGetOpaque(page)
Definition: bloom.h:60
Oid * rd_indcollation
Definition: rel.h:199
#define ERROR
Definition: elog.h:43
ambuild_function ambuild
Definition: amapi.h:216
static relopt_kind bl_relopt_kind
Definition: blutils.c:38
amoptions_function amoptions
Definition: amapi.h:223
void initBloomState(BloomState *state, Relation index)
Definition: blutils.c:160
static relopt_parse_elt bl_relopt_tab[INDEX_MAX_KEYS+1]
Definition: blutils.c:41
#define SIGNWORDBITS
Definition: bloom.h:86
bool amcaninclude
Definition: amapi.h:201
void fmgr_info_copy(FmgrInfo *dstinfo, FmgrInfo *srcinfo, MemoryContext destcxt)
Definition: fmgr.c:612
char sign
Definition: informix.c:668
amcostestimate_function amcostestimate
Definition: amapi.h:222
bool amcanunique
Definition: amapi.h:183
#define BloomPageGetFreeSpace(state, page)
Definition: bloom.h:152
IndexBulkDeleteResult * blbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state)
Definition: blvacuum.c:34
static char * buf
Definition: pg_test_fsync.c:67
amvacuumcleanup_function amvacuumcleanup
Definition: amapi.h:220
amendscan_function amendscan
Definition: amapi.h:231
bool amcanbackward
Definition: amapi.h:181
void BloomFillMetapage(Relation index, Page metaPage)
Definition: blutils.c:422
unsigned int uint32
Definition: c.h:367
MemoryContext CurrentMemoryContext
Definition: mcxt.c:38
#define BloomPageGetTuple(state, page, offset)
Definition: bloom.h:71
int64 blgetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
Definition: blscan.c:81
#define BufferGetPage(buffer)
Definition: bufmgr.h:169
#define BloomPageGetMeta(page)
Definition: bloom.h:136
amrescan_function amrescan
Definition: amapi.h:228
bool amcanparallel
Definition: amapi.h:199
bool ConditionalLockBuffer(Buffer buffer)
Definition: bufmgr.c:3748
MemoryContext TopMemoryContext
Definition: mcxt.c:44
#define BLOOM_NSTRATEGIES
Definition: bloom.h:30
void LockRelationForExtension(Relation relation, LOCKMODE lockmode)
Definition: lmgr.c:402
bool amsearchnulls
Definition: amapi.h:191
#define BLOOMTUPLEHDRSZ
Definition: bloom.h:166
void * palloc0(Size size)
Definition: mcxt.c:980
BloomOptions opts
Definition: bloom.h:126
void UnlockRelationForExtension(Relation relation, LOCKMODE lockmode)
Definition: lmgr.c:452
uintptr_t Datum
Definition: postgres.h:367
void blrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys, ScanKey orderbys, int norderbys)
Definition: blscan.c:48
void signValue(BloomState *state, BloomSignatureWord *sign, Datum value, int attno)
Definition: blutils.c:259
Datum FunctionCall1Coll(FmgrInfo *flinfo, Oid collation, Datum arg1)
Definition: fmgr.c:1132
void LockBuffer(Buffer buffer, int mode)
Definition: bufmgr.c:3722
bool amclusterable
Definition: amapi.h:195
const char * optname
Definition: reloptions.h:152
int32 nColumns
Definition: bloom.h:143
TupleDesc rd_att
Definition: rel.h:110
void BloomInitMetapage(Relation index)
Definition: blutils.c:454
bool amsearcharray
Definition: amapi.h:189
#define InvalidOid
Definition: postgres_ext.h:36
static struct @143 value
bool amusemaintenanceworkmem
Definition: amapi.h:203
BlockNumber GetFreeIndexPage(Relation rel)
Definition: indexfsm.c:38
#define makeNode(_type_)
Definition: nodes.h:577
PageHeaderData * PageHeader
Definition: bufpage.h:166
#define Assert(condition)
Definition: c.h:738
BloomTuple * BloomFormTuple(BloomState *state, ItemPointer iptr, Datum *values, bool *isnull)
Definition: blutils.c:292
static int32 myRand(void)
Definition: blutils.c:221
Definition: regguts.h:298
#define BLOOM_OPTIONS_PROC
Definition: bloom.h:25
XLogRecPtr GenericXLogFinish(GenericXLogState *state)
Definition: generic_xlog.c:333
Buffer ReadBuffer(Relation reln, BlockNumber blockNum)
Definition: bufmgr.c:606
static void mySrand(uint32 seed)
Definition: blutils.c:248
bool blinsert(Relation index, Datum *values, bool *isnull, ItemPointer ht_ctid, Relation heapRel, IndexUniqueCheck checkUnique, IndexInfo *indexInfo)
Definition: blinsert.c:198
#define INDEX_MAX_KEYS
#define InvalidBlockNumber
Definition: block.h:33
ammarkpos_function ammarkpos
Definition: amapi.h:232
bool amcanorder
Definition: amapi.h:177
ambuildphasename_function ambuildphasename
Definition: amapi.h:225
#define VACUUM_OPTION_PARALLEL_BULKDEL
Definition: vacuum.h:45
amestimateparallelscan_function amestimateparallelscan
Definition: amapi.h:236
BloomSignatureWord sign[FLEXIBLE_ARRAY_MEMBER]
Definition: bloom.h:163
void blbuildempty(Relation index)
Definition: blinsert.c:165
int bloomLength
Definition: bloom.h:104
relopt_kind add_reloption_kind(void)
Definition: reloptions.c:659
uint32 magickNumber
Definition: bloom.h:123
static Datum values[MAXATTR]
Definition: bootstrap.c:167
uint16 amstrategies
Definition: amapi.h:171
#define AccessExclusiveLock
Definition: lockdefs.h:45
void BloomInitPage(Page page, uint16 flags)
Definition: blutils.c:406
BlockNumber BufferGetBlockNumber(Buffer buffer)
Definition: bufmgr.c:2633
IndexScanDesc blbeginscan(Relation r, int nkeys, int norderbys)
Definition: blscan.c:28
ItemPointerData heapPtr
Definition: bloom.h:162
#define MAX_BLOOM_BITS
Definition: bloom.h:98
#define PageIsNew(page)
Definition: bufpage.h:229
char * MemoryContextStrdup(MemoryContext context, const char *string)
Definition: mcxt.c:1173
#define BLOOM_META
Definition: bloom.h:46
uint16 amoptsprocnum
Definition: amapi.h:175
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition: mcxt.c:796
relopt_kind
Definition: reloptions.h:39
#define elog(elevel,...)
Definition: elog.h:214
ambuildempty_function ambuildempty
Definition: amapi.h:217
MemoryContext rd_indexcxt
Definition: rel.h:186
bytea * bloptions(Datum reloptions, bool validate)
Definition: blutils.c:481
int i
#define BUFFER_LOCK_SHARE
Definition: bufmgr.h:97
bool BloomPageAddItem(BloomState *state, Page page, BloomTuple *tuple)
Definition: blutils.c:317
Definition: c.h:555
#define PG_FUNCTION_ARGS
Definition: fmgr.h:193
Datum blhandler(PG_FUNCTION_ARGS)
Definition: blutils.c:106
#define SET_VARSIZE(PTR, len)
Definition: postgres.h:329
struct BloomMetaPageData BloomMetaPageData
void * rd_amcache
Definition: rel.h:211
#define BLOOM_MAGICK_NUMBER
Definition: bloom.h:131
#define VACUUM_OPTION_PARALLEL_CLEANUP
Definition: vacuum.h:60
Size sizeOfBloomTuple
Definition: bloom.h:149
#define snprintf
Definition: port.h:193
int Buffer
Definition: buf.h:23
amcanreturn_function amcanreturn
Definition: amapi.h:221
#define BLOOM_HASH_PROC
Definition: bloom.h:24
#define GENERIC_XLOG_FULL_IMAGE
Definition: generic_xlog.h:26
bytea * rd_options
Definition: rel.h:157
#define offsetof(type, field)
Definition: c.h:661
GenericXLogState * GenericXLogStart(Relation relation)
Definition: generic_xlog.c:267
Pointer Page
Definition: bufpage.h:78
aminitparallelscan_function aminitparallelscan
Definition: amapi.h:237
amrestrpos_function amrestrpos
Definition: amapi.h:233
void PageInit(Page page, Size pageSize, Size specialSize)
Definition: bufpage.c:42