Struct izihawa_tantivy_columnar::Dictionary

source ·
pub struct Dictionary<TSSTable = VoidSSTable>
where 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 Dictionary

source

pub fn build_for_tests(terms: &[&str]) -> Dictionary

source§

impl<TSSTable> Dictionary<TSSTable>
where TSSTable: SSTable,

source

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

source

pub fn file_slice_for_range( &self, key_range: impl RangeBounds<[u8]>, limit: Option<u64> ) -> FileSlice

This function returns a file slice covering a set of sstable blocks that include the key range passed in arguments. Optionally returns only block for up to limit matching terms.

It works by identifying

  • first_block: the block containing the start boundary key
  • last_block: the block containing the end boundary key.

And then returning the range that spans over all blocks between. and including first_block and last_block, aka: [first_block.start_offset .. last_block.end_offset)

Technically this function does not provide the tightest fit, as for simplification, it treats the start bound of the key_range as if it was inclusive, even if it is exclusive. On the rare edge case where a user asks for (start_key, end_key] and start_key happens to be the last key of a block, we return a slice that is the first block was not necessary.

source

pub fn open( term_dictionary_file: FileSlice ) -> Result<Dictionary<TSSTable>, Error>

Opens a TermDictionary.

source

pub async fn open_async( term_dictionary_file: FileSlice ) -> Result<Dictionary<TSSTable>, Error>

source

pub fn from_bytes( owned_bytes: OwnedBytes ) -> Result<Dictionary<TSSTable>, Error>

Creates a term dictionary from the supplied bytes.

source

pub fn empty() -> Dictionary<TSSTable>

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>(&self, key: K) -> Result<Option<u64>, Error>
where K: AsRef<[u8]>,

Returns the ordinal associated with a given term.

source

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

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: u64 ) -> Result<Option<<TSSTable as SSTable>::Value>, Error>

Returns the number of terms in the dictionary.

source

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

Lookups the value corresponding to the key.

source

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

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>, Error>

A stream of all the sorted terms.

source

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

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

Trait Implementations§

source§

impl<TSSTable> Clone for Dictionary<TSSTable>
where TSSTable: Clone + SSTable,

source§

fn clone(&self) -> Dictionary<TSSTable>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<TSSTable> Debug for Dictionary<TSSTable>
where TSSTable: Debug + SSTable,

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<TSSTable> Freeze for Dictionary<TSSTable>

§

impl<TSSTable = VoidSSTable> !RefUnwindSafe for Dictionary<TSSTable>

§

impl<TSSTable> Send for Dictionary<TSSTable>

§

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

§

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

§

impl<TSSTable = VoidSSTable> !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> Downcast for T
where T: Any,

source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.