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

Function reorderqueue_push

src/backend/executor/nodeIndexscan.c:461–490  ·  view source on GitHub ↗

* Helper function to push a tuple to the reorder queue. */

Source from the content-addressed store, hash-verified

459 * Helper function to push a tuple to the reorder queue.
460 */
461static void
462reorderqueue_push(IndexScanState *node, TupleTableSlot *slot,
463 Datum *orderbyvals, bool *orderbynulls)
464{
465 IndexScanDesc scandesc = node->iss_ScanDesc;
466 EState *estate = node->ss.ps.state;
467 MemoryContext oldContext = MemoryContextSwitchTo(estate->es_query_cxt);
468 ReorderTuple *rt;
469 int i;
470
471 rt = (ReorderTuple *) palloc(sizeof(ReorderTuple));
472 rt->htup = ExecCopySlotHeapTuple(slot);
473 rt->orderbyvals =
474 (Datum *) palloc(sizeof(Datum) * scandesc->numberOfOrderBys);
475 rt->orderbynulls =
476 (bool *) palloc(sizeof(bool) * scandesc->numberOfOrderBys);
477 for (i = 0; i < node->iss_NumOrderByKeys; i++)
478 {
479 if (!orderbynulls[i])
480 rt->orderbyvals[i] = datumCopy(orderbyvals[i],
481 node->iss_OrderByTypByVals[i],
482 node->iss_OrderByTypLens[i]);
483 else
484 rt->orderbyvals[i] = (Datum) 0;
485 rt->orderbynulls[i] = orderbynulls[i];
486 }
487 pairingheap_add(node->iss_ReorderQueue, &rt->ph_node);
488
489 MemoryContextSwitchTo(oldContext);
490}
491
492/*
493 * Helper function to pop the next tuple from the reorder queue.

Callers 1

IndexNextWithReorderFunction · 0.85

Calls 5

MemoryContextSwitchToFunction · 0.85
ExecCopySlotHeapTupleFunction · 0.85
datumCopyFunction · 0.85
pairingheap_addFunction · 0.85
pallocFunction · 0.50

Tested by

no test coverage detected