liukun4515 commented on code in PR #2666:
URL: https://github.com/apache/arrow-rs/pull/2666#discussion_r963770006


##########
arrow/src/compute/kernels/arity.rs:
##########
@@ -17,39 +17,62 @@
 
 //! Defines kernels suitable to perform operations to primitive arrays.
 
-use crate::array::{Array, ArrayData, ArrayRef, DictionaryArray, 
PrimitiveArray};
+use crate::array::{
+    Array, ArrayData, ArrayRef, BufferBuilder, DictionaryArray, PrimitiveArray,
+};
 use crate::buffer::Buffer;
+use crate::compute::util::combine_option_bitmap;
 use crate::datatypes::{
     ArrowNumericType, ArrowPrimitiveType, DataType, Int16Type, Int32Type, 
Int64Type,
     Int8Type, UInt16Type, UInt32Type, UInt64Type, UInt8Type,
 };
 use crate::error::{ArrowError, Result};
+use crate::util::bit_iterator::{BitIndexIterator, BitSliceIterator};
 use std::sync::Arc;
 
+fn try_for_each_valid<F: FnMut(usize) -> Result<()>>(
+    len: usize,
+    null_count: usize,
+    nulls: Option<&[u8]>,
+    f: F,
+) -> Result<()> {
+    if null_count == 0 {
+        (0..len).try_for_each(f)
+    } else if null_count != len {
+        let selectivity = null_count as f64 / len as f64;
+        if selectivity > 0.8 {
+            BitSliceIterator::new(nulls.unwrap(), 0, len)
+                .flat_map(|(start, end)| start..end)
+                .try_for_each(f)
+        } else {
+            BitIndexIterator::new(nulls.unwrap(), 0, len).try_for_each(f)
+        }
+    } else {
+        Ok(())
+    }
+}
+
 #[inline]
-fn into_primitive_array_data<I: ArrowPrimitiveType, O: ArrowPrimitiveType>(
-    array: &PrimitiveArray<I>,
+unsafe fn build_primitive_array<O: ArrowPrimitiveType>(

Review Comment:
   the new name makes more sense than before



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