Hector:如何查询复合类型的各个部分
我使用 CompositeType
存储数据,如下所示:
RowKey: 101390
=> (column=1320987600000:P:350.0:symbol, value=AAPL/F6LbE.O, timestamp=1320771711561000)
=> (column=1320987600000:P:355.0:symbol, value=AAPL/F6LfE.O, timestamp=1320771711569000)
=> (column=1320987600000:P:360.0:symbol, value=AAPL/F6LjE.O, timestamp=1320771711576000)
=> (column=1320987600000:P:365.0:symbol, value=AAPL/F6LnE.O, timestamp=1320771711586000)
=> (column=1320987600000:P:370.0:symbol, value=AAPL/F6LrE.O, timestamp=1320771711592000)
=> (column=1320987600000:P:460.0:symbol, value=AAPL/F6LzF.O, timestamp=1320771711607000)
=> (column=1320987600000:C:350.0:symbol, value=AAPL/FuLbE.O, timestamp=1320771712117000)
=> (column=1320987600000:C:355.0:symbol, value=AAPL/FuLfE.O, timestamp=1320771712120000)
=> (column=1320987600000:C:360.0:symbol, value=AAPL/FuLjE.O, timestamp=1320771712123000)
=> (column=1320987600000:C:365.0:symbol, value=AAPL/FuLnE.O, timestamp=1320771712128000)
复合材料有四个部分:[时间戳:类型:价格:attribute_name]
是否可以使用 查询 1、2 或所有组件部分>SliceQuery
?
- 例如我想从时间戳 T1 查询 --> T2(工作正常)
- 还需要说时间戳 T1 --> T2 且类型 =“C”且仅“C”
- 时间戳 T1 --> T2,类型=“C”并且价格=“365.0”
是否可以以这种方式查询复合材料的各个部分?到目前为止,在我的测试中,我还无法对复合材料进行比较,就好像它只是长字节数组一样,而不是单个组件。
I have data stored using CompositeType
that looks like the following:
RowKey: 101390
=> (column=1320987600000:P:350.0:symbol, value=AAPL/F6LbE.O, timestamp=1320771711561000)
=> (column=1320987600000:P:355.0:symbol, value=AAPL/F6LfE.O, timestamp=1320771711569000)
=> (column=1320987600000:P:360.0:symbol, value=AAPL/F6LjE.O, timestamp=1320771711576000)
=> (column=1320987600000:P:365.0:symbol, value=AAPL/F6LnE.O, timestamp=1320771711586000)
=> (column=1320987600000:P:370.0:symbol, value=AAPL/F6LrE.O, timestamp=1320771711592000)
=> (column=1320987600000:P:460.0:symbol, value=AAPL/F6LzF.O, timestamp=1320771711607000)
=> (column=1320987600000:C:350.0:symbol, value=AAPL/FuLbE.O, timestamp=1320771712117000)
=> (column=1320987600000:C:355.0:symbol, value=AAPL/FuLfE.O, timestamp=1320771712120000)
=> (column=1320987600000:C:360.0:symbol, value=AAPL/FuLjE.O, timestamp=1320771712123000)
=> (column=1320987600000:C:365.0:symbol, value=AAPL/FuLnE.O, timestamp=1320771712128000)
The composite has four parts : [ timestamp : type : price : attribute_name]
Is it possible to query for 1, 2 or all components parts using SliceQuery
?
- For instance I want to query from timestamp T1 --> T2 (that works fine)
- Also need to say timestamp T1 --> T2 and Type = "C" and only "C"
- Timestamp T1 --> T2, Type = "C" AND price = "365.0"
Is it possible to query parts of the composite in this fashion? In my testing so far I have not been able to and the composite appears to be compared as if it is only long byte array -- instead of the individual components.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
来自 ML 的回答:
这是一个半起步的例子。应该有
评论中的内容足以让您继续前进:
https://github .com/zznate/cassandra-tutorial/blob/master/src/main/java/com/datastax/tutorial/StaticCompositeIndex.java
让我知道是否有帮助。
From ML answer:
Here is an example of such that is sort of half-started. There should
be enough here in the comments to get you going:
https://github.com/zznate/cassandra-tutorial/blob/master/src/main/java/com/datastax/tutorial/StaticCompositeIndex.java
Let me know if that helps.
是的,您可以搜索组合的各个部分。如果您使用的是 Cassandra 0.8.1 及更高版本,则需要在架构中将比较器指定为“CompositeType”。以下是使用 CompositeType 进行范围查询编程的完整教程:
http://randomizedsort.blogspot.com/2011/11/cassandra -range-query-using.html
Yes, you can search parts of a composite. If you are using Cassandra 0.8.1 and above, you need to specify the comparator to be "CompositeType" in your schema. Here is a complete tutorial on programming range query using CompositeType:
http://randomizedsort.blogspot.com/2011/11/cassandra-range-query-using.html