barrel_ngram_shards (barrel_ngram v0.7.1)
View SourceRendezvous (HRW) sharding for a corpus.
Maps a document key to exactly one of N shards, so each shard indexes only its slice and a document's entry never moves (the key is stable). Also holds the per-corpus metadata (shard count + config) the query planner needs before it can address the shards.
A shard is identified by a Ref: the corpus name when N =:= 1 (unchanged single-shard path) and {Corpus, I} for N > 1.
Summary
Functions
The shard refs for a corpus of N shards, index order.
The shard index owning Key out of N shards: the index with the highest phash2({I, Key}), tie-broken by the lowest index.
Types
-type ref() :: term().
Functions
-spec erase_meta(term()) -> ok.
-spec refs(term(), pos_integer()) -> [ref()].
The shard refs for a corpus of N shards, index order.
-spec shard_for(binary(), pos_integer()) -> non_neg_integer().
The shard index owning Key out of N shards: the index with the highest phash2({I, Key}), tie-broken by the lowest index.