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


##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/index/bloom/HoodieFileProbingFunction.java:
##########
@@ -67,19 +69,43 @@ public 
HoodieFileProbingFunction(Broadcast<HoodieTableFileSystemView> baseFileOn
   }
 
   @Override
-  public Iterator<List<HoodieKeyLookupResult>> 
call(Iterator<Tuple2<HoodieFileGroupId, HoodieBloomFilterProbingResult>> 
tuple2Iterator) throws Exception {
+  public Iterator<HoodieKeyLookupResult> 
call(Iterator<Tuple2<HoodieFileGroupId, HoodieBloomFilterProbingResult>> 
tuple2Iterator) throws Exception {
     return new BloomIndexLazyKeyCheckIterator(tuple2Iterator);
   }
 
   private class BloomIndexLazyKeyCheckIterator
-      extends LazyIterableIterator<Tuple2<HoodieFileGroupId, 
HoodieBloomFilterProbingResult>, List<HoodieKeyLookupResult>> {
+      extends LazyIterableIterator<Tuple2<HoodieFileGroupId, 
HoodieBloomFilterProbingResult>, HoodieKeyLookupResult> {
+
+    private List<HoodieKeyLookupResult> currentBatch;
+    private int currentBatchIndex;
 
     public BloomIndexLazyKeyCheckIterator(Iterator<Tuple2<HoodieFileGroupId, 
HoodieBloomFilterProbingResult>> tuple2Iterator) {
       super(tuple2Iterator);
+      this.currentBatch = Collections.emptyList();
+      this.currentBatchIndex = 0;
     }
 
     @Override
-    protected List<HoodieKeyLookupResult> computeNext() {
+    protected HoodieKeyLookupResult computeNext() {
+      // If we have results left in the current batch, return next one
+      if (currentBatchIndex < currentBatch.size()) {
+        return currentBatch.get(currentBatchIndex++);
+      }
+
+      // Need to fetch next batch
+      currentBatch = fetchNextBatch();
+      currentBatchIndex = 0;
+
+      // If new batch is empty, we're done
+      if (currentBatch.isEmpty()) {
+        return null;

Review Comment:
   Should caller filter out `null`s?



##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/index/bloom/SparkHoodieBloomIndexHelper.java:
##########
@@ -181,14 +181,14 @@ public HoodiePairData<HoodieKey, HoodieRecordLocation> 
findMatchingFilesForRecor
           .mapPartitions(new HoodieSparkBloomIndexCheckFunction(hoodieTable, 
config), true);
     }
 
-    return HoodieJavaPairRDD.of(keyLookupResultRDD.flatMap(List::iterator)
-        .filter(lr -> lr.getMatchingRecordKeysAndPositions().size() > 0)
+    return HoodieJavaPairRDD.of(keyLookupResultRDD
+        .filter(lr -> !lr.getMatchingRecordKeysAndPositions().isEmpty())

Review Comment:
   Should L160 with `HoodieFileProbingFunction` filter for non-nulls given that 
`HoodieFileProbingFunction#next` can return `null`?



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