Skip to content

Commit b64e0c1

Browse files
feat: Add bloom filter related proto fields (#1843)
* feat: Add bloom filter related proto fields (only in the preview API surface) PiperOrigin-RevId: 527090049 Source-Link: googleapis/googleapis@e2b7cb9 Source-Link: googleapis/googleapis-gen@b0d2cc1 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjBkMmNjMWM0OGRkYWMxYzVkYmFjMWNlMTk5ZDI5ZWFmMWM1ZWMwYyJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat: Add bloom filter related proto fields PiperOrigin-RevId: 529511263 Source-Link: googleapis/googleapis@b071320 Source-Link: googleapis/googleapis-gen@81dcde7 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiODFkY2RlNzA4YTZlMzlkYTBmMmY0N2RjOGYxNmVlNWU2ODFhNTU5ZiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent fda1242 commit b64e0c1

11 files changed

+176
-30
lines changed

dev/protos/google/api/client.proto

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ message Publishing {
157157
// long-running operation pattern.
158158
repeated MethodSettings method_settings = 2;
159159

160-
// Link to a place that API users can report issues. Example:
160+
// Link to a *public* URI where users can report issues. Example:
161161
// https://issuetracker.google.com/issues/new?component=190865&template=1161103
162162
string new_issue_uri = 101;
163163

@@ -368,6 +368,15 @@ enum ClientLibraryOrganization {
368368

369369
// Street View Org.
370370
STREET_VIEW = 4;
371+
372+
// Shopping Org.
373+
SHOPPING = 5;
374+
375+
// Geo Org.
376+
GEO = 6;
377+
378+
// Generative AI - https://developers.generativeai.google
379+
GENERATIVE_AI = 7;
371380
}
372381

373382
// To where should client libraries be published?

dev/protos/google/firestore/v1/aggregation_result.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2022 Google LLC
1+
// Copyright 2023 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Copyright 2023 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
package google.firestore.v1;
18+
19+
option csharp_namespace = "Google.Cloud.Firestore.V1";
20+
option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb";
21+
option java_multiple_files = true;
22+
option java_outer_classname = "BloomFilterProto";
23+
option java_package = "com.google.firestore.v1";
24+
option objc_class_prefix = "GCFS";
25+
option php_namespace = "Google\\Cloud\\Firestore\\V1";
26+
option ruby_package = "Google::Cloud::Firestore::V1";
27+
28+
// A sequence of bits, encoded in a byte array.
29+
//
30+
// Each byte in the `bitmap` byte array stores 8 bits of the sequence. The only
31+
// exception is the last byte, which may store 8 _or fewer_ bits. The `padding`
32+
// defines the number of bits of the last byte to be ignored as "padding". The
33+
// values of these "padding" bits are unspecified and must be ignored.
34+
//
35+
// To retrieve the first bit, bit 0, calculate: `(bitmap[0] & 0x01) != 0`.
36+
// To retrieve the second bit, bit 1, calculate: `(bitmap[0] & 0x02) != 0`.
37+
// To retrieve the third bit, bit 2, calculate: `(bitmap[0] & 0x04) != 0`.
38+
// To retrieve the fourth bit, bit 3, calculate: `(bitmap[0] & 0x08) != 0`.
39+
// To retrieve bit n, calculate: `(bitmap[n / 8] & (0x01 << (n % 8))) != 0`.
40+
//
41+
// The "size" of a `BitSequence` (the number of bits it contains) is calculated
42+
// by this formula: `(bitmap.length * 8) - padding`.
43+
message BitSequence {
44+
// The bytes that encode the bit sequence.
45+
// May have a length of zero.
46+
bytes bitmap = 1;
47+
48+
// The number of bits of the last byte in `bitmap` to ignore as "padding".
49+
// If the length of `bitmap` is zero, then this value must be `0`.
50+
// Otherwise, this value must be between 0 and 7, inclusive.
51+
int32 padding = 2;
52+
}
53+
54+
// A bloom filter (https://en.wikipedia.org/wiki/Bloom_filter).
55+
//
56+
// The bloom filter hashes the entries with MD5 and treats the resulting 128-bit
57+
// hash as 2 distinct 64-bit hash values, interpreted as unsigned integers
58+
// using 2's complement encoding.
59+
//
60+
// These two hash values, named `h1` and `h2`, are then used to compute the
61+
// `hash_count` hash values using the formula, starting at `i=0`:
62+
//
63+
// h(i) = h1 + (i * h2)
64+
//
65+
// These resulting values are then taken modulo the number of bits in the bloom
66+
// filter to get the bits of the bloom filter to test for the given entry.
67+
message BloomFilter {
68+
// The bloom filter data.
69+
BitSequence bits = 1;
70+
71+
// The number of hashes used by the algorithm.
72+
int32 hash_count = 2;
73+
}

dev/protos/google/firestore/v1/common.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2022 Google LLC
1+
// Copyright 2023 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

dev/protos/google/firestore/v1/document.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2022 Google LLC
1+
// Copyright 2023 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

dev/protos/google/firestore/v1/firestore.proto

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2022 Google LLC
1+
// Copyright 2023 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@ import "google/firestore/v1/query.proto";
2626
import "google/firestore/v1/write.proto";
2727
import "google/protobuf/empty.proto";
2828
import "google/protobuf/timestamp.proto";
29+
import "google/protobuf/wrappers.proto";
2930
import "google/rpc/status.proto";
3031

3132
option csharp_namespace = "Google.Cloud.Firestore.V1";
@@ -178,16 +179,16 @@ service Firestore {
178179
}
179180

180181
// Streams batches of document updates and deletes, in order. This method is
181-
// only available via the gRPC API (not REST).
182+
// only available via gRPC or WebChannel (not REST).
182183
rpc Write(stream WriteRequest) returns (stream WriteResponse) {
183184
option (google.api.http) = {
184185
post: "/v1/{database=projects/*/databases/*}/documents:write"
185186
body: "*"
186187
};
187188
}
188189

189-
// Listens to changes. This method is only available via the gRPC API (not
190-
// REST).
190+
// Listens to changes. This method is only available via gRPC or WebChannel
191+
// (not REST).
191192
rpc Listen(stream ListenRequest) returns (stream ListenResponse) {
192193
option (google.api.http) = {
193194
post: "/v1/{database=projects/*/databases/*}/documents:listen"
@@ -655,7 +656,14 @@ message RunAggregationQueryResponse {
655656
// a new transaction.
656657
bytes transaction = 2;
657658

658-
// The time at which the aggregate value is valid for.
659+
// The time at which the aggregate result was computed. This is always
660+
// monotonically increasing; in this case, the previous AggregationResult in
661+
// the result stream are guaranteed not to have changed between their
662+
// `read_time` and this one.
663+
//
664+
// If the query returns no results, a response with `read_time` and no
665+
// `result` will be sent, and this represents the time at which the query
666+
// was run.
659667
google.protobuf.Timestamp read_time = 3;
660668
}
661669

@@ -925,6 +933,14 @@ message Target {
925933

926934
// If the target should be removed once it is current and consistent.
927935
bool once = 6;
936+
937+
// The number of documents that last matched the query at the resume token or
938+
// read time.
939+
//
940+
// This value is only relevant when a `resume_type` is provided. This value
941+
// being present and greater than zero signals that the client wants
942+
// `ExistenceFilter.unchanged_names` to be included in the response.
943+
google.protobuf.Int32Value expected_count = 12;
928944
}
929945

930946
// Targets being watched have changed.

dev/protos/google/firestore/v1/query.proto

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2022 Google LLC
1+
// Copyright 2023 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -136,25 +136,28 @@ message StructuredQuery {
136136
//
137137
// Requires:
138138
//
139-
// * That `value` is a non-empty `ArrayValue` with at most 10 values.
140-
// * No other `IN` or `ARRAY_CONTAINS_ANY` or `NOT_IN`.
139+
// * That `value` is a non-empty `ArrayValue`, subject to disjunction
140+
// limits.
141+
// * No `NOT_IN` filters in the same query.
141142
IN = 8;
142143

143144
// The given `field` is an array that contains any of the values in the
144145
// given array.
145146
//
146147
// Requires:
147148
//
148-
// * That `value` is a non-empty `ArrayValue` with at most 10 values.
149-
// * No other `IN` or `ARRAY_CONTAINS_ANY` or `NOT_IN`.
149+
// * That `value` is a non-empty `ArrayValue`, subject to disjunction
150+
// limits.
151+
// * No other `ARRAY_CONTAINS_ANY` filters within the same disjunction.
152+
// * No `NOT_IN` filters in the same query.
150153
ARRAY_CONTAINS_ANY = 9;
151154

152155
// The value of the `field` is not in the given array.
153156
//
154157
// Requires:
155158
//
156159
// * That `value` is a non-empty `ArrayValue` with at most 10 values.
157-
// * No other `IN`, `ARRAY_CONTAINS_ANY`, `NOT_IN`, `NOT_EQUAL`,
160+
// * No other `OR`, `IN`, `ARRAY_CONTAINS_ANY`, `NOT_IN`, `NOT_EQUAL`,
158161
// `IS_NOT_NULL`, or `IS_NOT_NAN`.
159162
// * That `field` comes first in the `order_by`.
160163
NOT_IN = 10;
@@ -251,7 +254,11 @@ message StructuredQuery {
251254
repeated FieldReference fields = 2;
252255
}
253256

254-
// The projection to return.
257+
// Optional sub-set of the fields to return.
258+
//
259+
// This acts as a [DocumentMask][google.firestore.v1.DocumentMask] over the
260+
// documents returned from a query. When not set, assumes that the caller
261+
// wants all fields returned.
255262
Projection select = 1;
256263

257264
// The collections to query.
@@ -349,7 +356,7 @@ message StructuredQuery {
349356
// Firestore query for running an aggregation over a
350357
// [StructuredQuery][google.firestore.v1.StructuredQuery].
351358
message StructuredAggregationQuery {
352-
// Defines a aggregation that produces a single result.
359+
// Defines an aggregation that produces a single result.
353360
message Aggregation {
354361
// Count of documents that match the query.
355362
//
@@ -360,7 +367,7 @@ message StructuredAggregationQuery {
360367
// count.
361368
//
362369
// This provides a way to set an upper bound on the number of documents
363-
// to scan, limiting latency and cost.
370+
// to scan, limiting latency, and cost.
364371
//
365372
// Unspecified is interpreted as no bound.
366373
//
@@ -394,7 +401,7 @@ message StructuredAggregationQuery {
394401
// COUNT_UP_TO(1) AS count_up_to_1,
395402
// COUNT_UP_TO(2),
396403
// COUNT_UP_TO(3) AS count_up_to_3,
397-
// COUNT_UP_TO(4)
404+
// COUNT(*)
398405
// OVER (
399406
// ...
400407
// );
@@ -407,7 +414,7 @@ message StructuredAggregationQuery {
407414
// COUNT_UP_TO(1) AS count_up_to_1,
408415
// COUNT_UP_TO(2) AS field_1,
409416
// COUNT_UP_TO(3) AS count_up_to_3,
410-
// COUNT_UP_TO(4) AS field_2
417+
// COUNT(*) AS field_2
411418
// OVER (
412419
// ...
413420
// );

dev/protos/google/firestore/v1/write.proto

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2022 Google LLC
1+
// Copyright 2023 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@ syntax = "proto3";
1616

1717
package google.firestore.v1;
1818

19+
import "google/firestore/v1/bloom_filter.proto";
1920
import "google/firestore/v1/common.proto";
2021
import "google/firestore/v1/document.proto";
2122
import "google/protobuf/timestamp.proto";
@@ -264,4 +265,19 @@ message ExistenceFilter {
264265
// If different from the count of documents in the client that match, the
265266
// client must manually determine which documents no longer match the target.
266267
int32 count = 2;
268+
269+
// A bloom filter that contains the UTF-8 byte encodings of the resource names
270+
// of the documents that match
271+
// [target_id][google.firestore.v1.ExistenceFilter.target_id], in the form
272+
// `projects/{project_id}/databases/{database_id}/documents/{document_path}`
273+
// that have NOT changed since the query results indicated by the resume token
274+
// or timestamp given in `Target.resume_type`.
275+
//
276+
// This bloom filter may be omitted at the server's discretion, such as if it
277+
// is deemed that the client will not make use of it or if it is too
278+
// computationally expensive to calculate or transmit. Clients must gracefully
279+
// handle this field being absent by falling back to the logic used before
280+
// this field existed; that is, re-add the target without a resume token to
281+
// figure out which documents in the client's cache are out of sync.
282+
BloomFilter unchanged_names = 3;
267283
}

dev/protos/google/protobuf/descriptor.proto

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,17 @@ message ExtensionRangeOptions {
146146
// and enums.
147147
optional string type = 3;
148148

149-
// If true, indicates that the extension must be defined as repeated.
150-
// Otherwise the extension must be defined as optional.
151-
optional bool is_repeated = 4;
149+
// Deprecated. Please use "repeated".
150+
optional bool is_repeated = 4 [deprecated = true];
152151

153152
// If true, indicates that the number is reserved in the extension range,
154153
// and any extension field with the number will fail to compile. Set this
155154
// when a declared extension field is deleted.
156155
optional bool reserved = 5;
156+
157+
// If true, indicates that the extension must be defined as repeated.
158+
// Otherwise the extension must be defined as optional.
159+
optional bool repeated = 6;
157160
}
158161

159162
// go/protobuf-stripping-extension-declarations
@@ -162,6 +165,18 @@ message ExtensionRangeOptions {
162165
// extension range into small ranges in generated binaries.
163166
repeated Declaration declaration = 2 [retention = RETENTION_SOURCE];
164167

168+
// The verification state of the extension range.
169+
enum VerificationState {
170+
// All the extensions of the range must be declared.
171+
DECLARATION = 0;
172+
UNVERIFIED = 1;
173+
}
174+
175+
// The verification state of the range.
176+
// TODO(b/278783756): flip the default to DECLARATION once all empty ranges
177+
// are marked as UNVERIFIED.
178+
optional VerificationState verification = 3 [default = UNVERIFIED];
179+
165180
// Clients can define custom options in extensions of this message. See above.
166181
extensions 1000 to max;
167182
}
@@ -569,13 +584,21 @@ message MessageOptions {
569584
message FieldOptions {
570585
// The ctype option instructs the C++ code generator to use a different
571586
// representation of the field than it normally would. See the specific
572-
// options below. This option is not yet implemented in the open source
573-
// release -- sorry, we'll try to include it in a future version!
587+
// options below. This option is only implemented to support use of
588+
// [ctype=CORD] and [ctype=STRING] (the default) on non-repeated fields of
589+
// type "bytes" in the open source release -- sorry, we'll try to include
590+
// other types in a future version!
574591
optional CType ctype = 1 [default = STRING];
575592
enum CType {
576593
// Default mode.
577594
STRING = 0;
578595

596+
// The option [ctype=CORD] may be applied to a non-repeated field of type
597+
// "bytes". It indicates that in C++, the data should be stored in a Cord
598+
// instead of a string. For very large strings, this may reduce memory
599+
// fragmentation. It may also allow better performance when parsing from a
600+
// Cord, or when parsing with aliasing enabled, as the parsed Cord may then
601+
// alias the original buffer.
579602
CORD = 1;
580603

581604
STRING_PIECE = 2;
@@ -688,7 +711,6 @@ message FieldOptions {
688711
TARGET_TYPE_METHOD = 9;
689712
}
690713

691-
optional OptionTargetType target = 18 [deprecated = true];
692714
repeated OptionTargetType targets = 19;
693715

694716
// The parser stores options it doesn't recognize here. See above.
@@ -698,9 +720,11 @@ message FieldOptions {
698720
extensions 1000 to max;
699721

700722
reserved 4; // removed jtype
723+
optional OptionTargetType target_obsolete_do_not_use = 18 [deprecated = true];
701724
}
702725

703726
message OneofOptions {
727+
704728
// The parser stores options it doesn't recognize here. See above.
705729
repeated UninterpretedOption uninterpreted_option = 999;
706730

0 commit comments

Comments
 (0)