分区内的Cassandra分页

编程入门 行业动态 更新时间:2024-10-27 02:19:03
本文介绍了分区内的Cassandra分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何对分区内的数据进行分页?我不能为此使用令牌,所以我用创建时间创建了微时间字段并通过它对记录进行了排序.现在,我使用'<'分割数据和>",这对我的查询有很多限制.有更好的方法吗?

解决方案

对于前向分页,大多数驱动程序(我对Java& Node.js绝对了解)都具有分页.您基本上是在执行查询,但是将访存大小设置为您要在页面上拥有的条目数的值.您可以获取当前的分页状态" ,并将其设置为cookier(或页面的隐藏表单参数),并在用户单击下一步"按钮时将其还原,以便您可以检索下一页.

向后分页比较棘手,但也可行-基本上,您需要将聚簇键的值存储在上一页中输出的第一条记录的某个位置,然后执行类似select * from table where partition_key = value and clustering_column > value的查询. /p>

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. 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.

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.

更多推荐

分区内的Cassandra分页

本文发布于:2023-11-22 09:10:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1616823.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:分页   区内   Cassandra

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!