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



##########
File path: core/src/main/java/org/apache/iceberg/util/BinPacking.java
##########
@@ -169,19 +179,21 @@ public boolean hasNext() {
 
   private static class Bin<T> {
     private final long targetWeight;
+    private final int itemsPerBin;
     private final List<T> items = Lists.newArrayList();
     private long binWeight = 0L;
 
-    Bin(long targetWeight) {
+    Bin(long targetWeight, int itemsPerBin) {
       this.targetWeight = targetWeight;
+      this.itemsPerBin = itemsPerBin;
     }
 
     List<T> items() {
       return items;
     }
 
     boolean canAdd(long weight) {
-      return binWeight + weight <= targetWeight;
+      return binWeight + weight <= targetWeight && items.size() <= itemsPerBin;

Review comment:
       I think there is a slight issue with this implementation and how it 
interacts with lookback.
   
   Consider we have a lookback of 3 a max number of items per bin of 2 and a 
max value of bin of 10
   ```
   // Add Item (6)
   [ 8 ], [3, 4], [4, 3]
   // Neither of our completed bins [3, 4], and [4,3] will be removed 
regardless of whether removeLargest is set
   
   I think to properly do this we need to also finish off any bins which have 
reached their max item size
   ```




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



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

Reply via email to