Number of vShards per Hilbert bucket. With `P` prefix bits there are `2^P` buckets and `VSHARD_COUNT` total vShards. Stride = `VSHARD_COUNT >> P`. When `P >= log2(VSHARD_COUNT)` the stride is 1 (one vShard per bucket or less).
(prefix_bits: u8)
| 126 | /// total vShards. Stride = `VSHARD_COUNT >> P`. When `P >= log2(VSHARD_COUNT)` |
| 127 | /// the stride is 1 (one vShard per bucket or less). |
| 128 | fn vshard_stride(prefix_bits: u8) -> u32 { |
| 129 | // VSHARD_COUNT is a power of two (1024 = 2^10). |
| 130 | // Right-shifting by prefix_bits gives the stride, floored at 1. |
| 131 | let shifted = VSHARD_COUNT >> (prefix_bits as u32); |
| 132 | shifted.max(1) |
| 133 | } |
| 134 | |
| 135 | #[cfg(test)] |
| 136 | mod tests { |
no outgoing calls
no test coverage detected