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


##########
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:
   🤖 I think `ConcurrentHashMap.newKeySet()` is actually the better choice here 
— it gives O(1) for `add` and `contains`, whereas `TreeSet` would be O(log n) 
and would also need external synchronization (e.g. 
`Collections.synchronizedSortedSet`). Since the results are sorted downstream 
via `.sorted()` in the stream pipeline, there's no benefit to maintaining order 
within the set.



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