1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//! Trie compaction configuration, statistics, and progress reporting.
//!
//! Split out of the monolithic byte `dict_impl.rs` (lines ~386-479) as the
//! first piece of the Phase-5 decomposition. The compaction *execution*
//! logic still lives on `PersistentARTrie` in `dict_impl.rs`; only the
//! configuration / observability types live here.
/// Configuration for trie compaction operations.
///
/// Compaction rebuilds the trie from scratch, eliminating orphaned nodes
/// and fragmentation that accumulate from update/delete operations.
///
/// # Example
///
/// ```rust,no_run
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// use libdictenstein::persistent_artrie::{PersistentARTrie, CompactionConfig};
///
/// let mut trie = PersistentARTrie::<u64>::open("data.artrie")?;
///
/// // In-place compaction with default settings
/// let stats = trie.compact(CompactionConfig::default(), |progress| {
/// println!("{}: {:.1}%", progress.phase, progress.percent_complete);
/// })?;
///
/// println!("Saved {:.1}% space", stats.space_savings_percent);
/// # Ok(())
/// # }
/// ```
/// Statistics from a completed compaction operation.
/// Progress information during compaction.
///
/// Passed to the progress callback during `compact()` to report status.