pub fn collapse_below(
log: &dyn OpLog,
acks: &AckVector,
sink: &dyn SnapshotSink,
snapshot_for_array: impl Fn(&str, Hlc) -> ArrayResult<Option<TileSnapshot>>,
) -> ArrayResult<GcReport>Expand description
Compact ops below the min-ack frontier into snapshots, then prune the log.
Algorithm:
- Determine frontier =
acks.min_ack_hlc(). IfNone, return early with an empty report — GC must not proceed without knowing every peer’s progress. - Collect distinct array names whose ops have
hlc < frontier. - For each such array, call
snapshot_for_array(name, frontier).Some(snap)→ write viasink.write_snapshot(&snap)and incrementsnapshots_written.None→ the caller signals “no live state for this array”; skip the snapshot write (ops will still be dropped).Err→ propagate immediately; the log is not mutated.
- After all snapshots succeed, call
log.drop_below(frontier)and record the count inops_dropped. - Return the report.