You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[C++][Compute] Cache substring and regex matchers across invocations in scalar string kernels #53159
in cpp/src/arrow/compute/kernels/scalar_string_ascii.cc, the MatchSubstring kernels (match_substring, starts_with, ends_with, match_substring_regex and match_like) rebuild their matcher on every call to Exec.
for regex matchers that means the RE2 DFA gets recompiled for every batch or chunk in a stream or chunked array. for plain matchers it reallocates and rebuilds the Knuth-Morris-Pratt prefix table each batch.
both MatchSubstring<Type, Matcher>::Exec and MatchSubstring<Type, RegexSubstringMatcher>::Exec already carry a maintainer comment about this: // TODO Cache matcher across invocations (for regex compilation)
proposed solution
replace OptionsWrapper<MatchSubstringOptions> with a dedicated MatchSubstringState. it lazily builds the matcher once and keeps the compiled or precomputed result in the KernelState, so later invocations reuse it.
Activity
apacheGH-53159: [C++][Compute] Cache substring and regex matchers acr…