tustvold commented on code in PR #2883:
URL: https://github.com/apache/arrow-rs/pull/2883#discussion_r996405766
##########
arrow/src/ipc/reader.rs:
##########
@@ -499,6 +500,24 @@ fn create_primitive_array(
make_array(array_data)
}
+/// Checks if given `Buffer` is properly aligned with `i128`.
+/// If not, copying the data and padded it for alignment.
+fn get_aligned_buffer(buffer: &Buffer, length: usize) -> Buffer {
+ let ptr = buffer.as_ptr();
+ let align_req = std::mem::align_of::<i128>();
+ let align_offset = ptr.align_offset(align_req);
+ // The buffer is not aligned properly. The writer might use a smaller
alignment
+ // e.g. 8 bytes, but on some platform (e.g. ARM) i128 requires 16 bytes
alignment.
+ // We need to copy the buffer as fallback.
+ if align_offset != 0 {
+ let len_in_bytes = length * std::mem::size_of::<i128>();
Review Comment:
I think this is incorrect for the Decimal256 case? Perhaps we could make
this method generic on the native type, to ensure the correct size and
alignment is used?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]