zhuqi-lucas commented on code in PR #7748: URL: https://github.com/apache/arrow-rs/pull/7748#discussion_r2166362006
########## arrow-array/src/array/byte_view_array.rs: ########## @@ -545,9 +545,41 @@ impl<T: ByteViewType + ?Sized> GenericByteViewArray<T> { let r_len = *r_view as u32; if l_len <= 12 && r_len <= 12 { - let l_data = unsafe { GenericByteViewArray::<T>::inline_value(l_view, l_len as usize) }; - let r_data = unsafe { GenericByteViewArray::<T>::inline_value(r_view, r_len as usize) }; - return l_data.cmp(r_data); + // Directly load the 16-byte view as an u128 (little-endian) + let l_bits: u128 = *l_view; + let r_bits: u128 = *r_view; + + // The lower 32 bits encode the length (little-endian), + // the upper 96 bits hold the actual data + let l_len = (l_bits as u32) as usize; + let r_len = (r_bits as u32) as usize; + + // Mask to keep only the upper 96 bits (data), zeroing out the length + // 0xFFFF_FFFF_0000_0000_..._0000 + const DATA_MASK: u128 = !0u128 << 32; + + // Remove the length bits, leaving only the data + let l_data = (l_bits & DATA_MASK) >> 32; Review Comment: Thank you @Dandandan , reduce the bit masking in latest PR, i think ByteView from will use all convert to the struct field, we only use part of them, so i just use part of logic in latest PR. ```rust impl From<u128> for ByteView { #[inline] fn from(value: u128) -> Self { Self { length: value as u32, prefix: (value >> 32) as u32, buffer_index: (value >> 64) as u32, offset: (value >> 96) as u32, } } } ``` -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org