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

Function hashagg_spill_init

src/backend/executor/nodeAgg.c:3214–3237  ·  view source on GitHub ↗

* hashagg_spill_init * * Called after we determined that spilling is necessary. Chooses the number * of partitions to create, and initializes them. */

Source from the content-addressed store, hash-verified

3212 * of partitions to create, and initializes them.
3213 */
3214static void
3215hashagg_spill_init(AggState *aggstate, HashAggSpill *spill, HashTapeInfo *tapeinfo, int used_bits,
3216 double input_groups, double hashentrysize)
3217{
3218 int npartitions;
3219 int partition_bits;
3220
3221 npartitions = hash_choose_num_partitions(aggstate, input_groups, hashentrysize,
3222 used_bits, &partition_bits);
3223
3224 spill->partitions = palloc0(sizeof(int) * npartitions);
3225 spill->ntuples = palloc0(sizeof(int64) * npartitions);
3226 spill->hll_card = palloc0(sizeof(hyperLogLogState) * npartitions);
3227
3228 hashagg_tapeinfo_assign(tapeinfo, spill->partitions, npartitions);
3229
3230 spill->tapeset = tapeinfo->tapeset;
3231 spill->shift = 32 - used_bits - partition_bits;
3232 spill->mask = (npartitions - 1) << spill->shift;
3233 spill->npartitions = npartitions;
3234
3235 for (int i = 0; i < npartitions; i++)
3236 initHyperLogLog(&spill->hll_card[i], HASHAGG_HLL_BIT_WIDTH);
3237}
3238
3239/*
3240 * hashagg_spill_tuple

Callers 3

lookup_hash_entriesFunction · 0.85
agg_refill_hash_tableFunction · 0.85

Calls 4

hashagg_tapeinfo_assignFunction · 0.85
initHyperLogLogFunction · 0.85
palloc0Function · 0.50

Tested by

no test coverage detected