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

Function prefix_bucket

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

Extract the top `prefix_bits` bits of a Hilbert prefix as a bucket index.

(hilbert_prefix: u64, prefix_bits: u8)

Source from the content-addressed store, hash-verified

109
110/// Extract the top `prefix_bits` bits of a Hilbert prefix as a bucket index.
111fn prefix_bucket(hilbert_prefix: u64, prefix_bits: u8) -> u32 {
112 // Shift right so the top `prefix_bits` bits are in the low-order position.
113 let shift = 64u8.saturating_sub(prefix_bits);
114 (hilbert_prefix >> shift) as u32
115}
116
117/// Map a bucket index to the primary vShard in that bucket's range.
118fn bucket_to_vshard(bucket: u32, prefix_bits: u8) -> u32 {

Callers 2

array_vshard_for_tileFunction · 0.85
array_vshards_for_sliceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected