codope commented on code in PR #18826:
URL: https://github.com/apache/hudi/pull/18826#discussion_r3292770271


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadataWriter.java:
##########
@@ -824,28 +824,54 @@ private Pair<Integer, HoodieData<HoodieRecord>> 
initializeRecordIndexPartition(
         dataMetaClient,
         dataWriteConfig);
 
-    // Initialize the file groups
-    final int fileGroupCount = estimateFileGroupCount(records);
+    Pair<Integer, Integer> bounds = getRLIFileGroupCountBounds();
+    int minFileGroupCount = bounds.getLeft();
+    int maxFileGroupCount = bounds.getRight();
+
+    int fileGroupCount;
+    if (minFileGroupCount != maxFileGroupCount) {
+      // Estimate file group count based on record count read from base file 
footer metadata.
+      // Avoids the expensive records.persist() + records.count() pass over 
materialized records.
+      List<Pair<String, HoodieBaseFile>> partitionBaseFilePairs = 
latestMergedPartitionFileSliceList.stream()

Review Comment:
   For slices with log files only, should we just log warn and fall back to the 
old supplier path for just those slices? We can take it up as follow-up to 
factor in log files.



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