如何在Cassandra中存储无符号整数? [英] How do I store unsigned integers in Cassandra?

查看:66
本文介绍了如何在Cassandra中存储无符号整数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过Datastax驱动程序在Cassandra中存储一些数据,并且我需要存储无符号的16位和32位整数。对于无符号的16位整数,我可以轻松地将它们存储为有符号的32位整数,并根据需要进行强制转换。但是,对于无符号的64位整数,我很茫然。我可以将它们存储为字符串并进行解析,也可以将它们存储为字节数组。我可以将它们存储为64位有符号整数,并进行从64位无符号整数转换为64位无符号整数所需的位操作。

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?

推荐答案

您可以使用Cassandra的 varint ,在C#驱动程序中表示为 BigInteger

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

您可以显式转换 BigInteger ushort ulong

这篇关于如何在Cassandra中存储无符号整数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆