-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DATACASS-56 - Cassandra paging support. #114
Conversation
We now allow query option mutation through QueryOptions.mutate() returning an initialized builder. The mutation builder is initialized with the state of the QueryOptions object and allows further customization without changing the previous state of the immutable QueryOptions object. QueryOptions queryOptions = …; QueryOptions mutated = queryOptions.mutate().readTimeout(Duration.ofSeconds(5)).build();
We now support forward-only paging with Cassandra through the Template API and repositories. Results in Cassandra are paged by navigating forward-only through pages described by a binary paging state encapsulated by CassandraPageRequest and accessible via the returned Slice. Spring Data Page's do not fit to Cassandra's paging concept because Cassandra paging is not based on limit/offset. Page requests are applicable to a Query and as parameter of query methods. Query query = Query.empty().pageRequest(CassandraPageRequest.first(10)); Slice<User> slice = template.slice(query, User.class); do { // consume slice if (slice.hasNext()) { slice = template.select(query, slice.nextPageable(), User.class); } else { break; } } while (!slice.getContent().isEmpty()); assertThat(ids).hasSize(100); assertThat(iterations).isEqualTo(10); interface UserRepository implements Repository<User, String> { Slice<User> findAllByName(String name, Pageable pageRequest); }
Align override comments.
Reviewed, polished and merged to |
@mp911de |
Stores can return empty results but it's possible that the paging is not finished yet. In general, please file a ticket or ask questions on StackOverflow as closed pull requests are not a good place for discussions. |
@mp911de How to make it work with reactive repo? Not working with |
Please upgrade to at least 2.1RC1, see DATACASS-529. |
Hi all I have written a code block to use pagination with user action here is my code I hope it helps you well. |
We now support forward-only paging with Cassandra through the Template API and repositories. Results in Cassandra are paged by navigating forward-only through pages described by a binary paging state encapsulated by
CassandraPageRequest
and accessible via the returned Slice. Spring Data Page's do not fit to Cassandra's paging concept because Cassandra paging is not based on limit/offset.Page requests are applicable to a Query and as a parameter of query methods.
Related ticket: DATACASS-56.