tjo commented on code in PR #193:
URL: 
https://github.com/apache/flink-connector-aws/pull/193#discussion_r2013860291


##########
flink-connector-aws/flink-connector-dynamodb/src/main/java/org/apache/flink/connector/dynamodb/source/reader/DynamoDbStreamsSourceReader.java:
##########
@@ -58,10 +65,34 @@ public DynamoDbStreamsSourceReader(
             Map<String, DynamoDbStreamsShardMetrics> shardMetricGroupMap) {
         super(splitFetcherManager, recordEmitter, config, context);
         this.shardMetricGroupMap = shardMetricGroupMap;
+        this.splitFinishedEvents = new TreeMap<>();
+        this.currentCheckpointId = Long.MIN_VALUE;
     }
 
+    /**
+     * We store the finished splits in a map keyed by the checkpoint id.
+     *
+     * @param finishedSplitIds
+     */
     @Override
     protected void onSplitFinished(Map<String, DynamoDbStreamsShardSplitState> 
finishedSplitIds) {
+        if (finishedSplitIds.isEmpty()) {
+            return;
+        }
+
+        for (Map.Entry<String, DynamoDbStreamsShardSplitState> entry :

Review Comment:
   We could just use `values()` instead of `entrySet()`
   
   or as an alternative use the streaming API:
   ```
   Set<DynamoDbStreamsShardSplit> splitFinishedEventsForCheckpoint = 
splitFinishedEvents.computeIfAbsent(currentCheckpointId, k -> new HashSet<>());
           finishedSplitIds.values().stream().map(entry ->
                   new DynamoDbStreamsShardSplit(
                           entry.getStreamArn(),
                           entry.getShardId(),
                           entry.getNextStartingPosition(),
                           
entry.getDynamoDbStreamsShardSplit().getParentShardId(),
                           currentCheckpointId)
           ).forEach(e -> splitFinishedEventsForCheckpoint.add(e));
   ```



-- 
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]

Reply via email to