Rich-T-kid commented on code in PR #11676:
URL: https://github.com/apache/arrow-rs/pull/11676#discussion_r4425980962
##########
arrow-select/src/zip.rs:
##########
@@ -784,11 +784,20 @@ impl<T: ByteViewType> ByteViewScalarImpl<T> {
fn get_value_from_scalar(scalar: &dyn Array) -> (Option<u128>,
Arc<[Buffer]>) {
if scalar.is_null(0) {
- (None, empty_arc_buffers())
- } else {
- let (views, buffers, _) =
scalar.as_byte_view::<T>().clone().into_parts();
- (views.first().copied(), buffers)
+ return (None, empty_arc_buffers());
+ }
+ let array = scalar.as_byte_view::<T>();
+ let view = array.views()[0];
+ if (view as u32) <= MAX_INLINE_VIEW_LEN {
+ return (Some(view), empty_arc_buffers());
}
+ // Keep only the buffer the value points to, not every buffer of the
array it came from
+ let byte_view = ByteView::from(view);
+ let buffer = array.data_buffers()[byte_view.buffer_index as
usize].clone();
+ (
+ Some(byte_view.with_buffer_index(0).as_u128()),
+ Arc::from([buffer]),
+ )
Review Comment:
```suggestion
let (views, buffers, _) =
scalar.as_byte_view::<T>().clone().into_parts();
let view = views[0];
if (view as u32) <= MAX_INLINE_VIEW_LEN {
return (Some(view), empty_arc_buffers());
}
let byte_view = ByteView::from(view);
// Keep only the buffer the value points to, not every buffer of the
array it came from
let buffer = buffers[byte_view.buffer_index as usize].clone();
(
Some(byte_view.with_buffer_index(0).as_u128()),
Arc::from([buffer]),
)
```
--
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]