HappenLee commented on code in PR #22327:
URL: https://github.com/apache/doris/pull/22327#discussion_r1278604394


##########
be/src/vec/common/aggregation_common.h:
##########
@@ -218,6 +196,112 @@ T pack_fixed(size_t i, size_t keys_size, const 
ColumnRawPtrs& key_columns, const
     return key;
 }
 
+template <typename T>
+std::vector<T> pack_fixeds(size_t row_numbers, const ColumnRawPtrs& 
key_columns,
+                           const Sizes& key_sizes, const ColumnRawPtrs& 
nullmap_columns) {
+    size_t bitmap_size = 0;
+    if (!nullmap_columns.empty()) {
+        bitmap_size = std::tuple_size<KeysNullMap<T>>::value;
+    }
+
+    std::vector<T> result(row_numbers);
+    size_t offset = 0;
+    if (bitmap_size > 0) {
+        for (size_t j = 0; j < nullmap_columns.size(); j++) {
+            if (!nullmap_columns[j]) {
+                continue;
+            }
+            size_t bucket = j / 8;
+            size_t offset = j % 8;
+            const auto& data =
+                    assert_cast<const 
ColumnUInt8&>(*nullmap_columns[j]).get_data().data();
+            for (size_t i = 0; i < row_numbers; ++i) {
+                *((char*)(&result[i]) + bucket) |= data[i] << offset;
+            }
+        }
+        offset += bitmap_size;
+    }
+
+    // make sure null cell is filled by 0x0
+    T zero {};
+    for (size_t j = 0; j < key_columns.size(); ++j) {
+        const char* data = key_columns[j]->get_raw_data().data;
+
+        if (key_sizes[j] == 1) {
+            if (nullmap_columns.size() && nullmap_columns[j]) {
+                const auto& nullmap =
+                        assert_cast<const 
ColumnUInt8&>(*nullmap_columns[j]).get_data().data();
+                for (size_t i = 0; i < row_numbers; ++i) {
+                    memcpy_fixed_1((char*)(&result[i]) + offset,

Review Comment:
   why not use template to replace the 1,2,4,8,16?



##########
be/src/vec/common/aggregation_common.h:
##########
@@ -218,6 +196,112 @@ T pack_fixed(size_t i, size_t keys_size, const 
ColumnRawPtrs& key_columns, const
     return key;
 }
 
+template <typename T>
+std::vector<T> pack_fixeds(size_t row_numbers, const ColumnRawPtrs& 
key_columns,
+                           const Sizes& key_sizes, const ColumnRawPtrs& 
nullmap_columns) {
+    size_t bitmap_size = 0;
+    if (!nullmap_columns.empty()) {
+        bitmap_size = std::tuple_size<KeysNullMap<T>>::value;
+    }
+
+    std::vector<T> result(row_numbers);
+    size_t offset = 0;
+    if (bitmap_size > 0) {
+        for (size_t j = 0; j < nullmap_columns.size(); j++) {
+            if (!nullmap_columns[j]) {
+                continue;
+            }
+            size_t bucket = j / 8;
+            size_t offset = j % 8;
+            const auto& data =
+                    assert_cast<const 
ColumnUInt8&>(*nullmap_columns[j]).get_data().data();
+            for (size_t i = 0; i < row_numbers; ++i) {
+                *((char*)(&result[i]) + bucket) |= data[i] << offset;
+            }
+        }
+        offset += bitmap_size;
+    }
+
+    // make sure null cell is filled by 0x0
+    T zero {};
+    for (size_t j = 0; j < key_columns.size(); ++j) {
+        const char* data = key_columns[j]->get_raw_data().data;
+
+        if (key_sizes[j] == 1) {
+            if (nullmap_columns.size() && nullmap_columns[j]) {
+                const auto& nullmap =
+                        assert_cast<const 
ColumnUInt8&>(*nullmap_columns[j]).get_data().data();
+                for (size_t i = 0; i < row_numbers; ++i) {
+                    memcpy_fixed_1((char*)(&result[i]) + offset,

Review Comment:
   why not use template to replace the 1,2,4,8,16?



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