yangzhg commented on code in PR #15588:
URL: https://github.com/apache/doris/pull/15588#discussion_r1130645496


##########
be/src/vec/aggregate_functions/aggregate_function_orthogonal_bitmap.h:
##########
@@ -177,6 +178,102 @@ struct AggOrthBitMapIntersectCount : public 
AggOrthBitmapBaseData<T> {
     Int64 result = 0;
 };
 
+template <typename T>
+struct AggOrthBitmapExprCalBaseData {
+public:
+    using ColVecData = std::conditional_t<IsNumber<T>, ColumnVector<T>, 
ColumnString>;
+
+    void add(const IColumn** columns, size_t row_num) {
+        const auto& bitmap_col = static_cast<const ColumnBitmap&>(*columns[0]);
+        const auto& data_col = static_cast<const ColVecData&>(*columns[1]);
+        const auto& bitmap_value = bitmap_col.get_element(row_num);
+        std::string update_key = data_col.get_data_at(row_num).to_string();
+        bitmap_expr_cal.update(update_key, bitmap_value);
+    }
+
+    void init_add_key(const IColumn** columns, size_t row_num, int 
argument_size) {
+        if (first_init) {
+            DCHECK(argument_size > 1);
+            const auto& col = static_cast<const ColVecData&>(*columns[2]);
+            std::string expr = col.get_data_at(row_num).to_string();
+            bitmap_expr_cal.bitmap_calculation_init(expr);
+            first_init = false;
+        }
+    }
+
+protected:
+    doris::BitmapExprCalculation bitmap_expr_cal;
+    bool first_init = true;
+};
+
+template <typename T>
+struct AggOrthBitMapExprCal : public AggOrthBitmapExprCalBaseData<T> {
+public:
+    static constexpr auto name = "orthogonal_bitmap_expr_calculate";
+
+    static DataTypePtr get_return_type() { return 
std::make_shared<DataTypeBitMap>(); }
+
+    void merge(const AggOrthBitMapExprCal& rhs) {
+        if (rhs.first_init) {
+            return;
+        }
+        result |= rhs.result;
+    }
+
+    void write(BufferWritable& buf) {
+        write_binary(AggOrthBitmapExprCalBaseData<T>::first_init, buf);
+        result = 
AggOrthBitmapExprCalBaseData<T>::bitmap_expr_cal.bitmap_calculate();
+        DataTypeBitMap::serialize_as_stream(result, buf);
+    }
+
+    void read(BufferReadable& buf) {
+        read_binary(AggOrthBitmapExprCalBaseData<T>::first_init, buf);
+        DataTypeBitMap::deserialize_as_stream(result, buf);
+    }
+
+    void get(IColumn& to) const {
+        auto& column = static_cast<ColumnBitmap&>(to);
+        column.get_data().emplace_back(result);
+    }
+
+private:
+    BitmapValue result;
+};
+
+template <typename T>
+struct AggOrthBitMapExprCalCount : public AggOrthBitmapExprCalBaseData<T> {
+public:
+    static constexpr auto name = "orthogonal_bitmap_expr_calculate_count";
+
+    static DataTypePtr get_return_type() { return 
std::make_shared<DataTypeInt64>(); }
+
+    void merge(const AggOrthBitMapExprCalCount& rhs) {
+        if (rhs.first_init) {
+            return;
+        }
+        result += rhs.result;
+    }
+
+    void write(BufferWritable& buf) {
+        write_binary(AggOrthBitmapExprCalBaseData<T>::first_init, buf);
+        result = 
AggOrthBitmapExprCalBaseData<T>::bitmap_expr_cal.bitmap_calculate_count();
+        write_binary(result, buf);
+    }
+
+    void read(BufferReadable& buf) {
+        read_binary(AggOrthBitmapExprCalBaseData<T>::first_init, buf);
+        read_binary(result, buf);
+    }
+
+    void get(IColumn& to) const {
+        auto& column = static_cast<ColumnVector<Int64>&>(to);
+        column.get_data().emplace_back(result);
+    }
+
+private:
+    Int64 result = 0;

Review Comment:
   ```suggestion
       int64_t result = 0;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to