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


##########
hudi-common/src/main/java/org/apache/hudi/common/table/timeline/versioning/v1/ArchivedTimelineV1.java:
##########
@@ -274,6 +316,54 @@ public Map<String, List<HoodieInstant>> 
getInstantsInRangeCollected() {
     }
   }
 
+  public class InstantsLoaderWithLimit implements StoppableRecordConsumer {
+    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 boolean shouldStop() {
+      return loadedCount >= limit;
+    }
+
+    @Override
+    public void accept(String instantTime, GenericRecord record) {
+      if (shouldStop()) {
+        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;
+    }
+
+    public List<HoodieInstant> getCollectedInstants() {
+      // V1 needs to flatten because the map values are lists, while V2 can 
use the values directly. 
+      // V1 can have multiple instants with the same timestamp but different 
states (REQUESTED, INFLIGHT, COMPLETED).
+      return instantsInRange.values()
+          .stream()
+          .flatMap(Collection::stream)
+          .sorted()

Review Comment:
   we are loading only COMPLETED instants from the archived timeline ?



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