如何使用Cassandra Java驱动程序(版本3.6)在Cassandra访问器接口中传递分页状态? [英] How to pass Paging state in Cassandra accessor interface using cassandra java driver (version 3.6)?

查看:57
本文介绍了如何使用Cassandra Java驱动程序(版本3.6)在Cassandra访问器接口中传递分页状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一项要求,允许在cassandra访问器结果中进行分页.我们具有@Accessor批注的接口,带有@Query批注的方法签名,这些签名返回Result.在@QueryParameters批注中可以为查询传递页面大小的选项,但是如果对查询结果进行分页,则无法传递页面状态来获取下一组记录.如何在不更改访问器接口的返回类型的情况下实现这一目标?

We have a requirement to allow pagination in cassandra accessor results. We have @Accessor annotated interface with @Query annotated method signatures that returns Result. There is an option to pass page size for the query in @QueryParameters annotation but there is no way to pass page state for fetching next set of records if the query results are paginated. How do I achieve this without changing the return types of my accessor interface?

我已经尝试过在此提到的解决方案:

I have tried the solution mentioned in this:

Cassandra Datastax驱动程序在访问器上设置分页状态

但这需要我更改访问器方法以返回Statement对象而不是Result,这是不可接受的.

But this would require me to change my accessor methods to return Statement object instead of Result, and that is not acceptable.

有更好的方法吗?

请注意,我们没有使用Spring框架(不幸的是!)

Please note that we are not using Spring framework (Unfortunately!)

推荐答案

将访问器与 setPagingState 结合使用是最稳定的解决方案,它将使您具有相同的行为和性能.查询,而不管表的大小如何,因为它将一次处理固定数量的记录.

The use of the accessor combined with setPagingState is the most stable solution that will allow you to have the same behaviour and performance of the query, regardless the size of the table, as it will handle with a fixed amount of records at a time.

这篇关于如何使用Cassandra Java驱动程序(版本3.6)在Cassandra访问器接口中传递分页状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆