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

Function partition_for_key

nodedb-cluster/src/distributed_join.rs:106–108  ·  view source on GitHub ↗

Compute which node owns a given partition (based on join key hash). Uses consistent hashing: `partition = hash(key) % num_nodes`. The target node is selected from the routing table's active leaders.

(key: &str, num_partitions: usize)

Source from the content-addressed store, hash-verified

104/// Uses consistent hashing: `partition = hash(key) % num_nodes`.
105/// The target node is selected from the routing table's active leaders.
106pub fn partition_for_key(key: &str, num_partitions: usize) -> u32 {
107 (crate::routing::fnv1a_hash(key) % num_partitions as u64) as u32
108}
109
110/// Plan the node assignments for a shuffle join.
111///

Callers 1

partition_deterministicFunction · 0.85

Calls 1

fnv1a_hashFunction · 0.70

Tested by 1

partition_deterministicFunction · 0.68