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

Function bmbuild

src/backend/access/bitmap/bitmap.c:119–161  ·  view source on GitHub ↗

* bmbuild() -- Build a new bitmap index. */

Source from the content-addressed store, hash-verified

117 * bmbuild() -- Build a new bitmap index.
118 */
119IndexBuildResult *
120bmbuild(Relation heap, Relation index, IndexInfo *indexInfo)
121{
122 double reltuples;
123 BMBuildState bmstate;
124 IndexBuildResult *result;
125 TupleDesc tupDesc;
126
127 if (indexInfo->ii_Concurrent)
128 ereport(ERROR,
129 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
130 errmsg("CONCURRENTLY is not supported when creating bitmap indexes")));
131
132 /* We expect this to be called exactly once. */
133 if (RelationGetNumberOfBlocks(index) != 0)
134 ereport (ERROR,
135 (errcode(ERRCODE_INDEX_CORRUPTED),
136 errmsg("index \"%s\" already contains data",
137 RelationGetRelationName(index))));
138
139 tupDesc = RelationGetDescr(index);
140
141 /* initialize the bitmap index for MAIN_FORKNUM. */
142 _bitmap_init(index, RelationNeedsWAL(index), false);
143
144 /* initialize the build state. */
145 _bitmap_init_buildstate(index, &bmstate);
146
147 /* do the heap scan */
148 reltuples = table_index_build_scan(heap, index, indexInfo, false, true,
149 bmbuildCallback, (void *) &bmstate,
150 NULL);
151 /* clean up the build state */
152 _bitmap_cleanup_buildstate(index, &bmstate);
153
154 /* return statistics */
155 result = (IndexBuildResult *) palloc0(sizeof(IndexBuildResult));
156
157 result->heap_tuples = reltuples;
158 result->index_tuples = bmstate.ituples;
159
160 return result;
161}
162
163/*
164 * bmbuildempty() -- build an empty bitmap index in the initialization fork

Callers

nothing calls this directly

Calls 7

_bitmap_initFunction · 0.85
_bitmap_init_buildstateFunction · 0.85
table_index_build_scanFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50
palloc0Function · 0.50

Tested by

no test coverage detected