Jefffrey commented on code in PR #10405:
URL: https://github.com/apache/arrow-rs/pull/10405#discussion_r3635828485


##########
arrow-ipc/src/reader.rs:
##########
@@ -3116,6 +3116,101 @@ mod tests {
         );
     }
 
+    /// Verify that misaligned IPC buffers are caught by `require_alignment = 
true`.
+    ///
+    /// For each array type we shift the IPC body by every byte offset in 
0..OFFSET_RANGE and
+    /// assert that the decoder errors exactly when the offset violates the 
type's
+    /// minimum alignment requirement.  The Arrow columnar spec permits 
alignment to
+    /// any multiple of 8 or 64 bytes, so multiples of 8 (which include every 
multiple
+    /// of 64) must succeed; everything else must return a "Misaligned 
buffers" error.
+    /// See 
<https://arrow.apache.org/docs/format/Columnar.html#buffer-alignment-and-padding>.
+    #[test]
+    fn test_misaligned_buffers_error() {
+        const OFFSET_RANGE: usize = 128;
+
+        // (array, minimum required alignment in bytes)
+        // Fixed-width: alignment == element byte width.
+        // Variable-width (e.g. StringArray): the offsets buffer drives 
alignment (Int32 → 4).
+        let cases: Vec<(ArrayRef, usize)> = vec![
+            (Arc::new(Int32Array::from_iter(0i32..20_000)) as _, 4),

Review Comment:
   do we strictly need arrays this large? could reduce down to 1000 elements? 
(or even 500)



-- 
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]

Reply via email to