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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]