stevenzwu commented on code in PR #4943:
URL: https://github.com/apache/iceberg/pull/4943#discussion_r893040222
##########
flink/v1.15/flink/src/main/java/org/apache/iceberg/flink/source/StreamingMonitorFunction.java:
##########
@@ -143,7 +147,25 @@ public void run(SourceContext<FlinkInputSplit> ctx) throws
Exception {
}
}
- private void monitorAndForwardSplits() {
+ private long maxReachableSnapshotId(long lastConsumedSnapshotId, long
latestSnapshotId,
+ int maxSnapshotCountPerMonitorInterval) {
+ // This doesn't consider snapshot inheritance since it is already checked
in state initialization.
+ List<Long> snapshotIds = SnapshotUtil.snapshotIdsBetween(table,
lastConsumedSnapshotId, latestSnapshotId);
+
+ if (snapshotIds.size() <= maxSnapshotCountPerMonitorInterval) {
+ return latestSnapshotId;
+ } else {
+ // It uses reverted index since snapshotIdsBetween returns Ids that are
ordered by committed time descending.
+ return snapshotIds.get(snapshotIds.size() -
maxSnapshotCountPerMonitorInterval);
+ }
+ }
+
+ @VisibleForTesting
+ void sourceContext(SourceContext<FlinkInputSplit> ctx) {
+ this.sourceContext = ctx;
+ }
+
+ void monitorAndForwardSplits() {
Review Comment:
nit: add `@VisibleForTesting` annotation here too
--
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]