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

Function binary_predicate

arrow-string/src/like.rs:413–432  ·  view source on GitHub ↗
(
    l: impl Iterator<Item = Option<&'a str>>,
    r: impl Iterator<Item = Option<&'a str>>,
    neg: bool,
    f: impl Fn(&'a str) -> Result<Predicate<'a>, ArrowError>,
)

Source from the content-addressed store, hash-verified

411}
412
413fn binary_predicate<'a>(
414 l: impl Iterator<Item = Option<&'a str>>,
415 r: impl Iterator<Item = Option<&'a str>>,
416 neg: bool,
417 f: impl Fn(&'a str) -> Result<Predicate<'a>, ArrowError>,
418) -> Result<BooleanArray, ArrowError> {
419 let mut previous = None;
420 l.zip(r)
421 .map(|(l, r)| match (l, r) {
422 (Some(l), Some(r)) => {
423 let p: &Predicate = match previous {
424 Some((expr, ref predicate)) if expr == r => predicate,
425 _ => &previous.insert((r, f(r)?)).1,
426 };
427 Ok(Some(p.evaluate(l) != neg))
428 }
429 _ => Ok(None),
430 })
431 .collect()
432}
433
434#[cfg(test)]
435mod tests {

Callers 1

op_binaryFunction · 0.85

Calls 4

collectMethod · 0.80
zipMethod · 0.80
insertMethod · 0.45
evaluateMethod · 0.45

Tested by

no test coverage detected