yihua commented on code in PR #18408:
URL: https://github.com/apache/hudi/pull/18408#discussion_r3048287374


##########
hudi-common/src/main/java/org/apache/hudi/common/table/timeline/versioning/v1/ArchivedTimelineV1.java:
##########
@@ -320,8 +320,10 @@ private InstantsLoader(boolean loadInstantDetails) {
     public void accept(String instantTime, GenericRecord record) {
       Option<HoodieInstant> instant = readCommit(instantTime, record, 
loadInstantDetails, null);
       if (instant.isPresent()) {
-        instantsInRange.computeIfAbsent(instant.get().requestedTime(), s -> 
new ArrayList<>())
-            .add(instant.get());
+        List<HoodieInstant> instantsForTime = 
instantsInRange.computeIfAbsent(instant.get().requestedTime(), s -> new 
ArrayList<>());
+        if (!instantsForTime.contains(instant.get())) {
+          instantsForTime.add(instant.get());

Review Comment:
   🤖 `ConcurrentHashMap.newKeySet()` is already O(1) for add/contains, which is 
more efficient than TreeSet's O(log n). Since the downstream code applies 
`.sorted()` on the flattened stream anyway, there's no benefit to maintaining 
sorted order in the set itself. Plus `ConcurrentHashMap.newKeySet()` is 
thread-safe, matching the concurrency expectations of the outer 
`ConcurrentHashMap`.



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