alamb commented on code in PR #5704:
URL: https://github.com/apache/arrow-rs/pull/5704#discussion_r1591175126
##########
arrow-cast/src/cast/mod.rs:
##########
@@ -2299,6 +2307,32 @@ where
}))
}
+/// Helper function to cast from one `ByteViewType` array to `ByteArrayType`
array.
+fn cast_view_to_byte<FROM, TO>(array: &dyn Array) -> Result<ArrayRef,
ArrowError>
+where
+ FROM: ByteViewType,
+ TO: ByteArrayType,
+ FROM::Native: AsRef<TO::Native>,
+{
+ let data = array.to_data();
+ let view_array = GenericByteViewArray::<FROM>::from(data);
+
+ let len = view_array.len();
+ let bytes = view_array
+ .views()
+ .iter()
+ .map(|v| ByteView::from(*v).length as usize)
+ .sum::<usize>();
+
+ let mut byte_array_builder = GenericByteBuilder::<TO>::with_capacity(len,
bytes);
+
+ for val in view_array.iter() {
+ byte_array_builder.append_option(val);
Review Comment:
I suspect we could potentially make this code faster by special casing when
there are no nulls
--
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]