RussellSpitzer commented on a change in pull request #1704:
URL: https://github.com/apache/iceberg/pull/1704#discussion_r517613310



##########
File path: 
core/src/main/java/org/apache/iceberg/actions/BaseRewriteDataFilesAction.java
##########
@@ -228,9 +228,18 @@ public RewriteDataFilesActionResult execute() {
         .flatMap(Streams::stream)
         .collect(Collectors.toList());
 
+    // add a filter  to the CombinedScanTask list to avoid repeated rewrite 
datafile
+    List<CombinedScanTask> fileterCombinedScanTasks =
+        combinedScanTasks.stream().filter(task -> task.files().size() > 
1).collect(Collectors.toList());
+
+    if (fileterCombinedScanTasks.isEmpty()) {
+      return RewriteDataFilesActionResult.empty();
+    }
+
     List<DataFile> addedDataFiles = rewriteDataForTasks(combinedScanTasks);
-    List<DataFile> currentDataFiles = filteredGroupedTasks.values().stream()
-        .flatMap(tasks -> tasks.stream().map(FileScanTask::file))
+    List<DataFile> currentDataFiles = fileterCombinedScanTasks.stream()

Review comment:
       I think the flatmap here is unecessary since we can flatMap within the 
map operation instead,
   
   ```
       filteredCombinedScanTasks.stream()
           .flatMap(task -> task.files().stream().map(FileScanTask::file))
           .collect(Collectors.toList())
   ```
   
   This should skip at least one List allocation :) 




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

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to