HappenLee commented on a change in pull request #8138:
URL: https://github.com/apache/incubator-doris/pull/8138#discussion_r810653688



##########
File path: be/src/vec/functions/function_bitmap_variadic.cpp
##########
@@ -0,0 +1,229 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "vec/columns/column_complex.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_bitmap.h"
+#include "vec/functions/function_const.h"
+#include "vec/functions/function_string.h"
+#include "vec/functions/function_totype.h"
+#include "vec/functions/simple_function_factory.h"
+
+namespace doris::vectorized {
+
+struct BitmapAnd {
+    static constexpr auto name = "bitmap_and";
+    using ResultDataType = DataTypeBitMap;
+
+    static Status vector_vector(ColumnPtr argument_columns[], size_t col_size,
+                                size_t input_rows_count, 
std::vector<BitmapValue>& res) {
+
+        res = assert_cast<const 
ColumnBitmap*>(argument_columns[0].get())->get_data();
+
+        for (size_t col = 1; col < col_size; ++col) {
+            auto& col_data =
+                    assert_cast<const 
ColumnBitmap*>(argument_columns[col].get())->get_data();
+            for (size_t row = 0; row < input_rows_count; ++row) {
+                res[row] &= col_data[row];
+            }
+        }
+        return Status::OK();
+    }
+};
+
+struct BitmapOr {
+    static constexpr auto name = "bitmap_or";
+    using ResultDataType = DataTypeBitMap;
+
+    static Status vector_vector(ColumnPtr argument_columns[], size_t col_size,
+                                size_t input_rows_count, 
std::vector<BitmapValue>& res) {
+
+        res = assert_cast<const 
ColumnBitmap*>(argument_columns[0].get())->get_data();
+        for (size_t col = 1; col < col_size; ++col) {
+            auto& col_data =
+                    assert_cast<const 
ColumnBitmap*>(argument_columns[col].get())->get_data();
+            for (size_t row = 0; row < input_rows_count; ++row) {
+                res[row] |= col_data[row];
+            }
+        }
+        return Status::OK();
+    }
+};
+
+struct BitmapXor {
+    using ResultDataType = DataTypeBitMap;
+    static constexpr auto name = "bitmap_xor";
+
+    static Status vector_vector(ColumnPtr argument_columns[], size_t col_size,
+                                size_t input_rows_count, 
std::vector<BitmapValue>& res) {
+
+        res = assert_cast<const 
ColumnBitmap*>(argument_columns[0].get())->get_data();
+        for (size_t col = 1; col < col_size; ++col) {
+            auto& col_data =
+                    assert_cast<const 
ColumnBitmap*>(argument_columns[col].get())->get_data();
+            for (size_t row = 0; row < input_rows_count; ++row) {
+                res[row] ^= col_data[row];
+            }
+        }
+        return Status::OK();
+    }
+};
+
+struct BitmapOrCount {
+    static constexpr auto name = "bitmap_or_count";
+    using ResultDataType = DataTypeInt64;
+    using TData = std::vector<BitmapValue>;
+    using ResTData = typename ColumnVector<Int64>::Container;
+
+    static Status vector_vector(ColumnPtr argument_columns[], size_t col_size,
+                                size_t input_rows_count, ResTData& res) {
+
+        TData vals(input_rows_count);
+        for (size_t col = 0; col < col_size; ++col) {
+            auto& col_data =
+                    assert_cast<const 
ColumnBitmap*>(argument_columns[col].get())->get_data();
+            for (size_t row = 0; row < input_rows_count; ++row) {
+                vals[row] |= col_data[row];
+            }
+        }
+
+        for (size_t row = 0; row < input_rows_count; ++row) {
+            res[row] = vals[row].cardinality();
+        }
+        return Status::OK();
+    }
+};
+
+struct BitmapAndCount {
+    static constexpr auto name = "bitmap_and_count";
+    using ResultDataType = DataTypeInt64;
+    using TData = std::vector<BitmapValue>;
+    using ResTData = typename ColumnVector<Int64>::Container;
+
+    static Status vector_vector(ColumnPtr argument_columns[], size_t col_size,
+                                size_t input_rows_count, ResTData& res) {
+
+        TData vals(input_rows_count);
+        vals = assert_cast<const 
ColumnBitmap*>(argument_columns[0].get())->get_data();
+
+        for (size_t col = 1; col < col_size; ++col) {
+            auto& col_data =
+                    assert_cast<const 
ColumnBitmap*>(argument_columns[col].get())->get_data();
+            for (size_t row = 0; row < input_rows_count; ++row) {
+                vals[row] &= col_data[row];
+            }
+        }
+
+        for (size_t row = 0; row < input_rows_count; ++row) {
+            res[row] = vals[row].cardinality();
+        }
+        return Status::OK();
+    }
+};
+
+struct BitmapXorCount {
+    static constexpr auto name = "bitmap_xor_count";
+    using ResultDataType = DataTypeInt64;
+    using TData = std::vector<BitmapValue>;
+    using ResTData = typename ColumnVector<Int64>::Container;
+
+    static Status vector_vector(ColumnPtr argument_columns[], size_t col_size,
+                                size_t input_rows_count, ResTData& res) {
+
+        TData vals(input_rows_count);
+        vals = assert_cast<const 
ColumnBitmap*>(argument_columns[0].get())->get_data();
+
+        for (size_t col = 1; col < col_size; ++col) {
+            auto& col_data =
+                    assert_cast<const 
ColumnBitmap*>(argument_columns[col].get())->get_data();
+            for (size_t row = 0; row < input_rows_count; ++row) {
+                vals[row] ^= col_data[row];

Review comment:
       Here may change the Origin data ? Recheck the origin behavior do the 
same thing?

##########
File path: be/src/vec/functions/function_const.h
##########
@@ -92,8 +92,8 @@ class FunctionMathConstFloat64 : public IFunction {
     Status execute_impl(FunctionContext* context, Block& block, const 
ColumnNumbers& arguments,
                         size_t result, size_t input_rows_count) override {
         block.get_by_position(result).column =
-                block.get_by_position(result).type->create_column_const(
-                        input_rows_count == 0 ? 1 : input_rows_count, 
Impl::value);
+                
block.get_by_position(result).type->create_column_const(input_rows_count,

Review comment:
       why change the logic?




-- 
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