moomindani commented on code in PR #3474:
URL: https://github.com/apache/iceberg-python/pull/3474#discussion_r3548052467
##########
pyiceberg/table/deletion_vector.py:
##########
@@ -67,6 +93,24 @@ def _deserialize_bitmap(pl: bytes) -> list[BitMap]:
return bitmaps
+ @staticmethod
+ def _serialize_bitmap(bitmaps: list[BitMap]) -> bytes:
+ # Counterpart of _deserialize_bitmap: number of bitmaps (8 bytes,
little-endian), then for each
+ # non-empty bitmap in ascending key order its key (4 bytes,
little-endian) and serialized payload.
+ non_empty = [(key, bitmap) for key, bitmap in enumerate(bitmaps) if
len(bitmap) > 0]
+
+ with io.BytesIO() as out:
+ out.write(len(non_empty).to_bytes(8, "little"))
+ for key, bitmap in non_empty:
+ if key > MAX_JAVA_SIGNED:
Review Comment:
You're right, thanks — Java's `readKey` rejects `key > Integer.MAX_VALUE -
1` while this check allowed one more key, so we could write a DV that Java
cannot read. Fixed the bound to match Java. Since the key is the list index in
`_serialize_bitmap`, the boundary isn't practically constructible in a test (it
would need a 2^31-element list); the existing `MAX_POSITION` validation in
`from_positions` keeps user input below the bound, so this check stays as
defense in depth.
--
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]