crepererum commented on code in PR #4681:
URL: https://github.com/apache/arrow-rs/pull/4681#discussion_r1291214491
##########
arrow-data/src/data.rs:
##########
@@ -736,17 +753,25 @@ impl ArrayData {
self.buffers.iter().zip(layout.buffers.iter()).enumerate()
{
match spec {
- BufferSpec::FixedWidth { byte_width } => {
- let min_buffer_size = len_plus_offset
- .checked_mul(*byte_width)
- .expect("integer overflow computing min buffer size");
+ BufferSpec::FixedWidth {
+ byte_width,
+ alignment,
+ } => {
+ let min_buffer_size =
len_plus_offset.saturating_mul(*byte_width);
if buffer.len() < min_buffer_size {
return Err(ArrowError::InvalidArgumentError(format!(
"Need at least {} bytes in buffers[{}] in array of
type {:?}, but got {}",
min_buffer_size, i, self.data_type, buffer.len()
)));
}
+
+ if buffer.as_ptr().align_offset(*alignment) != 0 {
+ return Err(ArrowError::InvalidArgumentError(format!(
+ "Misaligned buffers[{i}] in array of type {:?},
expected {alignment}",
Review Comment:
I think it would be helpful for debugging to include the actual alignment in
addition to the expected value.
--
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]