a10y commented on code in PR #8645:
URL: https://github.com/apache/arrow-rs/pull/8645#discussion_r2456003176


##########
arrow-select/src/take.rs:
##########
@@ -621,6 +627,58 @@ where
     Ok(GenericListArray::<OffsetType::Native>::from(list_data))
 }
 
+fn take_list_view<IndexType, OffsetType>(
+    values: &GenericListViewArray<OffsetType::Native>,
+    indices: &PrimitiveArray<IndexType>,
+) -> Result<GenericListViewArray<OffsetType::Native>, ArrowError>
+where
+    IndexType: ArrowPrimitiveType,
+    OffsetType: ArrowPrimitiveType,
+    OffsetType::Native: OffsetSizeTrait,
+{
+    // Take executes only over the views.
+    let mut taken_offsets: Vec<OffsetType::Native> = 
Vec::with_capacity(indices.len());
+    let mut taken_sizes: Vec<OffsetType::Native> = 
Vec::with_capacity(indices.len());
+
+    // Initialize null buffer
+    let num_bytes = bit_util::ceil(indices.len(), 8);
+    let mut null_buf = MutableBuffer::new(num_bytes).with_bitset(num_bytes, 
true);
+    let null_slice = null_buf.as_slice_mut();
+
+    for i in 0..indices.len() {
+        if indices.is_valid(i) {
+            let idx = indices
+                .value(i)
+                .to_usize()
+                .ok_or_else(|| ArrowError::ComputeError("Cast to usize 
failed".to_string()))?;
+            taken_offsets.push(values.value_offset(idx));
+            taken_sizes.push(values.value_size(idx));
+
+            if !values.is_valid(idx) {
+                bit_util::unset_bit(null_slice, i);
+            }
+        } else {

Review Comment:
   yea i can do that. i sort of just based this on 
`take_value_indices_from_list` which doesn't seem to optimize for that case



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