You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2026/01/15 13:05:40 UTC
[PR] Avoid a clone when creating `FixedSizeBinaryArray` from ArrayData [arrow-rs]
alamb opened a new pull request, #9186:
URL: https://github.com/apache/arrow-rs/pull/9186
# Which issue does this PR close?
- Part of https://github.com/apache/arrow-rs/issues/9061
- broken out of https://github.com/apache/arrow-rs/pull/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 https://github.com/apache/arrow-rs/pull/9114
# Are these changes tested?
Existing tests
# Are there any user-facing changes?
No
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Avoid a clone when creating `FixedSizeBinaryArray` from ArrayData [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #9186:
URL: https://github.com/apache/arrow-rs/pull/9186#discussion_r2702395173
##########
arrow-array/src/array/fixed_size_binary_array.rs:
##########
@@ -497,24 +497,25 @@ impl FixedSizeBinaryArray {
impl From<ArrayData> for FixedSizeBinaryArray {
fn from(data: ArrayData) -> Self {
+ let (data_type, len, nulls, offset, buffers, _child_data) = data.into_parts();
+
assert_eq!(
- data.buffers().len(),
+ buffers.len(),
1,
"FixedSizeBinaryArray data should contain 1 buffer only (values)"
);
- let value_length = match data.data_type() {
- DataType::FixedSizeBinary(len) => *len,
+ let value_length = match data_type {
+ DataType::FixedSizeBinary(len) => len,
_ => panic!("Expected data type to be FixedSizeBinary"),
};
let size = value_length as usize;
- let value_data =
- data.buffers()[0].slice_with_length(data.offset() * size, data.len() * size);
+ let value_data = buffers[0].slice_with_length(offset * size, len * size);
Self {
- data_type: data.data_type().clone(),
- nulls: data.nulls().cloned(),
- len: data.len(),
+ data_type,
+ nulls,
Review Comment:
this saves a clone of NullBuffer and a drop of DataType
I don't expect this to make much of a performance difference but it will help and I want all the `From<ArrayData>` impls to be consistent
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Avoid a clone when creating `FixedSizeBinaryArray` from ArrayData [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #9186:
URL: https://github.com/apache/arrow-rs/pull/9186
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org