RussellSpitzer commented on code in PR #12824:
URL: https://github.com/apache/iceberg/pull/12824#discussion_r2054957665


##########
spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/actions/RewriteDataFilesSparkAction.java:
##########
@@ -407,15 +409,49 @@ private Builder doExecuteWithPartialProgress(
 
   Stream<RewriteFileGroup> toGroupStream(
       RewriteExecutionContext ctx, Map<StructLike, List<List<FileScanTask>>> 
groupsByPartition) {
-    return groupsByPartition.entrySet().stream()
+
+    if (maxFilesToRewrite == 0) {

Review Comment:
   something like
   ```java
       long maxFilesToRewrite = Long.MAX_VALUE;
       AtomicLong remainingFiles = new AtomicLong(maxFilesToRewrite);
       return groupsByPartition.entrySet().stream()
           .filter(e -> !e.getValue().isEmpty())
           .flatMap(
               e -> {
                 if (remainingFiles.get() == 0) {
                   // bail out early, no more files need to be planned for any 
partitions
                   return Stream.empty();
                 }
                 
                 StructLike partition = e.getKey();
                 List<List<FileScanTask>> scanGroups = e.getValue();
                 return scanGroups.stream().flatMap(tasks -> {
                   if (remainingFiles.get() == 0) {
                     // bail out early, no more files need to be planned for 
any files within this partition
                     return Stream.empty();
                   } 
                     
                   int filesToTake = (int) Math.min(tasks.size(), 
remainingFiles.get());
                   remainingFiles.addAndGet(-filesToTake);
                   return Stream.of(newRewriteGroup(ctx, partition, 
tasks.subList(0, filesToTake)));
                 });
               })
           .sorted(RewriteFileGroup.comparator(rewriteJobOrder));
     }
   ```
     
     



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to