ishaaaan17 opened a new issue, #53159: URL: https://github.com/apache/arrow/issues/53159
### Describe the enhancement requested ### description 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. ### Component(s) C++ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
