MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / vshard_stride

Function vshard_stride

nodedb-cluster/src/distributed_array/routing.rs:128–133  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

126/// total vShards. Stride = `VSHARD_COUNT >> P`. When `P >= log2(VSHARD_COUNT)`
127/// the stride is 1 (one vShard per bucket or less).
128fn 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)]
136mod tests {

Callers 2

array_vshards_for_sliceFunction · 0.85
bucket_to_vshardFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected