stevenzwu commented on code in PR #4943:
URL: https://github.com/apache/iceberg/pull/4943#discussion_r889713943
##########
flink/v1.15/flink/src/main/java/org/apache/iceberg/flink/source/StreamingMonitorFunction.java:
##########
@@ -134,15 +140,33 @@ public void snapshotState(FunctionSnapshotContext
context) throws Exception {
public void run(SourceContext<FlinkInputSplit> ctx) throws Exception {
this.sourceContext = ctx;
while (isRunning) {
+ LOG.debug("Start polling snapshots from snapshot id: {},
max-snapshots-per-monitor-interval: {}", lastSnapshotId,
+ scanContext.maxSnapshotsPerMonitorInterval());
+ long start = System.currentTimeMillis();
+ long startSnapshotId = lastSnapshotId;
synchronized (sourceContext.getCheckpointLock()) {
if (isRunning) {
monitorAndForwardSplits();
}
}
+ LOG.debug("Forwarded splits from {}(exclusive) to {}(inclusive), time
elapsed {}ms",
+ startSnapshotId, lastSnapshotId, System.currentTimeMillis() - start);
Thread.sleep(scanContext.monitorInterval().toMillis());
}
}
+ private long maxReachableSnapshotId(long lastConsumedSnapshotId, long
latestSnapshotId,
+ int maxSnapshotsPerMonitorInterval) {
+ List<Long> snapshotIds = SnapshotUtil.snapshotIdsBetween(table,
lastConsumedSnapshotId, latestSnapshotId);
+
+ if (snapshotIds.size() <= maxSnapshotsPerMonitorInterval) {
+ return latestSnapshotId;
+ } else {
+ // This doesn't consider snapshot inheritance since it is already
checked in state initialization.
+ return snapshotIds.get(snapshotIds.size() -
maxSnapshotsPerMonitorInterval);
Review Comment:
I got it now. it is actually correct. We should improve the comment. Because
it is a revert list (list size - maxSnapshotsPerMonitorInterval) will actually
point to the snapshot that results in (fromSnapshotId, toSnapshotId) with size
of maxSnapshotsPerMonitorInterval
--
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]