Skip to content

Commit 91b1405

Browse files
authored
Avoid a clone when creating NullArray from ArrayData (#9191)
# 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 1db1a88 commit 91b1405

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

arrow-array/src/array/null_array.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,21 +138,19 @@ impl Array for NullArray {
138138

139139
impl From<ArrayData> for NullArray {
140140
fn from(data: ArrayData) -> Self {
141+
let (data_type, len, nulls, _offset, buffers, _child_data) = data.into_parts();
142+
141143
assert_eq!(
142-
data.data_type(),
143-
&DataType::Null,
144+
data_type,
145+
DataType::Null,
144146
"NullArray data type should be Null"
145147
);
146-
assert_eq!(
147-
data.buffers().len(),
148-
0,
149-
"NullArray data should contain 0 buffers"
150-
);
148+
assert_eq!(buffers.len(), 0, "NullArray data should contain 0 buffers");
151149
assert!(
152-
data.nulls().is_none(),
150+
nulls.is_none(),
153151
"NullArray data should not contain a null buffer, as no buffers are required"
154152
);
155-
Self { len: data.len() }
153+
Self { len }
156154
}
157155
}
158156

0 commit comments

Comments
 (0)