1616
1717package com .google .cloud .firestore ;
1818
19- import static com .google .cloud .firestore .pipeline .expressions .Expr .field ;
19+ import static com .google .cloud .firestore .pipeline .expressions .Expression .field ;
2020
2121import com .google .api .core .ApiFuture ;
2222import com .google .api .core .BetaApi ;
2727import com .google .api .gax .rpc .ResponseObserver ;
2828import com .google .api .gax .rpc .StreamController ;
2929import com .google .cloud .Timestamp ;
30+ import com .google .cloud .firestore .pipeline .expressions .AggregateFunction ;
3031import 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 ;
3435import com .google .cloud .firestore .pipeline .expressions .Field ;
36+ import com .google .cloud .firestore .pipeline .expressions .FunctionExpression ;
3537import com .google .cloud .firestore .pipeline .expressions .Ordering ;
3638import com .google .cloud .firestore .pipeline .expressions .Selectable ;
3739import com .google .cloud .firestore .pipeline .stages .AddFields ;
9799 * Firestore firestore; // A valid firestore instance.
98100 *
99101 * // Example 1: Select specific fields and rename 'rating' to 'bookRating'
100- * List<PipelineResult> results1 = firestore.pipeline()
102+ * PipelineSnapshot results1 = firestore.pipeline()
101103 * .collection("books")
102- * .select("title", "author", field("rating").as("bookRating"))
104+ * .select(field( "title"), field( "author") , field("rating").as("bookRating"))
103105 * .execute()
104106 * .get();
105107 *
106108 * // 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()
108110 * .collection("books")
109111 * .where(and(eq("genre", "Science Fiction"), gt("published", 1950)))
110112 * .execute()
117119 * .get();
118120 *
119121 * // Example 3: Calculate the average rating of books published after 1980
120- * List<PipelineResult> results3 = firestore.pipeline()
122+ * PipelineSnapshot results3 = firestore.pipeline()
121123 * .collection("books")
122124 * .where(gt("published", 1980))
123125 * .aggregate(avg("rating").as("averageRating"))
@@ -156,9 +158,8 @@ private Pipeline append(Stage stage) {
156158 *
157159 * <ul>
158160 * <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)}.
162163 * </ul>
163164 *
164165 * <p>Example:
@@ -232,8 +233,8 @@ public Pipeline removeFields(Field... fields) {
232233 *
233234 * <ul>
234235 * <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)}
237238 * </ul>
238239 *
239240 * <p>If no selections are provided, the output of this stage is empty. Use {@link
@@ -287,18 +288,19 @@ public Pipeline select(String... fields) {
287288
288289 /**
289290 * Filters the documents from previous stages to only include those matching the specified {@link
290- * FilterCondition }.
291+ * BooleanExpression }.
291292 *
292293 * <p>This stage allows you to apply conditions to the data, similar to a "WHERE" clause in SQL.
293294 * 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:
295296 *
296297 * <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.
302304 * </ul>
303305 *
304306 * <p>Example:
@@ -308,16 +310,16 @@ public Pipeline select(String... fields) {
308310 * .where(
309311 * and(
310312 * 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")
312314 * )
313315 * );
314316 * }</pre>
315317 *
316- * @param condition The {@link FilterCondition } to apply.
318+ * @param condition The {@link BooleanExpression } to apply.
317319 * @return A new Pipeline object with this stage appended to the stage list.
318320 */
319321 @ BetaApi
320- public Pipeline where (BooleanExpr condition ) {
322+ public Pipeline where (BooleanExpression condition ) {
321323 return append (new Where (condition ));
322324 }
323325
@@ -380,8 +382,8 @@ public Pipeline limit(int limit) {
380382 * Performs aggregation operations on the documents from previous stages.
381383 *
382384 * <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.
385387 *
386388 * <p>Example:
387389 *
@@ -394,8 +396,8 @@ public Pipeline limit(int limit) {
394396 * );
395397 * }</pre>
396398 *
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.
399401 * @return A new Pipeline object with this stage appended to the stage list.
400402 */
401403 @ BetaApi
@@ -415,9 +417,10 @@ public Pipeline aggregate(AliasedAggregate... accumulators) {
415417 * If no grouping fields are provided, a single group containing all documents is used. Not
416418 * specifying groups is the same as putting the entire inputs into one group.
417419 * <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.
421424 * </ul>
422425 *
423426 * <p>Example:
@@ -468,17 +471,17 @@ public Pipeline distinct(String... fields) {
468471 }
469472
470473 /**
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.
472475 *
473476 * <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).
475478 *
476479 * <p>The parameters to this stage are defined using {@link Selectable} expressions, which can be:
477480 *
478481 * <ul>
479482 * <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)}
482485 * </ul>
483486 *
484487 * <p>Example:
@@ -548,7 +551,9 @@ public Pipeline findNearest(
548551 * // Find books with similar "topicVectors" to the given targetVector
549552 * firestore.pipeline().collection("books")
550553 * .findNearest(
551- * FindNearest.of(field("topicVectors"), targetVector, FindNearest.DistanceMeasure.COSINE),
554+ * field("topicVectors"),
555+ * targetVector,
556+ * FindNearest.DistanceMeasure.COSINE,
552557 * new FindNearestOptions()
553558 * .withLimit(10)
554559 * .withDistanceField("distance"));
@@ -563,7 +568,7 @@ public Pipeline findNearest(
563568 */
564569 @ BetaApi
565570 public Pipeline findNearest (
566- Expr property ,
571+ Expression property ,
567572 double [] vector ,
568573 FindNearest .DistanceMeasure distanceMeasure ,
569574 FindNearestOptions options ) {
@@ -617,7 +622,7 @@ public Pipeline sort(Ordering... orders) {
617622 * // }
618623 *
619624 * // Emit parents as document.
620- * firestore.pipeline().collection("people").replace ("parents");
625+ * firestore.pipeline().collection("people").replaceWith ("parents");
621626 *
622627 * // Output
623628 * // {
@@ -652,7 +657,7 @@ public Pipeline replaceWith(String fieldName) {
652657 * // }
653658 *
654659 * // Emit parents as document.
655- * firestore.pipeline().collection("people").replace (field("parents"));
660+ * firestore.pipeline().collection("people").replaceWith (field("parents"));
656661 *
657662 * // Output
658663 * // {
@@ -665,7 +670,7 @@ public Pipeline replaceWith(String fieldName) {
665670 * @return A new {@code Pipeline} object with this stage appended to the stage list.
666671 */
667672 @ BetaApi
668- public Pipeline replaceWith (Expr expr ) {
673+ public Pipeline replaceWith (Expression expr ) {
669674 return append (new ReplaceWith (expr ));
670675 }
671676
@@ -979,7 +984,7 @@ public Pipeline genericStage(String name, List<Object> params, GenericOptions op
979984 * <p>Example:
980985 *
981986 * <pre>{@code
982- * ApiFuture<List<PipelineResult> > futureResults = firestore.pipeline().collection("books")
987+ * ApiFuture<PipelineSnapshot > futureResults = firestore.pipeline().collection("books")
983988 * .where(gt("rating", 4.5))
984989 * .select("title", "author", "rating")
985990 * .execute();
@@ -1228,7 +1233,7 @@ public void onComplete() {
12281233 }
12291234 };
12301235
1231- logger .log (Level .INFO , "Sending pipeline request: " + request .getStructuredPipeline ());
1236+ logger .log (Level .FINEST , "Sending pipeline request: " + request .getStructuredPipeline ());
12321237
12331238 rpcContext .streamRequest (request , observer , rpcContext .getClient ().executePipelineCallable ());
12341239 }
0 commit comments