RandomPartitioner 下 Cassandra 中的二级索引
我正在研究使用 Aquiles 在 Cassandra 中使用二级索引功能的可能性。我知道对于主索引(键),我必须使用 OrderPreservingPartitioner 才能查询。起初,我认为使用二级索引就没有这样的限制,但我注意到开始键是 GetIndexedSlicesCommand 的一部分。这是否意味着在 RandomPartitioner 下,该命令不可用?
I am researching the possibility of using secondary index feature in Cassandra using Aquiles. I know for the primary index (key), a I must be using OrderPreservingPartitioner in order to query. At first, I thought that with secondary indexes, there is no such limitation, but I noticed that start key is part of GetIndexedSlicesCommand. Does that imply that under RandomPartitioner, this command is unusable?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不需要 OrderPreservingPartitioner 来按行键查询,仅当您想按行键获取有意义的行范围时才需要它,例如“键在 5 到 9 之间的所有行”。 (请注意,几乎总是可以并且应该改用RandomPartitioner.)
get_indexed_slices 的开始键的行为与 get_range_slices 的行为相同。也就是说,在使用 RandomPartitioner 时,对于检查两个键之间的一系列行来说意义不大,但对于分页大量行来说很有用。甚至还有一个关于该主题的常见问题解答条目。基本上,如果您要通过调用 get_indexed_slices 获得大量结果,您不想一次获取所有结果,而是希望获得一个块(10、100 或 1000 个,具体取决于大小)一次,然后将 start_key 设置为您在上一个块中看到的最后一个键以获取下一个块。
You don't need OrderPreservingPartitioner to query by row key, it's only needed if you want to get a meaningful range of rows by their key, like 'all rows with a key between 5 and 9'. (Note that can and should almost always use RandomPartitioner instead.)
The start key for get_indexed_slices behaves the same way that it does for get_range_slices. That is, it's not very meaningful for examining a range of rows between two keys when using RandomPartitioner, but it is useful for paging through a lot of rows. There's even a FAQ entry on the topic. Basically, if you're going to get a ton of results from a call to get_indexed_slices, you don't want to fetch them all at once, you want to get a chunk (of 10, 100, or 1000, depending on size) at a time, and then set the start_key to the last key you saw in the previous chunk to get the next chunk.