During my research I have come across this JIRA for Spring-Data-Cassandra: https://jira.spring.io/browse/DATACASS-56
Now, according to the post above, currently SDC is not supporting Pagination in the Spring App due to structure of Cassandra. However, I'm thinking, if I can pull the entire rows list into a Java List, can I Paginate that list ? I don't have much experience in Spring, but is there something I am missing when I assume this can be done ?
Cassandra does not support pagination in the sense of pointing to a specific page (limit/offset) but generates a continuation token (
PagingState) that is a set ofbytes. Pulling aListof records will load all records in memory and possibly exhaust your memory (depending on the amount of data).Spring Data Cassandra 1.5.0 RC1 comes with a streaming API in CassandraTemplate:
CassandraTemplate.stream(…)will return anIteratorthat operates on an underlyingResultSet. The DataStax driver uses a configurable fetch-size (5000rows by default) for bulk fetching. Streaming data access can fetch as much or as little data as you require to process data. Data is not retained by the driver nor Spring Data Cassandra, and once the fetched bulk is retrieved from theIterator, the underlyingResultSetwill fetch the next bulk itself.The other alternative is using
ResultSetdirectly that gives you access toPagingStateand do all the continuation/paging business yourself. You would lose all the higher level benefits of Spring Data Cassandra.