This is an automated email from the ASF dual-hosted git repository. panxiaolei pushed a commit to branch refactor_rf in repository https://gitbox.apache.org/repos/asf/doris.git
commit 6e4173933d9927a5f97c8d81f596ac4a617d5a0e Author: Gabriel <liwenqi...@selectdb.com> AuthorDate: Tue Mar 4 19:05:10 2025 +0800 test (#48630) --- be/src/runtime_filter/runtime_filter_wrapper.cpp | 5 +- .../runtime_filter/runtime_filter_wrapper_test.cpp | 64 ++++++++++++++++++++++ be/test/runtime_filter/utils_test.cpp | 2 +- 3 files changed, 68 insertions(+), 3 deletions(-) diff --git a/be/src/runtime_filter/runtime_filter_wrapper.cpp b/be/src/runtime_filter/runtime_filter_wrapper.cpp index df850312150..e248082667d 100644 --- a/be/src/runtime_filter/runtime_filter_wrapper.cpp +++ b/be/src/runtime_filter/runtime_filter_wrapper.cpp @@ -164,7 +164,7 @@ Status RuntimeFilterWrapper::merge(const RuntimeFilterWrapper* other) { DCHECK(_state != State::IGNORED); DCHECK(other->_state == State::READY); - DCHECK(_filter_type == other->_filter_type) << debug_string(); + DCHECK(_filter_type == other->_filter_type); switch (_filter_type) { case RuntimeFilterType::IN_FILTER: { @@ -580,7 +580,8 @@ std::string RuntimeFilterWrapper::debug_string() const { filter_type_to_string(get_real_type())) : filter_type_to_string(_filter_type); auto result = fmt::format("[id: {}, state: {}, type: {}, column_type: {}", _filter_id, - to_string(_state), type_string, type_to_string(_column_return_type)); + states_to_string<RuntimeFilterWrapper>({_state}), type_string, + type_to_string(_column_return_type)); if (_state == State::READY) { if (get_real_type() == RuntimeFilterType::BLOOM_FILTER) { diff --git a/be/test/runtime_filter/runtime_filter_wrapper_test.cpp b/be/test/runtime_filter/runtime_filter_wrapper_test.cpp index 5ca0443bfb9..af3f154b13a 100644 --- a/be/test/runtime_filter/runtime_filter_wrapper_test.cpp +++ b/be/test/runtime_filter/runtime_filter_wrapper_test.cpp @@ -1063,6 +1063,70 @@ TEST_F(RuntimeFilterWrapperTest, TestInOrBloom) { EXPECT_EQ(wrapper->hybrid_set()->size(), col->size() * 2); EXPECT_EQ(wrapper->get_real_type(), RuntimeFilterType::IN_FILTER); } + { + // In + In -> Bloom + max_in_num = 16; + runtime_size = 10; + RuntimeFilterParams params { + .filter_id = filter_id, + .filter_type = filter_type, + .column_return_type = column_return_type, + .null_aware = null_aware, + .max_in_num = max_in_num, + .runtime_bloom_filter_min_size = runtime_bloom_filter_min_size, + .runtime_bloom_filter_max_size = runtime_bloom_filter_max_size, + .bloom_filter_size = bloom_filter_size, + .build_bf_by_runtime_size = build_bf_by_runtime_size, + .bloom_filter_size_calculated_by_ndv = bloom_filter_size_calculated_by_ndv, + .enable_fixed_len_to_uint32_v2 = enable_fixed_len_to_uint32_v2, + .bitmap_filter_not_in = bitmap_filter_not_in}; + wrapper = std::make_shared<RuntimeFilterWrapper>(¶ms); + EXPECT_EQ(wrapper->get_real_type(), RuntimeFilterType::IN_FILTER); + EXPECT_TRUE(wrapper->init(runtime_size).ok()); + EXPECT_EQ(wrapper->get_real_type(), RuntimeFilterType::IN_FILTER); + RuntimeFilterParams new_params { + .filter_id = filter_id, + .filter_type = filter_type, + .column_return_type = column_return_type, + .null_aware = null_aware, + .max_in_num = max_in_num, + .runtime_bloom_filter_min_size = runtime_bloom_filter_min_size, + .runtime_bloom_filter_max_size = runtime_bloom_filter_max_size, + .bloom_filter_size = bloom_filter_size, + .build_bf_by_runtime_size = build_bf_by_runtime_size, + .bloom_filter_size_calculated_by_ndv = bloom_filter_size_calculated_by_ndv, + .enable_fixed_len_to_uint32_v2 = enable_fixed_len_to_uint32_v2, + .bitmap_filter_not_in = bitmap_filter_not_in}; + auto new_wrapper = std::make_shared<RuntimeFilterWrapper>(&new_params); + EXPECT_EQ(new_wrapper->get_real_type(), RuntimeFilterType::IN_FILTER); + EXPECT_TRUE(new_wrapper->init(runtime_size).ok()); + EXPECT_EQ(new_wrapper->get_real_type(), RuntimeFilterType::IN_FILTER); + // Insert + auto col = vectorized::ColumnHelper::create_column<DataType>(data_vector); + EXPECT_TRUE(wrapper->insert(col, 0).ok()); + EXPECT_EQ(wrapper->get_state(), RuntimeFilterWrapper::State::UNINITED); + EXPECT_EQ(wrapper->hybrid_set()->size(), col->size()); + + std::vector<int> new_data_vector(10); + std::iota(new_data_vector.begin(), new_data_vector.end(), 10); + col = vectorized::ColumnHelper::create_column<DataType>(new_data_vector); + EXPECT_TRUE(new_wrapper->insert(col, 0).ok()); + EXPECT_EQ(new_wrapper->get_state(), RuntimeFilterWrapper::State::UNINITED); + EXPECT_EQ(new_wrapper->hybrid_set()->size(), col->size()); + new_wrapper->_state = RuntimeFilterWrapper::State::READY; + // Merge + EXPECT_TRUE(wrapper->merge(new_wrapper.get()).ok()); + + + std::vector<int> final_data_vector(20); + std::iota(final_data_vector.begin(), final_data_vector.end(), 0); + col = vectorized::ColumnHelper::create_column<DataType>(final_data_vector); + std::vector<uint8_t> final_res(20); + wrapper->bloom_filter_func()->find_fixed_len(col, final_res.data()); + EXPECT_TRUE(std::all_of(final_res.begin(), final_res.end(), + [](uint8_t i) -> bool { return i; })); + EXPECT_EQ(wrapper->get_real_type(), RuntimeFilterType::BLOOM_FILTER); + } { // In + Bloom -> Bloom max_in_num = 18; diff --git a/be/test/runtime_filter/utils_test.cpp b/be/test/runtime_filter/utils_test.cpp index ca7a91a1fc7..6f41bf2c2f3 100644 --- a/be/test/runtime_filter/utils_test.cpp +++ b/be/test/runtime_filter/utils_test.cpp @@ -105,7 +105,7 @@ TEST_F(RuntimeFilterUtilsTest, TestCreateBinaryPredicate) { TExprNode pred_node; TypeDescriptor type(PrimitiveType::TYPE_INT); auto op = TExprOpcode::GE; - EXPECT_TRUE(create_vbin_predicate(type, op, expr, &pred_node, false).ok()); + EXPECT_TRUE(create_vbin_predicate(type, op, expr, &pred_node, true).ok()); } { vectorized::VExprSPtr expr; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org