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


##########
flink/v1.15/flink/src/main/java/org/apache/iceberg/flink/source/StreamingMonitorFunction.java:
##########
@@ -155,6 +162,12 @@ private void monitorAndForwardSplits() {
       if (lastSnapshotId == INIT_LAST_SNAPSHOT_ID) {
         newScanContext = scanContext.copyWithSnapshotId(snapshotId);
       } else {
+        List<Long> snapshotIds = SnapshotUtil.snapshotIdsBetween(table, 
lastSnapshotId, snapshot.snapshotId());
+        if (snapshotIds.size() < scanContext.monitorSnapshotNumber()) {
+          snapshotId = snapshot.snapshotId();
+        } else {
+          snapshotId = snapshotIds.get(snapshotIds.size() - 
scanContext.monitorSnapshotNumber());
+        }

Review Comment:
   Instead, I suggest using `lastSnapshotId` and `monitorSnapshotNumber` 
directly to get to the destination.
   
   Specifically, there should be two ways:
   
   1.  use `lastSnapshotId` and `monitorSnapshotNumber` to get `snapshotId`, 
instead of getting `currentSnapshotId` and comparing,
   2.  Use `lastSnapshotId` and `monitorSnapshotNumber` directly to get the 
snapshot list
   
   The above may require modifications to the core module, but I think it will 
make the logic more intuitive.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to