pub struct Table { /* private fields */ }Expand description
A trained symbol table, separated from the encode pass because the two cost wildly different amounts: training a table for one 1024-row chunk of short strings runs about 3.4ms and encoding that chunk against it runs about 0.13ms, so a writer that trains per chunk spends 96% of its time in training. A writer holding a column of chunks that are alike trains once, on a sample drawn across the whole column, and encodes every chunk with the result. Nothing about the encoded form changes: each buffer still carries the table it was encoded with, so a decoder cannot tell which of the two a writer did.
Implementations§
Source§impl Table
impl Table
Sourcepub fn read(bytes: &[u8]) -> Result<Table>
pub fn read(bytes: &[u8]) -> Result<Table>
Reads back the table a buffer was encoded with.
Training is the whole cost of writing a string column, and a writer that rewrites a column it already wrote is training on data it already trained on. The table is in the buffer already, so a rewrite can encode with that one instead and pay nothing; the codes it produces are as good as the codes on disk were, which is what a rewrite of the same column wants. A column that drifts away from its table is caught where it always was, by the writer measuring a chunk against the table and buying it one of its own.
Sourcepub fn header_len(&self) -> usize
pub fn header_len(&self) -> usize
What every encoded buffer pays to carry this table: the fixed header, one length byte per symbol and the symbol bytes. A writer comparing two encodings of different sizes has to take this out first, because a table costing 2 KiB is nothing against a whole column and a seventh of one 1024-row chunk of short strings.