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

Function begin_partition

src/backend/executor/nodeWindowAgg.c:1335–1494  ·  view source on GitHub ↗

* begin_partition * Start buffering rows of the next partition. */

Source from the content-addressed store, hash-verified

1333 * Start buffering rows of the next partition.
1334 */
1335static void
1336begin_partition(WindowAggState *winstate)
1337{
1338 WindowAgg *node = (WindowAgg *) winstate->ss.ps.plan;
1339 PlanState *outerPlan = outerPlanState(winstate);
1340 int frameOptions = winstate->frameOptions;
1341 int numfuncs = winstate->numfuncs;
1342 int i;
1343
1344 winstate->partition_spooled = false;
1345 winstate->framehead_valid = false;
1346 winstate->frametail_valid = false;
1347 winstate->grouptail_valid = false;
1348 winstate->spooled_rows = 0;
1349 winstate->currentpos = 0;
1350 winstate->frameheadpos = 0;
1351 winstate->frametailpos = 0;
1352 winstate->currentgroup = 0;
1353 winstate->frameheadgroup = 0;
1354 winstate->frametailgroup = 0;
1355 winstate->groupheadpos = 0;
1356 winstate->grouptailpos = -1; /* see update_grouptailpos */
1357 ExecClearTuple(winstate->agg_row_slot);
1358 if (winstate->framehead_slot)
1359 ExecClearTuple(winstate->framehead_slot);
1360 if (winstate->frametail_slot)
1361 ExecClearTuple(winstate->frametail_slot);
1362
1363 /*
1364 * If this is the very first partition, we need to fetch the first input
1365 * row to store in first_part_slot.
1366 */
1367 if (TupIsNull(winstate->first_part_slot))
1368 {
1369 TupleTableSlot *outerslot = ExecProcNode(outerPlan);
1370
1371 if (!TupIsNull(outerslot))
1372 ExecCopySlot(winstate->first_part_slot, outerslot);
1373 else
1374 {
1375 /* outer plan is empty, so we have nothing to do */
1376 winstate->partition_spooled = true;
1377 winstate->more_partitions = false;
1378 return;
1379 }
1380 }
1381
1382 /* Create new tuplestore for this partition */
1383 winstate->buffer =
1384 tuplestore_begin_heap(false, false,
1385 PlanStateOperatorMemKB((PlanState *) winstate));
1386
1387 /*
1388 * Set up read pointers for the tuplestore. The current pointer doesn't
1389 * need BACKWARD capability, but the per-window-function read pointers do,
1390 * and the aggregate pointer does if we might need to restart aggregation.
1391 */
1392 winstate->current_ptr = 0; /* read pointer 0 is pre-allocated */

Callers 1

ExecWindowAggFunction · 0.85

Calls 8

ExecClearTupleFunction · 0.85
ExecProcNodeFunction · 0.85
ExecCopySlotFunction · 0.85
tuplestore_begin_heapFunction · 0.85
PlanStateOperatorMemKBFunction · 0.85
tuplestore_set_eflagsFunction · 0.85
tuplestore_puttupleslotFunction · 0.85

Tested by

no test coverage detected