分页基于卡桑德拉Web应用程序(pagination in cassandra based web

2019-10-18 00:52发布

我该怎么办基于卡桑德拉Web应用程序分页。 我使用Spring MVC的服务器端和jQuery在客户端。 我试过这个 ,但没有sutisfied。

我行密钥UUIDType和每一个我发送开始键作为字符串从客户端浏览器,以便不知道如何将它转换回UUID时间。 一个简单的例子将被appriciated。

Answer 1:

Spring的数据具有此功能前推出:

http://static.springsource.org/spring-data/data-jpa/docs/current/reference/html/repositories.html#web-pagination



Answer 2:

如果您使用PlayOrm的卡桑德拉它返回时,查询光标和第一页的前20个结果中读取并显示它,下一个页面可以只使用相同的光标在你的会话,它拿起右边离开的地方,而不再次重新扫描前20行。

院长



Answer 3:

我会建议通用解决方案,不得以任何语言进行工作。 我用蟒蛇pycassa工作了这一点:

第一种方法:

-Say if column_count = 10 (How many results to display on front end) 
-collect first 11 rows, sort first 10, send it to user (front end) as JSON object and also parameter last=11th_column
-User then calls for page 2, with prev = 1st_column_id, column_start=11th_column and column_count = 10. Based on this, I query cassandra like cf.get('cf', key, column_start=11th_column, column_count=10)
-This way, I can traverse, next page and previous page.
-Only issue with this approach is, I don't have all columns in super column sorted. So this did not work.

第二条本办法(我在生产中使用):

-fetch all super columns and columns for a row key. e.g in python pycassa, cf.get('cf',key)
-Sort this in python using sorted and lambda function based on column values.
-Once sorted, prepare buckets and each bucked size is of page size/column count. Also filter out any rogue data if needed before bucketing.
-Store page by page results in Redis with keys such as 'row_key|page_1|super_column' and keep refreshing redis periodically.

我的第二个方法的工作相当不错的数据的小型/中型量。



文章来源: pagination in cassandra based web application