Skip to content

Commit b832d08

Browse files
committed
reformat and add explain suppor and new api.txt and query to pipeline
tests
1 parent 788a996 commit b832d08

File tree

296 files changed

+9919
-711
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

296 files changed

+9919
-711
lines changed

google-cloud-firestore/clirr-ignored-differences.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,11 @@
311311
<className>com/google/cloud/firestore/Transaction</className>
312312
<method>com.google.api.core.ApiFuture execute(com.google.cloud.firestore.Pipeline)</method>
313313
</difference>
314+
<difference>
315+
<differenceType>7013</differenceType>
316+
<className>com/google/cloud/firestore/Transaction</className>
317+
<method>com.google.api.core.ApiFuture execute(com.google.cloud.firestore.Pipeline, com.google.cloud.firestore.pipeline.stages.PipelineExecuteOptions)</method>
318+
</difference>
314319
<difference>
315320
<differenceType>7012</differenceType>
316321
<className>com/google/cloud/firestore/spi/v1/FirestoreRpc</className>

google-cloud-firestore/src/main/java/com/google/cloud/firestore/AggregateQuery.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import static com.google.cloud.firestore.telemetry.TraceUtil.SPAN_NAME_RUN_AGGREGATION_QUERY;
2222

2323
import com.google.api.core.ApiFuture;
24-
import com.google.api.core.BetaApi;
2524
import com.google.api.core.InternalExtensionOnly;
2625
import com.google.api.core.SettableApiFuture;
2726
import com.google.api.gax.rpc.ResponseObserver;
@@ -81,9 +80,7 @@ public Query getQuery() {
8180
return query;
8281
}
8382

84-
@Nonnull
85-
@BetaApi
86-
public Pipeline pipeline() {
83+
Pipeline pipeline() {
8784
Pipeline pipeline = getQuery().pipeline();
8885

8986
List<BooleanExpr> existsExprs =

google-cloud-firestore/src/main/java/com/google/cloud/firestore/BulkWriterException.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,37 @@ public BulkWriterException(
4141
this.failedAttempts = failedAttempts;
4242
}
4343

44-
/** @return The status code of the error. */
44+
/**
45+
* @return The status code of the error.
46+
*/
4547
public Status getStatus() {
4648
return status;
4749
}
4850

49-
/** @return The error message of the error. */
51+
/**
52+
* @return The error message of the error.
53+
*/
5054
public String getMessage() {
5155
return message;
5256
}
5357

54-
/** @return The DocumentReference the operation was performed on. */
58+
/**
59+
* @return The DocumentReference the operation was performed on.
60+
*/
5561
public DocumentReference getDocumentReference() {
5662
return documentReference;
5763
}
5864

59-
/** @return The type of operation performed. */
65+
/**
66+
* @return The type of operation performed.
67+
*/
6068
public OperationType getOperationType() {
6169
return operationType;
6270
}
6371

64-
/** @return How many times this operation has been attempted unsuccessfully. */
72+
/**
73+
* @return How many times this operation has been attempted unsuccessfully.
74+
*/
6575
public int getFailedAttempts() {
6676
return failedAttempts;
6777
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.cloud.firestore;
18+
19+
import com.google.api.core.BetaApi;
20+
import com.google.protobuf.Any;
21+
import com.google.protobuf.InvalidProtocolBufferException;
22+
import com.google.protobuf.StringValue;
23+
import javax.annotation.Nonnull;
24+
25+
/**
26+
* A wrapper object to access explain stats if explain or analyze was enabled for the Pipeline query
27+
* execution.
28+
*/
29+
@BetaApi
30+
public final class ExplainStats {
31+
32+
private final Any explainStatsData;
33+
34+
/**
35+
* @hideconstructor
36+
* @param explainStatsData The raw proto message of the explain stats.
37+
*/
38+
ExplainStats(@Nonnull Any explainStatsData) {
39+
this.explainStatsData = explainStatsData;
40+
}
41+
42+
/**
43+
* Returns the explain stats in an encoded proto format, as returned from the Firestore backend.
44+
* The caller is responsible for unpacking this proto message.
45+
*/
46+
@Nonnull
47+
public Any getRawData() {
48+
return explainStatsData;
49+
}
50+
51+
private StringValue decode() {
52+
try {
53+
return explainStatsData.unpack(StringValue.class);
54+
} catch (InvalidProtocolBufferException e) {
55+
throw new RuntimeException(
56+
"Unable to decode explain stats. Did you request an output format that returns a string value, such as 'text' or 'json'?",
57+
e);
58+
}
59+
}
60+
61+
/**
62+
* When explain stats were requested with `outputFormat = 'text'`, this returns the explain stats
63+
* string verbatim as returned from the Firestore backend.
64+
*
65+
* <p>If explain stats were requested with `outputFormat = 'json'`, this returns the explain stats
66+
* as stringified JSON, which was returned from the Firestore backend.
67+
*/
68+
@Nonnull
69+
public String getText() {
70+
return decode().getValue();
71+
}
72+
}

google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreBundle.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,7 @@ private Builder add(DocumentSnapshot documentSnapshot, Optional<String> queryNam
112112
documents
113113
.get(documentName)
114114
.setMetadata(
115-
documents
116-
.get(documentName)
117-
.getMetadata()
118-
.toBuilder()
115+
documents.get(documentName).getMetadata().toBuilder()
119116
.clearQueries()
120117
.addAllQueries(queries)
121118
.build());

0 commit comments

Comments
 (0)