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

Method maybe_compact

nodedb/src/engine/array/compact.rs:18–45  ·  view source on GitHub ↗

Run compaction on the array if the picker chooses one. Returns `true` if a merge happened. `audit_retain_ms` is the per-array retention window in milliseconds. `now_ms` is the wall-clock epoch-milliseconds at compaction start. Pass `now_ms = 0` and `audit_retain_ms = None` to disable retention (keeps all tile versions).

(
        &mut self,
        id: &ArrayId,
        audit_retain_ms: Option<i64>,
        now_ms: i64,
    )

Source from the content-addressed store, hash-verified

16 /// Pass `now_ms = 0` and `audit_retain_ms = None` to disable retention
17 /// (keeps all tile versions).
18 pub fn maybe_compact(
19 &mut self,
20 id: &ArrayId,
21 audit_retain_ms: Option<i64>,
22 now_ms: i64,
23 ) -> ArrayEngineResult<bool> {
24 let plan = match CompactionPicker::pick(self.store(id)?) {
25 Some(p) => p,
26 None => return Ok(false),
27 };
28 let store = self.store(id)?;
29 let out = CompactionMerger::run(
30 store,
31 &plan.inputs,
32 plan.output_level,
33 audit_retain_ms,
34 now_ms,
35 )?;
36 let store = self.store_mut(id)?;
37 let removed = out.removed.clone();
38 store.replace_segments(&removed, vec![out.segment_ref])?;
39 store.persist_manifest()?;
40 for old in removed {
41 // Best-effort unlink — the manifest is already authoritative.
42 let _ = store.unlink_segment(&old);
43 }
44 Ok(true)
45 }
46}
47
48#[cfg(test)]

Calls 7

store_mutMethod · 0.80
replace_segmentsMethod · 0.80
persist_manifestMethod · 0.80
unlink_segmentMethod · 0.80
runFunction · 0.50
storeMethod · 0.45
cloneMethod · 0.45