Skip to main content

turbo_persistence/
lib.rs

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