How do I store unsigned integers in Cassandra?

半腔热情 提交于 2019-12-11 02:24:37

问题


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?


回答1:


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

You can do explicit conversions from BigInteger to ushortand ulong.



来源:https://stackoverflow.com/questions/29237891/how-do-i-store-unsigned-integers-in-cassandra

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!