Skip to content

Commit

Permalink
branch-2.1: [fix](column_array)fix filter_generic in column_array func
Browse files Browse the repository at this point in the history
…#41990 (#44983)

Cherry-picked from #41990

Co-authored-by: amory <[email protected]>
  • Loading branch information
github-actions[bot] and amorynan authored Dec 12, 2024
1 parent 5901e94 commit da88569
Show file tree
Hide file tree
Showing 4 changed files with 542 additions and 10 deletions.
15 changes: 5 additions & 10 deletions be/src/vec/columns/column_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,22 +776,17 @@ ColumnPtr ColumnArray::filter_generic(const Filter& filt, ssize_t result_size_hi
if (size == 0) return ColumnArray::create(data);

Filter nested_filt(get_offsets().back());
ssize_t nested_result_size_hint = 0;
for (size_t i = 0; i < size; ++i) {
if (filt[i])
if (filt[i]) {
memset(&nested_filt[offset_at(i)], 1, size_at(i));
else
nested_result_size_hint += size_at(i);
} else {
memset(&nested_filt[offset_at(i)], 0, size_at(i));
}
}

auto res = ColumnArray::create(data->clone_empty());

ssize_t nested_result_size_hint = 0;
if (result_size_hint < 0)
nested_result_size_hint = result_size_hint;
else if (result_size_hint && result_size_hint < 1000000000 &&
data->size() < 1000000000) /// Avoid overflow.
nested_result_size_hint = result_size_hint * data->size() / size;

res->data = data->filter(nested_filt, nested_result_size_hint);

auto& res_offsets = res->get_offsets();
Expand Down
Loading

0 comments on commit da88569

Please sign in to comment.