RinChanNOWWW commented on code in PR #5686:
URL: https://github.com/apache/arrow-rs/pull/5686#discussion_r1580923532


##########
arrow-cast/src/cast/mod.rs:
##########
@@ -2238,6 +2249,50 @@ where
     Ok(Arc::new(GenericByteArray::<TO>::from(array_data)))
 }
 
+/// Helper function to cast from one `ByteArrayType` array to `ByteViewType` 
array.
+fn cast_byte_to_view<FROM, V>(array: &dyn Array) -> Result<ArrayRef, 
ArrowError>
+where
+    FROM: ByteArrayType,
+    FROM::Offset: OffsetSizeTrait + ToPrimitive,
+    V: ByteViewType,
+{
+    let data = array.to_data();
+    let len = array.len();
+    assert_eq!(data.data_type(), &FROM::DATA_TYPE);
+    let str_values_buf = data.buffers()[1].clone();
+    let offsets = data.buffers()[0].typed_data::<FROM::Offset>();
+
+    let mut views_builder = BufferBuilder::<u128>::new(len);
+    for w in offsets.windows(2) {
+        let offset = w[0].to_u32().unwrap();
+        let end = w[1].to_u32().unwrap();
+        let value_buf = &str_values_buf[offset as usize..end as usize];
+        let length = end - offset;
+
+        if length <= 12 {

Review Comment:
   The new enum `View` looks good to me.



-- 
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]

Reply via email to