-
Notifications
You must be signed in to change notification settings - Fork 192
DATACOUCH-588 - Refactoring part 1 of n. #278
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
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.
Couple remarks. Also note that there are many "not yet implement" comments in the code - I'm okay with these as long as they are not degrading functionality we had before. If so, we should probably work on this in a feature branch until we are back to feature parity with the stable code, so we don't break folks.
@@ -39,6 +42,7 @@ | |||
Iterable<Airport> findAll(); | |||
|
|||
@Override | |||
@ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS) | |||
Airport save(Airport airport); |
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.
isn't that a KV method which does not need the scan consistency?
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.
fixed
List<Airport> airports = airportRepository.findAllByIata("vie"); | ||
assertEquals(vie.getId(), airports.get(0).getId()); | ||
assertEquals(1, airports.size()); | ||
System.out.println("findAllByIata(0): " + airports.get(0)); |
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.
are these printlns leftovers from debugging in the tests?
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.
removed
vie = airportRepository.save(vie).block(); | ||
List<Airport> airports = airportRepository.findAllByIata("vie").collectList().block(); | ||
assertEquals(1, airports.size()); | ||
System.out.println("findAllByIata(0): " + airports.get(0)); |
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.
looks like some debugging leftovers - I'd recommend to remove all those prints from tests since they make them very noisy in logfiles
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.
removed
PageRequest pageable = PageRequest.of(page++, 2); | ||
System.out.println("findAllByIataLike: " + "%S"); | ||
// java.lang.IndexOutOfBoundsException: Source emitted more than one item | ||
// Flux<Airport> airportFlux = airportRepository.findAllByIataLike("S%"); |
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.
can this be removed or does this needs to be handled?
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 changed this to actually use the paging. Removed the commented-out lines and added assertions.
@@ -124,6 +143,23 @@ void count() { | |||
airportRepository.save(airport).block(); | |||
} | |||
|
|||
int page = 0; | |||
for (; page < 10;) { |
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.
a while(page < 10) is probably better here
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've flattened out the loop to better verify the results.
* @author Michael Reiche | ||
* @since 4.1 | ||
*/ | ||
public class ReactivePartTreeCouchbaseQuery extends AbstractReactiveCouchbaseQuery { |
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.
Same comment as with the string equivalent, is there a common base class for reactive and non-reactive that encapsulates the commonalities maybe?
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.
It seems there should be a way to make this tidier, but it eludes me.
* @return is this a 'delete'? | ||
*/ | ||
public boolean isDeleteQuery() { | ||
return getName().toLowerCase().startsWith("delete"); |
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.
should we use Locale.ROOT in the toLowerCase?
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.
done on exists, delete and count. Mark suggested an annotation. I will (eventually) see what mongo does.
* @return is this an 'exists' query? | ||
*/ | ||
public boolean isExistsQuery() { | ||
return getName().toLowerCase().startsWith("exists"); |
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.
should we use Locale.ROOT in the toLowerCase?
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.
done
*/ | ||
@Override | ||
public Object execute(Query query, Class<?> type, String collection) { | ||
return operations.removeByQuery(type)/*.inCollection(collection)*/.matching(query).all(); |
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.
does the collection string needs to be handled?
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.
The do eventually. The support of an inCollection(collection) was one of the things I backed out to keep the (initial) changes to a minium.
*/ | ||
@Override | ||
public Object execute(Query query, Class<?> type, String collection) { | ||
return operations.removeByQuery(type).matching(query).all(); |
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.
the collection string here is not handled at all - should we fail explicitly if it is present or even better handle it?
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.
As above - we are going to handle it, but I wanted to keep that out of the initial branch.
e6ee57b
to
0a72b4c
Compare
pom.xml
Outdated
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>9</source> |
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 are targeting java 8, not 9 right?
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.
Also, I would think this is part of the parent pom?
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 vaguely recall adding this when prompted by intellij to facilate some .of(...) call. Will check
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.
removed. It was for Set.of(...) in a test.
* @author Christoph Strobl | ||
* @since 1.10 | ||
*/ | ||
public enum CursorOption { |
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 do not have cursors, does this apply at all to the impl?
* @return {@literal 0 (zero)} by default. | ||
* @since 2.1 | ||
*/ | ||
int cursorBatchSize() default 0; |
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.
there are many references to cursors, comments etc which are all very mongo-ish but do not apply to couchbase
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 removed cursor, comment etc. I left maxExecutionTimeMs just so Meta isn't empty.
} | ||
|
||
if (meta.cursorBatchSize() != 0) { | ||
metaAttributes.setCursorBatchSize(meta.cursorBatchSize()); |
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.
does not apply? (see other comments)
0a72b4c
to
dfd7202
Compare
public class Meta { | ||
|
||
private enum MetaKey { | ||
MAX_TIME_MS("$maxTimeMS"), MAX_SCAN("$maxScan"), COMMENT("$comment"), SNAPSHOT("$snapshot"); |
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.
this stuff is mongo related, right? why do we keep this?
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 missed this when I cleaned out the Meta annotation. I've removed all the mongo-specific elements, I've left just an EXAMPLE in the enum because it can't be empty. I've also remove the mongo maxTimeMs from the Meta annotation.
dfd7202
to
b208391
Compare
This implements pageable for non-reactive queries and realigns reactive queries with other spring-data projects to facilitate the implementaion of pageable (done) and other types of queries such as projection and distinct (not yet done)
This implements pageable for non-reactive queries and realigns reactive queries with other spring-data projects to facilitate the implementaion of pageable (done) and other types of queries such as projection and distinct (not yet done)
e1acbbb
to
fce318c
Compare
fce318c
to
d9774a3
Compare
* DATACOUCH-588 - Implement pageable and realign repo query This implements pageable for non-reactive queries and realigns reactive queries with other spring-data projects to facilitate the implementaion of pageable (done) and other types of queries such as projection and distinct (not yet done) * DATACOUCH-588 - Implement pageable and realign repo query This implements pageable for non-reactive queries and realigns reactive queries with other spring-data projects to facilitate the implementaion of pageable (done) and other types of queries such as projection and distinct (not yet done) * DATACOUCH-588 - Refactoring part 1 of n. Co-authored-by: mikereiche <[email protected]>
* DATACOUCH-588 - Implement pageable and realign repo query This implements pageable for non-reactive queries and realigns reactive queries with other spring-data projects to facilitate the implementaion of pageable (done) and other types of queries such as projection and distinct (not yet done) * DATACOUCH-588 - Implement pageable and realign repo query This implements pageable for non-reactive queries and realigns reactive queries with other spring-data projects to facilitate the implementaion of pageable (done) and other types of queries such as projection and distinct (not yet done) * DATACOUCH-588 - Refactoring part 1 of n. Co-authored-by: mikereiche <[email protected]>
This is part 1 of a multi-part refactoring effort.
The files below are the non-test files involved. The classes marked new and old are exactly that, and the files marked 'replace' are replacements for similar classes. To understand the changes, start with the resolveQuery() of the two repository factory classes, the *PartTeeCouchbaseQuery and StringBasedCouchbaseQuery that they created, then their execute() method ( AbstractCouchbaseQueryBase.execute() ) which calls the AbstractCouchbaseQuery.doExecute(), which creates a *CouchbaseQueryExecution and executes it.
org/springframework/data/couchbase/repository/query/AbstractCouchbaseQuery.java new
org/springframework/data/couchbase/repository/query/AbstractCouchbaseQueryBase.java new
org/springframework/data/couchbase/repository/query/AbstractReactiveCouchbaseQuery.java new
org/springframework/data/couchbase/repository/query/CouchbaseQueryExecution.java new
org/springframework/data/couchbase/repository/query/CouchbaseQueryMethod.java old
org/springframework/data/couchbase/repository/query/DtoInstantiatingConverter.java new
org/springframework/data/couchbase/repository/query/PartTreeCouchbaseQuery.java replace
org/springframework/data/couchbase/repository/query/ReactiveCouchbaseQueryExecution.java new
org/springframework/data/couchbase/repository/query/ReactiveCouchbaseQueryMethod.java new
org/springframework/data/couchbase/repository/query/ReactivePartTreeCouchbaseQuery.java replace
org/springframework/data/couchbase/repository/query/ReactiveStringBasedCouchbaseQuery.java replace
org/springframework/data/couchbase/repository/query/ResultProcessingConverter.java new
org/springframework/data/couchbase/repository/query/StringBasedCouchbaseQuery.java replace
org/springframework/data/couchbase/repository/query/StringN1qlQueryCreator.java old
org/springframework/data/couchbase/repository/support/CouchbaseRepositoryFactory.java old
org/springframework/data/couchbase/repository/support/ReactiveCouchbaseRepositoryFactory.java old