MCPcopy Create free account
hub / github.com/apache/datafusion / split_constant_prefix

Function split_constant_prefix

datafusion/pruning/src/pruning_predicate.rs:1940–1954  ·  view source on GitHub ↗

Returns unescaped constant prefix of a LIKE pattern (possibly empty) and the remaining pattern (possibly empty)

(pattern: &str)

Source from the content-addressed store, hash-verified

1938
1939/// Returns unescaped constant prefix of a LIKE pattern (possibly empty) and the remaining pattern (possibly empty)
1940fn split_constant_prefix(pattern: &str) -> (String, &str) {
1941 let mut prefix = String::with_capacity(pattern.len());
1942 let mut iter = pattern.char_indices();
1943 while let Some((idx, c)) = iter.next() {
1944 match c {
1945 '%' | '_' => return (prefix, &pattern[idx..]),
1946 '\\' => match iter.next() {
1947 Some((_, escaped)) => prefix.push(escaped),
1948 None => prefix.push('\\'),
1949 },
1950 _ => prefix.push(c),
1951 }
1952 }
1953 (prefix, "")
1954}
1955
1956/// Increment a UTF8 string by one, returning `None` if it can't be incremented.
1957/// This makes it so that the returned string will always compare greater than the input string

Callers 2

build_like_matchFunction · 0.85
build_not_like_matchFunction · 0.85

Calls 3

lenMethod · 0.45
nextMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…