-
Notifications
You must be signed in to change notification settings - Fork 553
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
feat(firestore): Add support for Query Partitions #11635
Conversation
ce6730a
to
3895e3f
Compare
a8c3ee4
to
a8388a2
Compare
f5f8520
to
759d4e4
Compare
759d4e4
to
4e61da5
Compare
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 just found out that the Partition RPC does not necessarily return the partitions in order, which can lead to overlapping results if we do not sort them ourselves. Can you add code to sort the results before building the QueryPartition? We also need to fix this in Node and Java.
Added in new class |
google-cloud-firestore/lib/google/cloud/firestore/query_partition.rb
Outdated
Show resolved
Hide resolved
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 far as my Ruby expertise goes, this looks good. I did not verify the tests but the implementation handles the cases I handled in Node and Java.
* Fix return type docs for QueryPartition.
## | ||
# @private New QueryPartition from query and Cursor | ||
def initialize query, start_at, end_before | ||
@query = query |
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 should be possible for a user to serialize the result of the QueryPartition API so that the partitions can be processed on other machines.
A reference to the original Google::Cloud::Firestore::Query
instance is provided to each QueryPartition
. This object holds a reference to the Google::Cloud::Firestore::Client
instance, which is used in Query#get
to run the query.
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 discussed offline with @dazuma, serialization will be provided via new methods:
data = my_query_partition.to_json
my_query_partition = QueryPartition.from_json data, client
google-cloud-firestore/lib/google/cloud/firestore/collection_group.rb
Outdated
Show resolved
Hide resolved
google-cloud-firestore/lib/google/cloud/firestore/collection_reference.rb
Outdated
Show resolved
Hide resolved
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's here LGTM. Ping me if/when you add serialization.
Reference implementations:
Sorting logic in
ResourcePath
based on path.ts.