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

Function op_binary

arrow-string/src/binary_like.rs:143–162  ·  view source on GitHub ↗
(
    op: Op,
    l: impl Iterator<Item = Option<&'a [u8]>>,
    r: impl Iterator<Item = Option<&'a [u8]>>,
)

Source from the content-addressed store, hash-verified

141
142#[inline(never)]
143fn op_binary<'a>(
144 op: Op,
145 l: impl Iterator<Item = Option<&'a [u8]>>,
146 r: impl Iterator<Item = Option<&'a [u8]>>,
147) -> Result<BooleanArray, ArrowError> {
148 match op {
149 Op::Contains => Ok(l
150 .zip(r)
151 .map(|(l, r)| Some(bytes_contains(l?, r?)))
152 .collect()),
153 Op::StartsWith => Ok(l
154 .zip(r)
155 .map(|(l, r)| Some(BinaryPredicate::StartsWith(r?).evaluate(l?)))
156 .collect()),
157 Op::EndsWith => Ok(l
158 .zip(r)
159 .map(|(l, r)| Some(BinaryPredicate::EndsWith(r?).evaluate(l?)))
160 .collect()),
161 }
162}
163
164fn bytes_contains(haystack: &[u8], needle: &[u8]) -> bool {
165 memchr::memmem::find(haystack, needle).is_some()

Callers 1

binary_applyFunction · 0.70

Calls 4

bytes_containsFunction · 0.85
collectMethod · 0.80
zipMethod · 0.80
evaluateMethod · 0.45

Tested by

no test coverage detected