jhorstmann commented on code in PR #2064:
URL: https://github.com/apache/arrow-rs/pull/2064#discussion_r922281295


##########
arrow/src/compute/kernels/take.rs:
##########
@@ -599,76 +599,68 @@ where
     Ok(PrimitiveArray::<T>::from(data))
 }
 
-/// `take` implementation for boolean arrays
-fn take_boolean<IndexType>(
-    values: &BooleanArray,
+fn take_bits<IndexType>(
+    values: &Buffer,
+    values_offset: usize,
     indices: &PrimitiveArray<IndexType>,
-) -> Result<BooleanArray>
+) -> Result<Buffer>
 where
     IndexType: ArrowNumericType,
     IndexType::Native: ToPrimitive,
 {
-    let data_len = indices.len();
+    let len = indices.len();
+    let values_slice = values.as_slice();
+    let mut output_buffer = MutableBuffer::new_null(len);
+    let output_slice = output_buffer.as_slice_mut();
 
-    let num_byte = bit_util::ceil(data_len, 8);
-    let mut val_buf = MutableBuffer::from_len_zeroed(num_byte);
-
-    let val_slice = val_buf.as_slice_mut();
-
-    let null_count = values.null_count();
-
-    let nulls = if null_count == 0 {
-        (0..data_len).try_for_each::<_, Result<()>>(|i| {
-            let index = ToPrimitive::to_usize(&indices.value(i)).ok_or_else(|| 
{
-                ArrowError::ComputeError("Cast to usize failed".to_string())
-            })?;
+    indices

Review Comment:
   I was also a bit surprised, we are probably trading the bounds check for 
`indices.value(i)`, which is avoided by the iterator, vs. the added null check. 
I can try adding another variant without nulls and benchmark that.



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