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 40154029b81 branch-4.1: [fix](test) Restore bitmap config flags in 
bitmap unit tests (#71395)
40154029b81 is described below

commit 40154029b818c3e055e9d20b80ed74e7a9e56d53
Author: linrrarity <[email protected]>
AuthorDate: Fri Dec 4 09:28:41 2026 +0800

    branch-4.1: [fix](test) Restore bitmap config flags in bitmap unit tests 
(#71395)
    
    pick: https://github.com/apache/doris/pull/71341
---
 be/test/core/value/bitmap_value_test.cpp        | 177 +++++++++++++-----------
 be/test/exprs/function/function_bitmap_test.cpp |  43 +++---
 2 files changed, 118 insertions(+), 102 deletions(-)

diff --git a/be/test/core/value/bitmap_value_test.cpp 
b/be/test/core/value/bitmap_value_test.cpp
index 5b25551ae0c..141ef146e9c 100644
--- a/be/test/core/value/bitmap_value_test.cpp
+++ b/be/test/core/value/bitmap_value_test.cpp
@@ -21,6 +21,7 @@
 #include <gtest/gtest-test-part.h>
 #include <roaring/roaring.h>
 
+#include <algorithm>
 #include <cstdint>
 #include <string>
 
@@ -263,6 +264,7 @@ TEST(BitmapValueTest, Roaring64Map_iterators) {
 }
 
 TEST(BitmapValueTest, set) {
+    const auto old_enable_set = config::enable_set_in_bitmap_value;
     config::enable_set_in_bitmap_value = false;
     BitmapValue bitmap_value;
 
@@ -305,10 +307,11 @@ TEST(BitmapValueTest, set) {
     bitmap_value6.add(4294967297);
     EXPECT_EQ(bitmap_value6.get_type_code(), BitmapTypeCode::BITMAP64);
 
-    config::enable_set_in_bitmap_value = false;
+    config::enable_set_in_bitmap_value = old_enable_set;
 }
 
 TEST(BitmapValueTest, add) {
+    const auto old_enable_set = config::enable_set_in_bitmap_value;
     config::enable_set_in_bitmap_value = true;
 
     std::vector<uint64_t> values(1);
@@ -353,7 +356,7 @@ TEST(BitmapValueTest, add) {
     std::iota(values.begin(), values.end(), 32);
     bitmap_value.add_many(values.data(), values.size());
     EXPECT_EQ(bitmap_value.get_type_code(), BitmapTypeCode::BITMAP32);
-    config::enable_set_in_bitmap_value = false;
+    config::enable_set_in_bitmap_value = old_enable_set;
 }
 
 void check_bitmap_value_operator(const BitmapValue& left, const BitmapValue& 
right) {
@@ -426,6 +429,7 @@ TEST(BitmapValueTest, copy_operator) {
 
 // '-=', '|=', '&=', '^='
 TEST(BitmapValueTest, operators) {
+    const auto old_enable_set = config::enable_set_in_bitmap_value;
     config::enable_set_in_bitmap_value = true;
     BitmapValue left_empty;
     BitmapValue right_emtpy;
@@ -486,7 +490,7 @@ TEST(BitmapValueTest, operators) {
     check_bitmap_value_operator(left_bitmap, right_set);
     check_bitmap_value_operator(left_bitmap, right_bitmap);
 
-    config::enable_set_in_bitmap_value = false;
+    config::enable_set_in_bitmap_value = old_enable_set;
 }
 
 void check_bitmap_equal(const BitmapValue& left, const BitmapValue& right) {
@@ -504,6 +508,7 @@ void check_bitmap_equal(const BitmapValue& left, const 
BitmapValue& right) {
 }
 
 TEST(BitmapValueTest, write_read) {
+    const auto old_enable_set = config::enable_set_in_bitmap_value;
     config::enable_set_in_bitmap_value = true;
     BitmapValue bitmap_empty;
     BitmapValue bitmap_single(1);
@@ -560,10 +565,11 @@ TEST(BitmapValueTest, write_read) {
 
     check_bitmap_equal(deserialized, bitmap);
 
-    config::enable_set_in_bitmap_value = false;
+    config::enable_set_in_bitmap_value = old_enable_set;
 }
 
 TEST(BitmapValueTest, set_to_string) {
+    const auto old_enable_set = config::enable_set_in_bitmap_value;
     config::enable_set_in_bitmap_value = true;
     BitmapValue bitmap;
     bitmap.add(1);
@@ -573,10 +579,11 @@ TEST(BitmapValueTest, set_to_string) {
     EXPECT_EQ(bitmap.get_type_code(), BitmapTypeCode::SET);
 
     EXPECT_EQ(bitmap.to_string(), "1,2,3");
-    config::enable_set_in_bitmap_value = false;
+    config::enable_set_in_bitmap_value = old_enable_set;
 }
 
 TEST(BitmapValueTest, min_max) {
+    const auto old_enable_set = config::enable_set_in_bitmap_value;
     config::enable_set_in_bitmap_value = true;
     BitmapValue bitmap;
 
@@ -621,10 +628,11 @@ TEST(BitmapValueTest, min_max) {
     EXPECT_EQ(max, bitmap.maximum());
     EXPECT_EQ(max, 42949672970 + 63);
 
-    config::enable_set_in_bitmap_value = false;
+    config::enable_set_in_bitmap_value = old_enable_set;
 }
 
 TEST(BitmapValueTest, sub_range_limit) {
+    const auto old_enable_set = config::enable_set_in_bitmap_value;
     config::enable_set_in_bitmap_value = true;
     BitmapValue bitmap;
 
@@ -701,7 +709,7 @@ TEST(BitmapValueTest, sub_range_limit) {
     EXPECT_EQ(ret, 10);
     ret = bitmap.offset_limit(100, 10, &out);
     EXPECT_EQ(ret, 10);
-    config::enable_set_in_bitmap_value = false;
+    config::enable_set_in_bitmap_value = old_enable_set;
 }
 
 void bitmap_checker_for_all_type(const std::function<void(const 
BitmapValue&)>& checker) {
@@ -732,6 +740,7 @@ void bitmap_checker_for_all_type(const 
std::function<void(const BitmapValue&)>&
 }
 
 TEST(BitmapValueTest, to_array) {
+    const auto old_enable_set = config::enable_set_in_bitmap_value;
     config::enable_set_in_bitmap_value = true;
     auto checker = [](const BitmapValue& bitmap) {
         auto size = bitmap.cardinality();
@@ -749,10 +758,11 @@ TEST(BitmapValueTest, to_array) {
     };
 
     bitmap_checker_for_all_type(checker);
-    config::enable_set_in_bitmap_value = false;
+    config::enable_set_in_bitmap_value = old_enable_set;
 }
 
 TEST(BitmapValueTest, BitmapValueIterator) {
+    const auto old_enable_set = config::enable_set_in_bitmap_value;
     config::enable_set_in_bitmap_value = true;
     auto checker = [](const BitmapValue& bitmap) {
         auto begin = bitmap.begin();
@@ -774,29 +784,36 @@ TEST(BitmapValueTest, BitmapValueIterator) {
     };
 
     bitmap_checker_for_all_type(checker);
-    config::enable_set_in_bitmap_value = false;
+    config::enable_set_in_bitmap_value = old_enable_set;
 }
 
 TEST(BitmapValueTest, copy) {
-    BitmapValue empty;
-    BitmapValue single(1024);
-    BitmapValue bitmap({1024, 1025, 1026});
+    const auto old_enable_set = config::enable_set_in_bitmap_value;
+    for (bool enable_set : {false, true}) {
+        config::enable_set_in_bitmap_value = enable_set;
 
-    BitmapValue copied = bitmap;
-    EXPECT_TRUE(copied.contains(1024));
-    EXPECT_TRUE(copied.contains(1025));
-    EXPECT_TRUE(copied.contains(1026));
-    copied &= single;
-
-    // value of copied changed.
-    EXPECT_TRUE(copied.contains(1024));
-    EXPECT_FALSE(copied.contains(1025));
-    EXPECT_FALSE(copied.contains(1026));
-
-    // value of bitmap not changed.
-    EXPECT_TRUE(bitmap.contains(1024));
-    EXPECT_TRUE(bitmap.contains(1025));
-    EXPECT_TRUE(bitmap.contains(1026));
+        BitmapValue empty;
+        BitmapValue single(1024);
+        BitmapValue bitmap({1024, 1025, 1026});
+        EXPECT_EQ(enable_set ? BitmapValue::SET : BitmapValue::BITMAP, 
bitmap._type);
+
+        BitmapValue copied = bitmap;
+        EXPECT_TRUE(copied.contains(1024));
+        EXPECT_TRUE(copied.contains(1025));
+        EXPECT_TRUE(copied.contains(1026));
+        copied &= single;
+
+        // value of copied changed.
+        EXPECT_TRUE(copied.contains(1024));
+        EXPECT_FALSE(copied.contains(1025));
+        EXPECT_FALSE(copied.contains(1026));
+
+        // value of bitmap not changed.
+        EXPECT_TRUE(bitmap.contains(1024));
+        EXPECT_TRUE(bitmap.contains(1025));
+        EXPECT_TRUE(bitmap.contains(1026));
+    }
+    config::enable_set_in_bitmap_value = old_enable_set;
 }
 
 TEST(BitmapValueTest, bitmap_union) {
@@ -1109,25 +1126,36 @@ TEST(BitmapValueTest, bitmap_to_string) {
 }
 
 TEST(BitmapValueTest, sub_limit) {
-    BitmapValue bitmap({1, 2, 3, 10, 11, 5, 6, 7, 8, 9});
-    BitmapValue ret_bitmap1;
-    EXPECT_EQ(5, bitmap.sub_limit(0, 5, &ret_bitmap1));
-    EXPECT_STREQ("1,2,3,5,6", ret_bitmap1.to_string().c_str());
-
-    BitmapValue ret_bitmap2;
-    EXPECT_EQ(6, bitmap.sub_limit(6, 10, &ret_bitmap2));
-    EXPECT_STREQ("6,7,8,9,10,11", ret_bitmap2.to_string().c_str());
-
-    BitmapValue ret_bitmap3;
-    EXPECT_EQ(3, bitmap.sub_limit(5, 3, &ret_bitmap3));
-    EXPECT_STREQ("5,6,7", ret_bitmap3.to_string().c_str());
-
-    BitmapValue ret_bitmap4;
-    EXPECT_EQ(5, bitmap.sub_limit(2, 5, &ret_bitmap4));
-    EXPECT_STREQ("2,3,5,6,7", ret_bitmap4.to_string().c_str());
+    const auto old_enable_set = config::enable_set_in_bitmap_value;
+    for (bool enable_set : {false, true}) {
+        config::enable_set_in_bitmap_value = enable_set;
+
+        BitmapValue bitmap({1, 2, 3, 10, 11, 5, 6, 7, 8, 9});
+        EXPECT_EQ(enable_set ? BitmapValue::SET : BitmapValue::BITMAP, 
bitmap._type);
+
+        BitmapValue ret_bitmap1;
+        EXPECT_EQ(5, bitmap.sub_limit(0, 5, &ret_bitmap1));
+        EXPECT_STREQ("1,2,3,5,6", ret_bitmap1.to_string().c_str());
+
+        BitmapValue ret_bitmap2;
+        EXPECT_EQ(6, bitmap.sub_limit(6, 10, &ret_bitmap2));
+        EXPECT_STREQ("6,7,8,9,10,11", ret_bitmap2.to_string().c_str());
+
+        BitmapValue ret_bitmap3;
+        EXPECT_EQ(3, bitmap.sub_limit(5, 3, &ret_bitmap3));
+        EXPECT_STREQ("5,6,7", ret_bitmap3.to_string().c_str());
+
+        BitmapValue ret_bitmap4;
+        EXPECT_EQ(5, bitmap.sub_limit(2, 5, &ret_bitmap4));
+        EXPECT_STREQ("2,3,5,6,7", ret_bitmap4.to_string().c_str());
+    }
+    config::enable_set_in_bitmap_value = old_enable_set;
 }
 
 TEST(BitmapValueTest, bitmap_single_convert) {
+    const auto old_enable_set = config::enable_set_in_bitmap_value;
+    config::enable_set_in_bitmap_value = false;
+
     BitmapValue bitmap;
     EXPECT_STREQ("", bitmap.to_string().c_str());
     bitmap.add(1);
@@ -1146,47 +1174,42 @@ TEST(BitmapValueTest, bitmap_single_convert) {
 
     bitmap |= bitmap_u;
     EXPECT_EQ(BitmapValue::BITMAP, bitmap._type);
+
+    config::enable_set_in_bitmap_value = old_enable_set;
 }
 
 TEST(BitmapValueTest, bitmap_value_iterator_test) {
-    BitmapValue empty;
-    for (auto iter = empty.begin(); iter != empty.end(); ++iter) {
-        // should not goes here
-        EXPECT_TRUE(false);
-    }
+    const auto old_enable_set = config::enable_set_in_bitmap_value;
+    for (bool enable_set : {false, true}) {
+        config::enable_set_in_bitmap_value = enable_set;
 
-    BitmapValue single(1024);
-    auto single_iter = single.begin();
-    EXPECT_EQ(1024, *single_iter);
-    EXPECT_TRUE(single_iter == BitmapValue {1024}.begin());
-    EXPECT_TRUE(single_iter != single.end());
-
-    ++single_iter;
-    EXPECT_TRUE(single_iter == single.end());
-
-    int i = 0;
-    BitmapValue bitmap({0, 1025, 1026, UINT32_MAX, UINT64_MAX});
-    for (auto iter = bitmap.begin(); iter != bitmap.end(); ++iter, ++i) {
-        switch (i) {
-        case 0:
-            EXPECT_EQ(0, *iter);
-            break;
-        case 1:
-            EXPECT_EQ(1025, *iter);
-            break;
-        case 2:
-            EXPECT_EQ(1026, *iter);
-            break;
-        case 3:
-            EXPECT_EQ(UINT32_MAX, *iter);
-            break;
-        case 4:
-            EXPECT_EQ(UINT64_MAX, *iter);
-            break;
-        default:
+        BitmapValue empty;
+        for (auto iter = empty.begin(); iter != empty.end(); ++iter) {
+            // should not goes here
             EXPECT_TRUE(false);
         }
+
+        BitmapValue single(1024);
+        auto single_iter = single.begin();
+        EXPECT_EQ(1024, *single_iter);
+        EXPECT_TRUE(single_iter == BitmapValue {1024}.begin());
+        EXPECT_TRUE(single_iter != single.end());
+
+        ++single_iter;
+        EXPECT_TRUE(single_iter == single.end());
+
+        BitmapValue bitmap({0, 1025, 1026, UINT32_MAX, UINT64_MAX});
+        EXPECT_EQ(enable_set ? BitmapValue::SET : BitmapValue::BITMAP, 
bitmap._type);
+        std::vector<uint64_t> values;
+        for (auto value : bitmap) {
+            values.push_back(value);
+        }
+        if (enable_set) {
+            std::sort(values.begin(), values.end());
+        }
+        EXPECT_EQ((std::vector<uint64_t> {0, 1025, 1026, UINT32_MAX, 
UINT64_MAX}), values);
     }
+    config::enable_set_in_bitmap_value = old_enable_set;
 }
 
 TEST(BitmapValueTest, invalid_data) {
diff --git a/be/test/exprs/function/function_bitmap_test.cpp 
b/be/test/exprs/function/function_bitmap_test.cpp
index 6e18e10d2e3..c8ab64c6329 100644
--- a/be/test/exprs/function/function_bitmap_test.cpp
+++ b/be/test/exprs/function/function_bitmap_test.cpp
@@ -99,20 +99,14 @@ DECLARE_Bool(enable_set_in_bitmap_value);
 }
 
 TEST(function_bitmap_test, function_bitmap_to_base64) {
-    config::Register::Field field("bool", "enable_set_in_bitmap_value",
-                                  &config::enable_set_in_bitmap_value, 
"false", false);
-    config::Register::_s_field_map->insert(
-            std::make_pair(std::string("enable_set_in_bitmap_value"), field));
-
-    config::Register::Field field_ser_ver("int16_t", 
"bitmap_serialize_version",
-                                          &config::bitmap_serialize_version, 
"1", false);
-    config::Register::_s_field_map->insert(
-            std::make_pair(std::string("bitmap_serialize_version"), 
field_ser_ver));
+    const auto old_enable_set = config::enable_set_in_bitmap_value;
+    const auto old_serialize_version = config::bitmap_serialize_version;
 
     std::string func_name = "bitmap_to_base64";
     InputTypeSet input_types = {PrimitiveType::TYPE_BITMAP};
 
-    EXPECT_TRUE(config::set_config("enable_set_in_bitmap_value", "false", 
false, true).ok());
+    config::enable_set_in_bitmap_value = false;
+    config::bitmap_serialize_version = 1;
     std::vector<uint64_t> bits32 {0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 
11,
                                   12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 
23,
                                   24, 25, 26, 27, 28, 29, 30, 31, 32}; // 
SET_TYPE_THRESHOLD + 1
@@ -155,7 +149,7 @@ TEST(function_bitmap_test, function_bitmap_to_base64) {
         static_cast<void>(check_function<DataTypeString, true>(func_name, 
input_types, data_set));
     }
 
-    EXPECT_TRUE(config::set_config("enable_set_in_bitmap_value", "true", 
false, true).ok());
+    config::enable_set_in_bitmap_value = true;
     bitmap32_1 = BitmapValue(1);            // single
     bitmap32_2 = BitmapValue({1, 9999999}); // set
     bitmap32_3 = BitmapValue(bits32);       // bitmap
@@ -199,7 +193,7 @@ TEST(function_bitmap_test, function_bitmap_to_base64) {
     }
 
     // test bitmap serialize version2
-    EXPECT_TRUE(config::set_config("bitmap_serialize_version", "2", false, 
true).ok());
+    config::bitmap_serialize_version = 2;
     bitmap32_3 = BitmapValue(bits32); // bitmap32
     bitmap64_3 = BitmapValue(bits64); // bitmap64
     EXPECT_EQ(bitmap32_3.get_type_code(), BitmapTypeCode::BITMAP32_V2);
@@ -212,23 +206,19 @@ TEST(function_bitmap_test, function_bitmap_to_base64) {
 
         static_cast<void>(check_function<DataTypeString, true>(func_name, 
input_types, data_set));
     }
+
+    config::enable_set_in_bitmap_value = old_enable_set;
+    config::bitmap_serialize_version = old_serialize_version;
 }
 
 TEST(function_bitmap_test, function_bitmap_from_base64) {
-    config::Register::Field field("bool", "enable_set_in_bitmap_value",
-                                  &config::enable_set_in_bitmap_value, 
"false", false);
-    config::Register::_s_field_map->insert(
-            std::make_pair(std::string("enable_set_in_bitmap_value"), field));
-
-    config::Register::Field field_ser_ver("int16_t", 
"bitmap_serialize_version",
-                                          &config::bitmap_serialize_version, 
"1", false);
-    config::Register::_s_field_map->insert(
-            std::make_pair(std::string("bitmap_serialize_version"), 
field_ser_ver));
+    const auto old_enable_set = config::enable_set_in_bitmap_value;
+    const auto old_serialize_version = config::bitmap_serialize_version;
 
     std::string func_name = "bitmap_from_base64";
     InputTypeSet input_types = {PrimitiveType::TYPE_VARCHAR};
 
-    EXPECT_TRUE(config::set_config("enable_set_in_bitmap_value", "false", 
false, true).ok());
+    config::enable_set_in_bitmap_value = false;
     std::string bitmap32_base64_1("AQEAAAA=");
     std::string bitmap32_base64_2("AjowAAACAAAAAAAAAJgAAAAYAAAAGgAAAAEAf5Y=");
     std::string bitmap32_base64_3("AjswAAABAAAgAAEAAAAgAA==");
@@ -265,7 +255,7 @@ TEST(function_bitmap_test, function_bitmap_from_base64) {
         static_cast<void>(check_function<DataTypeBitMap, true>(func_name, 
input_types, data_set));
     }
 
-    EXPECT_TRUE(config::set_config("enable_set_in_bitmap_value", "true", 
false, true).ok());
+    config::enable_set_in_bitmap_value = true;
     bitmap32_base64_1 = ("AQEAAAA=");
     bitmap32_base64_2 = ("BQIBAAAAAAAAAH+WmAAAAAAA");
     bitmap32_base64_3 = ("AjswAAABAAAgAAEAAAAgAA==");
@@ -292,7 +282,7 @@ TEST(function_bitmap_test, function_bitmap_from_base64) {
         static_cast<void>(check_function<DataTypeBitMap, true>(func_name, 
input_types, data_set));
     }
     {
-        EXPECT_TRUE(config::set_config("bitmap_serialize_version", "1", false, 
true).ok());
+        config::bitmap_serialize_version = 1;
 
         std::string base64_32_v1(
                 
"AjowAAABAAAAAAAgABAAAAAAAAEAAgADAAQABQAGAAcACAAJAAoACwAMAA0ADgAPABAAEQASABMAFAAVAB"
@@ -304,7 +294,7 @@ TEST(function_bitmap_test, function_bitmap_from_base64) {
         static_cast<void>(check_function<DataTypeBitMap, true>(func_name, 
input_types, data_set));
     }
     {
-        EXPECT_TRUE(config::set_config("bitmap_serialize_version", "2", false, 
true).ok());
+        config::bitmap_serialize_version = 2;
 
         std::string base64_32_v2(
                 
"DAI6MAAAAQAAAAAAIAAQAAAAAAABAAIAAwAEAAUABgAHAAgACQAKAAsADAANAA4ADwAQABEAEgATABQAFQ"
@@ -315,6 +305,9 @@ TEST(function_bitmap_test, function_bitmap_from_base64) {
         DataSet data_set = {{{base64_32_v2}, &bitmap32_3}, {{base64_64_v2}, 
&bitmap64_3}};
         static_cast<void>(check_function<DataTypeBitMap, true>(func_name, 
input_types, data_set));
     }
+
+    config::enable_set_in_bitmap_value = old_enable_set;
+    config::bitmap_serialize_version = old_serialize_version;
 }
 
 TEST(function_bitmap_test, function_bitmap_and_count) {


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

Reply via email to