You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/12/23 11:51:05 UTC

[GitHub] [iceberg] hililiwei commented on a diff in pull request #6401: Flink: Change to oldestAncestorAfter

hililiwei commented on code in PR #6401:
URL: https://github.com/apache/iceberg/pull/6401#discussion_r1056284703


##########
flink/v1.14/flink/src/main/java/org/apache/iceberg/flink/source/enumerator/ContinuousSplitPlannerImpl.java:
##########
@@ -213,17 +213,12 @@ static Optional<Snapshot> startSnapshot(Table table, ScanContext scanContext) {
             "Start snapshot id not found in history: " + scanContext.startSnapshotId());
         return Optional.of(matchedSnapshotById);
       case INCREMENTAL_FROM_SNAPSHOT_TIMESTAMP:
-        long snapshotIdAsOfTime =
-            SnapshotUtil.snapshotIdAsOfTime(table, scanContext.startSnapshotTimestamp());
-        Snapshot matchedSnapshotByTimestamp = table.snapshot(snapshotIdAsOfTime);
-        if (matchedSnapshotByTimestamp.timestampMillis() == scanContext.startSnapshotTimestamp()) {
-          return Optional.of(matchedSnapshotByTimestamp);
-        } else {
-          // if the snapshotIdAsOfTime has the timestamp value smaller than the
-          // scanContext.startSnapshotTimestamp(),
-          // return the child snapshot whose timestamp value is larger
-          return Optional.of(SnapshotUtil.snapshotAfter(table, snapshotIdAsOfTime));
-        }
+        Snapshot matchedSnapshotByTimestamp =
+            SnapshotUtil.oldestAncestorAfter(table, scanContext.startSnapshotTimestamp());
+        Preconditions.checkArgument(
+            matchedSnapshotByTimestamp != null,
+            "Cannot find a snapshot after: " + scanContext.startSnapshotTimestamp());
+        return Optional.of(matchedSnapshotByTimestamp);

Review Comment:
   The old one was to first find a snapshot equal to the `scanContext.startSnapshotTimestamp()`. If not, look for a snapshot older than `scanContext.startSnapshotTimestamp()`. The logic is consistent with `oldestAncestorAfter`.
   It come from https://github.com/apache/iceberg/pull/6350#discussion_r1044901322



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org