Dandandan commented on code in PR #9236:
URL: https://github.com/apache/arrow-rs/pull/9236#discussion_r2713735375
##########
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]) });
Review Comment:
Yeah... although I probably need to recheck whether it makes a difference.
--
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]