Skip to main content

SymbolTable

Struct SymbolTable 

Source
pub struct SymbolTable { /* private fields */ }
Expand description

A trained symbol table, and everything needed to compress and decompress against it.

Implementations§

Source§

impl SymbolTable

Source

pub fn footprint(&self) -> usize

How many bytes of memory this table is holding.

Mostly the hash table, which is sixty five thousand slots however few symbols are in it. That is the number a vector in FSST form reports, and it is why the form is a decision about a page rather than about a chunk: one table over a hundred chunks is nothing per chunk and one table per chunk is a megabyte.

Source

pub fn empty() -> SymbolTable

A table with no symbols, which escapes everything and doubles its input. The starting point of training, and what a column of nothing but unique bytes ends up with.

Source

pub fn train(samples: &[&[u8]]) -> SymbolTable

Trains a table on a sample.

The caller picks the sample. Section 6.3 says a systematic sample across the chunk rather than the first N rows, because column data is frequently clustered, and that decision belongs to whoever knows what the chunk is rather than to this function.

Source

pub fn len(&self) -> usize

How many symbols are in the table.

Source

pub fn is_empty(&self) -> bool

Whether the table has no symbols, in which case every byte of every string escapes.

Source

pub fn serialized_len(&self) -> usize

How many bytes serialize writes. At most 2049 for a full table, and that is the number section 6.4 is weighing when it says a shared symbol table is cheaper than a shared dictionary.

Source

pub fn serialize(&self, out: &mut Vec<u8>)

Writes the table itself, which has to travel with the data it compressed.

Source

pub fn deserialize(bytes: &[u8]) -> Result<(SymbolTable, usize), Error>

Reads back what serialize wrote, and says how many bytes it consumed.

§Errors

If the bytes are truncated or describe a symbol of zero or more than eight bytes.

Source

pub fn compress(&self, input: &[u8], out: &mut Vec<u8>)

Compresses one string, appending to out.

Strings are compressed one at a time against a shared table rather than as one stream, because that is what keeps random access, which is the first of the two reasons this encoding was chosen at all.

Source

pub fn decompress(&self, input: &[u8], out: &mut Vec<u8>) -> Result<(), Error>

Decompresses one string, appending to out.

§Errors

If the input ends on an escape byte, or holds a code the table does not have.

Trait Implementations§

Source§

impl Debug for SymbolTable

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for SymbolTable

Source§

impl PartialEq for SymbolTable

Two tables are equal when they hold the same symbols in the same order.

The three lookup tables are built from the symbols when a table is built and hold nothing the symbols do not, so comparing them would be comparing the same information a second time over sixty five thousand entries. A vector in FSST form carries a table, and a vector is compared for equality all over the tests, so this is on a path that gets walked.

Source§

fn eq(&self, other: &SymbolTable) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

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.