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

Function fnv1a_hash

nodedb-cluster/src/routing.rs:280–287  ·  view source on GitHub ↗

FNV-1a 64-bit hash for deterministic key partitioning. Used by distributed join shuffle and shard split to assign keys to partitions. NOT for vShard routing — use `vshard_for_collection` for that.

(key: &str)

Source from the content-addressed store, hash-verified

278/// to partitions. NOT for vShard routing — use `vshard_for_collection`
279/// for that.
280pub fn fnv1a_hash(key: &str) -> u64 {
281 let mut hash: u64 = 0xcbf29ce484222325;
282 for byte in key.as_bytes() {
283 hash ^= *byte as u64;
284 hash = hash.wrapping_mul(0x100000001b3);
285 }
286 hash
287}
288
289/// Hash `key` using the algorithm recorded in the cluster's [`PlacementHashId`].
290///

Callers 2

partition_hashFunction · 0.70
partition_for_keyFunction · 0.70

Calls 1

as_bytesMethod · 0.45

Tested by

no test coverage detected