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

Function MultiExecBitmapAnd

src/backend/executor/nodeBitmapAnd.c:120–216  ·  view source on GitHub ↗

---------------------------------------------------------------- * MultiExecBitmapAnd * * BitmapAnd node gets the bitmaps generated from BitmapIndexScan * nodes and outputs a bitmap that ANDs all input bitmaps. * * The first input bitmap is utilized to store the result of the * AND and returned to the caller. In addition, the output points * to a newly created OpStream no

Source from the content-addressed store, hash-verified

118 * ----------------------------------------------------------------
119 */
120Node *
121MultiExecBitmapAnd(BitmapAndState *node)
122{
123 PlanState **bitmapplans;
124 int nplans;
125 int i;
126 bool empty = false;
127 TIDBitmap *hbm = NULL;
128
129 /* must provide our own instrumentation support */
130 if (node->ps.instrument)
131 InstrStartNode(node->ps.instrument);
132
133 /*
134 * get information from the node
135 */
136 bitmapplans = node->bitmapplans;
137 nplans = node->nplans;
138
139 /*
140 * Scan all the subplans and AND their result bitmaps
141 */
142 for (i = 0; i < nplans; i++)
143 {
144 PlanState *subnode = bitmapplans[i];
145 Node *subresult = NULL;
146
147 subresult = MultiExecProcNode(subnode);
148
149 if (!subresult || !(IsA(subresult, TIDBitmap) || IsA(subresult, StreamBitmap)))
150 elog(ERROR, "unrecognized result from subplan");
151
152 /*
153 * If this is a hash bitmap, intersect it now with other hash bitmaps.
154 * If we encounter some streamed bitmaps we'll add this hash bitmap
155 * as a stream to it.
156 */
157 if (IsA(subresult, TIDBitmap))
158 {
159 /* first subplan that generates a hash bitmap */
160 if (hbm == NULL)
161 hbm = (TIDBitmap *) subresult;
162 else
163 {
164 tbm_intersect(hbm, (TIDBitmap *)subresult);
165 tbm_generic_free(subresult);
166 }
167
168 /*
169 * If at any stage we have a completely empty bitmap, we can fall out
170 * without evaluating the remaining subplans, since ANDing them can no
171 * longer change the result. (Note: the fact that indxpath.c orders
172 * the subplans by selectivity should make this case more likely to
173 * occur.)
174 */
175 if (tbm_is_empty(hbm))
176 {
177 empty = true;

Callers 1

MultiExecProcNodeFunction · 0.85

Calls 9

InstrStartNodeFunction · 0.85
MultiExecProcNodeFunction · 0.85
tbm_intersectFunction · 0.85
tbm_generic_freeFunction · 0.85
tbm_is_emptyFunction · 0.85
stream_move_nodeFunction · 0.85
InstrStopNodeFunction · 0.85
stream_add_nodeFunction · 0.85
tbm_create_stream_nodeFunction · 0.85

Tested by

no test coverage detected