29
29
#include " Firestore/core/src/api/expressions.h"
30
30
#include " Firestore/core/src/api/ordering.h"
31
31
#include " Firestore/core/src/model/model_fwd.h"
32
+ #include " Firestore/core/src/model/resource_path.h"
32
33
#include " Firestore/core/src/nanopb/message.h"
33
34
#include " absl/types/optional.h"
34
35
@@ -68,25 +69,29 @@ class EvaluableStage : public Stage {
68
69
EvaluableStage () = default ;
69
70
virtual ~EvaluableStage () = default ;
70
71
72
+ virtual absl::string_view name () const = 0;
71
73
virtual model::PipelineInputOutputVector Evaluate (
72
74
const EvaluateContext& context,
73
75
const model::PipelineInputOutputVector& inputs) const = 0;
74
76
};
75
77
76
78
class CollectionSource : public EvaluableStage {
77
79
public:
78
- explicit CollectionSource (std::string path) : path_(std::move(path)) {
79
- }
80
+ explicit CollectionSource (std::string path);
80
81
~CollectionSource () override = default ;
81
82
82
83
google_firestore_v1_Pipeline_Stage to_proto () const override ;
83
84
85
+ absl::string_view name () const override {
86
+ return " collection" ;
87
+ }
88
+
84
89
model::PipelineInputOutputVector Evaluate (
85
90
const EvaluateContext& context,
86
91
const model::PipelineInputOutputVector& inputs) const override ;
87
92
88
93
private:
89
- std::string path_;
94
+ model::ResourcePath path_;
90
95
};
91
96
92
97
class DatabaseSource : public EvaluableStage {
@@ -95,12 +100,17 @@ class DatabaseSource : public EvaluableStage {
95
100
~DatabaseSource () override = default ;
96
101
97
102
google_firestore_v1_Pipeline_Stage to_proto () const override ;
103
+
104
+ absl::string_view name () const override {
105
+ return " database" ;
106
+ }
107
+
98
108
model::PipelineInputOutputVector Evaluate (
99
109
const EvaluateContext& context,
100
110
const model::PipelineInputOutputVector& inputs) const override ;
101
111
};
102
112
103
- class CollectionGroupSource : public Stage {
113
+ class CollectionGroupSource : public EvaluableStage {
104
114
public:
105
115
explicit CollectionGroupSource (std::string collection_id)
106
116
: collection_id_(std::move(collection_id)) {
@@ -109,6 +119,14 @@ class CollectionGroupSource : public Stage {
109
119
110
120
google_firestore_v1_Pipeline_Stage to_proto () const override ;
111
121
122
+ absl::string_view name () const override {
123
+ return " collection_group" ;
124
+ }
125
+
126
+ model::PipelineInputOutputVector Evaluate (
127
+ const EvaluateContext& context,
128
+ const model::PipelineInputOutputVector& inputs) const override ;
129
+
112
130
private:
113
131
std::string collection_id_;
114
132
};
@@ -122,6 +140,10 @@ class DocumentsSource : public Stage {
122
140
123
141
google_firestore_v1_Pipeline_Stage to_proto () const override ;
124
142
143
+ absl::string_view name () const {
144
+ return " documents" ;
145
+ }
146
+
125
147
private:
126
148
std::vector<std::string> documents_;
127
149
};
@@ -164,6 +186,11 @@ class Where : public EvaluableStage {
164
186
~Where () override = default ;
165
187
166
188
google_firestore_v1_Pipeline_Stage to_proto () const override ;
189
+
190
+ absl::string_view name () const override {
191
+ return " where" ;
192
+ }
193
+
167
194
model::PipelineInputOutputVector Evaluate (
168
195
const EvaluateContext& context,
169
196
const model::PipelineInputOutputVector& inputs) const override ;
@@ -215,6 +242,11 @@ class LimitStage : public EvaluableStage {
215
242
~LimitStage () override = default ;
216
243
217
244
google_firestore_v1_Pipeline_Stage to_proto () const override ;
245
+
246
+ absl::string_view name () const override {
247
+ return " limit" ;
248
+ }
249
+
218
250
model::PipelineInputOutputVector Evaluate (
219
251
const EvaluateContext& context,
220
252
const model::PipelineInputOutputVector& inputs) const override ;
@@ -249,17 +281,29 @@ class SelectStage : public Stage {
249
281
std::unordered_map<std::string, std::shared_ptr<Expr>> fields_;
250
282
};
251
283
252
- class SortStage : public Stage {
284
+ class SortStage : public EvaluableStage {
253
285
public:
254
- explicit SortStage (std::vector<std::shared_ptr< Ordering> > orders)
286
+ explicit SortStage (std::vector<Ordering> orders)
255
287
: orders_(std::move(orders)) {
256
288
}
257
289
~SortStage () override = default ;
258
290
259
291
google_firestore_v1_Pipeline_Stage to_proto () const override ;
260
292
293
+ absl::string_view name () const override {
294
+ return " sort" ;
295
+ }
296
+
297
+ model::PipelineInputOutputVector Evaluate (
298
+ const EvaluateContext& context,
299
+ const model::PipelineInputOutputVector& inputs) const override ;
300
+
301
+ const std::vector<Ordering>& orders () const {
302
+ return orders_;
303
+ }
304
+
261
305
private:
262
- std::vector<std::shared_ptr< Ordering> > orders_;
306
+ std::vector<Ordering> orders_;
263
307
};
264
308
265
309
class DistinctStage : public Stage {
0 commit comments