Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I store unsigned integers in Cassandra?

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?

like image 464
Mark Avatar asked Oct 31 '22 07:10

Mark


1 Answers

You can use Cassandra's varint, represented in the C# Driver as BigInteger.

You can do explicit conversions from BigInteger to ushortand ulong.

like image 95
jorgebg Avatar answered Nov 15 '22 03:11

jorgebg