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

Function initialize_hash_entry

src/backend/executor/nodeAgg.c:2219–2251  ·  view source on GitHub ↗

* Initialize a freshly-created TupleHashEntry. */

Source from the content-addressed store, hash-verified

2217 * Initialize a freshly-created TupleHashEntry.
2218 */
2219static void
2220initialize_hash_entry(AggState *aggstate, TupleHashTable hashtable,
2221 TupleHashEntry entry)
2222{
2223 AggStatePerGroup pergroup;
2224 int transno;
2225
2226 aggstate->hash_ngroups_current++;
2227 hash_agg_check_limits(aggstate);
2228
2229 /* no need to allocate or initialize per-group state */
2230 if (aggstate->numtrans == 0)
2231 return;
2232
2233 pergroup = (AggStatePerGroup)
2234 MemoryContextAlloc(hashtable->tablecxt,
2235 sizeof(AggStatePerGroupData) * aggstate->numtrans);
2236
2237 entry->additional = pergroup;
2238
2239 /*
2240 * Initialize aggregates for new tuple group, lookup_hash_entries()
2241 * already has selected the relevant grouping set.
2242 */
2243 for (transno = 0; transno < aggstate->numtrans; transno++)
2244 {
2245 AggStatePerTrans pertrans = &aggstate->pertrans[transno];
2246 AggStatePerGroup pergroupstate = &pergroup[transno];
2247 if (!bms_is_member(transno, aggstate->aggs_used))
2248 continue;
2249 initialize_aggregate(aggstate, pertrans, pergroupstate);
2250 }
2251}
2252
2253/*
2254 * Look up hash entries for the current tuple in all hashed grouping sets.

Callers 2

lookup_hash_entriesFunction · 0.85
agg_refill_hash_tableFunction · 0.85

Calls 4

hash_agg_check_limitsFunction · 0.85
MemoryContextAllocFunction · 0.85
bms_is_memberFunction · 0.85
initialize_aggregateFunction · 0.85

Tested by

no test coverage detected