Skip to main content

turbo_persistence/
lib.rs

1#![feature(once_cell_try)]
2#![feature(sync_unsafe_cell)]
3#![feature(iter_collect_into)]
4
5mod arc_bytes;
6mod collector;
7mod collector_entry;
8mod compaction;
9mod compression;
10mod constants;
11mod db;
12mod key;
13mod lookup_entry;
14mod merge_iter;
15pub mod meta_file;
16mod meta_file_builder;
17pub mod mmap_helper;
18mod parallel_scheduler;
19mod sst_filter;
20pub mod static_sorted_file;
21mod static_sorted_file_builder;
22mod value_block_count_tracker;
23mod value_buf;
24mod write_batch;
25
26#[cfg(test)]
27mod tests;
28
29pub use arc_bytes::ArcBytes;
30pub use compression::checksum_block;
31pub use db::{CompactConfig, MetaFileEntryInfo, MetaFileInfo, TurboPersistence};
32
33#[derive(Clone, Copy, Debug, PartialEq, Eq)]
34pub enum FamilyKind {
35    /// Each key maps to a single value (default LSM behavior).
36    /// When multiple entries have the same key, only the newest is retained during compaction or
37    /// returned by queries
38    /// Access must use `get` not `get_multiple`
39    SingleValue,
40    /// Each key can map to multiple values.
41    /// Duplicate values are not dropped.
42    /// The order of values returned by `get_multiple` is undefined.
43    /// Access must use `get_multiple` not `get`
44    MultiValue,
45}
46
47/// Configuration for a single family to describe how the data is stored.
48#[derive(Clone, Copy, Debug)]
49pub struct FamilyConfig {
50    pub kind: FamilyKind,
51}
52
53/// Database-wide configuration with per-family settings.
54///
55/// Each family (keyspace) can have different file size limits to optimize
56/// for its specific access patterns and data characteristics.
57#[derive(Clone, Debug)]
58pub struct DbConfig<const FAMILIES: usize> {
59    pub family_configs: [FamilyConfig; FAMILIES],
60}
61
62impl<const FAMILIES: usize> Default for DbConfig<FAMILIES> {
63    fn default() -> Self {
64        Self {
65            family_configs: [FamilyConfig {
66                kind: FamilyKind::SingleValue,
67            }; FAMILIES],
68        }
69    }
70}
71pub use key::{KeyBase, QueryKey, StoreKey, hash_key};
72pub use meta_file::MetaEntryFlags;
73pub use parallel_scheduler::{ParallelScheduler, SerialScheduler};
74pub use static_sorted_file::{
75    BlockCache, BlockWeighter, SstLookupResult, StaticSortedFile, StaticSortedFileMetaData,
76};
77pub use static_sorted_file_builder::{
78    BLOCK_HEADER_SIZE, Entry, EntryValue, StreamingSstWriter, write_static_stored_file,
79};
80pub use value_buf::ValueBuffer;
81pub use write_batch::WriteBatch;