Skip to content

Commit 71b8870

Browse files
committed
[improvement](be) Batch complex array_agg column copies
### What problem does this PR solve? Issue Number: close apache#65976 Related PR: apache#66601 Problem Summary: Complex array_agg state deserialization and result insertion copied contiguous column ranges one row at a time. Replace both loops with the column batch range insertion API to reduce virtual dispatch and per-row insertion overhead without changing aggregation semantics. ### Release note None ### Check List (For Author) - Test: No need to test (behavior-preserving replacement of contiguous insert_from loops; tests not run per request) - Behavior changed: No - Does this need documentation: No
1 parent 4d28bde commit 71b8870

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

‎be/src/exprs/aggregate/aggregate_function_array_agg.h‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,20 +249,15 @@ struct AggregateFunctionArrayAggData<T> {
249249
const auto& to_nested_col = to_arr.get_data();
250250
auto start = to_arr.get_offsets()[row_num - 1];
251251
auto end = start + to_arr.get_offsets()[row_num] - to_arr.get_offsets()[row_num - 1];
252-
for (auto i = start; i < end; ++i) {
253-
column_data->insert_from(to_nested_col, i);
254-
}
252+
column_data->insert_range_from(to_nested_col, start, end - start);
255253
}
256254

257255
void reset() { column_data->clear(); }
258256

259257
void insert_result_into(IColumn& to) const {
260258
auto& to_arr = assert_cast<ColumnArray&, TypeCheckOnRelease::DISABLE>(to);
261259
auto& to_nested_col = to_arr.get_data();
262-
size_t num_rows = column_data->size();
263-
for (size_t i = 0; i < num_rows; ++i) {
264-
to_nested_col.insert_from(*column_data, i);
265-
}
260+
to_nested_col.insert_range_from(*column_data, 0, column_data->size());
266261
to_arr.get_offsets().push_back(to_nested_col.size());
267262
}
268263

0 commit comments

Comments
 (0)