-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
GH-43258: [C++][Flight] Use a Base CRTP type for the types used in RPC calls #43255
Conversation
cpp/src/arrow/flight/types.h
Outdated
/// \brief Serialize this message to its wire-format representation. | ||
arrow::Result<std::string> SerializeToString() const; | ||
arrow::Status DoSerializeToString(std::string* out) 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.
Can we make the impls protected and/or update the docstrings to make it clear that these are internal?
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.
Making them private breaks self()->Do...
calls in the CRTP base class. I could work around this with friend
annotations, but to be frank, it was my intention to have these as public functions as well because if I ever deserialize object in a loop, I can re-use an std::string
and avoid mallocs.
I will add docstrings telling users that they can call Seria...
because they are more convenient.
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'd really rather not have so many different methods. If we're going to keep them, please at least make them overloads (so drop the 'Do') since they are just the same methods implemented in terms of each other.
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.
Just reiterating the comment above.
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 will drop the Do-
prefix.
I'd really rather not have so many different methods.
If I'm going to automatically generate code (for FlightSQL), the functions that take std::string*
produce much less binary bloat than Result<T>
which is why this is the pattern adopted in protobuf itself.
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.
Ok, sounds good to me.
To make it more consistent with the rest of serialization code. This reduces code size in ~4KiB.
It's small compared to the gigantic arrow library, but any reduction is good IMO. |
After merging your PR, Conbench analyzed the 0 benchmarking runs that have been run so far on merge-commit 9fb1129. None of the specified runs were found on the Conbench server. The full Conbench report has more details. |
Rationale for this change
Flight should eventually be buildable without a specific protobuf version. As such, all the protobuf types are wrapped in hand-written classes. Uniformity of the interface is not enforced even though it's desirable. Extending the interface requires adding functions to every struct. A common base class can mitigates risks and reduce the amount of hand-written code.
What changes are included in this PR?
SerializeToBuffer
to all the typesAre these changes tested?
By existing tests.