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

Function ExecAgg

src/backend/executor/nodeAgg.c:2336–2374  ·  view source on GitHub ↗

* ExecAgg - * * ExecAgg receives tuples from its outer subplan and aggregates over * the appropriate attribute for each aggregate function use (Aggref * node) appearing in the targetlist or qual of the node. The number * of tuples to aggregate over depends on whether grouped or plain * aggregation is selected. In grouped aggregation, we produce a result * row for each group; i

Source from the content-addressed store, hash-verified

2334 * Streaming: forces not spilling, roughly deduplicates to save network I/O.
2335 */
2336static TupleTableSlot *
2337ExecAgg(PlanState *pstate)
2338{
2339 AggState *node = castNode(AggState, pstate);
2340 TupleTableSlot *result = NULL;
2341
2342 CHECK_FOR_INTERRUPTS();
2343
2344 if (!node->agg_done)
2345 {
2346 /* Dispatch based on strategy */
2347 switch (node->phase->aggstrategy)
2348 {
2349 case AGG_HASHED:
2350 if (!node->table_filled)
2351 agg_fill_hash_table(node);
2352 /* FALLTHROUGH */
2353 case AGG_MIXED:
2354 result = agg_retrieve_hash_table(node);
2355 break;
2356 case AGG_PLAIN:
2357 case AGG_SORTED:
2358 result = agg_retrieve_direct(node);
2359 break;
2360 }
2361
2362 if (!TupIsNull(result))
2363 return result;
2364 }
2365
2366 /* Save statistics into the cdbexplainbuf for EXPLAIN ANALYZE */
2367 if (node->ss.ps.instrument &&
2368 (node->ss.ps.instrument)->need_cdb &&
2369 (node->phase->aggstrategy == AGG_HASHED ||
2370 node->phase->aggstrategy == AGG_MIXED))
2371 agg_hash_explain_extra_message(node);
2372
2373 return NULL;
2374}
2375
2376/*
2377 * ExecAgg for non-hashed case

Callers

nothing calls this directly

Calls 4

agg_fill_hash_tableFunction · 0.85
agg_retrieve_hash_tableFunction · 0.85
agg_retrieve_directFunction · 0.85

Tested by

no test coverage detected