This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 9d1c702b3a [improvement](function) do not use hyperscan for non-const partterns in like function (#23495) 9d1c702b3a is described below commit 9d1c702b3a88d0ea6623688d5d9f4272cbc2bcba Author: Jerry Hu <mrh...@gmail.com> AuthorDate: Fri Aug 25 20:40:23 2023 +0800 [improvement](function) do not use hyperscan for non-const partterns in like function (#23495) --- be/src/vec/functions/like.cpp | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/be/src/vec/functions/like.cpp b/be/src/vec/functions/like.cpp index 8d56c4f2d1..1a83dc8a87 100644 --- a/be/src/vec/functions/like.cpp +++ b/be/src/vec/functions/like.cpp @@ -272,27 +272,14 @@ Status FunctionLikeBase::regexp_fn_scalar(LikeSearchState* state, const StringRe const StringRef& pattern, unsigned char* result) { std::string re_pattern(pattern.data, pattern.size); - hs_database_t* database = nullptr; - hs_scratch_t* scratch = nullptr; - if (hs_prepare(nullptr, re_pattern.c_str(), &database, &scratch).ok()) { // use hyperscan - auto ret = hs_scan(database, val.data, val.size, 0, scratch, - doris::vectorized::LikeSearchState::hs_match_handler, (void*)result); - if (ret != HS_SUCCESS && ret != HS_SCAN_TERMINATED) { - return Status::RuntimeError(fmt::format("hyperscan error: {}", ret)); - } - - hs_free_scratch(scratch); - hs_free_database(database); - } else { // fallback to re2 - RE2::Options opts; - opts.set_never_nl(false); - opts.set_dot_nl(true); - re2::RE2 re(re_pattern, opts); - if (re.ok()) { - *result = RE2::PartialMatch(re2::StringPiece(val.data, val.size), re); - } else { - return Status::RuntimeError("Invalid pattern: {}", pattern.debug_string()); - } + RE2::Options opts; + opts.set_never_nl(false); + opts.set_dot_nl(true); + re2::RE2 re(re_pattern, opts); + if (re.ok()) { + *result = RE2::PartialMatch(re2::StringPiece(val.data, val.size), re); + } else { + return Status::RuntimeError("Invalid pattern: {}", pattern.debug_string()); } return Status::OK(); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org