Skip to content

perf: Avoid ArrayData allocation in PrimitiveArray::reinterpret_cast#9129

Merged
alamb merged 3 commits intoapache:mainfrom
alamb:alamb/avoid_array_data_in_reinterpret_cast
Jan 11, 2026
Merged

perf: Avoid ArrayData allocation in PrimitiveArray::reinterpret_cast#9129
alamb merged 3 commits intoapache:mainfrom
alamb:alamb/avoid_array_data_in_reinterpret_cast

Conversation

@alamb
Copy link
Copy Markdown
Contributor

@alamb alamb commented Jan 9, 2026

Which issue does this PR close?

Rationale for this change

While studying / profiling the Parquet reader I have noticed several places where unecessary allocations are happening

What changes are included in this PR?

Avoid ArrayData allocation in PrimitiveArray::reinterpret_cast

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions Bot added the arrow Changes to the arrow crate label Jan 9, 2026
// SAFETY:
// Native type is the same
PrimitiveArray::from(unsafe { d.build_unchecked() })
PrimitiveArray::new(self.values.clone(), self.nulls.clone())
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bonus points that it removes some unsafe

@alamb alamb marked this pull request as ready for review January 9, 2026 21:24
Copy link
Copy Markdown
Contributor

@scovich scovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@alamb
Copy link
Copy Markdown
Contributor Author

alamb commented Jan 11, 2026

Thanks @Jefffrey and @scovich

@alamb alamb merged commit 601be25 into apache:main Jan 11, 2026
26 checks passed
Dandandan pushed a commit to Dandandan/arrow-rs that referenced this pull request Jan 15, 2026
…pache#9129)

# Which issue does this PR close?

- part of apache#9128

# Rationale for this change

While studying / profiling the Parquet reader I have noticed several
places where unecessary allocations are happening

# What changes are included in this PR?

Avoid ArrayData allocation in `PrimitiveArray::reinterpret_cast`

# Are these changes tested?

<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code

If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->

# Are there any user-facing changes?

<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.

If there are any breaking changes to public APIs, please call them out.
-->

---------

Co-authored-by: Jeffrey Vo <jeffrey.vo.australia@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants