sunchao commented on code in PR #2276:
URL: https://github.com/apache/iceberg/pull/2276#discussion_r999802249


##########
core/src/main/java/org/apache/iceberg/util/TableScanUtil.java:
##########
@@ -87,11 +105,44 @@ public static CloseableIterable<CombinedScanTask> 
planTasks(
                     + 
file.deletes().stream().mapToLong(ContentFile::fileSizeInBytes).sum(),
                 (1 + file.deletes().size()) * openFileCost);
 
-    return CloseableIterable.transform(
-        CloseableIterable.combine(
-            new BinPacking.PackingIterable<>(splitFiles, splitSize, lookback, 
weightFunc, true),
-            splitFiles),
-        BaseCombinedScanTask::new);
+    if (preservedPartitionIds != null && !preservedPartitionIds.isEmpty()) {
+      Preconditions.checkArgument(
+          spec != null, "spec can't be null when " + "preservedPartitionIds is 
not null");
+      StructProjection projectedStruct =
+          StructProjection.create(spec.partitionType(), preservedPartitionIds);
+      Types.StructType projectedPartitionType = projectedStruct.type();
+      ListMultimap<StructLikeWrapper, FileScanTask> groupedFiles =
+          Multimaps.newListMultimap(Maps.newHashMap(), Lists::newArrayList);
+
+      splitFiles.forEach(
+          f -> {
+            StructLikeWrapper wrapper =
+                StructLikeWrapper.forType(projectedPartitionType)
+                    .set(projectedStruct.copy().wrap(f.file().partition()));
+            groupedFiles.put(wrapper, f);
+          });
+
+      List<Iterable<BaseCombinedScanTask>> groupedTasks =
+          groupedFiles.asMap().values().stream()
+              .map(
+                  t ->
+                      Iterables.transform(
+                          new BinPacking.PackingIterable<>(
+                              CloseableIterable.withNoopClose(t),

Review Comment:
   You mean to make the bin-packing faster? 



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