HappenLee commented on code in PR #30511:
URL: https://github.com/apache/doris/pull/30511#discussion_r1469468287
##########
be/src/vec/exec/vpartition_sort_node.cpp:
##########
@@ -38,23 +39,59 @@
#include "vec/exprs/vexpr_context.h"
namespace doris::vectorized {
-Status PartitionBlocks::do_partition_topn_sort() {
+Status PartitionBlocks::append_block_by_selector(const vectorized::Block*
input_block, bool eos) {
+ if (blocks.empty() || reach_limit()) {
+ _init_rows = _partition_sort_info->_runtime_state->batch_size();
+ blocks.push_back(Block::create_unique(
+
VectorizedUtils::create_empty_block(_partition_sort_info->_row_desc)));
+ }
+ auto columns = input_block->get_columns();
+ auto mutable_columns = blocks.back()->mutate_columns();
+ DCHECK(columns.size() == mutable_columns.size());
+ for (int i = 0; i < mutable_columns.size(); ++i) {
+ columns[i]->append_data_by_selector(mutable_columns[i], selector);
+ }
+ blocks.back()->set_columns(std::move(mutable_columns));
+ auto selector_rows = selector.size();
+ _init_rows = _init_rows - selector_rows;
+ _total_rows = _total_rows + selector_rows;
+ _current_input_rows = _current_input_rows + selector_rows;
+ selector.clear();
+ // maybe better could change by user PARTITION_SORT_ROWS_THRESHOLD
+ if (!eos && _partition_sort_info->_partition_inner_limit != -1 &&
+ _current_input_rows >= PARTITION_SORT_ROWS_THRESHOLD &&
+ _partition_sort_info->_topn_phase != TPartTopNPhase::TWO_PHASE_GLOBAL)
{
+ create_or_reset_sorter_state();
+ RETURN_IF_ERROR(do_partition_topn_sort());
+ _current_input_rows = 0; // reset record
Review Comment:
0? may rows still in `PartitionBlocks`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]