Skip to main content

Table

Struct Table 

Source
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

Source

pub fn train(bytes: &[u8]) -> Table

Trains on bytes, sampling it first when it is long.

Source

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.

Source

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.

Source

pub fn encode(&self, bytes: &[u8], out: &mut Vec<u8>) -> usize

Encodes bytes into out, returning the encoded byte length.

Auto Trait Implementations§

§

impl Freeze for Table

§

impl RefUnwindSafe for Table

§

impl Send for Table

§

impl Sync for Table

§

impl Unpin for Table

§

impl UnsafeUnpin for Table

§

impl UnwindSafe for Table

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.