Skip to content

Conversation

@scovich
Copy link
Contributor

@scovich scovich commented Sep 13, 2025

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.

  • Closes #NNN.

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. ArrowToVariantRowBuilder is already an enum, so it makes sense for VariantToArrowRowBuilder to 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.

@github-actions github-actions bot added the parquet-variant parquet-variant* crates label Sep 13, 2025
@scovich
Copy link
Contributor Author

scovich commented Sep 13, 2025

@alamb -- interested to hear your thoughts on this change?

Copy link
Contributor

@alamb alamb left a 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>> {
Copy link
Contributor

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.

@mbrobbel mbrobbel merged commit 378e9c2 into apache:main Sep 15, 2025
12 checks passed
@mbrobbel
Copy link
Member

Thanks @scovich

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parquet-variant parquet-variant* crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants