Skip to main content

noxu_db/
database_stats.rs

1//! Per-database statistics.
2//!
3//! Implements `DatabaseStats` (abstract) and `BtreeStats` (concrete).
4
5/// Base statistics type for a database.
6///
7/// Implements abstract `DatabaseStats`.  All concrete database stats in
8/// Noxu are represented by [`BtreeStats`].
9#[derive(Clone, Debug, Default)]
10pub struct DatabaseStats {
11    /// B-tree statistics for this database.
12    pub btree: BtreeStats,
13}
14
15/// B-tree statistics for a single database.
16///
17/// Returned by [`Database::stats`][crate::database::Database::stats].
18///
19/// Implements `BtreeStats` with the most commonly used fields:
20///
21/// | Field | |
22/// |-------|--------------|
23/// | `leaf_node_count` | `getLNCount()` |
24/// | `deleted_leaf_node_count` | `getDeletedLNCount()` |
25/// | `bottom_internal_node_count` | `getBottomInternalNodeCount()` |
26/// | `internal_node_count` | `getInternalNodeCount()` |
27/// | `main_tree_max_depth` | `getMainTreeMaxDepth()` |
28#[derive(Clone, Debug, Default)]
29pub struct BtreeStats {
30    /// Total number of leaf-node (LN) records in the tree.
31    /// Equivalent to the approximate record count for the database.
32    pub leaf_node_count: u64,
33    /// Number of known-deleted LN slots not yet compacted.
34    pub deleted_leaf_node_count: u64,
35    /// Number of Bottom Internal Nodes (BINs — leaf-level inner nodes).
36    pub bottom_internal_node_count: u64,
37    /// Number of upper Internal Nodes (INs above BIN level).
38    pub internal_node_count: u64,
39    /// Maximum depth of the main tree (root-to-BIN path length).
40    pub main_tree_max_depth: u32,
41}