Skip to content

Support selecting and counting in parallel in SimpleCouchbaseRepository#findAll(Pageable pageable) #1061

Open
@aaronjwhiteside

Description

@aaronjwhiteside

We use something like this in our custom base repository:

final Mono<Long> totalCount = getReactiveCouchbaseOperations().findByQuery(getEntityInformation().getJavaType())
                    .withConsistency(buildQueryScanConsistency())
                    .matching(new Query().with(pageable))
                    .count();

final Mono<List<T>> pageContents = getReactiveCouchbaseOperations().findByQuery(getEntityInformation().getJavaType())
                    .withConsistency(buildQueryScanConsistency())
                    .matching(new Query().with(pageable))
                    .all()
                    .collectList();

// zip the two queries together to return the requested Page
return Mono.zip(pageContents, totalCount, (list, count) -> new PageImpl<T>(list, pageable, count))
                    .block();

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions