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

Function array_vshard_for_name

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

Compute a vShard ID from an array name alone. Array-specific name-only fallback used by `array_sync` paths that route before a coordinate or tile extent is known. Uses the same DJB multiply-31 hash as `VShardId::from_collection_in_database`, but without the database scope — array-sync messages carry their own scoping in the op-log header and route per-array by name.

(array_name: &str)

Source from the content-addressed store, hash-verified

40/// the database scope — array-sync messages carry their own scoping in the
41/// op-log header and route per-array by name.
42pub fn array_vshard_for_name(array_name: &str) -> u32 {
43 let hash = array_name
44 .as_bytes()
45 .iter()
46 .fold(0u32, |h, &b| h.wrapping_mul(31).wrapping_add(b as u32));
47 hash % VSHARD_COUNT
48}
49
50/// Compute a vShard ID from an arbitrary byte key.
51///

Callers 8

vshard_for_array_coordFunction · 0.85
fallback_on_empty_coordFunction · 0.85
fallback_on_zero_extentFunction · 0.85
vshard_for_opMethod · 0.85
handle_schemaMethod · 0.85
apply_array_opFunction · 0.85

Calls 3

foldMethod · 0.80
iterMethod · 0.45
as_bytesMethod · 0.45

Tested by 4

fallback_on_empty_coordFunction · 0.68
fallback_on_zero_extentFunction · 0.68