Browse Source

Fix alignment errors when receiving empty arrays

Empty `Vec`s have a dummy pointer that is set to the alignment of the item type. Thus, the pointer for empty `Vec<u8>` data is `0x1`. Using this pointer to construct a `ArrayData` instance can lead to alignment errors if the arrow array is of a type with larger alignment, e.g. float64.

This commit fixes the alignment error by checking for an empty raw buffer and constructing an empty `ArrayData` instance in this case.

Fixes #362
tags/v0.3.0-rc
Philipp Oppermann 2 years ago
parent
commit
ac7d1740c3
Failed to extract signature
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      apis/rust/node/src/event_stream/event.rs

+ 5
- 1
apis/rust/node/src/event_stream/event.rs View File

@@ -57,7 +57,11 @@ pub struct SharedMemoryData {
fn buffer_into_arrow_array(
raw_buffer: &arrow::buffer::Buffer,
type_info: &ArrowTypeInfo,
) -> std::result::Result<arrow::array::ArrayData, eyre::Error> {
) -> eyre::Result<arrow::array::ArrayData> {
if raw_buffer.is_empty() {
return Ok(arrow::array::ArrayData::new_empty(&type_info.data_type));
}

let mut buffers = Vec::new();
for BufferOffset { offset, len } in &type_info.buffer_offsets {
buffers.push(raw_buffer.slice_with_length(*offset, *len));


Loading…
Cancel
Save