rdblue commented on a change in pull request #117: Sorts bin packing by weights 
in descending order
URL: https://github.com/apache/incubator-iceberg/pull/117#discussion_r262752702
 
 

 ##########
 File path: core/src/main/java/com/netflix/iceberg/util/BinPacking.java
 ##########
 @@ -107,6 +109,8 @@ public boolean hasNext() {
           bins.addLast(bin);
 
           if (bins.size() > lookback) {
+            // sort by bin weight, descending
+            bins.sort(Comparator.comparing(Bin::getWeight).reversed());
 
 Review comment:
   Modifying the order of the remaining bins changes the behavior of the 
algorithm more than intended. I think this should remove the bin with the 
largest weight, but should not reorder the other bins.
   
   That's also going to waste less time because removing the highest weight bin 
requires scanning all N bins, but sorting them is N*log(N).

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


With regards,
Apache Git Services

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

Reply via email to