简体   繁体   English

分区内的Cassandra分页

[英]Cassandra pagination inside partition

How can I paginate data inside partition? 如何在分区内分页数据? I can`t use token for this, so I made microtime field with creation time and ordered records by it. 我不能为此使用令牌,所以我用创建时间创建了微时间字段,并以此来排序记录。 Now I am slicing data using '<' and '>' and it makes a lot of constraints for my queries. 现在,我使用'<'和'>'对数据进行切片,这对我的查询造成了很多限制。 Is there better way to do this? 有更好的方法吗?

For forward pagination, most of drivers (I definitely know about Java & Node.js) have notion of paging . 对于前向分页,大多数驱动程序(我肯定对Java和Node.js都了解)具有分页的概念。 You're basically execute your query, but set fetch size to value of number of entries that you want to have on page. 您基本上是在执行查询,但是将访存大小设置为要在页面上具有的条目数的值。 You can grab current "paging state" and set it into cookier, or hidden form parameter of the page, and restore it when user clicks on "next" button, so you can retrieve next page. 您可以获取当前的“分页状态”并将其设置为cookier或页面的隐藏表单参数,并在用户单击“下一页”按钮时将其恢复,以便检索下一页。

Backward paging is more tricky, but is also doable - basically, you need to store somewhere the value of the clustering key(s) for first record that you output on previous page, and then execute query like select * from table where partition_key = value and clustering_column > value . 向后分页比较棘手,但也可行-基本上,您需要将聚簇键的值存储在上一页中输出的第一条记录的某个位置,然后执行查询,例如select * from table where partition_key = value and clustering_column > value

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM