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

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


The following commit(s) were added to refs/heads/branch-4.1 by this push:
     new ea18ba1f84b branch-4.1: [fix](be) Defer Bloom allocation for IN 
runtime filters #68763 (#68789)
ea18ba1f84b is described below

commit ea18ba1f84b49be09d19f0384d2305373b964c14
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Oct 9 09:26:35 2026 +0800

    branch-4.1: [fix](be) Defer Bloom allocation for IN runtime filters #68763 
(#68789)
    
    Cherry-picked from #68763
    
    Co-authored-by: Mryange <[email protected]>
---
 .../exec/runtime_filter/runtime_filter_wrapper.cpp |  2 +-
 .../runtime_filter/runtime_filter_wrapper_test.cpp | 42 ++++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/be/src/exec/runtime_filter/runtime_filter_wrapper.cpp 
b/be/src/exec/runtime_filter/runtime_filter_wrapper.cpp
index 4b0a8ca8090..330bcb6895e 100644
--- a/be/src/exec/runtime_filter/runtime_filter_wrapper.cpp
+++ b/be/src/exec/runtime_filter/runtime_filter_wrapper.cpp
@@ -75,7 +75,7 @@ Status RuntimeFilterWrapper::init(const size_t real_size) {
     if (get_real_type() == RuntimeFilterType::IN_FILTER && real_size > 
_max_in_num) {
         set_state(RuntimeFilterWrapper::State::DISABLED, "reach max in num");
     }
-    if (_bloom_filter_func) {
+    if (get_real_type() == RuntimeFilterType::BLOOM_FILTER) {
         RETURN_IF_ERROR(_bloom_filter_func->init_with_fixed_length(real_size));
     }
     return Status::OK();
diff --git a/be/test/exec/runtime_filter/runtime_filter_wrapper_test.cpp 
b/be/test/exec/runtime_filter/runtime_filter_wrapper_test.cpp
index d5b2f9d9641..44cde989ab0 100644
--- a/be/test/exec/runtime_filter/runtime_filter_wrapper_test.cpp
+++ b/be/test/exec/runtime_filter/runtime_filter_wrapper_test.cpp
@@ -749,6 +749,46 @@ TEST_F(RuntimeFilterWrapperTest, TestMinMax) {
     }
 }
 
+TEST_F(RuntimeFilterWrapperTest, TestInOrBloomLazyInitialization) {
+    for (bool build_by_runtime_size : {false, true}) {
+        RuntimeFilterParams params {.filter_id = 0,
+                                    .filter_type = 
RuntimeFilterType::IN_OR_BLOOM_FILTER,
+                                    .column_return_type = TYPE_INT,
+                                    .null_aware = false,
+                                    .max_in_num = 16,
+                                    .runtime_bloom_filter_min_size = 64,
+                                    .runtime_bloom_filter_max_size = 128,
+                                    .bloom_filter_size = 64,
+                                    .build_bf_by_runtime_size = 
build_by_runtime_size,
+                                    .bloom_filter_size_calculated_by_ndv = 
false};
+        for (size_t runtime_size : {0, 1, 16, 17}) {
+            SCOPED_TRACE(runtime_size);
+            SCOPED_TRACE(build_by_runtime_size);
+            RuntimeFilterWrapper wrapper(&params);
+            ASSERT_NE(wrapper.bloom_filter_func(), nullptr);
+            ASSERT_EQ(wrapper.bloom_filter_func()->get_size(), 0);
+            ASSERT_TRUE(wrapper.init(runtime_size).ok());
+            if (runtime_size <= static_cast<size_t>(params.max_in_num)) {
+                EXPECT_EQ(wrapper.get_real_type(), 
RuntimeFilterType::IN_FILTER);
+                EXPECT_EQ(wrapper.bloom_filter_func()->get_size(), 0);
+                EXPECT_EQ(wrapper.bloom_filter_func()->_bloom_filter_alloced, 
0);
+                EXPECT_EQ(wrapper.bloom_filter_func()->_bloom_filter, nullptr);
+                PMergeFilterRequest request;
+                
ASSERT_TRUE(wrapper.to_protobuf(request.mutable_in_filter()).ok());
+            } else {
+                EXPECT_EQ(wrapper.get_real_type(), 
RuntimeFilterType::BLOOM_FILTER);
+                EXPECT_GT(wrapper.bloom_filter_func()->get_size(), 0);
+                auto col = ColumnHelper::create_column<DataTypeInt32>({1, 2, 
3});
+                ASSERT_TRUE(wrapper.insert(col, 0).ok());
+                std::vector<uint8_t> matches(3);
+                wrapper.bloom_filter_func()->find_fixed_len(col, 
matches.data());
+                EXPECT_TRUE(std::all_of(matches.begin(), matches.end(),
+                                        [](uint8_t match) { return match != 0; 
}));
+            }
+        }
+    }
+}
+
 TEST_F(RuntimeFilterWrapperTest, TestInOrBloom) {
     std::vector<int> data_vector(10);
     std::iota(data_vector.begin(), data_vector.end(), 0);
@@ -817,6 +857,7 @@ TEST_F(RuntimeFilterWrapperTest, TestInOrBloom) {
         // Init (keep in filter)
         EXPECT_TRUE(wrapper->init(runtime_size).ok());
         EXPECT_EQ(wrapper->get_real_type(), RuntimeFilterType::IN_FILTER);
+        EXPECT_EQ(wrapper->bloom_filter_func()->get_size(), 0);
         EXPECT_EQ(wrapper->get_state(), RuntimeFilterWrapper::State::UNINITED);
         // Insert
         auto col = ColumnHelper::create_column<DataType>(data_vector);
@@ -875,6 +916,7 @@ TEST_F(RuntimeFilterWrapperTest, TestInOrBloom) {
         EXPECT_TRUE(wrapper->merge(new_wrapper.get()).ok());
         EXPECT_EQ(wrapper->hybrid_set()->size(), col->size() * 2);
         EXPECT_EQ(wrapper->get_real_type(), RuntimeFilterType::IN_FILTER);
+        EXPECT_EQ(wrapper->bloom_filter_func()->get_size(), 0);
     }
     {
         // In + In -> Bloom


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to