question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

INT64 uses "C long" type in struct.pack which is 4 bytes.

See original GitHub issue

Expected 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:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
mjurkuscommented, Apr 29, 2022

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?

1reaction
roelschrcommented, Apr 26, 2022

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.

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found