Dandandan commented on code in PR #9236:
URL: https://github.com/apache/arrow-rs/pull/9236#discussion_r2712602072


##########
parquet/src/arrow/array_reader/byte_view_array.rs:
##########
@@ -330,28 +342,26 @@ impl ByteViewArrayDecoderPlain {
         let to_read = len.min(self.max_remaining_values);
 
         let buf: &[u8] = self.buf.as_ref();
-        let mut read = 0;
+        let buf_len = buf.len();
+        let mut offset = self.offset;
+
         output.views.reserve(to_read);
 
-        let mut utf8_validation_begin = self.offset;
-        while self.offset < self.buf.len() && read != to_read {
-            if self.offset + 4 > self.buf.len() {
+        let mut utf8_validation_begin = offset;
+        for _ in 0..to_read {
+            if offset + 4 > buf_len {
                 return Err(ParquetError::EOF("eof decoding byte 
array".into()));
             }
-            let len_bytes: [u8; 4] = unsafe {
-                buf.get_unchecked(self.offset..self.offset + 4)
-                    .try_into()
-                    .unwrap()
-            };
-            let len = u32::from_le_bytes(len_bytes);
-
-            let start_offset = self.offset + 4;
+            let len = u32::from_le_bytes(unsafe { *(buf.as_ptr().add(offset) 
as *const [u8; 4]) });
+
+            let start_offset = offset + 4;
             let end_offset = start_offset + len as usize;
-            if end_offset > buf.len() {
+
+            if end_offset > buf_len {
                 return Err(ParquetError::EOF("eof decoding byte 
array".into()));
             }
 
-            if self.validate_utf8 {
+            if VALIDATE_UTF8 {

Review Comment:
   I think this is the main improvement for the plain decoder



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