Reputation: 11
What's an efficient way to go about paginating through a table in Cassandra via asynchronous calls in a web app?
I know that you can pull one more row than the page size and send that value on the client so that they can use it as a starting point for the next call, but that tightly couples Cassandra and the client.
Is there a better practice for this situation?
Upvotes: 1
Views: 770
Reputation: 2166
TL;DR; Yes there is. Use page states.
Take a look here: Results pagination in Cassandra (CQL) and here: http://www.datastax.com/dev/blog/client-side-improvements-in-cassandra-2-0
What is worth explaining, that when using Cassandra 2.0+ autopagination, in response you will get page results + current page state + next page state. Those page states are byte arrays. To get next page you just call as always for results, but you include page state.
Note: page state isn't protected against modification. You probably don't want to expose it for client side, because modification of a page state may return data which shouldn't be accessible for particular user.
Upvotes: 1