danny0405 commented on code in PR #14261:
URL: https://github.com/apache/hudi/pull/14261#discussion_r2544170168


##########
hudi-common/src/main/java/org/apache/hudi/common/table/timeline/versioning/v1/ArchivedTimelineV1.java:
##########
@@ -274,6 +308,39 @@ public Map<String, List<HoodieInstant>> 
getInstantsInRangeCollected() {
     }
   }
 
+  public class InstantsLoaderWithLimit implements BiConsumer<String, 
GenericRecord> {
+    private final Map<String, List<HoodieInstant>> instantsInRange = new 
ConcurrentHashMap<>();
+    private final boolean loadInstantDetails;
+    private final int limit;
+    private volatile int loadedCount = 0;
+
+    private InstantsLoaderWithLimit(boolean loadInstantDetails, int limit) {
+      this.loadInstantDetails = loadInstantDetails;
+      this.limit = limit;
+    }
+
+    @Override
+    public void accept(String instantTime, GenericRecord record) {
+      if (loadedCount >= limit) {
+        return;
+      }
+      Option<HoodieInstant> instant = readCommit(instantTime, record, 
loadInstantDetails, null);
+      if (instant.isPresent()) {
+        synchronized (this) {
+          if (loadedCount < limit) {
+            instantsInRange.computeIfAbsent(instant.get().requestedTime(), s 
-> new ArrayList<>())
+                .add(instant.get());
+            loadedCount++;
+          }
+        }
+      }
+    }
+
+    public Map<String, List<HoodieInstant>> getInstantsInRangeCollected() {
+      return instantsInRange;

Review Comment:
   should we sort the instants by instant time because the `Map` breaks the 
sequence.



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