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

Function hash_choose_num_buckets

src/backend/executor/nodeAgg.c:2123–2141  ·  view source on GitHub ↗

* Choose a reasonable number of buckets for the initial hash table size. */

Source from the content-addressed store, hash-verified

2121 * Choose a reasonable number of buckets for the initial hash table size.
2122 */
2123static long
2124hash_choose_num_buckets(double hashentrysize, long ngroups, Size memory)
2125{
2126 long max_nbuckets;
2127 long nbuckets = ngroups;
2128
2129 max_nbuckets = memory / hashentrysize;
2130
2131 /*
2132 * Underestimating is better than overestimating. Too many buckets crowd
2133 * out space for group keys and transition state values.
2134 */
2135 max_nbuckets >>= 1;
2136
2137 if (nbuckets > max_nbuckets)
2138 nbuckets = max_nbuckets;
2139
2140 return Max(nbuckets, 1);
2141}
2142
2143/*
2144 * Determine the number of partitions to create when spilling, which will

Callers 1

build_hash_tablesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected