Skip to content

Commit

Permalink
ffi_stream.rs: Align buffers when importing arrays (#4)
Browse files Browse the repository at this point in the history
* ffi_stream.rs: Align buffers when importing arrays
  • Loading branch information
felipecrv authored Feb 17, 2025
1 parent f5b51ff commit 93fa9d4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion arrow-array/src/ffi_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,13 @@ impl Iterator for ArrowArrayStreamReader {
let result = unsafe {
from_ffi_and_data_type(array, DataType::Struct(self.schema().fields().clone()))
};
Some(result.map(|data| RecordBatch::from(StructArray::from(data))))
Some(result.map(|mut data| {
// Ensure data is aligned (by potentially copying some buffers).
// This is needed because some Arrow C Data Interface sources(e.g.
// ADBC drivers) may produce unaligned buffers.
data.align_buffers();
RecordBatch::from(StructArray::from(data))
}))
} else {
let last_error = self.get_stream_last_error();
let err = ArrowError::CDataInterface(last_error.unwrap());
Expand Down

0 comments on commit 93fa9d4

Please sign in to comment.