This is an automated email from the ASF dual-hosted git repository.

tustvold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/master by this push:
     new 4c37ec24a StructArray::columns return slice (#3186)
4c37ec24a is described below

commit 4c37ec24a95a4a0c30f5f5eb4e81fd3647816a6f
Author: Raphael Taylor-Davies <[email protected]>
AuthorDate: Fri Nov 25 08:29:49 2022 +0000

    StructArray::columns return slice (#3186)
---
 arrow-array/src/array/struct_array.rs    | 7 ++++---
 arrow-cast/src/display.rs                | 2 +-
 arrow-ipc/src/writer.rs                  | 2 +-
 parquet/src/arrow/arrow_writer/levels.rs | 2 +-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arrow-array/src/array/struct_array.rs 
b/arrow-array/src/array/struct_array.rs
index fcbda600f..6c6490e31 100644
--- a/arrow-array/src/array/struct_array.rs
+++ b/arrow-array/src/array/struct_array.rs
@@ -68,13 +68,14 @@ impl StructArray {
     }
 
     /// Returns the fields of the struct array
-    pub fn columns(&self) -> Vec<&ArrayRef> {
-        self.boxed_fields.iter().collect()
+    pub fn columns(&self) -> &[ArrayRef] {
+        &self.boxed_fields
     }
 
     /// Returns child array refs of the struct array
+    #[deprecated(note = "Use columns().to_vec()")]
     pub fn columns_ref(&self) -> Vec<ArrayRef> {
-        self.boxed_fields.clone()
+        self.columns().to_vec()
     }
 
     /// Return field names in this struct array
diff --git a/arrow-cast/src/display.rs b/arrow-cast/src/display.rs
index ae1c799a4..434f750af 100644
--- a/arrow-cast/src/display.rs
+++ b/arrow-cast/src/display.rs
@@ -459,7 +459,7 @@ pub fn array_value_to_string(
 
             let mut s = String::new();
             s.push('{');
-            let mut kv_iter = 
st.columns().into_iter().zip(st.column_names().into_iter());
+            let mut kv_iter = st.columns().iter().zip(st.column_names());
             if let Some((col, name)) = kv_iter.next() {
                 append_struct_field_string(&mut s, name, col, row)?;
             }
diff --git a/arrow-ipc/src/writer.rs b/arrow-ipc/src/writer.rs
index dec44de17..0497cbe5e 100644
--- a/arrow-ipc/src/writer.rs
+++ b/arrow-ipc/src/writer.rs
@@ -177,7 +177,7 @@ impl IpcDataGenerator {
         match column.data_type() {
             DataType::Struct(fields) => {
                 let s = as_struct_array(column);
-                for (field, &column) in fields.iter().zip(s.columns().iter()) {
+                for (field, column) in fields.iter().zip(s.columns()) {
                     self.encode_dictionaries(
                         field,
                         column,
diff --git a/parquet/src/arrow/arrow_writer/levels.rs 
b/parquet/src/arrow/arrow_writer/levels.rs
index e2a8a8c50..182f68c49 100644
--- a/parquet/src/arrow/arrow_writer/levels.rs
+++ b/parquet/src/arrow/arrow_writer/levels.rs
@@ -324,7 +324,7 @@ impl LevelInfoBuilder {
         };
 
         let write_non_null = |children: &mut [LevelInfoBuilder], range: 
Range<usize>| {
-            for (child_array, child) in 
array.columns().into_iter().zip(children) {
+            for (child_array, child) in array.columns().iter().zip(children) {
                 child.write(child_array, range.clone())
             }
         };

Reply via email to