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