Dictionary

Struct Dictionary 

Source
pub struct Dictionary<TSSTable: SSTable> {
    pub sstable_slice: FileSlice,
    pub sstable_index: SSTableIndex,
    /* private fields */
}
Expand description

An SSTable is a sorted map that associates sorted &[u8] keys to any kind of typed values.

The SSTable is organized in blocks. In each block, keys and values are encoded separately.

The keys are encoded using incremental encoding. The values on the other hand, are encoded according to a value-specific codec defined in the TSSTable generic argument.

Finally, an index is joined to the Dictionary to make it possible, given a key to identify which block contains this key.

The codec was designed in such a way that the sstable reader is not aware of block, and yet can read any sequence of blocks, as long as the slice of bytes it is given starts and stops at block boundary.

(See also README.md)

Fields§

§sstable_slice: FileSlice§sstable_index: SSTableIndex

Implementations§

Source§

impl<TSSTable: SSTable> Dictionary<TSSTable>

Source

pub fn builder<W: Write>(wrt: W) -> Result<Writer<W, TSSTable::ValueWriter>>

Source

pub fn open(term_dictionary_file: FileSlice) -> Result<Self>

Opens a TermDictionary.

Source

pub fn from_bytes(owned_bytes: OwnedBytes) -> Result<Self>

Creates a term dictionary from the supplied bytes.

Source

pub fn empty() -> Self

Creates an empty term dictionary which contains no terms.

Source

pub fn num_terms(&self) -> usize

Returns the number of terms in the dictionary. Term ordinals range from 0 to num_terms() - 1.

Source

pub fn term_ord<K: AsRef<[u8]>>(&self, key: K) -> Result<Option<TermOrdinal>>

Returns the ordinal associated with a given term.

Source

pub fn ord_to_term(&self, ord: TermOrdinal, bytes: &mut Vec<u8>) -> Result<bool>

Returns the term associated with a given term ordinal.

Term ordinals are defined as the position of the term in the sorted list of terms.

Returns true if and only if the term has been found.

Regardless of whether the term is found or not, the buffer may be modified.

Source

pub fn term_info_from_ord( &self, term_ord: TermOrdinal, ) -> Result<Option<TSSTable::Value>>

Returns the number of terms in the dictionary.

Source

pub fn get<K: AsRef<[u8]>>(&self, key: K) -> Result<Option<TSSTable::Value>>

Lookups the value corresponding to the key.

Source

pub async fn get_async<K: AsRef<[u8]>>( &self, key: K, ) -> Result<Option<TSSTable::Value>>

Lookups the value corresponding to the key.

Source

pub fn range(&self) -> StreamerBuilder<'_, TSSTable>

Returns a range builder, to stream all of the terms within an interval.

Source

pub fn stream(&self) -> Result<Streamer<'_, TSSTable>>

A stream of all the sorted terms.

Source

pub fn search<'a, A: Automaton + 'a>( &'a self, automaton: A, ) -> StreamerBuilder<'a, TSSTable, A>
where A::State: Clone,

Returns a search builder, to stream all of the terms within the Automaton

Auto Trait Implementations§

§

impl<TSSTable> Freeze for Dictionary<TSSTable>

§

impl<TSSTable> !RefUnwindSafe for Dictionary<TSSTable>

§

impl<TSSTable> Send for Dictionary<TSSTable>
where TSSTable: Send,

§

impl<TSSTable> Sync for Dictionary<TSSTable>
where TSSTable: Sync,

§

impl<TSSTable> Unpin for Dictionary<TSSTable>
where TSSTable: Unpin,

§

impl<TSSTable> !UnwindSafe for Dictionary<TSSTable>

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.