Skip to content

Commit

Permalink
fix filter_generic in column_array func
Browse files Browse the repository at this point in the history
  • Loading branch information
amorynan committed Oct 16, 2024
1 parent 55cf348 commit a26553c
Show file tree
Hide file tree
Showing 3 changed files with 293 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 @@ -732,22 +732,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
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !array_filter --
0

-- !array_filter_2 --
300

-- !array_filter_3 --
0

-- !array_filter_4 --
0

-- !array_filter_5 --
0

-- !array_filter_6 --
0

-- !array_filter_7 --
0

-- !array_filter_8 --
false false
true true
false false
false true
false false
false false
false false
false false
false false
false false
false true
false true
false true
false false
false true
false false
false true
false false
false false
false false
false true
false true
false true
false true
false false
false \N
false true
false true
false false
false false
false false
false false
false false
false false
false false
false false
false false
false false
false true
false false
false false
false false
false \N
false true
false \N
false true
false false
false \N
false true
false true
false false
false false
false false
false false
false true
false false
false false
false false
false false
false false
false true
false false
false false
false false
false \N
false true
false false
false true
false false
false false
false false
false false
false false
false false
true true
false false
false false
false false
false false
false false
false false
false false
false \N
false false
false \N
false true
false true
false false
false true
false false
false true
false false
false true
false \N

Large diffs are not rendered by default.

0 comments on commit a26553c

Please sign in to comment.