Skip to main content

hashed_assignment

Function hashed_assignment 

Source
pub fn hashed_assignment(
    members: &[usize],
    dataset_shards: usize,
) -> Vec<WorkerShards>
Expand description

Assign 0..dataset_shards to members by capacity-bounded rendezvous (HRW) hashing: each shard is placed on the highest-weight member that still has spare capacity, with capacities chosen so worker loads differ by at most one.

members must be sorted ascending. The result is deterministic and exactly balanced, and — because shard ownership is decided independently per shard by a fixed hash — a single membership change relocates far fewer shards than the contiguous block_partition scheme (the minimal-movement property of rendezvous hashing). Returns one WorkerShards per member, in membership order, each with its owned shard indices in ascending order.