Expand description
Encoding for exact decimal columns — the i128 mantissa stream.
A decimal column stores mantissa × 10⁻ˢᶜᵃˡᵉ with the scale held once in
the column’s metadata, so what reaches this codec is a column of plain
integers. That is the whole argument for the type: the README’s
compression section already observes that most float columns are decimals
that went through an f64, and that ALP and pco spend their first stage
recovering the integer. A decimal column hands that integer over
directly — nothing to recover, nothing lost recovering it.
§Two physical forms
Almost every real decimal column is narrow. A quarter-hour meter register
in watt-hours at four decimal places needs 19 digits to reach 10¹⁴ kWh, so
its mantissas fit an i64 with room to spare, and the interesting shapes
— a monotone counter, a slowly varying price, a constant tariff — are
exactly the shapes the i64 stack is built for.
[form: u8 = 0][inner i64 block: tag + payload] narrow
[form: u8 = 1][count: u32][first: i128 LE][zigzag varint deltas…] wideThe narrow form is not a second codec: it delegates to
ColumnEncoder::encode_i64, so a
decimal column gets RLE on a constant register, frame-of-reference on a
narrow range, and pco on everything else — the same trial-and-keep-the-
smallest selection an i64 field gets, for free and for ever.
The wide form exists for the columns that genuinely need more than 63
bits of mantissa: 38-digit financial quantities, or a scale so large that
ordinary values overflow. Delta + ZigZag + LEB128 keeps a
slowly-varying wide column near the narrow one’s size, and a random wide
column costs at most 19 bytes per value against the 16 it would take raw.
Structs§
- Decimal
Decoder - Decoder for a column of
i128decimal mantissas. - Decimal
Encoder - Encoder for a column of
i128decimal mantissas.