zclllyybb commented on code in PR #37959:
URL: https://github.com/apache/doris/pull/37959#discussion_r1682270398


##########
be/src/vec/functions/regexps.h:
##########
@@ -136,42 +136,45 @@ Regexps constructRegexps(const std::vector<String>& 
str_patterns,
     /// We mark the patterns to provide the callback results.
     if constexpr (save_indices) {
         ids.reset(new unsigned int[patterns.size()]);
-        for (size_t i = 0; i < patterns.size(); ++i) ids[i] = 
static_cast<unsigned>(i + 1);
+        for (size_t i = 0; i < patterns.size(); ++i) {
+            ids[i] = static_cast<unsigned>(i + 1);
+        }
     }
 
     for (auto& pattern : patterns) {
         LOG(INFO) << "pattern: " << pattern << "\n";
     }
 
     hs_error_t err;
-    if constexpr (!WithEditDistance)
+    if constexpr (!WithEditDistance) {
         err = hs_compile_multi(patterns.data(), flags.data(), ids.get(),
                                static_cast<unsigned>(patterns.size()), 
HS_MODE_BLOCK, nullptr, &db,
                                &compile_error);
-    else
+    } else {
         err = hs_compile_ext_multi(patterns.data(), flags.data(), ids.get(), 
ext_exprs_ptrs.data(),
                                    static_cast<unsigned>(patterns.size()), 
HS_MODE_BLOCK, nullptr,
                                    &db, &compile_error);
+    }
 
     if (err != HS_SUCCESS) {
         /// CompilerError is a unique_ptr, so correct memory free after the 
exception is thrown.
         CompilerError error(compile_error);
 
-        if (error->expression < 0)
-            LOG(FATAL) << "Logical error: " + String(error->message);
-        else
-            LOG(FATAL) << "Bad arguments: Pattern " + 
str_patterns[error->expression] +
-                                  "failed with error " + 
String(error->message);
+        if (error->expression < 0) { // error has nothing to do with the 
patterns themselves
+            throw doris::Exception(Status::InternalError("Compile regexp 
expression failed. got {}",
+                                                         error->message));
+        } else {
+            throw doris::Exception(Status::InvalidArgument(
+                    "Compile regexp expression failed. got {}. some 
expressions may be illegal",
+                    error->message));
+        }
     }
 
     /// We allocate the scratch space only once, then copy it across multiple 
threads with hs_clone_scratch
     /// function which is faster than allocating scratch space each time in 
each thread.
     hs_scratch_t* scratch = nullptr;
     err = hs_alloc_scratch(db, &scratch);
 
-    /// If not HS_SUCCESS, it is guaranteed that the memory would not be 
allocated for scratch.
-    if (err != HS_SUCCESS) LOG(FATAL) << "Could not allocate scratch space for 
hyperscan";

Review Comment:
   it will be Exception thrown in code above. this check will never be 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