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.
| 273 | // When we reach this limit, we need to break processing of any further rows and resize. |
| 274 | // |
| 275 | int64_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 | |
| 292 | uint32_t SwissTable::wrap_global_slot_id(uint32_t global_slot_id) const { |
| 293 | uint32_t global_slot_id_mask = |
nothing calls this directly
no test coverage detected