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

Function BitmapHeapNext

src/backend/executor/nodeBitmapHeapscan.c:113–392  ·  view source on GitHub ↗

---------------------------------------------------------------- * BitmapHeapNext * * Retrieve next tuple from the BitmapHeapScan node's currentRelation * ---------------------------------------------------------------- */

Source from the content-addressed store, hash-verified

111 * ----------------------------------------------------------------
112 */
113static TupleTableSlot *
114BitmapHeapNext(BitmapHeapScanState *node)
115{
116 ExprContext *econtext;
117 TableScanDesc scan;
118 Node *tbm;
119 GenericBMIterator *tbmiterator = NULL;
120 TBMIterateResult *tbmres;
121#ifdef USE_PREFETCH
122 GenericBMIterator *prefetch_iterator;
123#endif
124
125 TBMSharedIterator *shared_tbmiterator = NULL;
126 TupleTableSlot *slot;
127 ParallelBitmapHeapState *pstate = node->pstate;
128 dsa_area *dsa = node->ss.ps.state->es_query_dsa;
129
130 /*
131 * extract necessary information from index scan node
132 */
133 econtext = node->ss.ps.ps_ExprContext;
134 slot = node->ss.ss_ScanTupleSlot;
135 scan = node->ss.ss_currentScanDesc;
136 tbm = node->tbm;
137 if (pstate == NULL)
138 tbmiterator = node->tbmiterator;
139 else
140 shared_tbmiterator = node->shared_tbmiterator;
141 tbmres = node->tbmres;
142
143 /*
144 * If we haven't yet performed the underlying index scan, do it, and begin
145 * the iteration over the bitmap.
146 *
147 * For prefetching, we use *two* iterators, one for the pages we are
148 * actually scanning and another that runs ahead of the first for
149 * prefetching. node->prefetch_pages tracks exactly how many pages ahead
150 * the prefetch iterator is. Also, node->prefetch_target tracks the
151 * desired prefetch distance, which starts small and increases up to the
152 * node->prefetch_maximum. This is to avoid doing a lot of prefetching in
153 * a scan that stops after a few tuples because of a LIMIT.
154 */
155 if (!node->initialized)
156 {
157 if (!pstate)
158 {
159 tbm = (Node *) MultiExecProcNode(outerPlanState(node));
160
161 if (!tbm || !(IsA(tbm, TIDBitmap) || IsA(tbm, StreamBitmap)))
162 elog(ERROR, "unrecognized result from subplan");
163
164 node->tbm = tbm;
165 node->tbmiterator = tbmiterator = tbm_generic_begin_iterate(tbm);
166 node->tbmres = tbmres = NULL;
167
168#ifdef USE_PREFETCH
169 if (node->prefetch_maximum > 0)
170 {

Callers

nothing calls this directly

Tested by

no test coverage detected