MCPcopy Create free account
hub / github.com/apache/cloudberry / bloomBuildCallback

Function bloomBuildCallback

contrib/bloom/blinsert.c:73–115  ·  view source on GitHub ↗

* Per-tuple callback for table_index_build_scan. */

Source from the content-addressed store, hash-verified

71 * Per-tuple callback for table_index_build_scan.
72 */
73static void
74bloomBuildCallback(Relation index, ItemPointer tid, Datum *values,
75 bool *isnull, bool tupleIsAlive, void *state)
76{
77 BloomBuildState *buildstate = (BloomBuildState *) state;
78 MemoryContext oldCtx;
79 BloomTuple *itup;
80
81 oldCtx = MemoryContextSwitchTo(buildstate->tmpCtx);
82
83 itup = BloomFormTuple(&buildstate->blstate, tid, values, isnull);
84
85 /* Try to add next item to cached page */
86 if (BloomPageAddItem(&buildstate->blstate, buildstate->data.data, itup))
87 {
88 /* Next item was added successfully */
89 buildstate->count++;
90 }
91 else
92 {
93 /* Cached page is full, flush it out and make a new one */
94 flushCachedPage(index, buildstate);
95
96 CHECK_FOR_INTERRUPTS();
97
98 initCachedPage(buildstate);
99
100 if (!BloomPageAddItem(&buildstate->blstate, buildstate->data.data, itup))
101 {
102 /* We shouldn't be here since we're inserting to the empty page */
103 elog(ERROR, "could not add new bloom tuple to empty page");
104 }
105
106 /* Next item was added successfully */
107 buildstate->count++;
108 }
109
110 /* Update total tuple count */
111 buildstate->indtuples += 1;
112
113 MemoryContextSwitchTo(oldCtx);
114 MemoryContextReset(buildstate->tmpCtx);
115}
116
117/*
118 * Build a new bloom index.

Callers

nothing calls this directly

Calls 6

MemoryContextSwitchToFunction · 0.85
BloomFormTupleFunction · 0.85
BloomPageAddItemFunction · 0.85
flushCachedPageFunction · 0.85
initCachedPageFunction · 0.85
MemoryContextResetFunction · 0.85

Tested by

no test coverage detected