Manages the 1,024-slot to shard-index mapping.
Provides the indirection layer between hash output and shard assignment:
key -> phash2(key) & 0x3FF -> slot -> slot_map[slot] -> shard_indexThe slot map is a 1,024-element tuple stored in :persistent_term for
~10ns read access. Updates via put/1 are atomic -- all processes see
the new map on their next read.
Summary
Functions
@spec build_uniform(pos_integer()) :: tuple()
@spec get() :: tuple()
@spec init(pos_integer()) :: :ok
@spec num_slots() :: pos_integer()
@spec put(tuple()) :: :ok
@spec reassign_slot(tuple(), non_neg_integer(), non_neg_integer()) :: tuple()
@spec shard_for_slot(tuple(), non_neg_integer()) :: non_neg_integer()
@spec slot_count_for_shard(tuple(), non_neg_integer()) :: non_neg_integer()
@spec slot_for_key(binary()) :: non_neg_integer()
@spec slot_ranges(tuple()) :: [ {non_neg_integer(), non_neg_integer(), non_neg_integer()} ]