feat(firestore): Add support for Query Partitions#11635
feat(firestore): Add support for Query Partitions#11635quartzmo merged 23 commits intogoogleapis:masterfrom
Conversation
ce6730a to
3895e3f
Compare
a8c3ee4 to
a8388a2
Compare
f5f8520 to
759d4e4
Compare
759d4e4 to
4e61da5
Compare
schmidt-sebastian
left a comment
There was a problem hiding this comment.
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
schmidt-sebastian
left a comment
There was a problem hiding this comment.
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.
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.
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
dazuma
left a comment
There was a problem hiding this comment.
What's here LGTM. Ping me if/when you add serialization.
Reference implementations:
Sorting logic in
ResourcePathbased on path.ts.