···6868 pub(crate) stats: StatsRef,
6969}
70707171+/// Point-in-time snapshot of fjall storage stats.
7272+pub struct StorageStats {
7373+ /// Total disk space used by the database (journals + all keyspaces).
7474+ pub disk_bytes: u64,
7575+ /// Disk space used by the default keyspace (repo state, queues, cursors).
7676+ pub default_ks_disk_bytes: u64,
7777+ /// Disk space used by the index keyspace (rbc + cbr).
7878+ pub index_ks_disk_bytes: u64,
7979+ /// Number of journal files on disk.
8080+ pub journal_count: usize,
8181+ /// Number of compactions currently running.
8282+ pub active_compactions: usize,
8383+ /// Total compactions completed since the database was opened.
8484+ pub compactions_completed: usize,
8585+ /// Total time spent compacting since the database was opened.
8686+ pub time_compacting: std::time::Duration,
8787+}
8888+8989+impl Db {
9090+ /// Collect a snapshot of fjall storage stats.
9191+ pub fn storage_stats(&self) -> StorageStats {
9292+ StorageStats {
9393+ disk_bytes: self.database.disk_space().unwrap_or(0),
9494+ default_ks_disk_bytes: self.ks.disk_space(),
9595+ index_ks_disk_bytes: self.index_ks.disk_space(),
9696+ journal_count: self.database.journal_count(),
9797+ active_compactions: self.database.active_compactions(),
9898+ compactions_completed: self.database.compactions_completed(),
9999+ time_compacting: self.database.time_compacting(),
100100+ }
101101+ }
102102+}
103103+71104/// Cheaply-cloneable reference to the shared database.
72105pub type DbRef = Arc<Db>;
73106