-
Notifications
You must be signed in to change notification settings - Fork 192
Scope and collection API for template. #1133
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
…name. Queries on field annotated properties have original name. They should use getFieldName() which will use the annotated if it exists.
a11a3ff
to
bb8e690
Compare
bb8e690
to
46072dc
Compare
if (cmc.isAutoIndexCreation()) { | ||
indexCreator = new CouchbasePersistentEntityIndexCreator(cmc, 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.
just formatting changes
* | ||
* @author Christoph Strobl | ||
* @since 2.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.
I'm just adding javadoc that was missing. As near as I can figure, the original author was Christoph
return new ExecutableFindByQuerySupport<T>(template, domainType, domainType, ALL_QUERY, | ||
QueryScanConsistency.NOT_BOUNDED, null, null); | ||
return new ExecutableFindByQuerySupport<T>(template, domainType, domainType, ALL_QUERY, null, null, null, null, | ||
null); |
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.
replace the default QueryScanConsistency.NOT_BOUNDED with null.
If it is not null, it will override the scanConsistency on the QueryOptions, if provided.
.getCollection(pArgs.getCollection()).reactive() | ||
.replace(converted.getId(), converted.export(), buildReplaceOptions(pArgs.getOptions(), object, converted)) | ||
.flatMap(result -> support.applyUpdatedId(object, converted.getId()) | ||
.flatMap(replacedObject -> (Mono<T>) support.applyUpdatedCas(replacedObject, result.cas()))) |
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 cast to Mono is necessary here because support (ReactiveTemplateSupport) is not parameterized with the entity type, the method just returns an Object. One day I will fix that.
.append('`').toString(); | ||
} | ||
} | ||
} |
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 don't know why this appears after rebasing. It should have already been in master (?????)
@@ -72,7 +76,7 @@ void shouldSaveAndFindAll() { | |||
Airport vie = null; | |||
Airport jfk = null; | |||
try { | |||
vie = new Airport("airports::vie", "vie", "loww"); | |||
vie = new Airport("airports::vie", "vie", "low1"); |
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.
After running tests, I found some "vie", "loww" Airport records. So I made them unique to figure out what test was creating them and not deleting them.
@@ -59,7 +59,7 @@ ClusterType type() { | |||
|
|||
@Override | |||
TestClusterConfig _start() throws Exception { | |||
bucketname = UUID.randomUUID().toString(); | |||
bucketname = "my_bucket"; // UUID.randomUUID().toString(); |
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.
Reuse "my_bucket" if it already exists. Creating the indexes, scopes and collections takes 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.
if you do that, you also remove the natural isolation of each test, since indexes and/or data might be left behind or still on there. If you take that into account it is fine, just wanted to mention 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.
There are some tests that don't delete everything they've inserted. So I will remove this change from the changeset and leave it for later when I have had time to verify that all the tests clean up after themselves.
Closes #1131. Original pull request: #1135. Co-authored-by: mikereiche <[email protected]>
Closes #1130. Co-authored-by: mikereiche <[email protected]>
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 change looks veeery solid already, most of my comments are nits and small changes -- should be able to merge afterwards
pom.xml
Outdated
@@ -173,6 +173,7 @@ | |||
<dependency> | |||
<groupId>io.projectreactor</groupId> | |||
<artifactId>reactor-test</artifactId> | |||
<version>3.1.0.RELEASE</version> |
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.
latest one is 3.4.6, might cause issues with testing when using such an old version?
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.
Updated to 3.4.6. Seems ok.
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.
changed one instance and removed the other (duplicate).
/** | ||
* {@inheritDoc} | ||
*/ | ||
public void setThreadLocalArgs(PseudoArgs pseudoArgs) { |
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.
since this is something internal, can it 1) be package private or 2) if not, add a comment that it is internal?
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.
Changed to package private.
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.
Unused. Removed.
import com.couchbase.client.java.kv.ReplicateTo; | ||
|
||
/** | ||
* Insert Operations |
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.
copy paste error ?
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.
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. For real, this time.
I'm not sure what happened to the things that are marked "fixed". Either I just marked them "fixed" without actually fixing them, or a pull/rebase un-fixed them.
/** | ||
* @param pseudoArgs - the metaArgs to set on the ThreadLocal field of the CouchbaseOperations | ||
*/ | ||
void setThreadLocalArgs(PseudoArgs<?> pseudoArgs); |
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 wonder if this should also be named getPseudoArgs and setPseudoArgs? the thread local would be an implementation detail
void setThreadLocalArgs(PseudoArgs<?> pseudoArgs); | ||
|
||
/** | ||
* @@return the metaArgs from the ThreadLocal field of the CouchbaseOperations |
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.
two @
* | ||
* @author Michael Reiche | ||
* @param <T> - the entity class | ||
*/ | ||
public interface WithCollection<T> { | ||
Object inCollection(String collectionName); | ||
public interface InScope<T> { |
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 T unused?
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.
Yes, it's not used. Ideally, the methods in all these With* interfaces would return a parameterized interface as in the Override and implementation. However, there is no common interface for all the different operations. So I just define it to return Object, and T is not used. I would like to leave the parameter there, in hopes that I eventually figure out how to define it properly.
interface FindByQueryInScope<T> extends FindByQueryInCollection<T>, InScope<T> {
/**
* With a different scope
*
* @param scope the scope to use.
*/
@Override
FindByQueryInCollection<T> inScope(String scope);
}
@@ -18,11 +18,16 @@ | |||
import com.couchbase.client.java.analytics.AnalyticsScanConsistency; | |||
|
|||
/** | |||
* A common interface for all of Insert, Replace, Upsert that take consistency | |||
* Interface for operations that take AnalyticsScanConsistency | |||
* | |||
* @author Michael Reiche | |||
* @param <T> - the entity class | |||
*/ | |||
public interface WithAnalyticsConsistency<T> { |
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.
unused T?
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.
Yes, it's not used. Ideally, the methods in all these With* interfaces would return a parameterized interface as in the Override and implementation. However, there is no common interface for all the different operations. So I just define it to return Object, and T is not used. I would like to leave the parameter there, in hopes that I eventually figure out how to define it properly.
* @author Michael Reiche | ||
* @param <T> - the entity class | ||
*/ | ||
public interface WithAnalyticsOptions<T> { |
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.
unused T ?
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.
Yes it's unused. But inCollection() should return an operation, and I was hoping to figure out how to achieve that eventually.
Object inCollection(String collection);
@@ -18,11 +18,16 @@ | |||
import org.springframework.data.couchbase.core.query.AnalyticsQuery; | |||
|
|||
/** | |||
* A common interface for all of Insert, Replace, Upsert that take Query | |||
* Interface for operations that take AnalyticsQuery | |||
* | |||
* @author Michael Reiche | |||
* @param <T> - the entity class | |||
*/ | |||
public interface WithAnalyticsQuery<T> { |
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'll stop with the T unused comment, please look through the others if valid too.
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.
Yes, it's not used. Ideally, the methods in all these With* interfaces would return a parameterized interface as in the Override and implementation. However, there is no common interface for all the different operations. So I just define it to return Object, and T is not used. I would like to leave the parameter there, in hopes that I eventually figure out how to define it properly.
@@ -86,7 +87,8 @@ protected Object doExecute(CouchbaseQueryMethod method, ResultProcessor processo | |||
ExecutableFindByQuery<?> find = typeToRead == null ? findOperationWithProjection // | |||
: findOperationWithProjection; // not yet implemented in core .as(typeToRead); | |||
|
|||
String collection = "_default._default";// method.getEntityInformation().getCollectionName(); // not yet implemented | |||
// TODO (maybe) // method.getEntityInformation().getCollectionName(); // not yet implemented |
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 a ticket be filed for 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.
This is irrelevant now. This _default._default is ignored.
…name. Queries on field annotated properties have original name. They should use getFieldName() which will use the annotated if it exists.
…com:spring-projects/spring-data-couchbase into datacouch_963_scope_and_collection_api_main
…com:spring-projects/spring-data-couchbase into datacouch_963_scope_and_collection_api_main
…com:spring-projects/spring-data-couchbase into datacouch_963_scope_and_collection_api_main
pom.xml
Outdated
@@ -173,6 +173,7 @@ | |||
<dependency> | |||
<groupId>io.projectreactor</groupId> | |||
<artifactId>reactor-test</artifactId> | |||
<version>3.1.0.RELEASE</version> |
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.
changed one instance and removed the other (duplicate).
pom.xml
Outdated
<source>8</source> | ||
<target>8</target> | ||
</configuration> | ||
</plugin> |
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. Shouldn't need this.
/** | ||
* {@inheritDoc} | ||
*/ | ||
public void setThreadLocalArgs(PseudoArgs pseudoArgs) { |
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.
Unused. Removed.
return new ExecutableFindByQuerySupport<>(template, domainType, returnType, query, scanConsistency, collection, | ||
distinctFields); | ||
return new ExecutableFindByQuerySupport<>(template, domainType, returnType, query, scanConsistency, scope, | ||
collection, options, distinctFields); | ||
} | ||
|
||
@Override |
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.
InCollection (below) got moved to the end. It is not missing.
import com.couchbase.client.java.kv.ReplicateTo; | ||
|
||
/** | ||
* Insert Operations |
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. For real, this time.
I'm not sure what happened to the things that are marked "fixed". Either I just marked them "fixed" without actually fixing them, or a pull/rebase un-fixed them.
|
||
/** | ||
* Insert Operations |
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.
@@ -31,4 +31,6 @@ | |||
* The field name can be different from the actual property name by using a custom annotation. | |||
*/ | |||
String getFieldName(); | |||
|
|||
Boolean isExpirationProperty(); |
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.
Changed to unboxed boolean.
But leaving as "is..." to be consistent with isIdProperty() and isVersionProperty() from PersistentProperty.
boolean isIdProperty();
boolean isVersionProperty();
@Documented | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ ElementType.FIELD, ElementType.ANNOTATION_TYPE }) | ||
public @interface Expiration { |
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 represents META().expiration so I named it Expiration. Did you still want it renamed? I could go either way.
* @author Michael Reiche | ||
* @param <T> - the entity class | ||
*/ | ||
public interface InCollection<T> { |
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.
Yes it's unused. But inCollection() should return an operation, and I was hoping to figure out how to achieve that eventually.
Object inCollection(String collection);
* @author Michael Reiche | ||
* @param <T> - the entity class | ||
*/ | ||
public interface WithAnalyticsOptions<T> { |
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.
Yes it's unused. But inCollection() should return an operation, and I was hoping to figure out how to achieve that eventually.
Object inCollection(String collection);
…com:spring-projects/spring-data-couchbase into datacouch_963_scope_and_collection_api_main
…com:spring-projects/spring-data-couchbase into datacouch_963_scope_and_collection_api_main
…com:spring-projects/spring-data-couchbase into datacouch_963_scope_and_collection_api_main
…com:spring-projects/spring-data-couchbase into datacouch_963_scope_and_collection_api_main
Scope and collection API for template.
Closes #963.
Original pull request: #1071.