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

Method like

arrow-string/src/predicate.rs:46–61  ·  view source on GitHub ↗

Create a predicate for the given like pattern

(pattern: &'a str)

Source from the content-addressed store, hash-verified

44impl<'a> Predicate<'a> {
45 /// Create a predicate for the given like pattern
46 pub(crate) fn like(pattern: &'a str) -> Result<Self, ArrowError> {
47 if !contains_like_pattern(pattern) {
48 Ok(Self::Eq(pattern))
49 } else if pattern.ends_with('%') && !contains_like_pattern(&pattern[..pattern.len() - 1]) {
50 Ok(Self::StartsWith(&pattern[..pattern.len() - 1]))
51 } else if pattern.starts_with('%') && !contains_like_pattern(&pattern[1..]) {
52 Ok(Self::EndsWith(&pattern[1..]))
53 } else if pattern.starts_with('%')
54 && pattern.ends_with('%')
55 && !contains_like_pattern(&pattern[1..pattern.len() - 1])
56 {
57 Ok(Self::contains(&pattern[1..pattern.len() - 1]))
58 } else {
59 Ok(Self::Regex(regex_like(pattern, false)?))
60 }
61 }
62
63 pub(crate) fn contains(needle: &'a str) -> Self {
64 Self::Contains(Finder::new(needle.as_bytes()))

Callers

nothing calls this directly

Calls 4

contains_like_patternFunction · 0.85
containsFunction · 0.85
regex_likeFunction · 0.85
lenMethod · 0.45

Tested by

no test coverage detected