-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Ppl API #14513
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: cheryllin/ppl
Are you sure you want to change the base?
Ppl API #14513
Conversation
Generated by 🚫 Danger |
f5f8445
to
5b2bd88
Compare
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.
Looks good overall, some minor nits.
@@ -40,6 +40,20 @@ void Pipeline::execute(util::StatusOrCallback<PipelineSnapshot> callback) { | |||
this->firestore_->RunPipeline(*this, std::move(callback)); | |||
} | |||
|
|||
google_firestore_v1_Value Pipeline::to_proto() const { |
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.
Where is this used?
Serializer::EncodePipeline does the same thing. If you want to move it here, we should update the logic there.
Firestore/core/src/api/stages.cc
Outdated
: expr_(std::move(expr)), field_name_(absl::nullopt) { | ||
} | ||
ReplaceWith::ReplaceWith(std::string field_name) | ||
: expr_(nullptr), field_name_(std::move(field_name)) { |
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.
How does this stage work? I am not sure i understand the implementation. Is it:
- if expr_ is set, and if it is a map, it will replace the input document?
- if field_name_ is set, it is evaluated against the document, and if it is a map it will replace the input document?
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.
I think I make some mistakes here and make it overly complicated. I have change the implementation in the latest commit, which basically convert "field_name" to Expr in the Swift side.
: orders_(std::move(orders)) { | ||
} | ||
~SortStage() override = default; | ||
|
||
google_firestore_v1_Pipeline_Stage to_proto() const override; | ||
|
||
private: | ||
std::vector<Ordering> orders_; | ||
std::vector<std::shared_ptr<Ordering>> orders_; |
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 a pointer is needed here? I think we only needed if you want polymorphism?
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.
Since in objective C file, if the c++ class is a class member field, it can only be created using pointer type. For example,
@implementation FIRFunctionExprBridge {
Ordering cpp_order;
}
will lead to compile error.
So use shared_ptr will make code a lot easier.
.collection(path: "/foo") | ||
.where(eq(field("foo"), constant("bar"))) | ||
.collection("/foo") | ||
.where(Field("foo") == Constant("bar")) |
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.
I thought we would move away from operator overload?
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.
Yes, I have changed it in the new commit. However, I still want to keep && , ||, and !. I will discuss with Nick later this week.
"awards": ["hugo": true, "nebula": true], | ||
], | ||
] | ||
|
||
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *) | ||
class PipelineIntegrationTests: FSTIntegrationTestCase { |
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.
Do these tests pass locally at least?
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.
Yes, all three tests passed test against nightly.
|
||
import FirebaseFirestore | ||
|
||
final class PipelineTests: FSTIntegrationTestCase { |
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.
I do not think we need to keep this file around. It serves a purpose as a way to check for compilation errors, but we can just move them to the test below and actually run them.
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.
I agree these tests here can be convert to integration tests which verify the result. However, I would like the Swift integration test file consistent with other platforms in order for easy maintenance in the future.
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
enum Helper { |
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 an enum instead of a struct or class? Is this a swift convention?
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.
Since Helper class only contains "static" methods, it should not be construct by itself. Since it is used internally, if we have other use case in the future, we can change it to struct.
import Foundation | ||
|
||
// TODO: the implementation of `Expr` is not complete | ||
public protocol Expr: Sendable { |
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.
All of these should have public documentation, with code samples.
} | ||
} | ||
|
||
/// Adds new fields to outputs from previous stages. |
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.
I believe other platforms include code samples of how to use this stage. Please add them here as well.
No description provided.