You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2022/06/30 10:03:28 UTC

[doris] 13/13: [bugfix]fix bitmap function bug (#10477)

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

morningman pushed a commit to branch dev-1.0.1
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 3948ef23b5d7336f3998d38e911127dce80ad19b
Author: starocean999 <40...@users.noreply.github.com>
AuthorDate: Wed Jun 29 09:04:26 2022 +0800

    [bugfix]fix bitmap function bug (#10477)
---
 .../aggregate_function_bitmap.h                    | 28 ++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/be/src/vec/aggregate_functions/aggregate_function_bitmap.h b/be/src/vec/aggregate_functions/aggregate_function_bitmap.h
index f4a237dbb9..e2fd2b8989 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_bitmap.h
+++ b/be/src/vec/aggregate_functions/aggregate_function_bitmap.h
@@ -36,9 +36,23 @@ struct AggregateFunctionBitmapUnionOp {
         res.add(data);
     }
 
-    static void add(BitmapValue& res, const BitmapValue& data, bool& is_first) { res |= data; }
+    static void add(BitmapValue& res, const BitmapValue& data, bool& is_first) {
+        if (UNLIKELY(is_first)) {
+            res = data;
+            is_first = false;
+        } else {
+            res |= data;
+        }
+    }
 
-    static void merge(BitmapValue& res, const BitmapValue& data, bool& is_first) { res |= data; }
+    static void merge(BitmapValue& res, const BitmapValue& data, bool& is_first) {
+        if (UNLIKELY(is_first)) {
+            res = data;
+            is_first = false;
+        } else {
+            res |= data;
+        }
+    }
 };
 
 struct AggregateFunctionBitmapIntersectOp {
@@ -79,6 +93,8 @@ struct AggregateFunctionBitmapData {
 
     void read(BufferReadable& buf) { DataTypeBitMap::deserialize_as_stream(value, buf); }
 
+    void reset() { is_first = true; }
+
     BitmapValue& get() { return value; }
 };
 
@@ -125,6 +141,10 @@ public:
         column.get_data().push_back(
                 const_cast<AggregateFunctionBitmapData<Op>&>(this->data(place)).get());
     }
+
+    void reset(AggregateDataPtr __restrict place) const override { 
+        this->data(place).reset(); 
+    }
 };
 
 template <bool nullable, typename ColVecType>
@@ -179,6 +199,10 @@ public:
         auto& column = static_cast<ColVecResult&>(to);
         column.get_data().push_back(value_data.cardinality());
     }
+
+    void reset(AggregateDataPtr __restrict place) const override { 
+        this->data(place).reset(); 
+    }
 };
 
 AggregateFunctionPtr create_aggregate_function_bitmap_union(const std::string& name,


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