tustvold commented on code in PR #5015:
URL: https://github.com/apache/arrow-rs/pull/5015#discussion_r1379824674
##########
arrow-cast/src/cast.rs:
##########
@@ -2317,6 +2341,23 @@ fn value_to_string<O: OffsetSizeTrait>(
Ok(Arc::new(builder.finish()))
}
+fn cast_numeric_to_binary<FROM: ArrowPrimitiveType, O: OffsetSizeTrait>(
+ array: &dyn Array,
+) -> Result<ArrayRef, ArrowError> {
+ let array = array.as_primitive::<FROM>();
+
+ let mut builder =
+ GenericBinaryBuilder::<O>::with_capacity(array.len(),
array.values().inner().capacity());
Review Comment:
This actually made me wonder if we could not do something even simpler like
```
let array = array.as_primitive::<FROM>();
let size = std::mem::size_of::<FROM::Native>().usize_as();
let offsets =
OffsetBuffer::from_lengths(std::iter::repeat(size).take(array.len());
Ok(GenericBinaryArray::<O>::new(offsets, array.values().inner().clone(),
array.nulls().cloned()))
```
--
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]