You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by "EMsnap (via GitHub)" <gi...@apache.org> on 2023/06/29 08:43:15 UTC

[GitHub] [inlong] EMsnap commented on a diff in pull request #8367: [INLONG-8366][Sort] Data loss occurs when checkpoint restores ingesting into iceberg

EMsnap commented on code in PR #8367:
URL: https://github.com/apache/inlong/pull/8367#discussion_r1246318277


##########
inlong-sort/sort-flink/sort-flink-v1.13/sort-connectors/iceberg/src/main/java/org/apache/inlong/sort/iceberg/sink/multiple/IcebergSingleFileCommiter.java:
##########
@@ -423,4 +482,50 @@ static long getMaxCommittedCheckpointId(Table table, String flinkJobId) {
 
         return lastCommittedCheckpointId;
     }
+
+    static long getSnapshotIdAssociatedWithChkId(Table table, String flinkJobId, Long checkpointId) {
+        Snapshot snapshot = table.currentSnapshot();
+        long associatedSnapshotId = INVALID_SNAPSHOT_ID;
+
+        while (snapshot != null) {
+            Map<String, String> summary = snapshot.summary();
+            String snapshotFlinkJobId = summary.get(FLINK_JOB_ID);
+            if (flinkJobId.equals(snapshotFlinkJobId)) {
+                String value = summary.get(MAX_COMMITTED_CHECKPOINT_ID);
+                if (value != null && checkpointId.equals(Long.parseLong(value))) {
+                    associatedSnapshotId = snapshot.snapshotId();
+                    break;
+                }
+            }
+            Long parentSnapshotId = snapshot.parentId();
+            snapshot = parentSnapshotId != null ? table.snapshot(parentSnapshotId) : null;
+        }
+        return associatedSnapshotId;
+    }
+
+    static long findLastCommittedManifest(NavigableMap<Long, byte[]> deltaManifestsMap, FileIO io) throws IOException {
+        List<Long> uncommittedChkList = deltaManifestsMap.keySet()
+            .stream()
+            .sorted((a, b) -> a < b ? 1 : ((a == b) ? 0 : -1))

Review Comment:
   lambda can be simplified to
   .sorted(Comparator.reverseOrder())



-- 
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: commits-unsubscribe@inlong.apache.org

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