BiteTheDDDDt commented on code in PR #57633:
URL: https://github.com/apache/doris/pull/57633#discussion_r2488881963


##########
be/src/vec/data_types/serde/data_type_agg_state_serde.cpp:
##########
@@ -0,0 +1,81 @@
+// 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/data_types/serde/data_type_agg_state_serde.h"
+
+#include <cmath>
+
+#include "util/url_coding.h"
+#include "vec/columns/column.h"
+#include "vec/columns/column_fixed_length_object.h"
+#include "vec/columns/column_string.h"
+#include "vec/common/string_buffer.hpp"
+
+namespace doris::vectorized {
+
+void DataTypeAggStateSerde::_encode_to_base64(const char* data, size_t size,
+                                              BufferWritable& bw) const {
+    // Use base64_encode from util to encode, avoid creating temporary string 
object
+    // Base64 encoded length: 4 * ceil(input_length / 3)
+    size_t encoded_size = (size_t)(4.0 * std::ceil(size / 3.0));
+    std::string base64_encoded(encoded_size, '\0');
+    size_t actual_len = base64_encode(reinterpret_cast<const unsigned 
char*>(data), size,
+                                      reinterpret_cast<unsigned 
char*>(base64_encoded.data()));
+    base64_encoded.resize(actual_len);
+
+    // Write base64 encoded string to buffer
+    bw.write(base64_encoded.data(), base64_encoded.size());
+}
+
+Status DataTypeAggStateSerde::serialize_one_cell_to_json(const IColumn& 
column, int64_t row_num,
+                                                         BufferWritable& bw,
+                                                         FormatOptions& 
options) const {
+    // Check column type: AggState may be stored as ColumnString or 
ColumnFixedLengthObject

Review Comment:
   这里可能有问题,agg state存储的column是根据内部agg 
function的get_serialized_type方法来的,不只有ColumnString 和 
ColumnFixedLengthObject,比如bitmap的一些相关函数会用ColumnBitmap,一些复杂类型相关的函数会用ColumnArray,ColumnMap,ColumnStruct



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