Expand description
Segment-level encoding selection, the BtrBlocks-style cascade.
encode_auto reads the chunk once, prices every legal candidate off
what that pass found, encodes with the winner, and falls back to
Plain if the winner loses to Plain on the full input. The payload is
prefixed with one stable EncodingId byte, so decode_any needs no
side channel.
Pricing is arithmetic rather than a trial encode, and that is the whole of what makes a write cheap. Sizing seven candidates by encoding each of them costs seven encodes of every chunk a column rewrite touches, and a fold is column rewrites: profiling a stream of single row writes put two thirds of the engine’s processor time inside the encoders, nearly all of it in candidates that lost. The containers are simple enough to price exactly instead. Frame of reference is a minimum and a width per 1024 values, the patched container prices its own width off a histogram this pass already builds, and the rest are a count of runs, a count of distinct values and the count of the value that dominates. Only the winner is encoded, and the Plain guard below catches an estimate that was wrong about the shape rather than about the arithmetic.
Functions§
- decode_
any - Decodes a segment produced by
encode_auto, appending at mostmax_valuesvalues toout. Every encoding here amplifies, that is the point of compression, so decoded counts are claims until the caller vouches for them: a container claiming more than the ceiling is rejected before anything is allocated for it. Callers always know the bound, the row count their segment meta or chunk index promised. - encode_
auto - Encodes
valueswith the estimated-best encoding, returning the id used.