Crate tantivy_sstable

Crate tantivy_sstable 

Source
Expand description

tantivy_sstable is a crate that provides a sorted string table data structure.

It is used in tantivy to store the term dictionary.

A sstable is a map of sorted &[u8] keys to values. The keys are encoded using incremental encoding.

Values and keys are compressed using zstd with the default feature flag zstd-compression.

§Example

Here is an example of how to create and search an sstable:

use common::OwnedBytes;
use tantivy_sstable::{Dictionary, MonotonicU64SSTable};

// Create a new sstable in memory.
let mut builder = Dictionary::<MonotonicU64SSTable>::builder(Vec::new()).unwrap();
builder.insert(b"apple", &1).unwrap();
builder.insert(b"banana", &2).unwrap();
builder.insert(b"orange", &3).unwrap();
let sstable_bytes = builder.finish().unwrap();

// Open the sstable.
let sstable =
    Dictionary::<MonotonicU64SSTable>::from_bytes(OwnedBytes::new(sstable_bytes)).unwrap();

// Search for a key.
let value = sstable.get(b"banana").unwrap();
assert_eq!(value, Some(2));

// Search for a non-existent key.
let value = sstable.get(b"grape").unwrap();
assert_eq!(value, None);

Re-exports§

pub use self::merge::VoidMerge;

Modules§

merge
value

Structs§

BlockAddr
BlockReader
DeltaReader
DeltaWriter
Dictionary
An SSTable is a sorted map that associates sorted &[u8] keys to any kind of typed values.
MonotonicU64SSTable
SSTable associated keys to u64 sorted in order.
RangeSSTable
SSTable associating keys to ranges. The range are required to partition the space.
Reader
SSTable reader.
SSTableDataCorruption
SSTableIndexBuilder
SSTableIndexV3
Streamer
Streamer acts as a cursor over a range of terms of a segment. Terms are guaranteed to be sorted.
StreamerBuilder
StreamerBuilder is a helper object used to define a range of terms that should be streamed.
VecU32ValueSSTable
SSTable associating keys to Vec.
VoidSSTable
Writer

Enums§

SSTableIndex

Traits§

SSTable
SSTable makes it possible to read and write sstables with typed values.

Type Aliases§

TermOrdinal