2929#include " Firestore/core/src/api/expressions.h"
3030#include " Firestore/core/src/api/ordering.h"
3131#include " Firestore/core/src/model/model_fwd.h"
32+ #include " Firestore/core/src/model/resource_path.h"
3233#include " Firestore/core/src/nanopb/message.h"
3334#include " absl/types/optional.h"
3435
@@ -67,25 +68,29 @@ class EvaluableStage : public Stage {
6768 EvaluableStage () = default ;
6869 virtual ~EvaluableStage () = default ;
6970
71+ virtual absl::string_view name () const = 0;
7072 virtual model::PipelineInputOutputVector Evaluate (
7173 const EvaluateContext& context,
7274 const model::PipelineInputOutputVector& inputs) const = 0;
7375};
7476
7577class CollectionSource : public EvaluableStage {
7678 public:
77- explicit CollectionSource (std::string path) : path_(std::move(path)) {
78- }
79+ explicit CollectionSource (std::string path);
7980 ~CollectionSource () override = default ;
8081
8182 google_firestore_v1_Pipeline_Stage to_proto () const override ;
8283
84+ absl::string_view name () const override {
85+ return " collection" ;
86+ }
87+
8388 model::PipelineInputOutputVector Evaluate (
8489 const EvaluateContext& context,
8590 const model::PipelineInputOutputVector& inputs) const override ;
8691
8792 private:
88- std::string path_;
93+ model::ResourcePath path_;
8994};
9095
9196class DatabaseSource : public EvaluableStage {
@@ -94,12 +99,17 @@ class DatabaseSource : public EvaluableStage {
9499 ~DatabaseSource () override = default ;
95100
96101 google_firestore_v1_Pipeline_Stage to_proto () const override ;
102+
103+ absl::string_view name () const override {
104+ return " database" ;
105+ }
106+
97107 model::PipelineInputOutputVector Evaluate (
98108 const EvaluateContext& context,
99109 const model::PipelineInputOutputVector& inputs) const override ;
100110};
101111
102- class CollectionGroupSource : public Stage {
112+ class CollectionGroupSource : public EvaluableStage {
103113 public:
104114 explicit CollectionGroupSource (std::string collection_id)
105115 : collection_id_(std::move(collection_id)) {
@@ -108,6 +118,14 @@ class CollectionGroupSource : public Stage {
108118
109119 google_firestore_v1_Pipeline_Stage to_proto () const override ;
110120
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+
111129 private:
112130 std::string collection_id_;
113131};
@@ -121,6 +139,10 @@ class DocumentsSource : public Stage {
121139
122140 google_firestore_v1_Pipeline_Stage to_proto () const override ;
123141
142+ absl::string_view name () const {
143+ return " documents" ;
144+ }
145+
124146 private:
125147 std::vector<std::string> documents_;
126148};
@@ -163,6 +185,11 @@ class Where : public EvaluableStage {
163185 ~Where () override = default ;
164186
165187 google_firestore_v1_Pipeline_Stage to_proto () const override ;
188+
189+ absl::string_view name () const override {
190+ return " where" ;
191+ }
192+
166193 model::PipelineInputOutputVector Evaluate (
167194 const EvaluateContext& context,
168195 const model::PipelineInputOutputVector& inputs) const override ;
@@ -218,6 +245,11 @@ class LimitStage : public EvaluableStage {
218245 ~LimitStage () override = default ;
219246
220247 google_firestore_v1_Pipeline_Stage to_proto () const override ;
248+
249+ absl::string_view name () const override {
250+ return " limit" ;
251+ }
252+
221253 model::PipelineInputOutputVector Evaluate (
222254 const EvaluateContext& context,
223255 const model::PipelineInputOutputVector& inputs) const override ;
@@ -252,17 +284,29 @@ class SelectStage : public Stage {
252284 std::unordered_map<std::string, std::shared_ptr<Expr>> fields_;
253285};
254286
255- class SortStage : public Stage {
287+ class SortStage : public EvaluableStage {
256288 public:
257- explicit SortStage (std::vector<std::shared_ptr< Ordering> > orders)
289+ explicit SortStage (std::vector<Ordering> orders)
258290 : orders_(std::move(orders)) {
259291 }
260292 ~SortStage () override = default ;
261293
262294 google_firestore_v1_Pipeline_Stage to_proto () const override ;
263295
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+
264308 private:
265- std::vector<std::shared_ptr< Ordering> > orders_;
309+ std::vector<Ordering> orders_;
266310};
267311
268312class DistinctStage : public Stage {
0 commit comments