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

Function execMotionSortedReceiver

src/backend/executor/nodeMotion.c:432–653  ·  view source on GitHub ↗

Sorted receiver using binary heap */

Source from the content-addressed store, hash-verified

430
431/* Sorted receiver using binary heap */
432static TupleTableSlot *
433execMotionSortedReceiver(MotionState *node)
434{
435 TupleTableSlot *slot;
436 binaryheap *hp = node->tupleheap;
437 MinimalTuple inputTuple;
438 Motion *motion = (Motion *) node->ps.plan;
439 EState *estate = node->ps.state;
440
441 AssertState(motion->motionType == MOTIONTYPE_GATHER &&
442 motion->sendSorted &&
443 hp != NULL);
444
445 /* Notify senders and return EOS if caller doesn't want any more data. */
446 if (node->stopRequested)
447 {
448
449 SendStopMessage(node->ps.state->motionlayer_context,
450 node->ps.state->interconnect_context,
451 motion->motionID);
452 return NULL;
453 }
454
455 if (estate->interconnect_context == NULL)
456 {
457 if (!estate->es_interconnect_is_setup && estate->dispatcherState &&
458 !estate->es_got_eos)
459 {
460 /*
461 * We could only possibly get here in the following scenario:
462 * 1. We are QD gracefully aborting a transaction.
463 * 2. We have torn down the interconnect of the current slice.
464 * 3. Since an error has happened, we no longer need to finish fetching
465 * all the tuples, hence squelching the executor subtree.
466 * 4. We are in the process of ExecSquelchShareInputScan(), and the
467 * Shared Scan has this Motion below it.
468 *
469 * NB: if you need to change this, see also execMotionUnsortedReceiver()
470 */
471 ereport(NOTICE,
472 (errmsg("An ERROR must have happened. Stopping a Shared Scan.")));
473 return NULL;
474 }
475 else
476 ereport(ERROR, (errmsg("Interconnect is down unexpectedly.")));
477 }
478
479 /*
480 * On first call, fill the priority queue with each sender's first tuple.
481 */
482 if (!node->tupleheapReady)
483 {
484 MinimalTuple inputTuple;
485 binaryheap *hp = node->tupleheap;
486 Motion *motion = (Motion *) node->ps.plan;
487 int iSegIdx;
488 ListCell *lcProcess;
489 ExecSlice *sendSlice = &node->ps.state->es_sliceTable->slices[motion->motionID];

Callers 1

ExecMotionFunction · 0.85

Calls 15

SendStopMessageFunction · 0.85
foreach_with_countFunction · 0.85
RecvTupleFromFunction · 0.85
MemoryContextSwitchToFunction · 0.85
MakeTupleTableSlotFunction · 0.85
ExecStoreMinimalTupleFunction · 0.85
slot_getsomeattrsFunction · 0.85
binaryheap_add_unorderedFunction · 0.85
initStringInfoFunction · 0.85
appendStringInfoFunction · 0.85
formatTupleFunction · 0.85
binaryheap_buildFunction · 0.85

Tested by

no test coverage detected