Skip to main content

noxu_db/
preload.rs

1//! Database preloading configuration and statistics.
2
3/// Configuration for database preloading.
4#[derive(Debug, Clone, PartialEq, Eq)]
5pub struct PreloadConfig {
6    /// Maximum bytes to load (0 = unlimited).
7    pub max_bytes: u64,
8    /// Maximum time in milliseconds (0 = unlimited).
9    pub max_millis: u64,
10    /// Whether to also load leaf node data (not just BINs).
11    pub load_lns: bool,
12}
13
14impl PreloadConfig {
15    /// Creates a new PreloadConfig with default settings (load everything).
16    pub fn new() -> Self {
17        Self { max_bytes: 0, max_millis: 0, load_lns: false }
18    }
19
20    /// Builder-style: set max_bytes.
21    pub fn with_max_bytes(mut self, max_bytes: u64) -> Self {
22        self.max_bytes = max_bytes;
23        self
24    }
25
26    /// Builder-style: set max_millis.
27    pub fn with_max_millis(mut self, max_millis: u64) -> Self {
28        self.max_millis = max_millis;
29        self
30    }
31
32    /// Builder-style: set load_lns.
33    pub fn with_load_lns(mut self, load_lns: bool) -> Self {
34        self.load_lns = load_lns;
35        self
36    }
37}
38
39impl Default for PreloadConfig {
40    fn default() -> Self {
41        Self::new()
42    }
43}
44
45/// Statistics returned from a database preload operation.
46#[derive(Debug, Clone, PartialEq, Eq, Default)]
47pub struct PreloadStats {
48    /// Number of BIN (bottom internal) nodes loaded.
49    pub bins_loaded: u64,
50    /// Number of leaf nodes (LNs) loaded.
51    pub lns_loaded: u64,
52    /// Total elapsed time in milliseconds.
53    pub elapsed_ms: u64,
54}