Skip to main content

Module alp

Module alp 

Source
Expand description

ALP for doubles (encoding id 6), the Afroozeh and Boncz adaptive lossless floating-point scheme: a double that is really a decimal, like a price or a coordinate, becomes round(d * 10^e / 10^f), an integer that frame-of-reference packs to a fraction of eight bytes. Values the transform cannot reproduce bit-exactly ride as patched exceptions, so NaN, infinities, negative zero and genuine full-mantissa doubles all survive.

The exponent pair is chosen on a sample: every legal (e, f) combo is scored by the packed width of the digits it produces plus the exceptions it fails on, and the smallest estimate wins. Decode is two multiplies per value after the digit stream unpacks, which is what keeps it on the 1 GB/s floor. Decode streams the digit chunks straight into the output, so scratch stays one MiniBlock chunk of 1024 values no matter how large the container is.

Layout: count: u32 LE, e: u8, f: u8, exc_count: u32 LE, positions_len: u32 LE, positions container, exception bit patterns (8 bytes LE each), then the zigzagged digits container.

Functionsยง

decode
Decodes an encoded buffer, appending at most max_values values to out. Every count is a claim checked against the caller ceiling and the streams, and a rejected payload leaves out untouched.
encode
Encodes values into out, returning the encoded byte length.