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

Method bitwise_unary

arrow-array/src/array/boolean_array.rs:334–345  ·  view source on GitHub ↗

Apply a bitwise operation to this array's values using u64 operations, returning a new [`BooleanArray`]. The null buffer is preserved unchanged. See [`BooleanBuffer::from_bitwise_unary_op`] for details on the operation. # Example ``` # use arrow_array::BooleanArray; let array = BooleanArray::from(vec![true, false, true]); let result = array.bitwise_unary(|x| !x); assert_eq!(result, BooleanArra

(&self, op: F)

Source from the content-addressed store, hash-verified

332 /// assert_eq!(result, BooleanArray::from(vec![false, true, false]));
333 /// ```
334 pub fn bitwise_unary<F>(&self, op: F) -> BooleanArray
335 where
336 F: FnMut(u64) -> u64,
337 {
338 let values = BooleanBuffer::from_bitwise_unary_op(
339 self.values.values(),
340 self.values.offset(),
341 self.values.len(),
342 op,
343 );
344 BooleanArray::new(values, self.nulls.clone())
345 }
346
347 /// Try to apply a bitwise operation to this array's values in place using
348 /// u64 operations.

Calls 4

valuesMethod · 0.45
offsetMethod · 0.45
lenMethod · 0.45
cloneMethod · 0.45

Tested by 4

test_bitwise_unary_notFunction · 0.64
test_bitwise_unary_emptyFunction · 0.64