pub struct Flat { /* private fields */ }Expand description
A decoded chunk as one buffer with the values laid end to end, and where each one ends in it.
This is what the decoder builds and decode is a copy out of it. The cascade is why: a nest
like FRONT(LZ(FSST)) decodes three levels to produce one, and a level that hands its caller a
Vec<Vec<u8>> has allocated once per value and copied every byte it holds. Three levels of that
on a chunk of a thousand URLs is three thousand allocations to produce a thousand strings that
the caller almost always wants back to back anyway.
It also makes the levels cheaper on their own terms. PLAIN is one memcpy of the whole
payload because the values are already end to end in the file. FRONT copies a shared prefix
out of the buffer it is writing into, so the previous value never has to be somewhere else.
LZ replays straight into the buffer, which is what its copy offsets meant in the first place.
Implementations§
Source§impl Flat
impl Flat
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether the chunk holds no values at all, which is not the same as holding empty ones.
Sourcepub fn bytes(&self) -> &[u8] ⓘ
pub fn bytes(&self) -> &[u8] ⓘ
The values laid end to end. A caller that already knows the boundaries, which is what a global dictionary’s offsets are, needs nothing else.
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
The buffer on its own, for a caller that wanted the bytes rather than the values.