github-actions[bot] commented on code in PR #32333:
URL: https://github.com/apache/doris/pull/32333#discussion_r1528627415


##########
be/src/vec/functions/like.cpp:
##########
@@ -416,11 +602,102 @@
     return Status::OK();
 }
 
+template <bool LIKE_PATTERN>
+VPatternSearchStateSPtr FunctionLikeBase::pattern_type_recognition(const 
ColumnString& patterns) {
+    VPatternSearchStateSPtr allpass_state = 
std::make_shared<VectorAllpassSearchState>();
+    VPatternSearchStateSPtr equal_state = 
std::make_shared<VectorEqualSearchState>();
+    VPatternSearchStateSPtr substring_state = 
std::make_shared<VectorSubStringSearchState>();
+    VPatternSearchStateSPtr starts_with_state = 
std::make_shared<VectorStartsWithSearchState>();
+    VPatternSearchStateSPtr ends_with_state = 
std::make_shared<VectorEndsWithSearchState>();
+    size_t size = patterns.size();
+
+    for (size_t i = 0; i < size; ++i) {
+        if (!allpass_state->_pattern_matched && !equal_state->_pattern_matched 
&&
+            !substring_state->_pattern_matched && 
!starts_with_state->_pattern_matched &&
+            !ends_with_state->_pattern_matched) {
+            return nullptr;
+        }
+        std::string pattern_str = patterns.get_data_at(i).to_string();
+        if (allpass_state->_pattern_matched) {
+            if constexpr (LIKE_PATTERN) {
+                allpass_state->like_pattern_match(pattern_str);
+            } else {
+                allpass_state->regexp_pattern_match(pattern_str);
+            }
+        }
+        if (equal_state->_pattern_matched) {
+            if constexpr (LIKE_PATTERN) {
+                equal_state->like_pattern_match(pattern_str);
+            } else {
+                equal_state->regexp_pattern_match(pattern_str);
+            }
+        }
+        if (substring_state->_pattern_matched) {
+            if constexpr (LIKE_PATTERN) {
+                substring_state->like_pattern_match(pattern_str);
+            } else {
+                substring_state->regexp_pattern_match(pattern_str);
+            }
+        }
+        if (starts_with_state->_pattern_matched) {
+            if constexpr (LIKE_PATTERN) {
+                starts_with_state->like_pattern_match(pattern_str);
+            } else {
+                starts_with_state->regexp_pattern_match(pattern_str);
+            }
+        }
+        if (ends_with_state->_pattern_matched) {
+            if constexpr (LIKE_PATTERN) {
+                ends_with_state->like_pattern_match(pattern_str);
+            } else {
+                ends_with_state->regexp_pattern_match(pattern_str);
+            }
+        }
+    }
+
+    if (allpass_state->_pattern_matched) {
+        return allpass_state;
+    } else if (equal_state->_pattern_matched) {
+        return equal_state;
+    } else if (substring_state->_pattern_matched) {
+        return substring_state;
+    } else if (starts_with_state->_pattern_matched) {
+        return starts_with_state;
+    } else if (ends_with_state->_pattern_matched) {
+        return ends_with_state;
+    } else {
+        return nullptr;
+    }
+}
+
+Status FunctionLikeBase::vector_non_const(const ColumnString& values, const 
ColumnString& patterns,

Review Comment:
   warning: method 'vector_non_const' can be made static 
[readability-convert-member-functions-to-static]
   
   ```suggestion
   static Status FunctionLikeBase::vector_non_const(const ColumnString& values, 
const ColumnString& patterns,
   ```
   
   be/src/vec/functions/like.cpp:674:
   ```diff
   -                                           size_t input_rows_count) const {
   +                                           size_t input_rows_count) {
   ```
   



##########
be/src/vec/functions/like.cpp:
##########
@@ -89,13 +213,26 @@ Status LikeSearchState::clone(LikeSearchState& cloned) {
     return Status::OK();
 }
 
-Status FunctionLikeBase::constant_allpass_fn(LikeSearchState* state, const 
ColumnString& val,
+Status FunctionLikeBase::constant_allpass_fn(LikeSearchState* state, const 
ColumnString& vals,

Review Comment:
   warning: method 'constant_allpass_fn' can be made static 
[readability-convert-member-functions-to-static]
   
   ```suggestion
   static Status FunctionLikeBase::constant_allpass_fn(LikeSearchState* state, 
const ColumnString& vals,
   ```
   



##########
be/src/vec/functions/like.h:
##########
@@ -118,12 +118,36 @@ using LikeFn = 
std::function<doris::Status(LikeSearchState*, const ColumnString&
 using ScalarLikeFn = std::function<doris::Status(LikeSearchState*, const 
StringRef&,
                                                  const StringRef&, unsigned 
char*)>;
 
+using VectorLikeFn = std::function<doris::Status(const ColumnString&, const 
ColumnString&,
+                                                 ColumnUInt8::Container&)>;
+
 struct LikeState {
+    bool is_like_pattern;
     LikeSearchState search_state;
     LikeFn function;
     ScalarLikeFn scalar_function;
 };
 
+struct VectorPatternSearchState {
+    MutableColumnPtr _search_strings;
+    std::string _search_string;
+    VectorLikeFn _vector_function;
+    bool _pattern_matched;

Review Comment:
   warning: use default member initializer for '_pattern_matched' 
[modernize-use-default-member-init]
   
   ```suggestion
       bool _pattern_matched{true};
   ```
   
   be/src/vec/functions/like.h:139:
   ```diff
   -               _pattern_matched(true) {}
   +               {}
   ```
   



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to