Skip to content

Commit

Permalink
Return reference from UnionArray::child (#2035) (#2099)
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed Jul 18, 2022
1 parent 6a37d9f commit 619be77
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions arrow/src/array/array_union.rs
Expand Up @@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion arrow/src/ipc/writer.rs
Expand Up @@ -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)))
Expand Down
2 changes: 1 addition & 1 deletion arrow/src/util/display.rs
Expand Up @@ -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,
Expand Down

0 comments on commit 619be77

Please sign in to comment.