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


##########
be/src/vec/columns/column_array.cpp:
##########
@@ -241,6 +250,173 @@ int ColumnArray::compare_at(size_t n, size_t m, const 
IColumn& rhs_, int nan_dir
     return lhs_size < rhs_size ? -1 : (lhs_size == rhs_size ? 0 : 1);
 }
 
+size_t ColumnArray::get_max_row_byte_size() const {
+    DCHECK(!data->is_variable_length() || data->is_column_string() || 
data->is_column_string64());
+    size_t max_size = 0;
+    size_t num_rows = size();
+    for (size_t i = 0; i < num_rows; ++i) {
+        max_size = std::max(max_size,
+                            size_at(i) * data->get_max_row_byte_size() +
+                                    (data->is_variable_length() ? 
sizeof(size_t) * size_at(i) : 0));
+    }
+
+    return sizeof(size_t) + max_size;
+}
+
+void ColumnArray::serialize_vec_with_null_map(StringRef* keys, size_t num_rows,
+                                              const UInt8* null_map) const {
+    DCHECK(null_map != nullptr);
+    DCHECK(!data->is_variable_length() || data->is_column_string() || 
data->is_column_string64());
+
+    const bool has_null = simd::contain_byte(null_map, num_rows, 1);
+
+    const auto* nested_col = data->get_ptr().get();
+    if (data->is_nullable()) {
+        nested_col = assert_cast<const ColumnNullable*>(data->get_ptr().get())
+                             ->get_nested_column_ptr()
+                             .get();
+    }
+    if (has_null) {
+        for (size_t i = 0; i < num_rows; ++i) {
+            char* __restrict dest = const_cast<char*>(keys[i].data + 
keys[i].size);
+            // serialize null first
+            memcpy(dest, null_map + i, sizeof(uint8_t));
+            dest += sizeof(uint8_t);
+            keys[i].size += sizeof(uint8_t);
+            if (null_map[i] == 0) {
+                size_t array_size = size_at(i);

Review Comment:
   the code should be function:
   ```
   size_t array_size = size_at(i);
                   size_t offset = offset_at(i);
   
                   memcpy(dest, &array_size, sizeof(array_size));
                   dest += sizeof(array_size);
                   keys[i].size += sizeof(array_size);
                   for (size_t j = 0; j < array_size; ++j) {
                       if (data->is_nullable()) {
                           auto flag = assert_cast<const 
ColumnNullable*>(data->get_ptr().get())
                                               ->get_null_map_data()[offset + 
j];
                           memcpy(dest, &flag, sizeof(flag));
                           dest += sizeof(flag);
                           keys[i].size += sizeof(flag);
                           if (flag) {
                               continue;
                           }
                       }
                       const auto& it = nested_col->get_data_at(offset + j);
                       if (nested_col->is_variable_length()) {
                           memcpy(dest, &it.size, sizeof(it.size));
                           dest += sizeof(it.size);
                           keys[i].size += sizeof(it.size);
                       }
                       memcpy(dest, it.data, it.size);
                       dest += it.size;
                       keys[i].size += it.size;
                   }
   ```
   all the code same like below code  line 325



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to