tustvold commented on code in PR #5922:
URL: https://github.com/apache/arrow-rs/pull/5922#discussion_r1650033053


##########
arrow-array/src/array/byte_view_array.rs:
##########
@@ -429,6 +514,40 @@ impl<T: ByteViewType + ?Sized> From<ArrayData> for 
GenericByteViewArray<T> {
     }
 }
 
+impl<FROM, V> From<&GenericByteArray<FROM>> for GenericByteViewArray<V>
+where
+    FROM: ByteArrayType,
+    FROM::Offset: OffsetSizeTrait + ToPrimitive,
+    V: ByteViewType,
+    FROM::Native: PartialEq<V::Native>, // this prevent users to convert 
between byte and string types.
+{
+    fn from(value: &GenericByteArray<FROM>) -> Self {
+        let byte_array = value;
+        let len = byte_array.len();
+        let str_values_buf = byte_array.values().clone();
+        let offsets = byte_array.offsets();
+
+        let mut views_builder = 
GenericByteViewBuilder::<V>::with_capacity(len);

Review Comment:
   A more efficient mechanism would be to inspect the offsets and if the max 
offset is `< u32::MAX` we can avoid copying the string data and just reuse the 
buffer



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