16
16
17
17
package com .google .cloud .firestore ;
18
18
19
- import static com .google .cloud .firestore .pipeline .expressions .Expr .field ;
19
+ import static com .google .cloud .firestore .pipeline .expressions .Expression .field ;
20
20
21
21
import com .google .api .core .ApiFuture ;
22
22
import com .google .api .core .BetaApi ;
27
27
import com .google .api .gax .rpc .ResponseObserver ;
28
28
import com .google .api .gax .rpc .StreamController ;
29
29
import com .google .cloud .Timestamp ;
30
+ import com .google .cloud .firestore .pipeline .expressions .AggregateFunction ;
30
31
import com .google .cloud .firestore .pipeline .expressions .AliasedAggregate ;
31
- import com .google .cloud .firestore .pipeline .expressions .AliasedExpr ;
32
- import com .google .cloud .firestore .pipeline .expressions .BooleanExpr ;
33
- import com .google .cloud .firestore .pipeline .expressions .Expr ;
32
+ import com .google .cloud .firestore .pipeline .expressions .AliasedExpression ;
33
+ import com .google .cloud .firestore .pipeline .expressions .BooleanExpression ;
34
+ import com .google .cloud .firestore .pipeline .expressions .Expression ;
34
35
import com .google .cloud .firestore .pipeline .expressions .Field ;
36
+ import com .google .cloud .firestore .pipeline .expressions .FunctionExpression ;
35
37
import com .google .cloud .firestore .pipeline .expressions .Ordering ;
36
38
import com .google .cloud .firestore .pipeline .expressions .Selectable ;
37
39
import com .google .cloud .firestore .pipeline .stages .AddFields ;
97
99
* Firestore firestore; // A valid firestore instance.
98
100
*
99
101
* // Example 1: Select specific fields and rename 'rating' to 'bookRating'
100
- * List<PipelineResult> results1 = firestore.pipeline()
102
+ * PipelineSnapshot results1 = firestore.pipeline()
101
103
* .collection("books")
102
- * .select("title", "author", field("rating").as("bookRating"))
104
+ * .select(field( "title"), field( "author") , field("rating").as("bookRating"))
103
105
* .execute()
104
106
* .get();
105
107
*
106
108
* // Example 2: Filter documents where 'genre' is "Science Fiction" and 'published' is after 1950
107
- * List<PipelineResult> results2 = firestore.pipeline()
109
+ * PipelineSnapshot results2 = firestore.pipeline()
108
110
* .collection("books")
109
111
* .where(and(eq("genre", "Science Fiction"), gt("published", 1950)))
110
112
* .execute()
117
119
* .get();
118
120
*
119
121
* // Example 3: Calculate the average rating of books published after 1980
120
- * List<PipelineResult> results3 = firestore.pipeline()
122
+ * PipelineSnapshot results3 = firestore.pipeline()
121
123
* .collection("books")
122
124
* .where(gt("published", 1980))
123
125
* .aggregate(avg("rating").as("averageRating"))
@@ -156,9 +158,8 @@ private Pipeline append(Stage stage) {
156
158
*
157
159
* <ul>
158
160
* <li>{@link Field}: References an existing document field.
159
- * <li>{@link Function}: Performs a calculation using functions like `add`, `multiply` with
160
- * assigned aliases using {@link
161
- * com.google.cloud.firestore.pipeline.expressions.Expr#as(String)}.
161
+ * <li>{@link FunctionExpression}: Performs a calculation using functions like `add`, `multiply`
162
+ * with assigned aliases using {@link Expression#as(String)}.
162
163
* </ul>
163
164
*
164
165
* <p>Example:
@@ -232,8 +233,8 @@ public Pipeline removeFields(Field... fields) {
232
233
*
233
234
* <ul>
234
235
* <li>{@link Field}: References an existing document field.
235
- * <li>{@link Function }: Represents the result of a function with an assigned alias name using
236
- * {@link com.google.cloud.firestore.pipeline.expressions.Expr #as(String)}
236
+ * <li>{@link FunctionExpression }: Represents the result of a function with an assigned alias
237
+ * name using {@link Expression #as(String)}
237
238
* </ul>
238
239
*
239
240
* <p>If no selections are provided, the output of this stage is empty. Use {@link
@@ -287,18 +288,19 @@ public Pipeline select(String... fields) {
287
288
288
289
/**
289
290
* Filters the documents from previous stages to only include those matching the specified {@link
290
- * FilterCondition }.
291
+ * BooleanExpression }.
291
292
*
292
293
* <p>This stage allows you to apply conditions to the data, similar to a "WHERE" clause in SQL.
293
294
* You can filter documents based on their field values, using implementions of {@link
294
- * FilterCondition }, typically including but not limited to:
295
+ * BooleanExpression }, typically including but not limited to:
295
296
*
296
297
* <ul>
297
- * <li>field comparators: {@link Function#eq}, {@link Function#lt} (less than), {@link
298
- * Function#gt} (greater than), etc.
299
- * <li>logical operators: {@link Function#and}, {@link Function#or}, {@link Function#not}, etc.
300
- * <li>advanced functions: {@link Function#regexMatch(String, String)}, {@link
301
- * Function#arrayContains(Expr, Expr)}, etc.
298
+ * <li>field comparators: {@link FunctionExpression#equal}, {@link FunctionExpression#lessThan}
299
+ * (less than), {@link FunctionExpression#greaterThan} (greater than), etc.
300
+ * <li>logical operators: {@link FunctionExpression#and}, {@link FunctionExpression#or}, {@link
301
+ * FunctionExpression#not}, etc.
302
+ * <li>advanced functions: {@link FunctionExpression#regexMatch(String, String)}, {@link
303
+ * FunctionExpression#arrayContains(Expression, Expression)}, etc.
302
304
* </ul>
303
305
*
304
306
* <p>Example:
@@ -308,16 +310,16 @@ public Pipeline select(String... fields) {
308
310
* .where(
309
311
* and(
310
312
* gt("rating", 4.0), // Filter for ratings greater than 4.0
311
- * field("genre").eq("Science Fiction") // Equivalent to gt ("genre", "Science Fiction")
313
+ * field("genre").eq("Science Fiction") // Equivalent to eq ("genre", "Science Fiction")
312
314
* )
313
315
* );
314
316
* }</pre>
315
317
*
316
- * @param condition The {@link FilterCondition } to apply.
318
+ * @param condition The {@link BooleanExpression } to apply.
317
319
* @return A new Pipeline object with this stage appended to the stage list.
318
320
*/
319
321
@ BetaApi
320
- public Pipeline where (BooleanExpr condition ) {
322
+ public Pipeline where (BooleanExpression condition ) {
321
323
return append (new Where (condition ));
322
324
}
323
325
@@ -380,8 +382,8 @@ public Pipeline limit(int limit) {
380
382
* Performs aggregation operations on the documents from previous stages.
381
383
*
382
384
* <p>This stage allows you to calculate aggregate values over a set of documents. You define the
383
- * aggregations to perform using {@link AliasedExpr } expressions which are typically results of
384
- * calling {@link Expr #as(String)} on {@link Accumulator } instances.
385
+ * aggregations to perform using {@link AliasedExpression } expressions which are typically results
386
+ * of calling {@link Expression #as(String)} on {@link AggregateFunction } instances.
385
387
*
386
388
* <p>Example:
387
389
*
@@ -394,8 +396,8 @@ public Pipeline limit(int limit) {
394
396
* );
395
397
* }</pre>
396
398
*
397
- * @param accumulators The {@link AliasedExpr } expressions, each wrapping an {@link Accumulator}
398
- * and provide a name for the accumulated results.
399
+ * @param accumulators The {@link AliasedExpression } expressions, each wrapping an {@link
400
+ * AggregateFunction} and provide a name for the accumulated results.
399
401
* @return A new Pipeline object with this stage appended to the stage list.
400
402
*/
401
403
@ BetaApi
@@ -415,9 +417,10 @@ public Pipeline aggregate(AliasedAggregate... accumulators) {
415
417
* If no grouping fields are provided, a single group containing all documents is used. Not
416
418
* specifying groups is the same as putting the entire inputs into one group.
417
419
* <li>**Accumulators:** One or more accumulation operations to perform within each group. These
418
- * are defined using {@link AliasedExpr} expressions, which are typically created by calling
419
- * {@link Expr#as(String)} on {@link Accumulator} instances. Each aggregation calculates a
420
- * value (e.g., sum, average, count) based on the documents within its group.
420
+ * are defined using {@link AliasedExpression} expressions, which are typically created by
421
+ * calling {@link Expression#as(String)} on {@link AggregateFunction} instances. Each
422
+ * aggregation calculates a value (e.g., sum, average, count) based on the documents within
423
+ * its group.
421
424
* </ul>
422
425
*
423
426
* <p>Example:
@@ -468,17 +471,17 @@ public Pipeline distinct(String... fields) {
468
471
}
469
472
470
473
/**
471
- * Returns a set of distinct {@link Expr } values from the inputs to this stage.
474
+ * Returns a set of distinct {@link Expression } values from the inputs to this stage.
472
475
*
473
476
* <p>This stage run through the results from previous stages to include only results with unique
474
- * combinations of {@link Expr } values ({@link Field}, {@link Function }, etc).
477
+ * combinations of {@link Expression } values ({@link Field}, {@link FunctionExpression }, etc).
475
478
*
476
479
* <p>The parameters to this stage are defined using {@link Selectable} expressions, which can be:
477
480
*
478
481
* <ul>
479
482
* <li>{@link Field}: References an existing document field.
480
- * <li>{@link Function }: Represents the result of a function with an assigned alias name using
481
- * {@link com.google.cloud.firestore.pipeline.expressions.Expr #as(String)}
483
+ * <li>{@link FunctionExpression }: Represents the result of a function with an assigned alias
484
+ * name using {@link Expression #as(String)}
482
485
* </ul>
483
486
*
484
487
* <p>Example:
@@ -548,7 +551,9 @@ public Pipeline findNearest(
548
551
* // Find books with similar "topicVectors" to the given targetVector
549
552
* firestore.pipeline().collection("books")
550
553
* .findNearest(
551
- * FindNearest.of(field("topicVectors"), targetVector, FindNearest.DistanceMeasure.COSINE),
554
+ * field("topicVectors"),
555
+ * targetVector,
556
+ * FindNearest.DistanceMeasure.COSINE,
552
557
* new FindNearestOptions()
553
558
* .withLimit(10)
554
559
* .withDistanceField("distance"));
@@ -563,7 +568,7 @@ public Pipeline findNearest(
563
568
*/
564
569
@ BetaApi
565
570
public Pipeline findNearest (
566
- Expr property ,
571
+ Expression property ,
567
572
double [] vector ,
568
573
FindNearest .DistanceMeasure distanceMeasure ,
569
574
FindNearestOptions options ) {
@@ -617,7 +622,7 @@ public Pipeline sort(Ordering... orders) {
617
622
* // }
618
623
*
619
624
* // Emit parents as document.
620
- * firestore.pipeline().collection("people").replace ("parents");
625
+ * firestore.pipeline().collection("people").replaceWith ("parents");
621
626
*
622
627
* // Output
623
628
* // {
@@ -652,7 +657,7 @@ public Pipeline replaceWith(String fieldName) {
652
657
* // }
653
658
*
654
659
* // Emit parents as document.
655
- * firestore.pipeline().collection("people").replace (field("parents"));
660
+ * firestore.pipeline().collection("people").replaceWith (field("parents"));
656
661
*
657
662
* // Output
658
663
* // {
@@ -665,7 +670,7 @@ public Pipeline replaceWith(String fieldName) {
665
670
* @return A new {@code Pipeline} object with this stage appended to the stage list.
666
671
*/
667
672
@ BetaApi
668
- public Pipeline replaceWith (Expr expr ) {
673
+ public Pipeline replaceWith (Expression expr ) {
669
674
return append (new ReplaceWith (expr ));
670
675
}
671
676
@@ -979,7 +984,7 @@ public Pipeline genericStage(String name, List<Object> params, GenericOptions op
979
984
* <p>Example:
980
985
*
981
986
* <pre>{@code
982
- * ApiFuture<List<PipelineResult> > futureResults = firestore.pipeline().collection("books")
987
+ * ApiFuture<PipelineSnapshot > futureResults = firestore.pipeline().collection("books")
983
988
* .where(gt("rating", 4.5))
984
989
* .select("title", "author", "rating")
985
990
* .execute();
@@ -1228,7 +1233,7 @@ public void onComplete() {
1228
1233
}
1229
1234
};
1230
1235
1231
- logger .log (Level .INFO , "Sending pipeline request: " + request .getStructuredPipeline ());
1236
+ logger .log (Level .FINEST , "Sending pipeline request: " + request .getStructuredPipeline ());
1232
1237
1233
1238
rpcContext .streamRequest (request , observer , rpcContext .getClient ().executePipelineCallable ());
1234
1239
}
0 commit comments