dhkim1920 commented on code in PR #73783:
URL: https://github.com/apache/airflow/pull/73783#discussion_r4259999292
##########
task-sdk/src/airflow/sdk/execution_time/comms.py:
##########
@@ -175,14 +177,42 @@ def _new_encoder() -> msgspec.msgpack.Encoder:
return msgspec.msgpack.Encoder(enc_hook=_msgpack_enc_hook)
+def _encode_large_ints(value: Any) -> Any:
+ if isinstance(value, int) and not -(2**63) <= value < 2**64:
+ return msgspec.msgpack.Ext(0, value.to_bytes((value.bit_length() + 8)
// 8, "big", signed=True))
+ if isinstance(value, dict):
+ return {key: _encode_large_ints(item) for key, item in value.items()}
+ if isinstance(value, (list, tuple)):
+ return [_encode_large_ints(item) for item in value]
+ if isinstance(value, msgspec.Struct):
+ return msgspec.structs.replace(
+ value, **{name: _encode_large_ints(getattr(value, name)) for name
in value.__struct_fields__}
+ )
+ if isinstance(value, BaseModel):
+ return _encode_large_ints(value.model_dump(exclude_unset=True))
+ return value
+
+
+def _decode_msgpack_ext(code: int, data: memoryview) -> Any:
+ if code == 0:
Review Comment:
Confirmed: `0` is a valid application-specific extension code in the
[MessagePack
specification](https://github.com/msgpack/msgpack/blob/master/spec.md#extension-types).
I've defined `MP_HUGEINT: Final[int] = 0` and updated both the encoder and
decoder to use it locally. That change has not been pushed yet.
---
Drafted-by: Codex (GPT-6); reviewed by @dhkim1920 before posting
--
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]