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

Function prepare_projection_slot

src/backend/executor/nodeAgg.c:1308–1344  ·  view source on GitHub ↗

* Prepare to finalize and project based on the specified representative tuple * slot and grouping set. * * In the specified tuple slot, force to null all attributes that should be * read as null in the context of the current grouping set. Also stash the * current group bitmap where GroupingExpr can get at it. * * This relies on three conditions: * * 1) Nothing is ever going to try and ex

Source from the content-addressed store, hash-verified

1306 * alternative was worse.
1307 */
1308static void
1309prepare_projection_slot(AggState *aggstate, TupleTableSlot *slot, int currentSet)
1310{
1311 if (aggstate->phase->grouped_cols)
1312 {
1313 Bitmapset *grouped_cols = aggstate->phase->grouped_cols[currentSet];
1314
1315 aggstate->grouped_cols = grouped_cols;
1316 aggstate->group_id = aggstate->phase->group_id[currentSet];
1317 aggstate->gset_id = aggstate->phase->gset_id[currentSet];
1318
1319 if (TTS_EMPTY(slot))
1320 {
1321 /*
1322 * Force all values to be NULL if working on an empty input tuple
1323 * (i.e. an empty grouping set for which no input rows were
1324 * supplied).
1325 */
1326 ExecStoreAllNullTuple(slot);
1327 }
1328 else if (aggstate->all_grouped_cols)
1329 {
1330 ListCell *lc;
1331
1332 /* all_grouped_cols is arranged in desc order */
1333 slot_getsomeattrs(slot, linitial_int(aggstate->all_grouped_cols));
1334
1335 foreach(lc, aggstate->all_grouped_cols)
1336 {
1337 int attnum = lfirst_int(lc);
1338
1339 if (!bms_is_member(attnum, grouped_cols))
1340 slot->tts_isnull[attnum - 1] = true;
1341 }
1342 }
1343 }
1344}
1345
1346/*
1347 * Compute the final value of all aggregates for one group.

Callers 2

agg_retrieve_directFunction · 0.85

Calls 4

ExecStoreAllNullTupleFunction · 0.85
slot_getsomeattrsFunction · 0.85
bms_is_memberFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected