* hashagg_spill_init * * Called after we determined that spilling is necessary. Chooses the number * of partitions to create, and initializes them. */
| 3212 | * of partitions to create, and initializes them. |
| 3213 | */ |
| 3214 | static void |
| 3215 | hashagg_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 |
no test coverage detected