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