HappenLee commented on code in PR #46300:
URL: https://github.com/apache/doris/pull/46300#discussion_r1910317666


##########
be/src/pipeline/exec/partition_sort_sink_operator.cpp:
##########
@@ -134,17 +137,23 @@ Status PartitionSortSinkOperatorX::sink(RuntimeState* 
state, vectorized::Block*
         //seems could free for hashtable
         local_state._agg_arena_pool.reset(nullptr);
         local_state._partitioned_data.reset(nullptr);
+        SCOPED_TIMER(local_state._sorted_data_timer);
+        for (auto& _value_place : local_state._value_places) {
+            _value_place->create_or_reset_sorter_state();
+            local_state._shared_state->partition_sorts.emplace_back(
+                    std::move(_value_place->_partition_topn_sorter));
+        }
+        // notice: need split two for loop, as maybe need check sorter early
         for (int i = 0; i < local_state._value_places.size(); ++i) {
-            local_state._value_places[i]->create_or_reset_sorter_state();
-            auto sorter = 
std::move(local_state._value_places[i]->_partition_topn_sorter);
-
-            //get blocks from every partition, and sorter get those data.
+            auto& sorter = local_state._shared_state->partition_sorts[i];
             for (const auto& block : local_state._value_places[i]->_blocks) {
                 RETURN_IF_ERROR(sorter->append_block(block.get()));
             }
             local_state._value_places[i]->_blocks.clear();
             RETURN_IF_ERROR(sorter->prepare_for_read());
-            
local_state._shared_state->partition_sorts.push_back(std::move(sorter));
+            // iff one sorter have data, then could set source ready to read
+            std::unique_lock<std::mutex> 
lc(local_state._shared_state->sink_eos_lock);

Review Comment:
   move up 153 line



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to