public class SnapshotManager extends Object implements Serializable
Snapshot
, providing utility methods related to paths and snapshot hints.Modifier and Type | Field and Description |
---|---|
static String |
EARLIEST |
static String |
LATEST |
Constructor and Description |
---|
SnapshotManager(FileIO fileIO,
Path tablePath) |
SnapshotManager(FileIO fileIO,
Path tablePath,
String branchName)
Specify the default branch for data writing.
|
Modifier and Type | Method and Description |
---|---|
String |
branch() |
Changelog |
changelog(long snapshotId) |
Path |
changelogDirectory() |
Iterator<Changelog> |
changelogs() |
void |
commitChangelog(Changelog changelog,
long id) |
void |
commitEarliestHint(long snapshotId) |
void |
commitLatestHint(long snapshotId) |
void |
commitLongLivedChangelogEarliestHint(long snapshotId) |
void |
commitLongLivedChangelogLatestHint(long snapshotId) |
SnapshotManager |
copyWithBranch(String branchName) |
void |
deleteLatestHint() |
Snapshot |
earlierOrEqualTimeMills(long timestampMills)
Returns a
Snapshot whoes commit time is earlier than or equal to given timestamp
mills. |
Long |
earlierThanTimeMills(long timestampMills,
boolean startFromChangelog)
Returns the latest snapshot earlier than the timestamp mills.
|
Long |
earliestLongLivedChangelogId() |
Snapshot |
earliestSnapshot() |
Long |
earliestSnapshotId() |
FileIO |
fileIO() |
static List<Snapshot> |
findOverlappedSnapshots(List<Snapshot> sortedSnapshots,
long beginInclusive,
long endExclusive)
Find the overlapping snapshots between sortedSnapshots and range of [beginInclusive,
endExclusive).
|
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.
|
Snapshot |
laterOrEqualTimeMills(long timestampMills)
Returns a
Snapshot whoes commit time is later than or equal to given timestamp mills. |
Snapshot |
laterOrEqualWatermark(long watermark) |
Long |
latestChangelogId() |
Long |
latestLongLivedChangelogId() |
Snapshot |
latestSnapshot() |
Long |
latestSnapshotId() |
Optional<Snapshot> |
latestSnapshotOfUser(String user) |
Changelog |
longLivedChangelog(long snapshotId) |
boolean |
longLivedChangelogExists(long snapshotId) |
Path |
longLivedChangelogPath(long snapshotId) |
Long |
pickOrLatest(java.util.function.Predicate<Snapshot> predicate) |
Long |
readHint(String fileName) |
Long |
readHint(String fileName,
Path dir) |
List<Changelog> |
safelyGetAllChangelogs() |
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) |
Iterator<Snapshot> |
snapshots() |
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.
|
List<Path> |
tryGetNonChangelogFiles(java.util.function.Predicate<FileStatus> fileStatusFilter) |
List<Path> |
tryGetNonSnapshotFiles(java.util.function.Predicate<FileStatus> fileStatusFilter)
Try to get non snapshot files.
|
public static final String EARLIEST
public static final String LATEST
public SnapshotManager copyWithBranch(String branchName)
public FileIO fileIO()
public Path tablePath()
public String branch()
public Path changelogDirectory()
public Path longLivedChangelogPath(long snapshotId)
public Path snapshotPath(long snapshotId)
public Path snapshotDirectory()
public Snapshot snapshot(long snapshotId)
public Changelog changelog(long snapshotId)
public Changelog longLivedChangelog(long snapshotId)
public boolean snapshotExists(long snapshotId)
public boolean longLivedChangelogExists(long snapshotId)
@Nullable public Long pickOrLatest(java.util.function.Predicate<Snapshot> predicate)
@Nullable public Long earlierThanTimeMills(long timestampMills, boolean startFromChangelog)
@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 Iterator<Snapshot> snapshotsWithinRange(Optional<Long> optionalMaxSnapshotId, Optional<Long> optionalMinSnapshotId) throws IOException
IOException
public Iterator<Changelog> changelogs() throws IOException
IOException
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<Changelog> safelyGetAllChangelogs() throws IOException
IOException
public List<Path> tryGetNonSnapshotFiles(java.util.function.Predicate<FileStatus> fileStatusFilter)
public List<Path> tryGetNonChangelogFiles(java.util.function.Predicate<FileStatus> fileStatusFilter)
public List<Snapshot> findSnapshotsForIdentifiers(@Nonnull String user, List<Long> identifiers)
public void commitChangelog(Changelog changelog, long id) throws IOException
IOException
@Nullable public Snapshot traversalSnapshotsFromLatestSafely(Filter<Snapshot> checker)
public static List<Snapshot> findOverlappedSnapshots(List<Snapshot> sortedSnapshots, long beginInclusive, long endExclusive)
public static int findPreviousSnapshot(List<Snapshot> sortedSnapshots, long targetSnapshotId)
public void deleteLatestHint() throws IOException
IOException
public void commitLatestHint(long snapshotId) throws IOException
IOException
public void commitLongLivedChangelogLatestHint(long snapshotId) throws IOException
IOException
public void commitLongLivedChangelogEarliestHint(long snapshotId) throws IOException
IOException
public void commitEarliestHint(long snapshotId) throws IOException
IOException
Copyright © 2023–2024 The Apache Software Foundation. All rights reserved.