Skip to content

Commit

Permalink
StructArray::columns return slice
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed Nov 24, 2022
1 parent 5640a5b commit 98e0f16
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions arrow-array/src/array/struct_array.rs
Expand Up @@ -67,13 +67,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
Expand Down
2 changes: 1 addition & 1 deletion arrow-cast/src/display.rs
Expand Up @@ -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)?;
}
Expand Down
2 changes: 1 addition & 1 deletion arrow-ipc/src/writer.rs
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion parquet/src/arrow/arrow_writer/levels.rs
Expand Up @@ -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())
}
};
Expand Down

0 comments on commit 98e0f16

Please sign in to comment.