MCPcopy Create free account
hub / github.com/apache/arrow-rs / unary

Method unary

arrow-array/src/array/primitive_array.rs:895–904  ·  view source on GitHub ↗

Applies a unary infallible function to a primitive array, producing a new array of potentially different type. This is the fastest way to perform an operation on a primitive array when the benefits of a vectorized operation outweigh the cost of branching nulls and non-nulls. See also [`Self::unary_mut`] for in place modification. [`Self::try_unary`] for fallible operations. [`arrow::compute::bin

(&self, op: F)

Source from the content-addressed store, hash-verified

893 /// # }
894 /// ```
895 pub fn unary<F, O>(&self, op: F) -> PrimitiveArray<O>
896 where
897 O: ArrowPrimitiveType,
898 F: Fn(T::Native) -> O::Native,
899 {
900 let nulls = self.nulls().cloned();
901 let values = self.values().into_iter().map(|v| op(*v));
902 let buffer: Vec<_> = values.collect();
903 PrimitiveArray::new(buffer.into(), nulls)
904 }
905
906 /// Applies a unary and infallible function to the array in place if possible.
907 ///

Callers 11

replace_primitive_valueFunction · 0.80
apply_decimal_castFunction · 0.80
get_flight_infoMethod · 0.80
poll_flight_infoMethod · 0.80
get_schemaMethod · 0.80
callMethod · 0.80
coerce_i32Function · 0.80
coerce_i64Function · 0.80
write_leafFunction · 0.80
unaryFunction · 0.80

Calls 4

collectMethod · 0.80
nullsMethod · 0.45
into_iterMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected