This is an automated email from the ASF dual-hosted git repository.

lihaopeng pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 5e82c2bb7b2 [cherry-pick](branch-20) fix partition-topn calculate 
partition input rows have error (#39100) (#39581) (#40003)
5e82c2bb7b2 is described below

commit 5e82c2bb7b239af6fe914b218ddecea233b020c1
Author: zhangstar333 <87313068+zhangstar...@users.noreply.github.com>
AuthorDate: Sat Aug 31 14:22:51 2024 +0800

    [cherry-pick](branch-20) fix partition-topn calculate partition input rows 
have error (#39100) (#39581) (#40003)
    
    cherry-pick from master
    https://github.com/apache/doris/pull/39100
    https://github.com/apache/doris/pull/39581
---
 be/src/vec/columns/column_impl.h         | 6 ++++--
 be/src/vec/exec/vpartition_sort_node.cpp | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/be/src/vec/columns/column_impl.h b/be/src/vec/columns/column_impl.h
index 0d573b24fbd..64a73ac47fd 100644
--- a/be/src/vec/columns/column_impl.h
+++ b/be/src/vec/columns/column_impl.h
@@ -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]);
diff --git a/be/src/vec/exec/vpartition_sort_node.cpp 
b/be/src/vec/exec/vpartition_sort_node.cpp
index 09d3d1be1de..e82cb37bb6b 100644
--- a/be/src/vec/exec/vpartition_sort_node.cpp
+++ b/be/src/vec/exec/vpartition_sort_node.cpp
@@ -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()));
@@ -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;
             }
         }
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to