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
12 changes: 7 additions & 5 deletions arrow-array/src/array/byte_view_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -988,14 +988,16 @@ impl<'a, T: ByteViewType + ?Sized> IntoIterator for &'a GenericByteViewArray<T>

impl<T: ByteViewType + ?Sized> From<ArrayData> for GenericByteViewArray<T> {
fn from(data: ArrayData) -> Self {
let (_data_type, len, nulls, offset, mut buffers, _child_data) = data.into_parts();
let views = buffers.remove(0); // need to maintain order of remaining buffers
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the idea is that remove(0) copies all the buffers and then Arc::from allocates/copies it again. Using Arc::from_iter builds the results directly

let buffers = Arc::from(buffers);
let views = ScalarBuffer::new(views, offset, len);
let (_data_type, len, nulls, offset, buffers, _child_data) = data.into_parts();

let mut buffers = buffers.into_iter();
// first buffer is views, remaining are data buffers
let views = ScalarBuffer::new(buffers.next().unwrap(), offset, len);

Self {
data_type: T::DATA_TYPE,
views,
buffers,
buffers: Arc::from_iter(buffers),
nulls,
phantom: Default::default(),
}
Expand Down
Loading