I need to serialize a uint64 into a Avro field.
However in the docs I only see signed integers:
The set of primitive type names is:
null: no value
boolean: a binary value
int: 32-bit signed integer
long: 64-bit signed integer
float: single precision (32-bit) IEEE 754 floating-point number
double: double precision (64-bit) IEEE 754 floating-point number
bytes: sequence of 8-bit unsigned bytes
string: unicode character sequence
What is the "canonical" way to serialize a uint64 in Avro? As bytes?
{
"name": "payload",
"type": "record",
"fields": [
{
"name": "my_uint64",
"type": "bytes"
}
]
}
Edit:
Or should the data be encoded as a long
and then be casted on the consumer side?
{
"name": "payload",
"type": "record",
"fields": [
{
"name": "my_uint64",
"type": "long"
}
]
}
My problem with both approaches is that the receiver will have to know that some bytes
/longs
are in reality unit64
- however where do I store this information so that the consumer can rely on the schema?
My tendency is toward using bytes
with a magic byte in front that indicates a uint64
within.
Has anyone had similar issues and came to a conclusion?