Package org.apache.iceberg.util
Class SnapshotUtil
- java.lang.Object
-
- org.apache.iceberg.util.SnapshotUtil
-
public class SnapshotUtil extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.List<java.lang.Long>
ancestorIds(Snapshot snapshot, java.util.function.Function<java.lang.Long,Snapshot> lookup)
static boolean
ancestorOf(Table table, long snapshotId, long ancestorSnapshotId)
Returns whether ancestorSnapshotId is an ancestor of snapshotId.static java.util.List<java.lang.Long>
currentAncestors(Table table)
Return the snapshot IDs for the ancestors of the current table state.static java.util.List<DataFile>
newFiles(java.lang.Long baseSnapshotId, long latestSnapshotId, java.util.function.Function<java.lang.Long,Snapshot> lookup)
static Snapshot
oldestSnapshot(Table table)
Traverses the history of the table's current snapshot and finds the oldest Snapshot.static Snapshot
snapshotAfter(Table table, long snapshotId)
Traverses the history of the table's current snapshot and finds the snapshot with the given snapshot id as its parent.static java.util.List<java.lang.Long>
snapshotIdsBetween(Table table, long fromSnapshotId, long toSnapshotId)
Returns list of snapshot ids in the range - (fromSnapshotId, toSnapshotId]
-
-
-
Method Detail
-
ancestorOf
public static boolean ancestorOf(Table table, long snapshotId, long ancestorSnapshotId)
Returns whether ancestorSnapshotId is an ancestor of snapshotId.
-
currentAncestors
public static java.util.List<java.lang.Long> currentAncestors(Table table)
Return the snapshot IDs for the ancestors of the current table state.Ancestor IDs are ordered by commit time, descending. The first ID is the current snapshot, followed by its parent, and so on.
- Parameters:
table
- aTable
- Returns:
- a set of snapshot IDs of the known ancestor snapshots, including the current ID
-
oldestSnapshot
public static Snapshot oldestSnapshot(Table table)
Traverses the history of the table's current snapshot and finds the oldest Snapshot.- Returns:
- null if there is no current snapshot in the table, else the oldest Snapshot.
-
snapshotIdsBetween
public static java.util.List<java.lang.Long> snapshotIdsBetween(Table table, long fromSnapshotId, long toSnapshotId)
Returns list of snapshot ids in the range - (fromSnapshotId, toSnapshotId]This method assumes that fromSnapshotId is an ancestor of toSnapshotId.
-
ancestorIds
public static java.util.List<java.lang.Long> ancestorIds(Snapshot snapshot, java.util.function.Function<java.lang.Long,Snapshot> lookup)
-
newFiles
public static java.util.List<DataFile> newFiles(java.lang.Long baseSnapshotId, long latestSnapshotId, java.util.function.Function<java.lang.Long,Snapshot> lookup)
-
snapshotAfter
public static Snapshot snapshotAfter(Table table, long snapshotId)
Traverses the history of the table's current snapshot and finds the snapshot with the given snapshot id as its parent.- Returns:
- the snapshot for which the given snapshot is the parent
- Throws:
java.lang.IllegalArgumentException
- when the given snapshotId is not found in the tablejava.lang.IllegalStateException
- when the given snapshotId is not an ancestor of the current table state
-
-