Expand description
Random-slicing distribution: a small, gap-free partition table over the 64-bit hash space.
The hash space is split into a contiguous run of intervals.
Each interval is owned by exactly one claimant (a peer or
peer-name in our terminology). Lookups are an O(log N)
binary search over the interval table, where N is the
claimant count.
Two construction-time invariants give the technique its name:
- The intervals are laid out end-to-end so their union is
the entire ring. Whatever rounding remainder integer
division leaves over is absorbed by the last interval, so
no value of
hash(key)can fail to map to a claimant. - Adding or removing a claimant only re-slices its share. Keys outside the affected slice keep their assignment.
The structure is built once per rack at config-load /
SIGHUP-reload time and thereafter consulted read-only by
the dispatcher; see crate::cluster::dispatch.
§Examples
use dynomite::hashkit::random_slicing::RandomSlices;
let slices = RandomSlices::from_uniform(&["peer-a", "peer-b"]).unwrap();
// Either of the two claimants must own the lookup; the
// partition is gap-free by construction.
let owner = slices.claimant_for(0).unwrap();
assert!(owner == "peer-a" || owner == "peer-b");Structs§
- Random
Slices - Slice table indexed by
u64hash values.
Enums§
- Random
Slices Error - Failure mode produced by the
RandomSlicesbuilders.