Skip to content

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

@varsenyantitan

Description

@varsenyantitan

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions