tustvold commented on code in PR #5735:
URL: https://github.com/apache/arrow-rs/pull/5735#discussion_r1593964614
##########
arrow-array/src/array/byte_view_array.rs:
##########
@@ -237,15 +237,13 @@ impl<T: ByteViewType + ?Sized> GenericByteViewArray<T> {
/// Caller is responsible for ensuring that the index is within the bounds
of the array
pub unsafe fn value_unchecked(&self, idx: usize) -> &T::Native {
let v = self.views.get_unchecked(idx);
- let len = *v as u32;
- let b = if len <= 12 {
- let ptr = self.views.as_ptr() as *const u8;
- std::slice::from_raw_parts(ptr.add(idx * 16 + 4), len as usize)
- } else {
- let view = ByteView::from(*v);
- let data = self.buffers.get_unchecked(view.buffer_index as usize);
- let offset = view.offset as usize;
- data.get_unchecked(offset..offset + len as usize)
+ let b = match ByteView::try_new(v) {
Review Comment:
We can see here how try_new encapsulates the logic for interpreting the u128
--
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]