Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return reference from UnionArray::child (#2035) #2099

Merged
merged 1 commit into from Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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