Skip to content

Commit

Permalink
[cherry-pick](branch-20) fix partition-topn calculate partition input…
Browse files Browse the repository at this point in the history
… rows have error (#39100) (#39581) (#40003)

cherry-pick from master 
#39100
#39581
  • Loading branch information
zhangstar333 authored Aug 31, 2024
1 parent fb2ccf0 commit 5e82c2b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions be/src/vec/columns/column_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ void IColumn::append_data_by_selector_impl(MutablePtr& res, const Selector& sele
LOG(FATAL) << fmt::format("Size of selector: {}, is larger than size of column:{}",
selector.size(), num_rows);
}

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

for (size_t i = 0; i < selector.size(); ++i)
static_cast<Derived&>(*res).insert_from(*this, selector[i]);
Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/exec/vpartition_sort_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ void VPartitionSortNode::_emplace_into_hash_table(const ColumnRawPtrs& key_colum
Status VPartitionSortNode::sink(RuntimeState* state, vectorized::Block* input_block, bool eos) {
auto current_rows = input_block->rows();
if (current_rows > 0) {
child_input_rows = child_input_rows + current_rows;
if (UNLIKELY(_partition_exprs_num == 0)) {
if (UNLIKELY(_value_places.empty())) {
_value_places.push_back(_pool->add(new PartitionBlocks()));
Expand All @@ -192,6 +191,7 @@ Status VPartitionSortNode::sink(RuntimeState* state, vectorized::Block* input_bl
RETURN_IF_ERROR(
state->check_query_state("VPartitionSortNode, while split input block."));
input_block->clear_column_data();
child_input_rows = child_input_rows + current_rows;
}
}
}
Expand Down

0 comments on commit 5e82c2b

Please sign in to comment.