-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[realppl 6] offline ppl evaluation and tests #14852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ | |
#include "Firestore/core/src/api/expressions.h" | ||
#include "Firestore/core/src/api/ordering.h" | ||
#include "Firestore/core/src/model/model_fwd.h" | ||
#include "Firestore/core/src/model/resource_path.h" | ||
#include "Firestore/core/src/nanopb/message.h" | ||
#include "absl/types/optional.h" | ||
|
||
|
@@ -71,25 +72,29 @@ class EvaluableStage : public Stage { | |
EvaluableStage() = default; | ||
virtual ~EvaluableStage() = default; | ||
|
||
virtual absl::string_view name() const = 0; | ||
virtual model::PipelineInputOutputVector Evaluate( | ||
const EvaluateContext& context, | ||
const model::PipelineInputOutputVector& inputs) const = 0; | ||
}; | ||
|
||
class CollectionSource : public EvaluableStage { | ||
public: | ||
explicit CollectionSource(std::string path) : path_(std::move(path)) { | ||
} | ||
explicit CollectionSource(std::string path); | ||
~CollectionSource() override = default; | ||
|
||
google_firestore_v1_Pipeline_Stage to_proto() const override; | ||
|
||
absl::string_view name() const override { | ||
return "collection"; | ||
} | ||
|
||
model::PipelineInputOutputVector Evaluate( | ||
const EvaluateContext& context, | ||
const model::PipelineInputOutputVector& inputs) const override; | ||
|
||
private: | ||
std::string path_; | ||
model::ResourcePath path_; | ||
}; | ||
|
||
class DatabaseSource : public EvaluableStage { | ||
|
@@ -98,12 +103,17 @@ class DatabaseSource : public EvaluableStage { | |
~DatabaseSource() override = default; | ||
|
||
google_firestore_v1_Pipeline_Stage to_proto() const override; | ||
|
||
absl::string_view name() const override { | ||
return "database"; | ||
} | ||
|
||
model::PipelineInputOutputVector Evaluate( | ||
const EvaluateContext& context, | ||
const model::PipelineInputOutputVector& inputs) const override; | ||
}; | ||
|
||
class CollectionGroupSource : public Stage { | ||
class CollectionGroupSource : public EvaluableStage { | ||
public: | ||
explicit CollectionGroupSource(std::string collection_id) | ||
: collection_id_(std::move(collection_id)) { | ||
|
@@ -112,6 +122,14 @@ class CollectionGroupSource : public Stage { | |
|
||
google_firestore_v1_Pipeline_Stage to_proto() const override; | ||
|
||
absl::string_view name() const override { | ||
return "collection_group"; | ||
} | ||
|
||
model::PipelineInputOutputVector Evaluate( | ||
const EvaluateContext& context, | ||
const model::PipelineInputOutputVector& inputs) const override; | ||
|
||
private: | ||
std::string collection_id_; | ||
}; | ||
|
@@ -125,6 +143,10 @@ class DocumentsSource : public Stage { | |
|
||
google_firestore_v1_Pipeline_Stage to_proto() const override; | ||
|
||
absl::string_view name() const { | ||
return "documents"; | ||
} | ||
Comment on lines
+146
to
+148
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change was applied in a later PR. |
||
|
||
private: | ||
std::vector<std::string> documents_; | ||
}; | ||
|
@@ -167,6 +189,11 @@ class Where : public EvaluableStage { | |
~Where() override = default; | ||
|
||
google_firestore_v1_Pipeline_Stage to_proto() const override; | ||
|
||
absl::string_view name() const override { | ||
return "where"; | ||
} | ||
|
||
model::PipelineInputOutputVector Evaluate( | ||
const EvaluateContext& context, | ||
const model::PipelineInputOutputVector& inputs) const override; | ||
|
@@ -218,6 +245,11 @@ class LimitStage : public EvaluableStage { | |
~LimitStage() override = default; | ||
|
||
google_firestore_v1_Pipeline_Stage to_proto() const override; | ||
|
||
absl::string_view name() const override { | ||
return "limit"; | ||
} | ||
|
||
model::PipelineInputOutputVector Evaluate( | ||
const EvaluateContext& context, | ||
const model::PipelineInputOutputVector& inputs) const override; | ||
|
@@ -252,17 +284,29 @@ class SelectStage : public Stage { | |
std::unordered_map<std::string, std::shared_ptr<Expr>> fields_; | ||
}; | ||
|
||
class SortStage : public Stage { | ||
class SortStage : public EvaluableStage { | ||
public: | ||
explicit SortStage(std::vector<std::shared_ptr<Ordering>> orders) | ||
explicit SortStage(std::vector<Ordering> orders) | ||
: orders_(std::move(orders)) { | ||
} | ||
~SortStage() override = default; | ||
|
||
google_firestore_v1_Pipeline_Stage to_proto() const override; | ||
|
||
absl::string_view name() const override { | ||
return "sort"; | ||
} | ||
|
||
model::PipelineInputOutputVector Evaluate( | ||
const EvaluateContext& context, | ||
const model::PipelineInputOutputVector& inputs) const override; | ||
|
||
const std::vector<Ordering>& orders() const { | ||
return orders_; | ||
} | ||
|
||
private: | ||
std::vector<std::shared_ptr<Ordering>> orders_; | ||
std::vector<Ordering> orders_; | ||
}; | ||
|
||
class DistinctStage : public Stage { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not take
inputs
by copy instead of taking by reference and copying it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. The reason is not every stage needs to copy the inputs, some of them can work with a reference.
Also worth pointing out, documents are optimized for copy, the actual document content are usually not copied (they are held via shared_ptr).