INT64 uses "C long" type in struct.pack which is 4 bytes.
See original GitHub issueExpected Behavior
INT64 should be packed as “C long long” to have 64 bits memory capacity.
Current Behavior
INT64 is packed as “C long” which is 32 bits
Steps to reproduce
Materialization of entities with IDs larger than supported range of “C long” raises exception.
Specifications
The bug is in the _serialize_val function in key_encoding_utils.
def _serialize_val(value_type, v: ValueProto) -> Tuple[bytes, int]:
if value_type == "string_val":
return v.string_val.encode("utf8"), ValueType.STRING
elif value_type == "bytes_val":
return v.bytes_val, ValueType.BYTES
elif value_type == "int32_val":
return struct.pack("<i", v.int32_val), ValueType.INT32
elif value_type == "int64_val":
return struct.pack("<q", v.int64_val), ValueType.INT64
else:
raise ValueError(f"Value type not supported for Firestore: {v}")
- Version:
- feast: 0.18.1
- Platform:
- MacOS 12.0.1
- Subsystem:
- python: 3.8.1
Possible Solution
changing struct.pack("<l", v.int64_val), ValueType.INT64
to struct.pack("<q", v.int64_val), ValueType.INT64
fixes this.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
struct — Interpret bytes as packed binary data — Python 3.11 ...
It packs or unpacks data based on the platform and compiler on which the Python interpreter was built. The result of packing a...
Read more >How to convert integer value to array of four bytes in python
Have a look at the struct module. Probably all you need is struct.pack("I", your_int) to pack the integer in a string, and then...
Read more >7.1. struct — Interpret bytes as packed binary data
7.1. struct — Interpret bytes as packed binary data¶. Source code: Lib/struct.py. This module performs conversions between Python values and C structs ......
Read more >7.3. struct — Interpret strings as packed binary data - Jython
This module performs conversions between Python values and C structs ... any type (so you have to use pad bytes); short is 2...
Read more >7.3. struct — Interpret strings as packed binary data
By default, the result of packing a given C struct includes pad bytes in order to maintain proper alignment for the C types...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We ran into the same issue and we had patched on our fork too in the same way. But that’s not the only issue - the java server doesn’t work with our patch because of this EntityKeySerializerV2.java#L82-L85
Is it really necessary to add backward compatibility for this?
That makes total sense, thank you for this! I’ll move my PR back to draft and try to work on this backward compatibility issue.