-
Notifications
You must be signed in to change notification settings - Fork 67
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
fix: replace usages of transform proto with update_transform #213
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.
We should probably merge this into a feature branch and only merge to master
once this PR and the conformance test update is ready. We need the updated conformance tests to validate these changes thoroughly.
@@ -535,13 +527,11 @@ public boolean allowTransform() { | |||
Mutation mutation = addMutation(); |
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 think we can probably remove the Mutation
type and replace it with the Proto type. What do you think?
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.
Good call. I remember you did this for node and the code became much cleaner. Removed Mutation
and renamed mutation related variables to write
.
|
||
if (mutation.document != null) { | ||
request.addWrites(mutation.document); | ||
mutation.document.setCurrentDocument(mutation.precondition); |
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 we use the Write proto directly instead of Mutation
, we should be able to get rid of this line.
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 using the write proto directly now, but I can't see how to remove this line. Don't we always need to check if the precondition exists before setting it onto the write?
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.
Yep, sorry - I thought this was in "commit()". Looks good.
responseIterator.next(); | ||
} | ||
|
||
mutationIterator.next(); |
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.
Might be simpler now if we just replace it with a for
loop.
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.
Tried it with a for loop, intellij recommended I use while
loop since the local variable in the for loop was redundant.
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.
You should iterator over writeResults
and drop mutationIterator
altogether.
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 changing it to iterate through writeResults
, intellij recommended that it be converted to an "enhanced for loop".
@@ -196,7 +200,10 @@ public void arrayUnionWithPojo() throws ExecutionException, InterruptedException | |||
doc.update("array", FieldValue.arrayUnion(SINGLE_FIELD_OBJECT)).get(); | |||
|
|||
CommitRequest expectedRequest = | |||
commit(transform(UPDATE_PRECONDITION, "array", arrayUnion(SINGLE_FIELD_VALUE))); | |||
commit( |
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.
What do you think of exposing an overload to commit?
public static CommitRequest commit(Write write, List<FieldTransform> transform) {
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. Got rid of writeWithTransform
.
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 should probably merge this into a feature branch and only merge to master once this PR and the conformance test update is ready. We need the updated conformance tests to validate these changes thoroughly.
I detailed the merge steps in the PR description. I talked to Ben about this, and he said that he will help facilitate merging this PR in once the new conformance tests have been added. I've run these against the updated conformance tests locally and they are passing. Merging this into a separate branch might make things easier for him though.
responseIterator.next(); | ||
} | ||
|
||
mutationIterator.next(); |
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.
Tried it with a for loop, intellij recommended I use while
loop since the local variable in the for loop was redundant.
@@ -196,7 +200,10 @@ public void arrayUnionWithPojo() throws ExecutionException, InterruptedException | |||
doc.update("array", FieldValue.arrayUnion(SINGLE_FIELD_OBJECT)).get(); | |||
|
|||
CommitRequest expectedRequest = | |||
commit(transform(UPDATE_PRECONDITION, "array", arrayUnion(SINGLE_FIELD_VALUE))); | |||
commit( |
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. Got rid of writeWithTransform
.
|
||
if (mutation.document != null) { | ||
request.addWrites(mutation.document); | ||
mutation.document.setCurrentDocument(mutation.precondition); |
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 using the write proto directly now, but I can't see how to remove this line. Don't we always need to check if the precondition exists before setting it onto the write?
@@ -535,13 +527,11 @@ public boolean allowTransform() { | |||
Mutation mutation = addMutation(); |
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.
Good call. I remember you did this for node and the code became much cleaner. Removed Mutation
and renamed mutation related variables to write
.
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.
LGTM with one final nit (the while loop)
Thanks for forcing me to read the PR description.
} else if (hasDocumentData || documentTransform.isEmpty()) { | ||
mutation.document = documentSnapshot.toPb(); | ||
mutation.document.setUpdateMask(documentMask.toPb()); | ||
verifyNotCommitted(); |
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 feels out of place now. Move to top of method?
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.
|
||
if (mutation.document != null) { | ||
request.addWrites(mutation.document); | ||
mutation.document.setCurrentDocument(mutation.precondition); |
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.
Yep, sorry - I thought this was in "commit()". Looks good.
responseIterator.next(); | ||
} | ||
|
||
mutationIterator.next(); |
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.
You should iterator over writeResults
and drop mutationIterator
altogether.
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.
LGTM
return (T) this; | ||
} | ||
|
||
/** Adds a new mutation to the batch. */ | ||
private Mutation addMutation() { | ||
/** Adds a new write to the batch. */ |
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.
Incorrect javadoc now that the mutation has been removed.
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 the javadoc since the method is pretty straightforward now.
The release of the conformance tests is available. @thebrianchen Can you bump the dependency like is done in this PR: #218 that should allow your builds to be green. |
Codecov Report
@@ Coverage Diff @@
## master #213 +/- ##
============================================
- Coverage 73.09% 72.94% -0.16%
+ Complexity 1031 1015 -16
============================================
Files 63 63
Lines 5434 5407 -27
Branches 627 617 -10
============================================
- Hits 3972 3944 -28
- Misses 1264 1266 +2
+ Partials 198 197 -1
Continue to review full report at Codecov.
|
Pinged someone to update the branch protection settings to unblock this. |
🤖 I have created a release \*beep\* \*boop\* --- ## [1.34.0](https://www.github.com/googleapis/java-firestore/compare/v1.33.0...v1.34.0) (2020-05-29) ### Features * add support for BigDecimal to CustomClassMapper ([#196](https://www.github.com/googleapis/java-firestore/issues/196)) ([a471f1e](https://www.github.com/googleapis/java-firestore/commit/a471f1eed1e555e95b3d9bcda31ce0277e35a14a)) * Create CODEOWNERS ([#207](https://www.github.com/googleapis/java-firestore/issues/207)) ([cd19eae](https://www.github.com/googleapis/java-firestore/commit/cd19eae68a4898a53c6c3cc8189eab30545a661d)) ### Bug Fixes * add RateLimiter ([#230](https://www.github.com/googleapis/java-firestore/issues/230)) ([47d4a11](https://www.github.com/googleapis/java-firestore/commit/47d4a11625d5888d6f31e494923853a08bb8af77)) * catch null Firestore in system tests ([#215](https://www.github.com/googleapis/java-firestore/issues/215)) ([2a4a7b5](https://www.github.com/googleapis/java-firestore/commit/2a4a7b50d40ff1c165e3d359d5f4eaf929f6ffbc)) * Fields used in whereIn should be equality filters ([#216](https://www.github.com/googleapis/java-firestore/issues/216)) ([4a62633](https://www.github.com/googleapis/java-firestore/commit/4a626333e5af0d70a4dc4853ed373dcf50ea0f4a)) * replace usages of transform proto with update_transform ([#213](https://www.github.com/googleapis/java-firestore/issues/213)) ([46a3c51](https://www.github.com/googleapis/java-firestore/commit/46a3c51386b57f20bd65c564e93181e9ce399e2b)) * support array of references for IN queries ([#211](https://www.github.com/googleapis/java-firestore/issues/211)) ([b376003](https://www.github.com/googleapis/java-firestore/commit/b3760032952529f148065928c3bf13ff73a34edd)) ### Dependencies * update core dependencies to v1.93.5 ([#229](https://www.github.com/googleapis/java-firestore/issues/229)) ([b078213](https://www.github.com/googleapis/java-firestore/commit/b078213209f3936cfe9c9e2cdea040c1262621d4)) * update dependency com.google.api:api-common to v1.9.1 ([#228](https://www.github.com/googleapis/java-firestore/issues/228)) ([7e4568d](https://www.github.com/googleapis/java-firestore/commit/7e4568d8b3f0fc6f591640ccc2d646eb2764e572)) * update dependency com.google.api.grpc:proto-google-common-protos to v1.18.0 ([#204](https://www.github.com/googleapis/java-firestore/issues/204)) ([1e05de4](https://www.github.com/googleapis/java-firestore/commit/1e05de4ecfde055a1c84c2f6dd338604b8580a61)) * update dependency com.google.cloud:google-cloud-conformance-tests to v0.0.10 ([#197](https://www.github.com/googleapis/java-firestore/issues/197)) ([69372af](https://www.github.com/googleapis/java-firestore/commit/69372af7253564691b291766e2bf4d80e9ecc770)) * update dependency com.google.guava:guava-bom to v29 ([#180](https://www.github.com/googleapis/java-firestore/issues/180)) ([3c204b4](https://www.github.com/googleapis/java-firestore/commit/3c204b42ddfbe435ac095368d1e695ed282280bd)) * update dependency io.grpc:grpc-bom to v1.29.0 ([#206](https://www.github.com/googleapis/java-firestore/issues/206)) ([5d8c50f](https://www.github.com/googleapis/java-firestore/commit/5d8c50f105649100abf4fa7a6882bb0469ccbf8f)) * update dependency org.threeten:threetenbp to v1.4.4 ([#194](https://www.github.com/googleapis/java-firestore/issues/194)) ([c867bd5](https://www.github.com/googleapis/java-firestore/commit/c867bd5772aa4a4710c622546e69fdc0f1ca22b6)) * update jackson dependencies to v2.11.0 ([#195](https://www.github.com/googleapis/java-firestore/issues/195)) ([5066812](https://www.github.com/googleapis/java-firestore/commit/50668126e99422cc9498b317c9c76a80a8bf7b30)) * update protobuf.version to v3.12.0 ([#220](https://www.github.com/googleapis/java-firestore/issues/220)) ([2c0b35d](https://www.github.com/googleapis/java-firestore/commit/2c0b35dfc5786b986b5301a00f06177f527496c3)) * update protobuf.version to v3.12.2 ([#226](https://www.github.com/googleapis/java-firestore/issues/226)) ([2eeea19](https://www.github.com/googleapis/java-firestore/commit/2eeea193d7eb54b1efa92b4d5dd996c170048a73)) ### Documentation * update README to include code formatting ([#209](https://www.github.com/googleapis/java-firestore/issues/209)) ([04f8b3b](https://www.github.com/googleapis/java-firestore/commit/04f8b3b0f873c2f1988c184de1e5268e0de9053f)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please).
Porting from node. Also added additional system test port as well.
Conformance tests are passing locally against the custom [branch] of modified conformance tests (https://github.com/googleapis/java-conformance-tests/tree/bump/2020-05-12_141750) in
googleapis/java-conformance-test
. According to @BenWhitehead, once this PR is LGTM'd, we will:conformance-tests
.java-conformance-tests
.java-firestore
to the new release.