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

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


The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
     new 6f79eb61f0 [Bug](bloomfilter) Fix bloom filter for date type (#18205) 
(#18491)
6f79eb61f0 is described below

commit 6f79eb61f00822dcc897f590a2395bcbf1db85d7
Author: Gabriel <gabrielleeb...@gmail.com>
AuthorDate: Mon Apr 10 09:59:11 2023 +0800

    [Bug](bloomfilter) Fix bloom filter for date type (#18205) (#18491)
    
    pick #18205
---
 be/src/exprs/bloomfilter_predicate.h |  5 +++++
 be/src/vec/functions/like.cpp        | 22 +++++++++++-----------
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/be/src/exprs/bloomfilter_predicate.h 
b/be/src/exprs/bloomfilter_predicate.h
index c0c6516fe6..88ad5e7e26 100644
--- a/be/src/exprs/bloomfilter_predicate.h
+++ b/be/src/exprs/bloomfilter_predicate.h
@@ -346,6 +346,11 @@ struct DateFindOp : public 
CommonFindOp<vectorized::VecDateTimeValue> {
 
         vectorized::VecDateTimeValue date_value;
         date_value.from_olap_date(value);
+        // So confusing here. For join node with condition (a.date_col = 
b.date_col), the actual
+        // expression is CAST(a.date_col AS DATETIME) = CAST(b.date_col AS 
DATETIME). So we build
+        // this bloom filter by CAST(a.date_col AS DATETIME) and also need to 
probe this bloom
+        // filter by a datetime value.
+        date_value.set_type(TimeType::TIME_DATETIME);
 
         return bloom_filter.test(Slice((char*)&date_value, 
sizeof(vectorized::VecDateTimeValue)));
     }
diff --git a/be/src/vec/functions/like.cpp b/be/src/vec/functions/like.cpp
index 9f4b10bae2..041f6a7a80 100644
--- a/be/src/vec/functions/like.cpp
+++ b/be/src/vec/functions/like.cpp
@@ -67,7 +67,7 @@ Status LikeSearchState::clone(LikeSearchState& cloned) {
         if (!cloned.regex->ok()) {
             return Status::InternalError("Invalid regex expression: {}", 
re_pattern);
         }
-     }
+    }
 
     return Status::OK();
 }
@@ -211,7 +211,7 @@ Status 
FunctionLikeBase::constant_regex_fn_scalar(LikeSearchState* state, const
                                                   unsigned char* result) {
     if (state->hs_database) { // use hyperscan
         auto ret = hs_scan(state->hs_database.get(), val.data, val.size, 0, 
state->hs_scratch.get(),
-                        state->hs_match_handler, (void*)result);
+                           state->hs_match_handler, (void*)result);
         if (ret != HS_SUCCESS && ret != HS_SCAN_TERMINATED) {
             return Status::RuntimeError(fmt::format("hyperscan error: {}", 
ret));
         }
@@ -230,7 +230,7 @@ Status FunctionLikeBase::regexp_fn_scalar(LikeSearchState* 
state, const StringRe
     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, 
state->hs_match_handler,
-                        (void*)result);
+                           (void*)result);
         if (ret != HS_SUCCESS && ret != HS_SCAN_TERMINATED) {
             return Status::RuntimeError(fmt::format("hyperscan error: {}", 
ret));
         }
@@ -247,7 +247,7 @@ Status FunctionLikeBase::regexp_fn_scalar(LikeSearchState* 
state, const StringRe
         } else {
             return Status::RuntimeError("Invalid pattern: {}", 
pattern.debug_string());
         }
-    }    
+    }
 
     return Status::OK();
 }
@@ -260,8 +260,8 @@ Status FunctionLikeBase::constant_regex_fn(LikeSearchState* 
state, const ColumnS
         for (size_t i = 0; i < sz; i++) {
             const auto& str_ref = val.get_data_at(i);
             auto ret = hs_scan(state->hs_database.get(), str_ref.data, 
str_ref.size, 0,
-                            state->hs_scratch.get(), state->hs_match_handler,
-                            (void*)(result.data() + i));
+                               state->hs_scratch.get(), 
state->hs_match_handler,
+                               (void*)(result.data() + i));
             if (ret != HS_SUCCESS && ret != HS_SCAN_TERMINATED) {
                 return Status::RuntimeError(fmt::format("hyperscan error: {}", 
ret));
             }
@@ -288,7 +288,7 @@ Status FunctionLikeBase::regexp_fn(LikeSearchState* state, 
const ColumnString& v
         for (size_t i = 0; i < sz; i++) {
             const auto& str_ref = val.get_data_at(i);
             auto ret = hs_scan(database, str_ref.data, str_ref.size, 0, 
scratch,
-                            state->hs_match_handler, (void*)(result.data() + 
i));
+                               state->hs_match_handler, (void*)(result.data() 
+ i));
             if (ret != HS_SUCCESS && ret != HS_SCAN_TERMINATED) {
                 return Status::RuntimeError(fmt::format("hyperscan error: {}", 
ret));
             }
@@ -324,9 +324,9 @@ Status 
FunctionLikeBase::constant_regex_fn_predicate(LikeSearchState* state,
     auto data_ptr = reinterpret_cast<const StringRef*>(val.get_data().data());
     if (state->hs_database) { // use hyperscan
         for (size_t i = 0; i < sz; i++) {
-            auto ret = hs_scan(state->hs_database.get(), 
data_ptr[sel[i]].data, data_ptr[sel[i]].size,
-                            0, state->hs_scratch.get(), 
state->hs_match_handler,
-                            (void*)(result.data() + i));
+            auto ret = hs_scan(state->hs_database.get(), data_ptr[sel[i]].data,
+                               data_ptr[sel[i]].size, 0, 
state->hs_scratch.get(),
+                               state->hs_match_handler, (void*)(result.data() 
+ i));
             if (ret != HS_SUCCESS && ret != HS_SCAN_TERMINATED) {
                 return Status::RuntimeError(fmt::format("hyperscan error: {}", 
ret));
             }
@@ -355,7 +355,7 @@ Status 
FunctionLikeBase::regexp_fn_predicate(LikeSearchState* state,
         auto data_ptr = reinterpret_cast<const 
StringRef*>(val.get_data().data());
         for (size_t i = 0; i < sz; i++) {
             auto ret = hs_scan(database, data_ptr[sel[i]].data, 
data_ptr[sel[i]].size, 0, scratch,
-                            state->hs_match_handler, (void*)(result.data() + 
i));
+                               state->hs_match_handler, (void*)(result.data() 
+ i));
             if (ret != HS_SUCCESS && ret != HS_SCAN_TERMINATED) {
                 return Status::RuntimeError(fmt::format("hyperscan error: {}", 
ret));
             }


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

Reply via email to