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

Method from_binary

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

Create a [`BooleanArray`] by evaluating the binary operation for each element of the provided arrays ``` # use arrow_array::{BooleanArray, Int32Array}; let a = Int32Array::from(vec![1, 2, 3, 4, 5]); let b = Int32Array::from(vec![1, 2, 0, 2, 5]); let r = BooleanArray::from_binary(&a, &b, |a, b| a == b); assert_eq!(&r, &BooleanArray::from(vec![true, true, false, false, true])); ``` # Panics This

(left: T, right: S, mut op: F)

Source from the content-addressed store, hash-verified

300 /// This function panics if left and right are not the same length
301 ///
302 pub fn from_binary<T: ArrayAccessor, S: ArrayAccessor, F>(left: T, right: S, mut op: F) -> Self
303 where
304 F: FnMut(T::Item, S::Item) -> bool,
305 {
306 assert_eq!(left.len(), right.len());
307
308 let nulls = NullBuffer::union(
309 left.logical_nulls().as_ref(),
310 right.logical_nulls().as_ref(),
311 );
312 let values = BooleanBuffer::collect_bool(left.len(), |i| unsafe {
313 // SAFETY: i in range 0..len
314 op(left.value_unchecked(i), right.value_unchecked(i))
315 });
316 Self::new(values, nulls)
317 }
318
319 /// Apply a bitwise operation to this array's values using u64 operations,
320 /// returning a new [`BooleanArray`].

Callers

nothing calls this directly

Calls 5

collect_boolFunction · 0.85
as_refMethod · 0.45
logical_nullsMethod · 0.45
lenMethod · 0.45
value_uncheckedMethod · 0.45

Tested by

no test coverage detected