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


##########
be/src/exprs/aggregate/aggregate_function_foreach.h:
##########
@@ -292,6 +402,77 @@ class AggregateFunctionForEach : public 
AggregateFunctionNonFinalBase,
         }
     }
 
+    void add_batch(size_t batch_size, AggregateDataPtr* places, size_t 
place_offset,
+                   const IColumn** columns, Arena& arena, bool /*agg_many*/) 
const override {
+        auto normalized_columns =
+                normalize_batch_columns(batch_size, columns, [](size_t) { 
return true; });
+        std::vector<const IColumn*> effective_columns(num_arguments);
+        for (size_t i = 0; i < num_arguments; ++i) {
+            effective_columns[i] =
+                    normalized_columns.empty() ? columns[i] : 
normalized_columns[i].get();

Review Comment:
   Please simplify the batch preparation here. `add_batch`, 
`add_batch_selected`, and `add_batch_single_place` repeat the same setup for 
normalized/effective columns, nested columns, and the first array's offsets. A 
small shared helper could retain ownership of any normalized columns and expose 
the prepared inputs, leaving each entry point responsible for row selection and 
destination-state handling.
   
   Also, `normalize_batch_columns` currently builds an identical offsets column 
separately for every argument. The validation pass already guarantees equal 
lengths for selected rows, and unselected rows receive repeated offsets, so 
these offsets can be built once and shared across the normalized arrays. That 
would remove `num_arguments - 1` redundant offsets buffers while preserving the 
existing aligned-input fast path.
   
   This is a maintainability and allocation simplification; a small internal 
helper should be sufficient.



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