forked from spring-attic/spring-data-aerospike
-
Notifications
You must be signed in to change notification settings - Fork 29
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
FMWK-199 Refactor implementation of paginated queries #658
Merged
Merged
Changes from 12 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ce93b21
add queryMaxRecords configuration parameter to limit query results qu…
agrgr 53cfc40
refactor paginated query processing
agrgr 6ff3802
add support for paginated queries for reactive flow
agrgr 5d34e37
cleanup
agrgr 52eb141
cleanup
agrgr f6ad97c
Merge branch 'main' into FMWK-199-refactor-paginated-queries
agrgr 6328dd2
cleanup
agrgr 2e80823
configure paginated queries processing, add support for Pageable.unpa…
agrgr e9c4409
cleanup
agrgr 35595d0
code format
agrgr 160e517
add support for Pageable.unpaged() for both sync and reactive flows
agrgr 1aaad1d
cleanup
agrgr 78adfb4
rephrase
agrgr afa5f62
cleanup
agrgr cf424a4
cleanup
agrgr 660af78
code format, update Javadoc
agrgr ccc0f25
code format
agrgr ba5178f
code format, remove unused parameters
agrgr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -974,14 +974,23 @@ public Mono<Long> count(Query query, String setName) { | |
Assert.notNull(query, "Query must not be null!"); | ||
Assert.notNull(setName, "Set for count must not be null!"); | ||
|
||
return findRecordsUsingQuery(setName, query).count(); | ||
return countRecordsUsingQuery(setName, query).count(); | ||
} | ||
|
||
private Flux<KeyRecord> findRecordsUsingQuery(String setName, Query query) { | ||
private Flux<KeyRecord> countRecordsUsingQuery(String setName, Query query) { | ||
Assert.notNull(query, "Query must not be null!"); | ||
Assert.notNull(setName, "Set name must not be null!"); | ||
|
||
return findRecordsUsingQuery(setName, null, query); | ||
Qualifier qualifier = queryCriteriaIsNotNull(query) ? query.getQualifier() : null; | ||
if (qualifier != null) { | ||
Qualifier idQualifier = getOneIdQualifier(qualifier); | ||
if (idQualifier != null) { | ||
// a special flow if there is id given | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same |
||
return findByIdsWithoutMapping(getIdValue(idQualifier), setName, null, | ||
new Query(excludeIdQualifier(qualifier))); | ||
} | ||
} | ||
return this.reactorQueryEngine.selectForCount(this.namespace, setName, query); | ||
} | ||
|
||
@Override | ||
|
@@ -1094,6 +1103,11 @@ public IAerospikeReactorClient getAerospikeReactorClient() { | |
return reactorClient; | ||
} | ||
|
||
@Override | ||
public long getQueryMaxRecords() { | ||
return reactorQueryEngine.getQueryMaxRecords(); | ||
} | ||
|
||
private <T> Mono<T> doPersistAndHandleError(T document, AerospikeWriteData data, WritePolicy policy, | ||
Operation[] operations) { | ||
return reactorClient | ||
|
@@ -1177,6 +1191,13 @@ private <T> Flux<T> findUsingQueryWithPostProcessing(String setName, Class<T> ta | |
return results; | ||
} | ||
|
||
@Override | ||
public <T, S> Flux<S> findUsingQueryWithoutPostProcessing(Class<T> entityClass, Class<S> targetClass, Query query) { | ||
verifyUnsortedWithOffset(query.getSort(), query.getOffset()); | ||
return findUsingQueryWithDistinctPredicate(getSetName(entityClass), targetClass, | ||
getDistinctPredicate(query), query); | ||
} | ||
|
||
private void verifyUnsortedWithOffset(Sort sort, long offset) { | ||
if ((sort == null || sort.isUnsorted()) | ||
&& offset > 0) { | ||
|
@@ -1229,7 +1250,7 @@ private <T> Flux<T> findUsingQueryWithDistinctPredicate(String setName, Class<T> | |
} | ||
|
||
private <T> Flux<KeyRecord> findRecordsUsingQuery(String setName, Class<T> targetClass, Query query) { | ||
Qualifier qualifier = queryCriteriaIsNotNull(query) ? query.getCriteria().getCriteriaObject() : null; | ||
Qualifier qualifier = queryCriteriaIsNotNull(query) ? query.getQualifier() : null; | ||
if (qualifier != null) { | ||
Qualifier idQualifier = getOneIdQualifier(qualifier); | ||
if (idQualifier != null) { | ||
|
@@ -1243,7 +1264,7 @@ private <T> Flux<KeyRecord> findRecordsUsingQuery(String setName, Class<T> targe | |
String[] binNames = getBinNamesFromTargetClass(targetClass); | ||
return this.reactorQueryEngine.select(this.namespace, setName, binNames, query); | ||
} else { | ||
return this.reactorQueryEngine.select(this.namespace, setName, query); | ||
return this.reactorQueryEngine.select(this.namespace, setName, null, query); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Sounds grammatically wrong, maybe:
// Dedicate flow when id is given
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.
Agree, updated to a similar phrase