-
Notifications
You must be signed in to change notification settings - Fork 75
feat: Query.count() implementation, part 1 #1026
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
|
🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use -- conventional-commit-lint bot |
0dfda07 to
7467804
Compare
7467804 to
1be2496
Compare
google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITAggregateQueryTest.java
Show resolved
Hide resolved
| throws Exception { | ||
| CollectionReference collection = createCollectionWithDocuments(20); | ||
| ApiFuture<AggregateQuerySnapshot> task = collection.count().get(); | ||
| collection.getFirestore().close(); |
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.
Interesting, will this be flaky?
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.
close() appears to peform a "graceful" shutdown, in which in-flight operations are allowed to run to completion. That being the case, this shouldn't be flaky.
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.
So if for whatever reason the backend does not respond, close() will hang forever?
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 believe so, yes. The main thing I want to test is that nothing "bad" happens, like silly exceptions that simply didn't take this code path into account. I can confirm if you'd like.
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.
Well, I would like to see it for my curiosity now. Not a blocker for this PR though.
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 looked into whether or not close() will hang forever if the server takes too long to respond, and, it appears that no, it will not hang. That being said, it's difficult to tell from stepping through the gory details of grpc's shutdown logic.
google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryCountTest.java
Outdated
Show resolved
Hide resolved
google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryCountTest.java
Outdated
Show resolved
Hide resolved
| * Blocks the calling thread until the given future completes. Note that this method does not | ||
| * check the success or failure of the future; it returns regardless of its success or failure. | ||
| */ | ||
| private static void await(ApiFuture<?> future) throws InterruptedException { |
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 we use future.get()?
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.
future.get() will throw the exception if the task fails, which isn't the desired behavior for the singular use of this function.
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.
Will this do:
try {future.get()} finally {assertTrue(future.done());}
?
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.
That would still throw the exception thrown by get(). The caller of await() just wants to make sure that the future completes, but doesn't care about its success or failure.
…ta between consecutive read times
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!
| throws Exception { | ||
| CollectionReference collection = createCollectionWithDocuments(20); | ||
| ApiFuture<AggregateQuerySnapshot> task = collection.count().get(); | ||
| collection.getFirestore().close(); |
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.
Well, I would like to see it for my curiosity now. Not a blocker for this PR though.
Initial implementation of server-side query result set counting.
This initial implementation is still missing some work, which will be done in follow-up PRs:
Transaction.getCount())Tracing.getTracer())