public interface ExpireSnapshots extends PendingUpdate<java.util.List<Snapshot>>
snapshots
from a table.
This API accumulates snapshot deletions and commits the new list to the table. This API does not allow deleting the current snapshot.
When committing, these changes will be applied to the latest table metadata. Commit conflicts will be resolved by applying the changes to the new latest metadata and reattempting the commit.
Manifest files that are no longer used by valid snapshots will be deleted. Data files that
were deleted by snapshots that are expired will be deleted. deleteWith(Consumer)
can be
used to pass an alternative deletion method.
PendingUpdate.apply()
returns a list of the snapshots that will be removed.
Modifier and Type | Method and Description |
---|---|
ExpireSnapshots |
cleanExpiredFiles(boolean clean)
Allows expiration of snapshots without any cleanup of underlying manifest or data files.
|
ExpireSnapshots |
deleteWith(java.util.function.Consumer<java.lang.String> deleteFunc)
Passes an alternative delete implementation that will be used for manifests and data files.
|
ExpireSnapshots |
executeDeleteWith(java.util.concurrent.ExecutorService executorService)
Passes an alternative executor service that will be used for manifests and data files deletion.
|
ExpireSnapshots |
expireOlderThan(long timestampMillis)
Expires all snapshots older than the given timestamp.
|
ExpireSnapshots |
expireSnapshotId(long snapshotId)
Expires a specific
Snapshot identified by id. |
ExpireSnapshots |
planWith(java.util.concurrent.ExecutorService executorService)
Passes an alternative executor service that will be used for planning.
|
ExpireSnapshots |
retainLast(int numSnapshots)
Retains the most recent ancestors of the current snapshot.
|
apply, commit, updateEvent
ExpireSnapshots expireSnapshotId(long snapshotId)
Snapshot
identified by id.snapshotId
- long id of the snapshot to expireExpireSnapshots expireOlderThan(long timestampMillis)
timestampMillis
- a long timestamp, as returned by System.currentTimeMillis()
ExpireSnapshots retainLast(int numSnapshots)
If a snapshot would be expired because it is older than the expiration timestamp, but is one
of the numSnapshots
most recent ancestors of the current state, it will be retained.
This will not cause snapshots explicitly identified by id from expiring.
This may keep more than numSnapshots
ancestors if snapshots are added concurrently.
This may keep less than numSnapshots
ancestors if the current table state does not have
that many.
numSnapshots
- the number of snapshots to retainExpireSnapshots deleteWith(java.util.function.Consumer<java.lang.String> deleteFunc)
Manifest files that are no longer used by valid snapshots will be deleted. Data files that were deleted by snapshots that are expired will be deleted.
If this method is not called, unnecessary manifests and data files will still be deleted.
deleteFunc
- a function that will be called to delete manifests and data filesExpireSnapshots executeDeleteWith(java.util.concurrent.ExecutorService executorService)
Manifest files that are no longer used by valid snapshots will be deleted. Data files that were deleted by snapshots that are expired will be deleted.
If this method is not called, unnecessary manifests and data files will still be deleted using a single threaded executor service.
executorService
- an executor service to parallelize tasks to delete manifests and data
filesExpireSnapshots planWith(java.util.concurrent.ExecutorService executorService)
executorService
- an executor service to planExpireSnapshots cleanExpiredFiles(boolean clean)
Allows control in removing data and manifest files which may be more efficiently removed using a distributed framework through the actions API.
clean
- setting this to false will skip deleting expired manifests and files