alamb commented on code in PR #9114:
URL: https://github.com/apache/arrow-rs/pull/9114#discussion_r2679552465


##########
arrow-array/src/array/byte_view_array.rs:
##########
@@ -967,15 +967,16 @@ impl<'a, T: ByteViewType + ?Sized> IntoIterator for &'a 
GenericByteViewArray<T>
 }
 
 impl<T: ByteViewType + ?Sized> From<ArrayData> for GenericByteViewArray<T> {
-    fn from(value: ArrayData) -> Self {
-        let views = value.buffers()[0].clone();
-        let views = ScalarBuffer::new(views, value.offset(), value.len());
-        let buffers = value.buffers()[1..].to_vec().into();
+    fn from(data: ArrayData) -> Self {
+        let (_data_type, len, nulls, offset, mut buffers, _child_data) = 
data.into_parts();
+        let views = buffers.remove(0); // need to maintain order of remaining 
buffers
+        let buffers = buffers.into(); // convert to Arc

Review Comment:
   > Is this equivalent?
   
   Yes, and I think it is clearer. I will make that change. 
   
   >  I was going to ask the same thing... except for Arc::new.
   
   I think technically `Arc::new()` would make `Arc<Vec<..>>` rather than 
`Arc<[..]>`
   
   The difference being that I think Vec is slightly larger than a `Arc<[]>` 
(it has another usize for the capacity)



##########
arrow-array/src/array/struct_array.rs:
##########
@@ -347,25 +347,26 @@ impl StructArray {
 
 impl From<ArrayData> for StructArray {
     fn from(data: ArrayData) -> Self {
-        let parent_offset = data.offset();
-        let parent_len = data.len();
+        let (data_type, len, nulls, offset, _buffers, child_data) = 
data.into_parts();
 
-        let fields = data
-            .child_data()
-            .iter()
+        let parent_offset = offset;
+        let parent_len = len;
+
+        let fields = child_data
+            .into_iter()
             .map(|cd| {
                 if parent_offset != 0 || parent_len != cd.len() {
                     make_array(cd.slice(parent_offset, parent_len))

Review Comment:
   I filed a ticket to track this idea
   - https://github.com/apache/arrow-rs/issues/9140



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