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
@@ -71,25 +72,29 @@ class EvaluableStage : public Stage {
71
72
EvaluableStage () = default ;
72
73
virtual ~EvaluableStage () = default ;
73
74
75
+ virtual absl::string_view name () const = 0;
74
76
virtual model::PipelineInputOutputVector Evaluate (
75
77
const EvaluateContext& context,
76
78
const model::PipelineInputOutputVector& inputs) const = 0;
77
79
};
78
80
79
81
class CollectionSource : public EvaluableStage {
80
82
public:
81
- explicit CollectionSource (std::string path) : path_(std::move(path)) {
82
- }
83
+ explicit CollectionSource (std::string path);
83
84
~CollectionSource () override = default ;
84
85
85
86
google_firestore_v1_Pipeline_Stage to_proto () const override ;
86
87
88
+ absl::string_view name () const override {
89
+ return " collection" ;
90
+ }
91
+
87
92
model::PipelineInputOutputVector Evaluate (
88
93
const EvaluateContext& context,
89
94
const model::PipelineInputOutputVector& inputs) const override ;
90
95
91
96
private:
92
- std::string path_;
97
+ model::ResourcePath path_;
93
98
};
94
99
95
100
class DatabaseSource : public EvaluableStage {
@@ -98,12 +103,17 @@ class DatabaseSource : public EvaluableStage {
98
103
~DatabaseSource () override = default ;
99
104
100
105
google_firestore_v1_Pipeline_Stage to_proto () const override ;
106
+
107
+ absl::string_view name () const override {
108
+ return " database" ;
109
+ }
110
+
101
111
model::PipelineInputOutputVector Evaluate (
102
112
const EvaluateContext& context,
103
113
const model::PipelineInputOutputVector& inputs) const override ;
104
114
};
105
115
106
- class CollectionGroupSource : public Stage {
116
+ class CollectionGroupSource : public EvaluableStage {
107
117
public:
108
118
explicit CollectionGroupSource (std::string collection_id)
109
119
: collection_id_(std::move(collection_id)) {
@@ -112,6 +122,14 @@ class CollectionGroupSource : public Stage {
112
122
113
123
google_firestore_v1_Pipeline_Stage to_proto () const override ;
114
124
125
+ absl::string_view name () const override {
126
+ return " collection_group" ;
127
+ }
128
+
129
+ model::PipelineInputOutputVector Evaluate (
130
+ const EvaluateContext& context,
131
+ const model::PipelineInputOutputVector& inputs) const override ;
132
+
115
133
private:
116
134
std::string collection_id_;
117
135
};
@@ -125,6 +143,10 @@ class DocumentsSource : public Stage {
125
143
126
144
google_firestore_v1_Pipeline_Stage to_proto () const override ;
127
145
146
+ absl::string_view name () const {
147
+ return " documents" ;
148
+ }
149
+
128
150
private:
129
151
std::vector<std::string> documents_;
130
152
};
@@ -167,6 +189,11 @@ class Where : public EvaluableStage {
167
189
~Where () override = default ;
168
190
169
191
google_firestore_v1_Pipeline_Stage to_proto () const override ;
192
+
193
+ absl::string_view name () const override {
194
+ return " where" ;
195
+ }
196
+
170
197
model::PipelineInputOutputVector Evaluate (
171
198
const EvaluateContext& context,
172
199
const model::PipelineInputOutputVector& inputs) const override ;
@@ -218,6 +245,11 @@ class LimitStage : public EvaluableStage {
218
245
~LimitStage () override = default ;
219
246
220
247
google_firestore_v1_Pipeline_Stage to_proto () const override ;
248
+
249
+ absl::string_view name () const override {
250
+ return " limit" ;
251
+ }
252
+
221
253
model::PipelineInputOutputVector Evaluate (
222
254
const EvaluateContext& context,
223
255
const model::PipelineInputOutputVector& inputs) const override ;
@@ -252,17 +284,29 @@ class SelectStage : public Stage {
252
284
std::unordered_map<std::string, std::shared_ptr<Expr>> fields_;
253
285
};
254
286
255
- class SortStage : public Stage {
287
+ class SortStage : public EvaluableStage {
256
288
public:
257
- explicit SortStage (std::vector<std::shared_ptr< Ordering> > orders)
289
+ explicit SortStage (std::vector<Ordering> orders)
258
290
: orders_(std::move(orders)) {
259
291
}
260
292
~SortStage () override = default ;
261
293
262
294
google_firestore_v1_Pipeline_Stage to_proto () const override ;
263
295
296
+ absl::string_view name () const override {
297
+ return " sort" ;
298
+ }
299
+
300
+ model::PipelineInputOutputVector Evaluate (
301
+ const EvaluateContext& context,
302
+ const model::PipelineInputOutputVector& inputs) const override ;
303
+
304
+ const std::vector<Ordering>& orders () const {
305
+ return orders_;
306
+ }
307
+
264
308
private:
265
- std::vector<std::shared_ptr< Ordering> > orders_;
309
+ std::vector<Ordering> orders_;
266
310
};
267
311
268
312
class DistinctStage : public Stage {
0 commit comments