Skip to content

Commit b64b458

Browse files
authored
Avoid a clone when creating FixedSizeListArray from ArrayData (#9187)
# Which issue does this PR close? - Part of #9061 - broken out of #9058 # Rationale for this change Let's make arrow-rs the fastest we can and the fewer allocations the better # What changes are included in this PR? Apply pattern from #9114 # Are these changes tested? Existing tests # Are there any user-facing changes? No
1 parent 93ebd3a commit b64b458

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

arrow-array/src/array/fixed_size_list_array.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,10 @@ impl FixedSizeListArray {
429429

430430
impl From<ArrayData> for FixedSizeListArray {
431431
fn from(data: ArrayData) -> Self {
432-
let value_length = match data.data_type() {
433-
DataType::FixedSizeList(_, len) => *len,
432+
let (data_type, len, nulls, offset, _buffers, child_data) = data.into_parts();
433+
434+
let value_length = match data_type {
435+
DataType::FixedSizeList(_, len) => len,
434436
data_type => {
435437
panic!(
436438
"FixedSizeListArray data should contain a FixedSizeList data type, got {data_type}"
@@ -439,14 +441,13 @@ impl From<ArrayData> for FixedSizeListArray {
439441
};
440442

441443
let size = value_length as usize;
442-
let values =
443-
make_array(data.child_data()[0].slice(data.offset() * size, data.len() * size));
444+
let values = make_array(child_data[0].slice(offset * size, len * size));
444445
Self {
445-
data_type: data.data_type().clone(),
446+
data_type,
446447
values,
447-
nulls: data.nulls().cloned(),
448+
nulls,
448449
value_length,
449-
len: data.len(),
450+
len,
450451
}
451452
}
452453
}

0 commit comments

Comments
 (0)