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

Method try_bitwise_unary_in_place

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

Try to apply a unary op in place. Returns `op` back on failure so callers can fall back to an allocating path without requiring `F: Clone`.

(self, op: F)

Source from the content-addressed store, hash-verified

398 /// Try to apply a unary op in place. Returns `op` back on failure so
399 /// callers can fall back to an allocating path without requiring `F: Clone`.
400 fn try_bitwise_unary_in_place<F>(self, op: F) -> Result<BooleanArray, (BooleanArray, F)>
401 where
402 F: FnMut(u64) -> u64,
403 {
404 let (values, nulls) = self.into_parts();
405 let offset = values.offset();
406 let len = values.len();
407 let buffer = values.into_inner();
408 match buffer.into_mutable() {
409 Ok(mut buf) => {
410 bit_util::apply_bitwise_unary_op(buf.as_slice_mut(), offset, len, op);
411 let values = BooleanBuffer::new(buf.into(), offset, len);
412 Ok(BooleanArray::new(values, nulls))
413 }
414 Err(buffer) => {
415 let values = BooleanBuffer::new(buffer, offset, len);
416 Err((BooleanArray::new(values, nulls), op))
417 }
418 }
419 }
420
421 /// Apply a bitwise binary operation to this array and `rhs` using u64
422 /// operations, returning a new [`BooleanArray`].

Callers 2

bitwise_unary_mutMethod · 0.80

Calls 7

apply_bitwise_unary_opFunction · 0.85
into_mutableMethod · 0.80
into_partsMethod · 0.45
offsetMethod · 0.45
lenMethod · 0.45
into_innerMethod · 0.45
as_slice_mutMethod · 0.45

Tested by

no test coverage detected