pub fn encode_shard_table(slot_shard: &[u16], out: &mut [u8]) -> Result<usize>Expand description
Run length encodes a slot to shard mapping into out.
Returns the number of bytes written. The encoding is a sequence of four byte
pairs, each a u16 run length followed by a u16 shard id. The
uncompressed form is 32 KiB of u16, which does not fit in a 16 KiB slot at
all, and the compressed form is four bytes per contiguous range. Slot to
shard assignment is contiguous by construction, so a sixty four shard
database spends 256 bytes here.
ยงErrors
Code::Full if the encoding does not fit in out, and Code::Invalid
if slot_shard is not exactly SLOT_COUNT entries.