-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[realppl 2] Minimalistic ppl offline evaluation #14827
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
base: wuandy/RealPpl_1
Are you sure you want to change the base?
Conversation
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback. |
Generated by 🚫 Danger |
7c6e249
to
f7cc868
Compare
e43ea96
to
c950299
Compare
public: | ||
explicit Field(std::string name) : name_(std::move(name)) { | ||
~Selectable() override = default; |
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.
It's better to use virtual ~Selectable() override = default;
the rule of thumb is: if a class has at least one virtual function, it should have a virtual destructor
RealtimePipeline(std::vector<std::shared_ptr<EvaluableStage>> stages, | ||
remote::Serializer serializer); | ||
|
||
RealtimePipeline AddingStage(std::shared_ptr<EvaluableStage> 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.
should this be AddStage
?
@@ -43,24 +49,55 @@ class Stage { | |||
virtual google_firestore_v1_Pipeline_Stage to_proto() const = 0; | |||
}; | |||
|
|||
class CollectionSource : public Stage { | |||
class EvaluateContext { |
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.
Is there going to be more stuff added to the EvaluateContext?
As of right now it's just a wrapper around remote::Serializer and it's not clear why it's needed. For example, EvaluableStage constructor could just take a remote::Serializer parameter rather than an EvaluateContext parameter.
remote::Serializer* serializer_; | ||
}; | ||
|
||
class EvaluableStage : 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.
Please add a brief comment above each class to highlight its purpose and intended usage.
const model::PipelineInputOutputVector& inputs) const = 0; | ||
}; | ||
|
||
class CollectionSource : public EvaluableStage { |
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.
It's not clear why some stages below are EvaluableStage
s but some aren't. Is it just because you haven't implemented them yet?
return EvaluateResult(ResultType::kUnset, | ||
nanopb::Message<google_firestore_v1_Value>()); |
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.
same
if (model::GetTypeOrder(*left.value()) != | ||
model::GetTypeOrder(*right.value())) { | ||
return EvaluateResult::NewValue(nanopb::MakeMessage(model::FalseValue())); | ||
} | ||
if (model::IsNaNValue(*left.value()) || model::IsNaNValue(*right.value())) { | ||
return EvaluateResult::NewValue(nanopb::MakeMessage(model::FalseValue())); | ||
} | ||
|
||
// TODO(pipeline): Port strictEquals from web | ||
if (model::Equals(*left.value(), *right.value())) { | ||
return EvaluateResult::NewValue(nanopb::MakeMessage(model::TrueValue())); | ||
} else { | ||
return EvaluateResult::NewValue(nanopb::MakeMessage(model::FalseValue())); | ||
} |
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.
ideally we should reuse the logic from model::Equals, and replace this whole block with:
if (model::Equals(*left.value(), *right.value())) {
return EvaluateResult::NewValue(nanopb::MakeMessage(model::TrueValue()));
} else {
return EvaluateResult::NewValue(nanopb::MakeMessage(model::FalseValue()));
}
I see some discrepancy. For example: on line 169 we are saying NaN is not equal to any other value, but value comparison logic says NaN is equal to NaN.
return EvaluateResult(ResultType::kBoolean, std::move(value)); | ||
} else if (model::IsInteger(*value)) { | ||
return EvaluateResult(ResultType::kInt, std::move(value)); | ||
} else if (model::IsDouble(*value)) { | ||
return EvaluateResult(ResultType::kDouble, std::move(value)); | ||
} else if (value->which_value_type == | ||
google_firestore_v1_Value_timestamp_value_tag) { | ||
return EvaluateResult(ResultType::kTimestamp, std::move(value)); | ||
} else if (value->which_value_type == | ||
google_firestore_v1_Value_string_value_tag) { | ||
return EvaluateResult(ResultType::kString, std::move(value)); | ||
} else if (value->which_value_type == | ||
google_firestore_v1_Value_bytes_value_tag) { | ||
return EvaluateResult(ResultType::kBytes, std::move(value)); | ||
} else if (value->which_value_type == | ||
google_firestore_v1_Value_reference_value_tag) { | ||
return EvaluateResult(ResultType::kReference, std::move(value)); | ||
} else if (value->which_value_type == | ||
google_firestore_v1_Value_geo_point_value_tag) { | ||
return EvaluateResult(ResultType::kGeoPoint, std::move(value)); | ||
} else if (model::IsArray(*value)) { | ||
return EvaluateResult(ResultType::kArray, std::move(value)); | ||
} else if (model::IsVectorValue(*value)) { | ||
// vector value must be before map value | ||
return EvaluateResult(ResultType::kVector, std::move(value)); | ||
} else if (model::IsMap(*value)) { | ||
return EvaluateResult(ResultType::kMap, std::move(value)); | ||
} else { | ||
return EvaluateResult(ResultType::kError, {}); |
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.
nit: you can use brace initialization for all of EvaluateResult(...)
here. e.g.
return {ResultType::kBoolean, std::move(value)};
/** Represents the result of evaluating an expression. */ | ||
class EvaluateResult { | ||
public: | ||
enum class ResultType { |
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.
Presumably we'll need to add the Extended Types here in the future? :'-)
|
||
auto x = results.size(); | ||
EXPECT_EQ(x, 1); | ||
// EXPECT_THAT(RunPipeline(ppl, {doc1, doc2, doc3}), Returns({doc1})); |
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.
commented code.
Also need to add a unit test for each kind of EvaluableExpr
No description provided.