You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "jhorstmann (via GitHub)" <gi...@apache.org> on 2026/08/27 21:10:14 UTC
Re: [PR] perf(arrow-array): Reduce binary size 0.5%: do `PrimitiveArray` → `ArrayData` conversion once, not per type [arrow-rs]
jhorstmann commented on code in PR #10893:
URL: https://github.com/apache/arrow-rs/pull/10893#discussion_r3875889938
##########
arrow-array/src/array/primitive_array.rs:
##########
@@ -1196,15 +1196,31 @@ impl<T: ArrowPrimitiveType> PrimitiveArray<T> {
impl<T: ArrowPrimitiveType> From<PrimitiveArray<T>> for ArrayData {
fn from(array: PrimitiveArray<T>) -> Self {
- let builder = ArrayDataBuilder::new(array.data_type)
- .len(array.values.len())
- .nulls(array.nulls)
- .buffers(vec![array.values.into_inner()]);
-
- unsafe { builder.build_unchecked() }
+ let len = array.values.len();
+ primitive_to_array_data(array.data_type, len, array.values.into_inner(), array.nulls)
Review Comment:
Nice improvement.
I think `primitive_to_array_data` needs to be `unsafe`, and the safety comment moved to the call here, since the new function does no validation on the parameters and calls `build_unchecked`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org