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§
Structs§
- Block
Addr - Block
Reader - Delta
Reader - Delta
Writer - Dictionary
- An SSTable is a sorted map that associates sorted
&[u8]keys to any kind of typed values. - Monotonic
U64SS Table - SSTable associated keys to u64 sorted in order.
- RangeSS
Table - SSTable associating keys to ranges. The range are required to partition the space.
- Reader
- SSTable reader.
- SSTable
Data Corruption - SSTable
Index Builder - SSTable
Index V3 - Streamer
Streameracts as a cursor over a range of terms of a segment. Terms are guaranteed to be sorted.- Streamer
Builder StreamerBuilderis a helper object used to define a range of terms that should be streamed.- VecU32
ValueSS Table - SSTable associating keys to Vec
. - VoidSS
Table - Writer
Enums§
Traits§
- SSTable
- SSTable makes it possible to read and write sstables with typed values.