You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/08/23 05:46:56 UTC
[GitHub] [iceberg] Fokko opened a new pull request, #5617: Python: Add types to bin packing
Fokko opened a new pull request, #5617:
URL: https://github.com/apache/iceberg/pull/5617
Everyone loves types 👍🏻
--
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-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] Fokko merged pull request #5617: Python: Add types to bin packing
Posted by GitBox <gi...@apache.org>.
Fokko merged PR #5617:
URL: https://github.com/apache/iceberg/pull/5617
--
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-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] rdblue commented on a diff in pull request #5617: Python: Add types to bin packing
Posted by GitBox <gi...@apache.org>.
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] Fokko commented on a diff in pull request #5617: Python: Add types to bin packing
Posted by GitBox <gi...@apache.org>.
Fokko commented on code in PR #5617:
URL: https://github.com/apache/iceberg/pull/5617#discussion_r954351727
##########
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:
Got it, I was unsure as well, but all the tests were based around `int`'s. Just updated it
--
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-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org