MCPcopy Create free account
hub / github.com/apache/arrow / num_groups_for_resize

Method num_groups_for_resize

cpp/src/arrow/compute/key_map_internal.cc:275–290  ·  view source on GitHub ↗

How many groups we can keep in the hash table without the need for resizing. When we reach this limit, we need to break processing of any further rows and resize.

Source from the content-addressed store, hash-verified

273// When we reach this limit, we need to break processing of any further rows and resize.
274//
275int64_t SwissTable::num_groups_for_resize() const {
276 // Consider N = 9 (aka 2 ^ 9 = 512 blocks) as small.
277 // When N = 9, a slot id takes N + 3 = 12 bits, rounded up to 16 bits. This is also the
278 // number of bits needed for a key id. Since each slot stores a status byte and a key
279 // id, then a slot takes 1 byte + 16 bits = 3 bytes. Therefore a block of 8 slots takes
280 // 24 bytes. The threshold of a small hash table ends up being 24 bytes * 512 = 12 KB.
281 constexpr int log_blocks_small_ = 9;
282 int64_t num_slots = num_slots_from_log_blocks(log_blocks_);
283 if (log_blocks_ <= log_blocks_small_) {
284 // Resize small hash tables when 50% full.
285 return num_slots / 2;
286 } else {
287 // Resize large hash tables when 75% full.
288 return num_slots * 3 / 4;
289 }
290}
291
292uint32_t SwissTable::wrap_global_slot_id(uint32_t global_slot_id) const {
293 uint32_t global_slot_id_mask =

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected