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

Function compile_and_cache_regex

datafusion/functions/src/regex/mod.rs:131–147  ·  view source on GitHub ↗
(
    regex: &'strings str,
    flags: Option<&'strings str>,
    regex_cache: &'cache mut HashMap<(&'strings str, Option<&'strings str>), Regex>,
)

Source from the content-addressed store, hash-verified

129}
130
131pub fn compile_and_cache_regex<'strings, 'cache>(
132 regex: &'strings str,
133 flags: Option<&'strings str>,
134 regex_cache: &'cache mut HashMap<(&'strings str, Option<&'strings str>), Regex>,
135) -> Result<&'cache Regex, ArrowError>
136where
137 'strings: 'cache,
138{
139 let result = match regex_cache.entry((regex, flags)) {
140 Entry::Occupied(occupied_entry) => occupied_entry.into_mut(),
141 Entry::Vacant(vacant_entry) => {
142 let compiled = compile_regex(regex, flags)?;
143 vacant_entry.insert(compiled)
144 }
145 };
146 Ok(result)
147}
148
149pub fn compile_regex(regex: &str, flags: Option<&str>) -> Result<Regex, ArrowError> {
150 let pattern = match flags {

Callers 2

regexp_count_innerFunction · 0.85
get_indexFunction · 0.85

Calls 2

compile_regexFunction · 0.85
insertMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…