-
Notifications
You must be signed in to change notification settings - Fork 311
DATACASS-529 - Allow slice queries using reactive repositories. #128
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
Conversation
|
Thanks a lot, we'll take a look as soon as we have time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a few comments to this pull request. Do you want to address these issues from your side or should we take your pull request from here and apply the changes ourselves?
| * @param rowMapper must not be {@literal null}. | ||
| * @return the resulting {@link Slice}. | ||
| */ | ||
| static <T> Mono<Slice<T>> readSlice(ReactiveResultSet resultSet, Integer fetchSize, Function<Row, T> rowMapper) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't introduce dependencies to reactive types here as we want the module to run without reactive dependencies as well.
We also need to be careful about fetching/reading progress. If the fetch size differs from the actual number of rows returned for a page, we might request the next page without intending to do so. I think we need another method on ReactiveResultSet that gives us a Flux without transparent next page fetching.
| * | ||
| * @param statement the CQL statement, must not be {@literal null}. | ||
| * @param entityClass The entity type must not be {@literal null}. | ||
| * @return the result object returned by the action or {@link Mono#empty()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, we're mixing paradigms. We should return an empty Slice (see Page.empty()) as the query terminates without rows and the query result is the container for rows, not the rows themselves.
|
Hi @mp911de, |
|
Cool, thanks for your timely update. We'll take care of this one. |
|
@mp911de do you have any plans when you could handle this? |
|
This pull request needs some polishing before we can merge it. We intend to ship the change with the next release candidate. |
|
So |
|
@mp911de |
|
@lukasz-gosiewski Please file a new ticket in Spring Data Cassandra. We'll see what we can do for you. |
We now support Slice queries using reactive Cassandra repositories. Repository query methods can declare Mono<Slice<T>> as their return type to query for slices without applying transparent paging. The resulting Mono always completes with a value. An empty query result returns a Mono emitting an empty Slice.
interface UserRepository extends CrudRepository<User, String> {
Mono<Slice<User>> findByLastname(String firstname, Pageable pageable);
}
Mono<Slice<User>> result =repository.findByLastname("White", CassandraPageRequest.first(1));
Original pull request: #128.
Introduce ReactiveResultSet.availableRows() to fetch rows without transparent paging. Refactor QueryUtils to extract a Slice from an Iterable. Add slice(Query, Class) to ReactiveCassandraOperations to expose a consistent API. Convert space indentation to tab indentation. Add tests. Add since tags. Add documentation. Reformat code. Original pull request: #128.
|
That's merged and polished now. Thanks a lot! |
Reactive repositories now support methods returning
Mono<Slice<T>>.Related ticket: DATACASS-529.