* Per-tuple callback for table_index_build_scan. */
| 71 | * Per-tuple callback for table_index_build_scan. |
| 72 | */ |
| 73 | static void |
| 74 | bloomBuildCallback(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. |
nothing calls this directly
no test coverage detected