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

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


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new f27ae8fa097 [fix](bitmap) incorrect type of BitmapValue with fastunion 
(#36834) (#36896)
f27ae8fa097 is described below

commit f27ae8fa097902d2c7cfb7f0020ebeed5c7f95ac
Author: Jerry Hu <mrh...@gmail.com>
AuthorDate: Fri Jun 28 11:29:03 2024 +0800

    [fix](bitmap) incorrect type of BitmapValue with fastunion (#36834) (#36896)
---
 be/src/util/bitmap_value.h         |  5 +++--
 be/test/util/bitmap_value_test.cpp | 23 +++++++++++++++++++++++
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/be/src/util/bitmap_value.h b/be/src/util/bitmap_value.h
index d8f68a227e7..ea99fa58baf 100644
--- a/be/src/util/bitmap_value.h
+++ b/be/src/util/bitmap_value.h
@@ -1652,7 +1652,6 @@ public:
             case SINGLE: {
                 _set.insert(_sv);
                 _type = SET;
-                _convert_to_bitmap_if_need();
                 break;
             }
             case BITMAP:
@@ -1663,10 +1662,12 @@ public:
                 _type = BITMAP;
                 break;
             case SET: {
-                _convert_to_bitmap_if_need();
                 break;
             }
             }
+            if (_type == SET) {
+                _convert_to_bitmap_if_need();
+            }
         }
 
         if (_type == EMPTY && single_values.size() == 1) {
diff --git a/be/test/util/bitmap_value_test.cpp 
b/be/test/util/bitmap_value_test.cpp
index e7652199ab0..d0ad3a82fda 100644
--- a/be/test/util/bitmap_value_test.cpp
+++ b/be/test/util/bitmap_value_test.cpp
@@ -1026,6 +1026,29 @@ TEST(BitmapValueTest, bitmap_union) {
     EXPECT_EQ(3, bitmap3.cardinality());
     bitmap3.fastunion({&bitmap});
     EXPECT_EQ(5, bitmap3.cardinality());
+
+    const auto old_config = config::enable_set_in_bitmap_value;
+    config::enable_set_in_bitmap_value = true;
+    BitmapValue bitmap4; // empty
+
+    BitmapValue bitmap_set1;
+    BitmapValue bitmap_set2;
+    BitmapValue bitmap_set3;
+
+    const int set_data1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 
15};
+    bitmap_set1.add_many(set_data1, 15);
+
+    const int set_data2[] = {16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 
28, 29, 30};
+    bitmap_set2.add_many(set_data2, 15);
+
+    const int set_data3[] = {31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 
43, 44, 45};
+    bitmap_set3.add_many(set_data3, 15);
+
+    bitmap4.fastunion({&bitmap_set1, &bitmap_set2, &bitmap_set3});
+
+    EXPECT_EQ(bitmap4.cardinality(), 45);
+    EXPECT_EQ(bitmap4.get_type_code(), BitmapTypeCode::BITMAP32);
+    config::enable_set_in_bitmap_value = old_config;
 }
 
 TEST(BitmapValueTest, bitmap_intersect) {


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

Reply via email to