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

Function vshard_for_array_tile

nodedb-cluster/src/array_routing.rs:137–142  ·  view source on GitHub ↗

Compute the vShard ID for an array tile by tile identifier. Use this when the tile_id is already known (e.g. from the op-log key or snapshot metadata) and coord re-derivation is unnecessary. Returns a raw `u16` in `0..1023`. Callers wrap it in `VShardId::new(…)`.

(array_name: &str, tile_id: u64)

Source from the content-addressed store, hash-verified

135///
136/// Returns a raw `u16` in `0..1023`. Callers wrap it in `VShardId::new(…)`.
137pub fn vshard_for_array_tile(array_name: &str, tile_id: u64) -> u32 {
138 let mut buf = Vec::with_capacity(array_name.len() + 8);
139 buf.extend_from_slice(array_name.as_bytes());
140 buf.extend_from_slice(&tile_id.to_le_bytes());
141 vshard_from_key(&buf)
142}
143
144// ─── Tests ────────────────────────────────────────────────────────────────────
145

Calls 3

vshard_from_keyFunction · 0.85
lenMethod · 0.45
as_bytesMethod · 0.45