Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug](column) fix append_data_by_selector_impl reserve too mush useless memory #39581

Merged
merged 3 commits into from
Aug 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions be/src/vec/columns/column_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ void IColumn::append_data_by_selector_impl(MutablePtr& res, const Selector& sele
"Size of selector: {} is larger than size of column: {}",
selector.size(), num_rows);
}

res->reserve(num_rows);
DCHECK_GE(end, begin);
// here wants insert some value from this column, and the nums is (end - begin)
// and many be this column num_rows is 4096, but only need insert num is (1 - 0) = 1
// so can't call res->reserve(num_rows), it's will be too mush waste memory
res->reserve(res->size() + (end - begin));

for (size_t i = begin; i < end; ++i) {
static_cast<Derived&>(*res).insert_from(*this, selector[i]);
Expand Down
Loading