pub struct Replay<'a> { /* private fields */ }Expand description
Encode an integer chunk the way an earlier one came out, and search only where it stops fitting.
Settled holds one kind per level, which is too coarse for a cascade that branches: an RLE
wants its run values packed and its run lengths constant, and a shape of one kind per level
cannot say both. This holds every level’s kind in the order the encoder asks for them, which is
what integer::shape reads back out of an encoded chunk, and hands them back one per question.
The first question whose answer is not among the kinds offered ends the replay, and from there
on every question goes to fallback. A chunk only offers kinds that apply to it, so a shape
that stops fitting costs a search and never a chunk that will not decode. The order of the
questions is the order of the kinds only while every answer is a single kind, which is why the
replay does not pick back up after a search.
A shape that still fits can still be the wrong one. Bit packing applies to everything, so a
shape settled on a stretch of noise replays happily over a column that has since become one
value with exceptions, at forty times the size. What does change when the column does is the set
of kinds the top level offers, so a replay can be told the set its shape was searched under with
Replay::expecting, and searches from the top when the chunk offers anything else. The set is
worked out for the chunk whatever the chooser, so the check costs nothing.
One of these is for one chunk. The position is kept in atomics because a chooser is shared between threads by contract, not because a chunk’s encode is ever split between them.
Implementations§
Source§impl<'a> Replay<'a>
impl<'a> Replay<'a>
Sourcepub fn new(kinds: &'a [Kind], fallback: &'a dyn Chooser) -> Self
pub fn new(kinds: &'a [Kind], fallback: &'a dyn Chooser) -> Self
A replay of kinds, with fallback answering once they stop fitting.
Sourcepub fn expecting(self, offered: &[Kind]) -> Self
pub fn expecting(self, offered: &[Kind]) -> Self
The same replay, going ahead only on a chunk whose top level offers exactly offered.
Sourcepub fn first_offered(&self) -> Vec<Kind>
pub fn first_offered(&self) -> Vec<Kind>
What the top level of the chunk offered, in tag order, or nothing before it was asked.
Trait Implementations§
Source§impl Chooser for Replay<'_>
impl Chooser for Replay<'_>
Source§fn narrow_integers(
&self,
values: &[i64],
offered: &[Kind],
depth: u8,
) -> Vec<Kind>
fn narrow_integers( &self, values: &[i64], offered: &[Kind], depth: u8, ) -> Vec<Kind>
offered to encode in full, for a chunk of integers at depth.