Mryange commented on code in PR #70202:
URL: https://github.com/apache/doris/pull/70202#discussion_r4489844440


##########
be/src/exprs/aggregate/aggregate_function_collect.h:
##########
@@ -352,15 +358,60 @@ struct AggregateFunctionCollectListData<T, HasLimit> {
         }
     }
 
+    void write(BufferWritable& buf, const IDataType& column_type, int 
query_version) const {
+        // A mixed cluster still uses the old query version: old BEs can only 
read JSON states.
+        if (query_version < SUPPORT_COLLECT_LIST_NATIVE_SERIALIZATION_VERSION) 
{
+            write(buf);
+            return;
+        }
+
+        // JSON can split the single array string a","b into two elements. 
Serialize the
+        // column in place and frame only the actual native bytes, as nullable 
array_agg does.
+        const auto capacity = cast_set<size_t>(
+                column_type.get_uncompressed_serialized_bytes(*column_data, 
query_version));
+        buf.resize(sizeof(UInt64) + capacity);
+        auto* begin = buf.data() + sizeof(UInt64);
+        const char* end = nullptr;
+        try {
+            end = column_type.serialize(*column_data, begin, query_version);
+        } catch (...) {
+            buf.resize(0);
+            throw;
+        }
+        DORIS_CHECK_LE(end, begin + capacity);
+        const auto serialized_bytes = static_cast<UInt64>(end - begin);
+        memcpy(buf.data(), &serialized_bytes, sizeof(serialized_bytes));
+        const auto frame_bytes = sizeof(serialized_bytes) + 
cast_set<size_t>(serialized_bytes);
+        buf.resize(frame_bytes);
+        buf.add_offset(frame_bytes);
+        write_var_int(max_size, buf);
+    }
+
+    void read(BufferReadable& buf, const IDataType& column_type, int 
query_version) {
+        // Match the sender's query version, including when this BE supports a 
newer version.
+        if (query_version < SUPPORT_COLLECT_LIST_NATIVE_SERIALIZATION_VERSION) 
{
+            read(buf);
+            return;
+        }
+
+        UInt64 serialized_bytes = 0;
+        buf.read_binary(serialized_bytes);
+        const auto* begin = buf.data();
+        column_data->clear();
+        const auto* end = column_type.deserialize(begin, &column_data, 
query_version);

Review Comment:
   哎呀,这个就不处理了,这个中间结果要是损坏了,那怎么防都防不住的。



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