You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2022/12/19 10:29:51 UTC

[doris] branch branch-1.1-lts updated: [Performance] Optimize performance of like expr (#15168)

This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-1.1-lts
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-1.1-lts by this push:
     new 8f6c8ec5cd [Performance] Optimize performance of like expr (#15168)
8f6c8ec5cd is described below

commit 8f6c8ec5cd5d2452ce3d1dd7a678028e9bc91c40
Author: weizuo93 <we...@apache.org>
AuthorDate: Mon Dec 19 18:29:42 2022 +0800

    [Performance] Optimize performance of like expr (#15168)
---
 be/src/runtime/string_search.hpp | 8 +++-----
 be/src/vec/functions/like.cpp    | 2 +-
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/be/src/runtime/string_search.hpp b/be/src/runtime/string_search.hpp
index 3f657b6fa4..14800f2903 100644
--- a/be/src/runtime/string_search.hpp
+++ b/be/src/runtime/string_search.hpp
@@ -41,13 +41,11 @@ public:
             return -1;
         }
 
-        auto it = std::search(str->ptr, str->ptr + str->len,
-                              std::default_searcher(_pattern->ptr, _pattern->ptr + _pattern->len));
-        if (it == str->ptr + str->len) {
+        char* occurence = std::strstr(str->ptr, _pattern->ptr);
+        if (occurence == nullptr) {
             return -1;
-        } else {
-            return it - str->ptr;
         }
+        return occurence - str->ptr;
     }
 
 private:
diff --git a/be/src/vec/functions/like.cpp b/be/src/vec/functions/like.cpp
index c6bf479582..f0c37787ad 100644
--- a/be/src/vec/functions/like.cpp
+++ b/be/src/vec/functions/like.cpp
@@ -76,7 +76,7 @@ Status FunctionLikeBase::constant_substring_fn(LikeSearchState* state, const Str
         *result = true;
         return Status::OK();
     }
-    StringValue pattern_value = StringValue::from_string_val(val.ptr);
+    StringValue pattern_value(val.ptr, val.len);
     *result = state->substring_pattern.search(&pattern_value) != -1;
     return Status::OK();
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org