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
@@ -67,25 +68,29 @@ class EvaluableStage : public Stage {
67
68
EvaluableStage () = default ;
68
69
virtual ~EvaluableStage () = default ;
69
70
71
+ virtual absl::string_view name () const = 0;
70
72
virtual model::PipelineInputOutputVector Evaluate (
71
73
const EvaluateContext& context,
72
74
const model::PipelineInputOutputVector& inputs) const = 0;
73
75
};
74
76
75
77
class CollectionSource : public EvaluableStage {
76
78
public:
77
- explicit CollectionSource (std::string path) : path_(std::move(path)) {
78
- }
79
+ explicit CollectionSource (std::string path);
79
80
~CollectionSource () override = default ;
80
81
81
82
google_firestore_v1_Pipeline_Stage to_proto () const override ;
82
83
84
+ absl::string_view name () const override {
85
+ return " collection" ;
86
+ }
87
+
83
88
model::PipelineInputOutputVector Evaluate (
84
89
const EvaluateContext& context,
85
90
const model::PipelineInputOutputVector& inputs) const override ;
86
91
87
92
private:
88
- std::string path_;
93
+ model::ResourcePath path_;
89
94
};
90
95
91
96
class DatabaseSource : public EvaluableStage {
@@ -94,12 +99,17 @@ class DatabaseSource : public EvaluableStage {
94
99
~DatabaseSource () override = default ;
95
100
96
101
google_firestore_v1_Pipeline_Stage to_proto () const override ;
102
+
103
+ absl::string_view name () const override {
104
+ return " database" ;
105
+ }
106
+
97
107
model::PipelineInputOutputVector Evaluate (
98
108
const EvaluateContext& context,
99
109
const model::PipelineInputOutputVector& inputs) const override ;
100
110
};
101
111
102
- class CollectionGroupSource : public Stage {
112
+ class CollectionGroupSource : public EvaluableStage {
103
113
public:
104
114
explicit CollectionGroupSource (std::string collection_id)
105
115
: collection_id_(std::move(collection_id)) {
@@ -108,6 +118,14 @@ class CollectionGroupSource : public Stage {
108
118
109
119
google_firestore_v1_Pipeline_Stage to_proto () const override ;
110
120
121
+ absl::string_view name () const override {
122
+ return " collection_group" ;
123
+ }
124
+
125
+ model::PipelineInputOutputVector Evaluate (
126
+ const EvaluateContext& context,
127
+ const model::PipelineInputOutputVector& inputs) const override ;
128
+
111
129
private:
112
130
std::string collection_id_;
113
131
};
@@ -121,6 +139,10 @@ class DocumentsSource : public Stage {
121
139
122
140
google_firestore_v1_Pipeline_Stage to_proto () const override ;
123
141
142
+ absl::string_view name () const {
143
+ return " documents" ;
144
+ }
145
+
124
146
private:
125
147
std::vector<std::string> documents_;
126
148
};
@@ -163,6 +185,11 @@ class Where : public EvaluableStage {
163
185
~Where () override = default ;
164
186
165
187
google_firestore_v1_Pipeline_Stage to_proto () const override ;
188
+
189
+ absl::string_view name () const override {
190
+ return " where" ;
191
+ }
192
+
166
193
model::PipelineInputOutputVector Evaluate (
167
194
const EvaluateContext& context,
168
195
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