Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions arrow-array/src/array/fixed_size_binary_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

len,
value_data,
value_length,
}
Expand Down
Loading