Cassandra 和 Hector = MultiGetSliceQuery,具有各种不同类型的列值?
你好,
我不明白,如何用 hector 查询 cassandra,但返回的列值不是一种单一类型,而是多种类型:
我输入了 ????我不知道该怎么做:
MultigetSliceQuery<String, String, ??????> multigetSliceQuery = HFactory.createMultigetSliceQuery(keyspace, stringSerializer, stringSerializer, ???????);
例如,如果我所有的列值都是 String 类型,我会放入 String.但我在一行中有不同的类型,例如 String、Integer 和 byte[]。所以我必须传入多个序列化程序。
怎么解决这个问题呢?
谢谢。
(可以创建 hector 作为标签吗?我不允许这样做)
Hallo,
I do not understand, how to query cassandra with hector, but the column-values returned are not of one single type, but of many:
I put in ???? where I do not know what to do:
MultigetSliceQuery<String, String, ??????> multigetSliceQuery = HFactory.createMultigetSliceQuery(keyspace, stringSerializer, stringSerializer, ???????);
For for example, if all my column-values are of String type, I would put in String. But I have differnt ones like String, Integer, and byte[] in one single row. So I must pass in more then one Serializer.
How to solve this?
Thank you.
(can one pls create hector as tag? I am not allowed to do this)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我们通过模板方法模式提供任意类型。看测试用例:
https://github。 com/rantav/hector/blob/master/core/src/test/java/me/prettyprint/cassandra/service/template/ColumnFamilyTemplateTest.java
新的入门指南也应该很有帮助:
https://github.com/rantav/hector/wiki/Getting-started-% 285分钟%29
We provide arbitrary typing via a template-method pattern. See the test case:
https://github.com/rantav/hector/blob/master/core/src/test/java/me/prettyprint/cassandra/service/template/ColumnFamilyTemplateTest.java
The new getting started guide should be helpful as well:
https://github.com/rantav/hector/wiki/Getting-started-%285-minutes%29
您可以使用 ByteBufferSerializer,然后将从 ByteBufferSerializer 返回的 ByteBuffer 转换为 StringSerializer 和 IntegerSerializer 的参数,以转换字符串和整数列。
You can use the ByteBufferSerializer, and then convert the ByteBuffers returned from ByteBufferSerializer as the argument to StringSerializer and IntegerSerializer to convert the columns which are Strings and Integers.