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


##########
arrow-ipc/src/reader.rs:
##########
@@ -290,11 +296,43 @@ impl RecordBatchDecoder<'_> {
     /// Update the ArrayDataBuilder based on settings in this decoder
     fn create_array_from_builder(&self, builder: ArrayDataBuilder) -> 
Result<ArrayRef, ArrowError> {
         let mut builder = builder.align_buffers(!self.require_alignment);
-        if self.skip_validation.get() {
+        let skip_validation = self.skip_validation.get();
+        if skip_validation {
             // SAFETY: flag can only be set via unsafe code
             unsafe { builder = builder.skip_validation(true) }
         }
-        Ok(make_array(builder.build()?))
+        let data = builder.build()?;
+        if skip_validation && self.require_alignment {
+            // Children were checked as they were created.
+            let layout = layout(data.data_type());
+            for (index, (buffer, spec)) in 
data.buffers().iter().zip(&layout.buffers).enumerate() {
+                if let BufferSpec::FixedWidth { alignment, .. } = spec {
+                    check_alignment(buffer, *alignment, data.data_type(), 
index)?;
+                }
+            }
+        }
+        Ok(make_array(data))
+    }
+
+    /// Converts `buffer`, the buffer at `index` in an array of `data_type`, 
to a
+    /// [`ScalarBuffer`] based on the alignment settings in this decoder

Review Comment:
   it might be worth mentioning here that `data_type` and `index` are purely 
used for the error message, nothing else;



##########
arrow-ipc/src/reader/stream.rs:
##########
@@ -506,6 +507,92 @@ mod tests {
         );
     }
 
+    /// Writes a stream holding a single batch with one union column of the 
given mode
+    fn union_stream(mut builder: UnionBuilder) -> (RecordBatch, Vec<u8>) {
+        builder.append::<Int32Type>("a", 1).unwrap();
+        builder.append::<Float64Type>("b", 2.5).unwrap();
+        builder.append_null::<Int32Type>("a").unwrap();
+        builder.append::<Float64Type>("b", 4.5).unwrap();
+        builder.append::<Int32Type>("a", 5).unwrap();
+        let union = builder.build().unwrap();
+
+        let schema = Arc::new(Schema::new(vec![Field::new(
+            "union",
+            union.data_type().clone(),
+            false,
+        )]));
+        let batch = RecordBatch::try_new(schema.clone(), 
vec![Arc::new(union)]).unwrap();
+
+        let mut stream = Vec::new();
+        let mut writer = StreamWriter::try_new(&mut stream, &schema).unwrap();
+        writer.write(&batch).unwrap();
+        writer.finish().unwrap();
+        drop(writer);
+        (batch, stream)
+    }
+
+    /// Returns a copy of `stream` whose first byte sits `offset` bytes past 
an allocation
+    /// boundary.
+    ///
+    /// `MutableBuffer` allocates at an address aligned to at least 32 bytes 
on every target,

Review Comment:
   isnt it 64 bytes?



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