etseidl commented on code in PR #6252:
URL: https://github.com/apache/arrow-rs/pull/6252#discussion_r1722306457


##########
arrow-array/src/array/fixed_size_binary_array.rs:
##########
@@ -464,6 +466,42 @@ impl FixedSizeBinaryArray {
     pub fn iter(&self) -> FixedSizeBinaryIter<'_> {
         FixedSizeBinaryIter::new(self)
     }
+
+    /// Applies a unary infallible function to a fixed-size binary array, 
producing a
+    /// new primitive array.
+    ///
+    /// This is the fastest way to perform an operation on a fixed-size binary 
array
+    /// when the benefits of a vectorized operation outweigh the cost of
+    /// branching nulls and non-nulls.
+    ///
+    /// # Null Handling
+    ///
+    /// Applies the function for all values, including those on null slots. 
This
+    /// will often allow the compiler to generate faster vectorized code, but
+    /// requires that the operation must be infallible (not error/panic) for 
any
+    /// value of the corresponding type or this function may panic.
+    pub fn unary<F, O>(&self, op: F) -> PrimitiveArray<O>

Review Comment:
   Ok, added `PrimitiveArray::from_unary`. Comparing against 
`FixedSizeBinaryArray::unary`:
   ```
   group                                                                        
                           opt2                                   opt4
   -----                                                                        
                           ----                                   ----
   arrow_array_reader/BYTE_STREAM_SPLIT/Decimal128Array/byte_stream_split 
encoded, mandatory, no NULLs     1.12    508.8±5.76µs        ? ?/sec    1.00    
456.1±7.06µs        ? ?/sec
   arrow_array_reader/BYTE_STREAM_SPLIT/Decimal128Array/byte_stream_split 
encoded, optional, half NULLs    1.11    626.5±6.79µs        ? ?/sec    1.00   
561.9±11.12µs        ? ?/sec
   arrow_array_reader/BYTE_STREAM_SPLIT/Decimal128Array/byte_stream_split 
encoded, optional, no NULLs      1.13    517.7±7.51µs        ? ?/sec    1.00    
460.0±6.63µs        ? ?/sec
   arrow_array_reader/BYTE_STREAM_SPLIT/Float16Array/byte_stream_split encoded, 
mandatory, no NULLs        1.17     70.6±0.90µs        ? ?/sec    1.00     
60.4±0.58µs        ? ?/sec
   arrow_array_reader/BYTE_STREAM_SPLIT/Float16Array/byte_stream_split encoded, 
optional, half NULLs       1.14    140.7±1.31µs        ? ?/sec    1.00    
123.4±1.88µs        ? ?/sec
   arrow_array_reader/BYTE_STREAM_SPLIT/Float16Array/byte_stream_split encoded, 
optional, no NULLs         1.11     73.6±0.55µs        ? ?/sec    1.00     
66.3±0.56µs        ? ?/sec
   arrow_array_reader/FIXED_LENGTH_BYTE_ARRAY/Decimal128Array/plain encoded, 
mandatory, no NULLs           1.47    247.0±2.83µs        ? ?/sec    1.00    
167.6±1.52µs        ? ?/sec
   arrow_array_reader/FIXED_LENGTH_BYTE_ARRAY/Decimal128Array/plain encoded, 
optional, half NULLs          1.20    497.5±5.20µs        ? ?/sec    1.00    
414.9±4.92µs        ? ?/sec
   arrow_array_reader/FIXED_LENGTH_BYTE_ARRAY/Decimal128Array/plain encoded, 
optional, no NULLs            1.45    250.1±2.46µs        ? ?/sec    1.00    
172.6±1.17µs        ? ?/sec
   ```



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