Package org.apache.iceberg
Class SnapshotManager
- java.lang.Object
-
- org.apache.iceberg.SnapshotManager
-
- All Implemented Interfaces:
ManageSnapshots,PendingUpdate<Snapshot>
public class SnapshotManager extends java.lang.Object implements ManageSnapshots
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Snapshotapply()Apply the pending changes and return the uncommitted changes for validation.ManageSnapshotscherrypick(long snapshotId)Apply supported changes in given snapshot and create a new snapshot which will be set as the current snapshot on commit.voidcommit()Apply the pending changes and commit.ManageSnapshotscreateBranch(java.lang.String name)Create a new branch.ManageSnapshotscreateBranch(java.lang.String name, long snapshotId)Create a new branch pointing to the given snapshot id.ManageSnapshotscreateTag(java.lang.String name, long snapshotId)Create a new tag pointing to the given snapshot idManageSnapshotsfastForwardBranch(java.lang.String name, java.lang.String source)Performs a fast-forward of the given target branch up to the source snapshot if target is an ancestor of source.ManageSnapshotsremoveBranch(java.lang.String name)Remove a branch by nameManageSnapshotsremoveTag(java.lang.String name)Remove the tag with the given name.ManageSnapshotsrenameBranch(java.lang.String name, java.lang.String newName)Rename a branchManageSnapshotsreplaceBranch(java.lang.String name, long snapshotId)Replaces the branch with the given name to point to the specified snapshotManageSnapshotsreplaceBranch(java.lang.String name, java.lang.String source)Replaces the branch with the given name to point to the source snapshot.ManageSnapshotsreplaceTag(java.lang.String name, long snapshotId)Replaces the tag with the given name to point to the specified snapshot.ManageSnapshotsrollbackTo(long snapshotId)Rollback table's state to a specificSnapshotidentified by id.ManageSnapshotsrollbackToTime(long timestampMillis)Roll this table's data back to the lastSnapshotbefore the given timestamp.ManageSnapshotssetCurrentSnapshot(long snapshotId)Roll this table's data back to a specificSnapshotidentified by id.ManageSnapshotssetMaxRefAgeMs(java.lang.String name, long maxRefAgeMs)Updates the retention policy for a reference.ManageSnapshotssetMaxSnapshotAgeMs(java.lang.String name, long maxSnapshotAgeMs)Updates the max snapshot age for a branch.ManageSnapshotssetMinSnapshotsToKeep(java.lang.String name, int minSnapshotsToKeep)Updates the minimum number of snapshots to keep for a branch.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.iceberg.PendingUpdate
updateEvent
-
-
-
-
Method Detail
-
cherrypick
public ManageSnapshots cherrypick(long snapshotId)
Description copied from interface:ManageSnapshotsApply supported changes in given snapshot and create a new snapshot which will be set as the current snapshot on commit.- Specified by:
cherrypickin interfaceManageSnapshots- Parameters:
snapshotId- a snapshotId whose changes to apply- Returns:
- this for method chaining
-
setCurrentSnapshot
public ManageSnapshots setCurrentSnapshot(long snapshotId)
Description copied from interface:ManageSnapshotsRoll this table's data back to a specificSnapshotidentified by id.- Specified by:
setCurrentSnapshotin interfaceManageSnapshots- Parameters:
snapshotId- long id of the snapshot to roll back table data to- Returns:
- this for method chaining
-
rollbackToTime
public ManageSnapshots rollbackToTime(long timestampMillis)
Description copied from interface:ManageSnapshotsRoll this table's data back to the lastSnapshotbefore the given timestamp.- Specified by:
rollbackToTimein interfaceManageSnapshots- Parameters:
timestampMillis- a long timestamp, as returned bySystem.currentTimeMillis()- Returns:
- this for method chaining
-
rollbackTo
public ManageSnapshots rollbackTo(long snapshotId)
Description copied from interface:ManageSnapshotsRollback table's state to a specificSnapshotidentified by id.- Specified by:
rollbackToin interfaceManageSnapshots- Parameters:
snapshotId- long id of snapshot id to roll back table to. Must be an ancestor of the current snapshot
-
createBranch
public ManageSnapshots createBranch(java.lang.String name)
Description copied from interface:ManageSnapshotsCreate a new branch. The branch will point to current snapshot if the current snapshot is not NULL. Otherwise, the branch will point to a newly created empty snapshot.- Specified by:
createBranchin interfaceManageSnapshots- Parameters:
name- branch name- Returns:
- this for method chaining
-
createBranch
public ManageSnapshots createBranch(java.lang.String name, long snapshotId)
Description copied from interface:ManageSnapshotsCreate a new branch pointing to the given snapshot id.- Specified by:
createBranchin interfaceManageSnapshots- Parameters:
name- branch namesnapshotId- id of the snapshot which will be the head of the branch- Returns:
- this for method chaining
-
createTag
public ManageSnapshots createTag(java.lang.String name, long snapshotId)
Description copied from interface:ManageSnapshotsCreate a new tag pointing to the given snapshot id- Specified by:
createTagin interfaceManageSnapshots- Parameters:
name- tag namesnapshotId- snapshotId for the head of the new branch.- Returns:
- this for method chaining
-
removeBranch
public ManageSnapshots removeBranch(java.lang.String name)
Description copied from interface:ManageSnapshotsRemove a branch by name- Specified by:
removeBranchin interfaceManageSnapshots- Parameters:
name- branch name- Returns:
- this for method chaining
-
removeTag
public ManageSnapshots removeTag(java.lang.String name)
Description copied from interface:ManageSnapshotsRemove the tag with the given name.- Specified by:
removeTagin interfaceManageSnapshots- Parameters:
name- tag name- Returns:
- this for method chaining
-
setMinSnapshotsToKeep
public ManageSnapshots setMinSnapshotsToKeep(java.lang.String name, int minSnapshotsToKeep)
Description copied from interface:ManageSnapshotsUpdates the minimum number of snapshots to keep for a branch.- Specified by:
setMinSnapshotsToKeepin interfaceManageSnapshots- Parameters:
name- branch nameminSnapshotsToKeep- minimum number of snapshots to retain on the branch- Returns:
- this for method chaining
-
setMaxSnapshotAgeMs
public ManageSnapshots setMaxSnapshotAgeMs(java.lang.String name, long maxSnapshotAgeMs)
Description copied from interface:ManageSnapshotsUpdates the max snapshot age for a branch.- Specified by:
setMaxSnapshotAgeMsin interfaceManageSnapshots- Parameters:
name- branch namemaxSnapshotAgeMs- maximum snapshot age in milliseconds to retain on branch- Returns:
- this for method chaining
-
setMaxRefAgeMs
public ManageSnapshots setMaxRefAgeMs(java.lang.String name, long maxRefAgeMs)
Description copied from interface:ManageSnapshotsUpdates the retention policy for a reference.- Specified by:
setMaxRefAgeMsin interfaceManageSnapshots- Parameters:
name- branch namemaxRefAgeMs- retention age in milliseconds of the tag reference itself- Returns:
- this for method chaining
-
replaceTag
public ManageSnapshots replaceTag(java.lang.String name, long snapshotId)
Description copied from interface:ManageSnapshotsReplaces the tag with the given name to point to the specified snapshot.- Specified by:
replaceTagin interfaceManageSnapshots- Parameters:
name- Tag to replacesnapshotId- new snapshot id for the given tag- Returns:
- this for method chaining
-
replaceBranch
public ManageSnapshots replaceBranch(java.lang.String name, long snapshotId)
Description copied from interface:ManageSnapshotsReplaces the branch with the given name to point to the specified snapshot- Specified by:
replaceBranchin interfaceManageSnapshots- Parameters:
name- Branch to replacesnapshotId- new snapshot id for the given branch- Returns:
- this for method chaining
-
replaceBranch
public ManageSnapshots replaceBranch(java.lang.String name, java.lang.String source)
Description copied from interface:ManageSnapshotsReplaces the branch with the given name to point to the source snapshot. The source branch will remain unchanged, the target branch will retain its retention properties.- Specified by:
replaceBranchin interfaceManageSnapshots- Parameters:
name- Branch to replacesource- Source reference for the target to be replaced with- Returns:
- this for method chaining
-
fastForwardBranch
public ManageSnapshots fastForwardBranch(java.lang.String name, java.lang.String source)
Description copied from interface:ManageSnapshotsPerforms a fast-forward of the given target branch up to the source snapshot if target is an ancestor of source. The source branch will remain unchanged, the target branch will retain its retention properties.- Specified by:
fastForwardBranchin interfaceManageSnapshots- Parameters:
name- Branch to fast-forwardsource- Source reference for the target to be fast forwarded to- Returns:
- this for method chaining
-
renameBranch
public ManageSnapshots renameBranch(java.lang.String name, java.lang.String newName)
Description copied from interface:ManageSnapshotsRename a branch- Specified by:
renameBranchin interfaceManageSnapshots- Parameters:
name- name of branch to renamenewName- the desired new name of the branch
-
apply
public Snapshot apply()
Description copied from interface:PendingUpdateApply the pending changes and return the uncommitted changes for validation.This does not result in a permanent update.
- Specified by:
applyin interfacePendingUpdate<Snapshot>- Returns:
- the uncommitted changes that would be committed by calling
PendingUpdate.commit()
-
commit
public void commit()
Description copied from interface:PendingUpdateApply the pending changes and commit.Changes are committed by calling the underlying table's commit method.
Once the commit is successful, the updated table will be refreshed.
- Specified by:
commitin interfacePendingUpdate<Snapshot>
-
-