How to serialize unsigned int / long values in AVRO

1.1k Views Asked by At

I am trying to serialize data with unsigned values to AVRO, but I see only signed int, long, float and double are supported by the AVRO libraries.

I could not find any native support for unsigned values in AVRO libraries.

Can you please help me in pointing to any references for serializing unsigned values with AVRO libraries or any workaround for this?

One workaround I can think of is, treat unsigned long as byte array and have custom methods to serialize and de-serialize it back to unsigned long.

1

There are 1 best solutions below

0
On

In Avro schema, write it as long and while serializing cast original property ulong property as long.

Original Property

 public ulong ABC{ get; }

Schema can be

{
        "name": "ABC",
        "type": "long"
},

Then Avro schema will generate a class with same data type and you have to serialize that with type casting.

ABC= (long)msg.ABC