I am storing some data in Cassandra via the Datastax driver, and I have the need to store unsigned 16-bit and 32-bit integers. For unsigned 16-bit integers, I can easily store them as signed 32-bit integers and cast them as needed. For unsigned 64-bit integers, however, I am at a loss. I can store them as strings and parse them, or I can store them as byte arrays. I could store them as 64-bit signed integers and do the bit manipulation required to convert from and to 64-bit unsigned integers.
What is the recommended way?
You can use Cassandra's varint
, represented in the C# Driver as BigInteger.
You can do explicit conversions from BigInteger
to ushort
and ulong
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With