You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by tu...@apache.org on 2022/07/18 21:13:32 UTC

[arrow-rs] branch master updated: Return reference from UnionArray::child (#2035) (#2099)

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 619be77a6 Return reference from UnionArray::child (#2035) (#2099)
619be77a6 is described below

commit 619be77a6aeaf31c524f3a25973c4941ac267a63
Author: Raphael Taylor-Davies <17...@users.noreply.github.com>
AuthorDate: Mon Jul 18 17:13:25 2022 -0400

    Return reference from UnionArray::child (#2035) (#2099)
---
 arrow/src/array/array_union.rs | 4 ++--
 arrow/src/ipc/writer.rs        | 2 +-
 arrow/src/util/display.rs      | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arrow/src/array/array_union.rs b/arrow/src/array/array_union.rs
index e7ddec01f..09cc1ab59 100644
--- a/arrow/src/array/array_union.rs
+++ b/arrow/src/array/array_union.rs
@@ -231,10 +231,10 @@ impl UnionArray {
     ///
     /// Panics if the `type_id` provided is less than zero or greater than the number of types
     /// in the `Union`.
-    pub fn child(&self, type_id: i8) -> ArrayRef {
+    pub fn child(&self, type_id: i8) -> &ArrayRef {
         assert!(0 <= type_id);
         assert!((type_id as usize) < self.boxed_fields.len());
-        self.boxed_fields[type_id as usize].clone()
+        &self.boxed_fields[type_id as usize]
     }
 
     /// Returns the `type_id` for the array slot at `index`.
diff --git a/arrow/src/ipc/writer.rs b/arrow/src/ipc/writer.rs
index 3847661db..279edd572 100644
--- a/arrow/src/ipc/writer.rs
+++ b/arrow/src/ipc/writer.rs
@@ -226,7 +226,7 @@ impl IpcDataGenerator {
             }
             DataType::Union(fields, _, _) => {
                 let union = as_union_array(column);
-                for (field, ref column) in fields
+                for (field, column) in fields
                     .iter()
                     .enumerate()
                     .map(|(n, f)| (f, union.child(n as i8)))
diff --git a/arrow/src/util/display.rs b/arrow/src/util/display.rs
index 7a7da8ccb..655905042 100644
--- a/arrow/src/util/display.rs
+++ b/arrow/src/util/display.rs
@@ -434,7 +434,7 @@ fn union_to_string(
     let name = fields.get(field_idx).unwrap().name();
 
     let value = array_value_to_string(
-        &list.child(type_id),
+        list.child(type_id),
         match mode {
             UnionMode::Dense => list.value_offset(row) as usize,
             UnionMode::Sparse => row,