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

Function gather_getnext

src/backend/executor/nodeGather.c:263–306  ·  view source on GitHub ↗

* Read the next tuple. We might fetch a tuple from one of the tuple queues * using gather_readnext, or if no tuple queue contains a tuple and the * single_copy flag is not set, we might generate one locally instead. */

Source from the content-addressed store, hash-verified

261 * single_copy flag is not set, we might generate one locally instead.
262 */
263static TupleTableSlot *
264gather_getnext(GatherState *gatherstate)
265{
266 PlanState *outerPlan = outerPlanState(gatherstate);
267 TupleTableSlot *outerTupleSlot;
268 TupleTableSlot *fslot = gatherstate->funnel_slot;
269 MinimalTuple tup;
270
271 while (gatherstate->nreaders > 0 || gatherstate->need_to_scan_locally)
272 {
273 CHECK_FOR_INTERRUPTS();
274
275 if (gatherstate->nreaders > 0)
276 {
277 tup = gather_readnext(gatherstate);
278
279 if (HeapTupleIsValid(tup))
280 {
281 ExecStoreMinimalTuple(tup, /* tuple to store */
282 fslot, /* slot to store the tuple */
283 false); /* don't pfree tuple */
284 return fslot;
285 }
286 }
287
288 if (gatherstate->need_to_scan_locally)
289 {
290 EState *estate = gatherstate->ps.state;
291
292 /* Install our DSA area while executing the plan. */
293 estate->es_query_dsa =
294 gatherstate->pei ? gatherstate->pei->area : NULL;
295 outerTupleSlot = ExecProcNode(outerPlan);
296 estate->es_query_dsa = NULL;
297
298 if (!TupIsNull(outerTupleSlot))
299 return outerTupleSlot;
300
301 gatherstate->need_to_scan_locally = false;
302 }
303 }
304
305 return ExecClearTuple(fslot);
306}
307
308/*
309 * Attempt to read a tuple from one of our parallel workers.

Callers 1

ExecGatherFunction · 0.85

Calls 4

gather_readnextFunction · 0.85
ExecStoreMinimalTupleFunction · 0.85
ExecProcNodeFunction · 0.85
ExecClearTupleFunction · 0.85

Tested by

no test coverage detected