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

Method evaluate_array

arrow-string/src/binary_predicate.rs:49–90  ·  view source on GitHub ↗
(&self, array: T, negate: bool)

Source from the content-addressed store, hash-verified

47 /// If `negate` is true the result of the predicate will be negated
48 #[inline(never)]
49 pub fn evaluate_array<'i, T>(&self, array: T, negate: bool) -> BooleanArray
50 where
51 T: ArrayAccessor<Item = &'i [u8]>,
52 {
53 match self {
54 Self::Contains(finder) => BooleanArray::from_unary(array, |haystack| {
55 finder.find(haystack).is_some() != negate
56 }),
57 Self::StartsWith(v) => {
58 if let Some(view_array) = array.as_any().downcast_ref::<BinaryViewArray>() {
59 let nulls = view_array.logical_nulls();
60 let values = BooleanBuffer::from(
61 view_array
62 .prefix_bytes_iter(v.len())
63 .map(|haystack| equals_bytes(haystack, v, equals_kernel) != negate)
64 .collect::<Vec<_>>(),
65 );
66 BooleanArray::new(values, nulls)
67 } else {
68 BooleanArray::from_unary(array, |haystack| {
69 starts_with(haystack, v, equals_kernel) != negate
70 })
71 }
72 }
73 Self::EndsWith(v) => {
74 if let Some(view_array) = array.as_any().downcast_ref::<BinaryViewArray>() {
75 let nulls = view_array.logical_nulls();
76 let values = BooleanBuffer::from(
77 view_array
78 .suffix_bytes_iter(v.len())
79 .map(|haystack| equals_bytes(haystack, v, equals_kernel) != negate)
80 .collect::<Vec<_>>(),
81 );
82 BooleanArray::new(values, nulls)
83 } else {
84 BooleanArray::from_unary(array, |haystack| {
85 ends_with(haystack, v, equals_kernel) != negate
86 })
87 }
88 }
89 }
90 }
91}
92
93fn equals_bytes(lhs: &[u8], rhs: &[u8], byte_eq_kernel: impl Fn((&u8, &u8)) -> bool) -> bool {

Callers

nothing calls this directly

Calls 9

findMethod · 0.80
prefix_bytes_iterMethod · 0.80
suffix_bytes_iterMethod · 0.80
equals_bytesFunction · 0.70
starts_withFunction · 0.70
ends_withFunction · 0.70
as_anyMethod · 0.45
logical_nullsMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected