Skip to content

Commit b27c5b8

Browse files
committed
Tweaks
1 parent 42cc0e5 commit b27c5b8

File tree

4 files changed

+21
-48
lines changed

4 files changed

+21
-48
lines changed

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

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -82,35 +82,25 @@
8282
*/
8383
public final class Pipeline {
8484
private final ImmutableList<Stage> stages;
85-
private final String name;
8685

87-
private Pipeline(List<Stage> stages, String name) {
86+
private Pipeline(List<Stage> stages) {
8887
this.stages = ImmutableList.copyOf(stages);
89-
this.name = name;
9088
}
9189

9290
private Pipeline(Collection collection) {
93-
this(Lists.newArrayList(collection), collection.getPath());
91+
this(Lists.newArrayList(collection));
9492
}
9593

9694
private Pipeline(CollectionGroup group) {
97-
this(Lists.newArrayList(group), group.getCollectionId());
95+
this(Lists.newArrayList(group));
9896
}
9997

10098
private Pipeline(Database db) {
101-
this(Lists.newArrayList(db), db.getName());
99+
this(Lists.newArrayList(db));
102100
}
103101

104102
private Pipeline(Documents docs) {
105-
this(Lists.newArrayList(docs), docs.getName());
106-
}
107-
108-
public static Pipeline from(CollectionReference source) {
109-
return new Pipeline(new Collection(source.getPath()));
110-
}
111-
112-
public static Pipeline from(com.google.cloud.firestore.CollectionGroup source) {
113-
return new Pipeline(new CollectionGroup(source.options.getCollectionId()));
103+
this(Lists.newArrayList(docs));
114104
}
115105

116106
public static Pipeline fromCollection(String collectionName) {
@@ -165,51 +155,46 @@ public Pipeline addFields(Selectable... fields) {
165155
ImmutableList.<Stage>builder()
166156
.addAll(stages)
167157
.add(new AddFields(projectablesToMap(fields)))
168-
.build(),
169-
name);
158+
.build());
170159
}
171160

172161
public Pipeline select(Selectable... projections) {
173162
return new Pipeline(
174163
ImmutableList.<Stage>builder()
175164
.addAll(stages)
176165
.add(new Select(projectablesToMap(projections)))
177-
.build(),
178-
name);
166+
.build());
179167
}
180168

181169
public Pipeline select(String... fields) {
182170
return new Pipeline(
183171
ImmutableList.<Stage>builder()
184172
.addAll(stages)
185173
.add(new Select(fieldNamesToMap(fields)))
186-
.build(),
187-
name);
174+
.build());
188175
}
189176

190177
public Pipeline filter(FilterCondition condition) {
191178
return new Pipeline(
192179
ImmutableList.<Stage>builder()
193180
.addAll(stages)
194181
.add(new com.google.cloud.firestore.pipeline.stages.Filter(condition))
195-
.build(),
196-
name);
182+
.build());
197183
}
198184

199185
public Pipeline offset(int offset) {
200186
return new Pipeline(
201-
ImmutableList.<Stage>builder().addAll(stages).add(new Offset(offset)).build(), name);
187+
ImmutableList.<Stage>builder().addAll(stages).add(new Offset(offset)).build());
202188
}
203189

204190
public Pipeline limit(int limit) {
205191
return new Pipeline(
206-
ImmutableList.<Stage>builder().addAll(stages).add(new Limit(limit)).build(), name);
192+
ImmutableList.<Stage>builder().addAll(stages).add(new Limit(limit)).build());
207193
}
208194

209195
public Pipeline aggregate(AggregatorTarget... aggregators) {
210196
return new Pipeline(
211-
ImmutableList.<Stage>builder().addAll(stages).add(new Aggregate(aggregators)).build(),
212-
name);
197+
ImmutableList.<Stage>builder().addAll(stages).add(new Aggregate(aggregators)).build());
213198
}
214199

215200
public Pipeline findNearest(
@@ -226,17 +211,15 @@ public Pipeline findNearest(
226211
.add(
227212
new FindNearest(
228213
property, vector, options)) // Assuming FindNearest takes these arguments
229-
.build(),
230-
name);
214+
.build());
231215
}
232216

233217
public Pipeline sort(List<Ordering> orders, Sort.Density density, Sort.Truncation truncation) {
234218
return new Pipeline(
235219
ImmutableList.<Stage>builder()
236220
.addAll(stages)
237221
.add(new Sort(orders, density, truncation))
238-
.build(),
239-
name);
222+
.build());
240223
}
241224

242225
// Sugar
@@ -258,8 +241,7 @@ public Pipeline genericStage(String name, Map<String, Object> params) {
258241
name,
259242
Lists.newArrayList(
260243
params.values()))) // Assuming GenericStage takes a list of params
261-
.build(),
262-
name);
244+
.build());
263245
}
264246

265247
public ApiFuture<List<PipelineResult>> execute(Firestore db) {

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2122,8 +2122,10 @@ public AggregateQuery aggregate(
21222122
@Nonnull
21232123
public Pipeline toPipeline() {
21242124
// From
2125-
Pipeline ppl =
2126-
Pipeline.fromCollection(
2125+
Pipeline ppl = this.options.getAllDescendants() ?
2126+
Pipeline.fromCollectionGroup(
2127+
this.options.getCollectionId())
2128+
: Pipeline.fromCollection(
21272129
this.options.getParentPath().append(this.options.getCollectionId()).getPath());
21282130

21292131
// Filters

google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/AggregatorTarget.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.google.cloud.firestore.pipeline.expressions;
22

3-
public final class AggregatorTarget implements Selectable, Accumulator {
3+
public final class AggregatorTarget implements Selectable{
44
private final Accumulator accumulator;
55
private final String fieldName;
66

@@ -17,9 +17,4 @@ public Accumulator getAccumulator() {
1717
public String getFieldName() {
1818
return fieldName;
1919
}
20-
21-
@Override
22-
public AggregatorTarget toField(String fieldName) {
23-
return null;
24-
}
2520
}

google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Function.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,6 @@ public static Or or(FilterCondition left, FilterCondition... other) {
164164
return new Or(conditions);
165165
}
166166

167-
// File: FunctionUtils.java (or similar)
168-
169-
// ... other static methods ...
170-
171167
public static ArrayContains arrayContains(Expr expr, Expr element) {
172168
return new ArrayContains(expr, element);
173169
}
@@ -218,7 +214,7 @@ public static IsNull isNull(String field) {
218214
return new IsNull(Field.of(field));
219215
}
220216

221-
public static Not not(Expr expr) {
217+
public static Not not(FilterCondition expr) {
222218
return new Not(expr);
223219
}
224220

@@ -238,8 +234,6 @@ public static Avg avg(String field) {
238234
return new Avg(Field.of(field), false);
239235
}
240236

241-
// Note: There seems to be a typo in the Kotlin code.
242-
// `min` and `max` are calling `Sum` and `Avg` constructors respectively
243237
public static Min min(Expr expr) {
244238
return new Min(expr, false); // Corrected constructor call
245239
}

0 commit comments

Comments
 (0)