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

Function op_binary

arrow-string/src/like.rs:385–407  ·  view source on GitHub ↗
(
    op: Op,
    l: impl Iterator<Item = Option<&'a str>>,
    r: impl Iterator<Item = Option<&'a str>>,
)

Source from the content-addressed store, hash-verified

383
384#[inline(never)]
385fn op_binary<'a>(
386 op: Op,
387 l: impl Iterator<Item = Option<&'a str>>,
388 r: impl Iterator<Item = Option<&'a str>>,
389) -> Result<BooleanArray, ArrowError> {
390 match op {
391 Op::Like(neg) => binary_predicate(l, r, neg, Predicate::like),
392 Op::ILike(neg) => binary_predicate(l, r, neg, |s| Predicate::ilike(s, false)),
393 Op::Contains => Ok(l.zip(r).map(|(l, r)| Some(str_contains(l?, r?))).collect()),
394 Op::EqIgnoreAsciiCase => Ok(l
395 .zip(r)
396 .map(|(l, r)| Some(Predicate::IEqAscii(l?).evaluate(r?)))
397 .collect()),
398 Op::StartsWith => Ok(l
399 .zip(r)
400 .map(|(l, r)| Some(Predicate::StartsWith(r?).evaluate(l?)))
401 .collect()),
402 Op::EndsWith => Ok(l
403 .zip(r)
404 .map(|(l, r)| Some(Predicate::EndsWith(r?).evaluate(l?)))
405 .collect()),
406 }
407}
408
409fn str_contains(haystack: &str, needle: &str) -> bool {
410 memchr::memmem::find(haystack.as_bytes(), needle.as_bytes()).is_some()

Callers 1

string_applyFunction · 0.70

Calls 6

binary_predicateFunction · 0.85
ilikeFunction · 0.85
str_containsFunction · 0.85
collectMethod · 0.80
zipMethod · 0.80
evaluateMethod · 0.45

Tested by

no test coverage detected