MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / compact_drops_old_records

Function compact_drops_old_records

nodedb-vector/src/sieve/workload.rs:176–193  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

174 /// `compact` drops entries older than the retention window.
175 #[test]
176 fn compact_drops_old_records() {
177 let mut analyzer = WorkloadAnalyzer::new(0.05);
178 // Timestamps: 0..50 old, 150..200 recent.
179 for i in 0u64..50 {
180 analyzer.record("old".to_string(), i);
181 }
182 for i in 150u64..200 {
183 analyzer.record("recent".to_string(), i);
184 }
185
186 // now=200, retention=100 → cutoff=100; entries with ts < 100 removed.
187 analyzer.compact(200, 100);
188
189 let stable = analyzer.stable_predicates();
190 // Only "recent" entries remain.
191 assert_eq!(stable.len(), 1);
192 assert_eq!(stable[0].0, "recent");
193 }
194
195 /// After compacting everything, log is empty.
196 #[test]

Callers

nothing calls this directly

Calls 4

to_stringMethod · 0.80
stable_predicatesMethod · 0.80
recordMethod · 0.45
compactMethod · 0.45

Tested by

no test coverage detected