Skip to main content

Module varint

Module varint 

Source
Expand description

LEB128 varint coding for posting lists.

Posting entries store fact-id deltas; lists are sorted by construction (fact ids are assigned monotonically), so deltas are small and most entries take 1 byte instead of 4.

Constants§

MAX_VARINT
Maximum encoded size of a u32 (5 × 7 bits ≥ 32 bits).

Functions§

decode_u32
Decodes one u32 from the front of bytes, returning the value and the number of bytes consumed. None on truncated input or a value that does not fit 32 bits (a 5th byte with more than 4 payload bits, or a continuation bit on the 5th byte).
encode_u32
Encodes v into out, returning the number of bytes written (1..=5).