hello-stephen commented on code in PR #71438:
URL: https://github.com/apache/doris/pull/71438#discussion_r4810235296


##########
be/src/exprs/function/ai/embed.h:
##########
@@ -313,30 +377,42 @@ class FunctionEmbed : public AIFunction<FunctionEmbed> {
     }
 
     // EMBED-private helper.
-    // Flushes one accumulated multimodal embedding batch into the output 
array column.
-    Status _flush_multimodal_embedding_batch(std::vector<MultimodalType>& 
batch_media_types,
-                                             std::vector<std::string>& 
batch_media_content_types,
-                                             std::vector<std::string>& 
batch_media_urls,
-                                             ColumnArray& col_result, const 
AIResource& config,
-                                             std::shared_ptr<AIAdapter>& 
adapter,
-                                             FunctionContext* context) const {
-        if (batch_media_urls.empty()) {
+    // Flushes one accumulated multimodal or fused multimodal embedding batch 
into col_result.
+    Status _flush_multimodal_embedding_batch(
+            std::vector<std::vector<MultimodalInputItem>>& batch_inputs, bool 
is_fused,
+            ColumnArray& col_result, const AIResource& config, 
std::shared_ptr<AIAdapter>& adapter,
+            FunctionContext* context) const {
+        if (batch_inputs.empty()) {
             return Status::OK();
         }
 
         std::string request_body;
-        RETURN_IF_ERROR(adapter->build_multimodal_embedding_request(
-                batch_media_types, batch_media_urls, 
batch_media_content_types, request_body));
+        if (is_fused) {
+            RETURN_IF_ERROR(
+                    
adapter->build_fused_multimodal_embedding_request(batch_inputs, request_body));
+        } else {
+            std::vector<MultimodalType> media_types;
+            std::vector<std::string> media_urls;
+            std::vector<std::string> media_content_types;
+            media_types.reserve(batch_inputs.size());
+            media_urls.reserve(batch_inputs.size());
+            media_content_types.reserve(batch_inputs.size());
+            for (const auto& row : batch_inputs) {
+                media_types.push_back(row[0].type);
+                media_urls.push_back(row[0].value);

Review Comment:
   [P3] Avoid copying scalar multimodal payloads back into parallel vectors. 
The old scalar JSON path moved the parsed strings directly into the batch; here 
each row owns a vector and this loop copies its value and content_type into new 
vectors. Qwen then builds another owning singleton-row vector in 
ai_adapter.h:1407–1412. This adds allocations and full-string copies for every 
scalar row, including the newly supported text payloads. Pass the row 
representation through to the serializer, or move the strings at the flush 
boundary and avoid regrouping them in Qwen.



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