Skip to main content

Module patch

Module patch 

Source
Expand description

Patched bit packing, the exception container behind encoding id 12.

Plain per-chunk packing pays the width of the widest value for all 1024 values, which is exactly how adjacency deltas die: neighbor lists average about 14 values on social graphs, a chunk crosses about 70 lists, and nearly every chunk holds one hub-sized gap that prices the whole chunk at 23 bits. Here the encoder picks the packed width that minimizes total bytes; values wider than the pick become exceptions, stored at the chunk’s max width behind a presence bitmap while their packed slots hold zero.

Layout: count: u32 LE, then per 1024-value chunk a header of width: u8, exc_width: u8, a packed body of packed_bytes(width, take) bytes, a presence bitmap of packed_bytes(1, take) bytes, and the exceptions in position order, packed_bytes(exc_width, popcount) bytes.

Functions§

decode
Decodes an encoded buffer, appending at most max_values values to out; a container claiming more is rejected before allocation.
encode
Encodes values into out, returning the encoded byte length.