-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[Variant] Make VariantToArrowRowBuilder an enum #8345
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
Conversation
|
@alamb -- interested to hear your thoughts on this change? |
alamb
left a comment
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.
Thanks @scovich -- I think this looks like a nice change to me
I am not sure I have ever seen the overhead of an enum vs trait measured or really making a difference, but I personally do find the enums easier to work with and removing Box'es (aka allocations) is never a bad idea in my opinion as long as it doesn't make the code harder to understand
So all in all, 👍
cc @codephage2020 and @klion26
| data_type: Option<&'a datatypes::DataType>, | ||
| data_type: Option<&'a DataType>, | ||
| cast_options: &'a CastOptions, | ||
| ) -> Result<Box<dyn VariantToArrowRowBuilder + 'a>> { |
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.
Remioving this Box seems like a good idea to me.
|
Thanks @scovich |
Which issue does this PR close?
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax.
Rationale for this change
Enum dispatch in rust is more efficient than virtual method dispatch, and enums require far less boxing which makes them more memory efficient as well.
ArrowToVariantRowBuilderis already an enum, so it makes sense forVariantToArrowRowBuilderto take the same approach.What changes are included in this PR?
Replace the trait with an enum.
Are these changes tested?
Yes, existing row builder tests continue to pass.
Are there any user-facing changes?
No.