rdblue commented on code in PR #5617:
URL: https://github.com/apache/iceberg/pull/5617#discussion_r954125752


##########
python/pyiceberg/utils/bin_packing.py:
##########
@@ -14,21 +14,54 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
+from typing import (
+    Callable,
+    Iterable,
+    List,
+    Optional,
+)
+
+
+class Bin:
+    def __init__(self, target_weight: int) -> None:
+        self.bin_weight = 0
+        self.target_weight = target_weight
+        self.items: List[int] = []
+
+    def weight(self) -> int:
+        return self.bin_weight
+
+    def can_add(self, weight: int) -> bool:
+        return self.bin_weight + weight <= self.target_weight
+
+    def add(self, item: int, weight: int) -> None:
+        self.bin_weight += weight
+        self.items.append(item)
 
 
 class PackingIterator:
-    def __init__(self, items, target_weight, lookback, weight_func, 
largest_bin_first=False):
+
+    bins: List[Bin]
+
+    def __init__(
+        self,
+        items: Iterable[int],

Review Comment:
   I think this needs to be parameterized with `T` rather than `int`. The bins 
can contain any type and the only thing that matters is that `weight_func` can 
return a value for them.



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