MCPcopy Create free account
hub / github.com/apache/paimon-rust / clean_larger_than

Function clean_larger_than

crates/integrations/datafusion/src/procedures.rs:330–363  ·  view source on GitHub ↗
(
    sm: &SnapshotManager,
    tm: &TagManager,
    retained_snapshot_id: i64,
)

Source from the content-addressed store, hash-verified

328}
329
330async fn clean_larger_than(
331 sm: &SnapshotManager,
332 tm: &TagManager,
333 retained_snapshot_id: i64,
334) -> DFResult<()> {
335 // 1. Update LATEST hint
336 sm.write_latest_hint(retained_snapshot_id)
337 .await
338 .map_err(to_datafusion_error)?;
339
340 // 2. Delete snapshots newer than the target
341 let all_ids = sm.list_all_ids().await.map_err(to_datafusion_error)?;
342 for &id in all_ids.iter().rev() {
343 if id <= retained_snapshot_id {
344 break;
345 }
346 sm.delete_snapshot(id).await.map_err(to_datafusion_error)?;
347 }
348
349 // TODO: clean long-lived changelogs newer than retained_snapshot_id
350 // Java's RollbackHelper.cleanLargerThan also calls cleanLongLivedChangelogs here.
351 // Implement once ChangelogManager is available.
352
353 // 3. Delete tags that reference snapshots newer than the target
354 let tags = tm.list_all().await.map_err(to_datafusion_error)?;
355 for (name, snap) in tags.iter().rev() {
356 if snap.id() <= retained_snapshot_id {
357 continue;
358 }
359 tm.delete(name).await.map_err(to_datafusion_error)?;
360 }
361
362 Ok(())
363}
364
365async fn proc_rollback_to(
366 ctx: &SessionContext,

Callers 2

proc_rollback_toFunction · 0.85

Calls 7

write_latest_hintMethod · 0.80
delete_snapshotMethod · 0.80
list_all_idsMethod · 0.45
iterMethod · 0.45
list_allMethod · 0.45
idMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected