Package org.apache.iceberg
Class SnapshotManager
java.lang.Object
org.apache.iceberg.SnapshotManager
- All Implemented Interfaces:
ManageSnapshots
,PendingUpdate<Snapshot>
-
Method Summary
Modifier and TypeMethodDescriptionapply()
Apply the pending changes and return the uncommitted changes for validation.cherrypick
(long snapshotId) Apply supported changes in given snapshot and create a new snapshot which will be set as the current snapshot on commit.void
commit()
Apply the pending changes and commit.createBranch
(String name) Create a new branch.createBranch
(String name, long snapshotId) Create a new branch pointing to the given snapshot id.Create a new tag pointing to the given snapshot idfastForwardBranch
(String from, String to) Performs a fast-forward offrom
up to theto
snapshot iffrom
is an ancestor ofto
.removeBranch
(String name) Remove a branch by nameRemove the tag with the given name.renameBranch
(String name, String newName) Rename a branchreplaceBranch
(String name, long snapshotId) Replaces the branch with the given name to point to the specified snapshotreplaceBranch
(String from, String to) Replaces thefrom
branch to point to theto
snapshot.replaceTag
(String name, long snapshotId) Replaces the tag with the given name to point to the specified snapshot.rollbackTo
(long snapshotId) Rollback table's state to a specificSnapshot
identified by id.rollbackToTime
(long timestampMillis) Roll this table's data back to the lastSnapshot
before the given timestamp.setCurrentSnapshot
(long snapshotId) Roll this table's data back to a specificSnapshot
identified by id.setMaxRefAgeMs
(String name, long maxRefAgeMs) Updates the retention policy for a reference.setMaxSnapshotAgeMs
(String name, long maxSnapshotAgeMs) Updates the max snapshot age for a branch.setMinSnapshotsToKeep
(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 Details
-
cherrypick
Description copied from interface:ManageSnapshots
Apply supported changes in given snapshot and create a new snapshot which will be set as the current snapshot on commit.- Specified by:
cherrypick
in interfaceManageSnapshots
- Parameters:
snapshotId
- a snapshotId whose changes to apply- Returns:
- this for method chaining
-
setCurrentSnapshot
Description copied from interface:ManageSnapshots
Roll this table's data back to a specificSnapshot
identified by id.- Specified by:
setCurrentSnapshot
in interfaceManageSnapshots
- Parameters:
snapshotId
- long id of the snapshot to roll back table data to- Returns:
- this for method chaining
-
rollbackToTime
Description copied from interface:ManageSnapshots
Roll this table's data back to the lastSnapshot
before the given timestamp.- Specified by:
rollbackToTime
in interfaceManageSnapshots
- Parameters:
timestampMillis
- a long timestamp, as returned bySystem.currentTimeMillis()
- Returns:
- this for method chaining
-
rollbackTo
Description copied from interface:ManageSnapshots
Rollback table's state to a specificSnapshot
identified by id.- Specified by:
rollbackTo
in interfaceManageSnapshots
- Parameters:
snapshotId
- long id of snapshot id to roll back table to. Must be an ancestor of the current snapshot
-
createBranch
Description copied from interface:ManageSnapshots
Create 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:
createBranch
in interfaceManageSnapshots
- Parameters:
name
- branch name- Returns:
- this for method chaining
-
createBranch
Description copied from interface:ManageSnapshots
Create a new branch pointing to the given snapshot id.- Specified by:
createBranch
in interfaceManageSnapshots
- Parameters:
name
- branch namesnapshotId
- id of the snapshot which will be the head of the branch- Returns:
- this for method chaining
-
createTag
Description copied from interface:ManageSnapshots
Create a new tag pointing to the given snapshot id- Specified by:
createTag
in interfaceManageSnapshots
- Parameters:
name
- tag namesnapshotId
- snapshotId for the head of the new branch.- Returns:
- this for method chaining
-
removeBranch
Description copied from interface:ManageSnapshots
Remove a branch by name- Specified by:
removeBranch
in interfaceManageSnapshots
- Parameters:
name
- branch name- Returns:
- this for method chaining
-
removeTag
Description copied from interface:ManageSnapshots
Remove the tag with the given name.- Specified by:
removeTag
in interfaceManageSnapshots
- Parameters:
name
- tag name- Returns:
- this for method chaining
-
setMinSnapshotsToKeep
Description copied from interface:ManageSnapshots
Updates the minimum number of snapshots to keep for a branch.- Specified by:
setMinSnapshotsToKeep
in interfaceManageSnapshots
- Parameters:
name
- branch nameminSnapshotsToKeep
- minimum number of snapshots to retain on the branch- Returns:
- this for method chaining
-
setMaxSnapshotAgeMs
Description copied from interface:ManageSnapshots
Updates the max snapshot age for a branch.- Specified by:
setMaxSnapshotAgeMs
in interfaceManageSnapshots
- Parameters:
name
- branch namemaxSnapshotAgeMs
- maximum snapshot age in milliseconds to retain on branch- Returns:
- this for method chaining
-
setMaxRefAgeMs
Description copied from interface:ManageSnapshots
Updates the retention policy for a reference.- Specified by:
setMaxRefAgeMs
in interfaceManageSnapshots
- Parameters:
name
- branch namemaxRefAgeMs
- retention age in milliseconds of the tag reference itself- Returns:
- this for method chaining
-
replaceTag
Description copied from interface:ManageSnapshots
Replaces the tag with the given name to point to the specified snapshot.- Specified by:
replaceTag
in interfaceManageSnapshots
- Parameters:
name
- Tag to replacesnapshotId
- new snapshot id for the given tag- Returns:
- this for method chaining
-
replaceBranch
Description copied from interface:ManageSnapshots
Replaces the branch with the given name to point to the specified snapshot- Specified by:
replaceBranch
in interfaceManageSnapshots
- Parameters:
name
- Branch to replacesnapshotId
- new snapshot id for the given branch- Returns:
- this for method chaining
-
replaceBranch
Description copied from interface:ManageSnapshots
Replaces thefrom
branch to point to theto
snapshot. Theto
will remain unchanged, andfrom
branch will retain its retention properties. If thefrom
branch does not exist, it will be created with default retention properties.- Specified by:
replaceBranch
in interfaceManageSnapshots
- Parameters:
from
- Branch to replaceto
- The branchfrom
should be replaced with- Returns:
- this for method chaining
-
fastForwardBranch
Description copied from interface:ManageSnapshots
Performs a fast-forward offrom
up to theto
snapshot iffrom
is an ancestor ofto
. Theto
will remain unchanged, andfrom
will retain its retention properties. If thefrom
branch does not exist, it will be created with default retention properties.- Specified by:
fastForwardBranch
in interfaceManageSnapshots
- Parameters:
from
- Branch to fast-forwardto
- Ref for thefrom
branch to be fast forwarded to- Returns:
- this for method chaining
-
renameBranch
Description copied from interface:ManageSnapshots
Rename a branch- Specified by:
renameBranch
in interfaceManageSnapshots
- Parameters:
name
- name of branch to renamenewName
- the desired new name of the branch
-
apply
Description copied from interface:PendingUpdate
Apply the pending changes and return the uncommitted changes for validation.This does not result in a permanent update.
- Specified by:
apply
in interfacePendingUpdate<Snapshot>
- Returns:
- the uncommitted changes that would be committed by calling
PendingUpdate.commit()
-
commit
public void commit()Description copied from interface:PendingUpdate
Apply 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:
commit
in interfacePendingUpdate<Snapshot>
-