public class SnapshotManager extends Object implements Serializable
Snapshot
, providing utility methods related to paths and snapshot hints.Modifier and Type | Field and Description |
---|---|
static int |
EARLIEST_SNAPSHOT_DEFAULT_RETRY_NUM |
static String |
SNAPSHOT_PREFIX |
Constructor and Description |
---|
SnapshotManager(FileIO fileIO,
Path tablePath,
String branchName,
SnapshotLoader snapshotLoader,
org.apache.paimon.shade.caffeine2.com.github.benmanes.caffeine.cache.Cache<Path,Snapshot> cache) |
Modifier and Type | Method and Description |
---|---|
String |
branch() |
void |
commitEarliestHint(long snapshotId) |
void |
commitLatestHint(long snapshotId) |
SnapshotManager |
copyWithBranch(String branchName) |
void |
deleteLatestHint() |
void |
deleteSnapshot(long snapshotId) |
Snapshot |
earlierOrEqualTimeMills(long timestampMills)
Returns a
Snapshot whoes commit time is earlier than or equal to given timestamp
mills. |
Snapshot |
earlierOrEqualWatermark(long watermark) |
boolean |
earliestFileNotExists() |
Snapshot |
earliestSnapshot() |
Long |
earliestSnapshotId() |
FileIO |
fileIO() |
static int |
findPreviousOrEqualSnapshot(List<Snapshot> sortedSnapshots,
long targetSnapshotId) |
static int |
findPreviousSnapshot(List<Snapshot> sortedSnapshots,
long targetSnapshotId) |
List<Snapshot> |
findSnapshotsForIdentifiers(String user,
List<Long> identifiers)
Find the snapshot of the specified identifiers written by the specified user.
|
void |
invalidateCache() |
Snapshot |
laterOrEqualTimeMills(long timestampMills)
Returns a
Snapshot whoes commit time is later than or equal to given timestamp mills. |
Snapshot |
laterOrEqualWatermark(long watermark) |
Snapshot |
latestSnapshot() |
Long |
latestSnapshotId() |
Optional<Snapshot> |
latestSnapshotOfUser(String user) |
Long |
pickOrLatest(java.util.function.Predicate<Snapshot> predicate) |
List<Snapshot> |
safelyGetAllSnapshots()
If
FileNotFoundException is thrown when reading the snapshot file, this snapshot may
be deleted by other processes, so just skip this snapshot. |
Snapshot |
snapshot(long snapshotId) |
long |
snapshotCount() |
Path |
snapshotDirectory() |
boolean |
snapshotExists(long snapshotId) |
Path |
snapshotPath(long snapshotId) |
List<Path> |
snapshotPaths(java.util.function.Predicate<Long> predicate) |
Iterator<Snapshot> |
snapshots() |
Iterator<Snapshot> |
snapshotsWithId(List<Long> snapshotIds) |
Iterator<Snapshot> |
snapshotsWithinRange(Optional<Long> optionalMaxSnapshotId,
Optional<Long> optionalMinSnapshotId) |
Path |
tablePath() |
Snapshot |
traversalSnapshotsFromLatestSafely(Filter<Snapshot> checker)
Traversal snapshots from latest to earliest safely, this is applied on the writer side
because the committer may delete obsolete snapshots, which may cause the writer to encounter
unreadable snapshots.
|
Snapshot |
tryGetSnapshot(long snapshotId) |
public static final String SNAPSHOT_PREFIX
public static final int EARLIEST_SNAPSHOT_DEFAULT_RETRY_NUM
public SnapshotManager copyWithBranch(String branchName)
public FileIO fileIO()
public Path tablePath()
public String branch()
public Path snapshotPath(long snapshotId)
public Path snapshotDirectory()
public void invalidateCache()
public Snapshot snapshot(long snapshotId)
public Snapshot tryGetSnapshot(long snapshotId) throws FileNotFoundException
FileNotFoundException
public boolean snapshotExists(long snapshotId)
public void deleteSnapshot(long snapshotId)
public boolean earliestFileNotExists()
@Nullable public Long pickOrLatest(java.util.function.Predicate<Snapshot> predicate)
@Nullable public Snapshot earlierOrEqualTimeMills(long timestampMills)
Snapshot
whoes commit time is earlier than or equal to given timestamp
mills. If there is no such a snapshot, returns null.@Nullable public Snapshot laterOrEqualTimeMills(long timestampMills)
Snapshot
whoes commit time is later than or equal to given timestamp mills.
If there is no such a snapshot, returns null.public long snapshotCount() throws IOException
IOException
public Iterator<Snapshot> snapshots() throws IOException
IOException
public List<Path> snapshotPaths(java.util.function.Predicate<Long> predicate) throws IOException
IOException
public Iterator<Snapshot> snapshotsWithinRange(Optional<Long> optionalMaxSnapshotId, Optional<Long> optionalMinSnapshotId)
public List<Snapshot> safelyGetAllSnapshots() throws IOException
FileNotFoundException
is thrown when reading the snapshot file, this snapshot may
be deleted by other processes, so just skip this snapshot.IOException
public List<Snapshot> findSnapshotsForIdentifiers(@Nonnull String user, List<Long> identifiers)
@Nullable public Snapshot traversalSnapshotsFromLatestSafely(Filter<Snapshot> checker)
public static int findPreviousSnapshot(List<Snapshot> sortedSnapshots, long targetSnapshotId)
public static int findPreviousOrEqualSnapshot(List<Snapshot> sortedSnapshots, long targetSnapshotId)
public void deleteLatestHint() throws IOException
IOException
public void commitLatestHint(long snapshotId) throws IOException
IOException
public void commitEarliestHint(long snapshotId) throws IOException
IOException
Copyright © 2023–2025 The Apache Software Foundation. All rights reserved.