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

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


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

commit c44d1582a1eb2c310358c688e4d00d6bc509bdaa
Author: Jerry Hu <mrh...@gmail.com>
AuthorDate: Mon Jul 1 10:19:07 2024 +0800

    [fix](bitmap) incorrect type of BitmapValue with fastunion (#36834) (#36898)
    
    ## Proposed changes
    
    pick #36834
    
    <!--Describe your changes.-->
---
 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 f75ca59bae6..9229945f529 100644
--- a/be/src/util/bitmap_value.h
+++ b/be/src/util/bitmap_value.h
@@ -1662,7 +1662,6 @@ public:
             case SINGLE: {
                 _set.insert(_sv);
                 _type = SET;
-                _convert_to_bitmap_if_need();
                 break;
             }
             case BITMAP:
@@ -1673,10 +1672,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 6524a8152c5..d536e2e581e 100644
--- a/be/test/util/bitmap_value_test.cpp
+++ b/be/test/util/bitmap_value_test.cpp
@@ -124,6 +124,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