Gabriel39 commented on code in PR #35682:
URL: https://github.com/apache/doris/pull/35682#discussion_r1625261179


##########
be/src/pipeline/local_exchange/local_exchanger.cpp:
##########
@@ -261,6 +264,66 @@ Status PassToOneExchanger::get_block(RuntimeState* state, 
vectorized::Block* blo
     return Status::OK();
 }
 
+Status LocalMergeSortExchanger::sink(RuntimeState* state, vectorized::Block* 
in_block, bool eos,
+                                     LocalExchangeSinkLocalState& local_state) 
{
+    vectorized::Block new_block;
+    if (!_free_blocks.try_dequeue(new_block)) {
+        new_block = {in_block->clone_empty()};
+    }
+    new_block.swap(*in_block);
+    DCHECK_LE(local_state._channel_id, _data_queue.size());
+    _data_queue[local_state._channel_id].enqueue(std::move(new_block));

Review Comment:
   We should control memory in _data_queue by sink dependencies



##########
be/src/pipeline/exec/sort_source_operator.cpp:
##########
@@ -28,7 +29,33 @@ SortLocalState::SortLocalState(RuntimeState* state, 
OperatorXBase* parent)
 
 SortSourceOperatorX::SortSourceOperatorX(ObjectPool* pool, const TPlanNode& 
tnode, int operator_id,
                                          const DescriptorTbl& descs)
-        : OperatorX<SortLocalState>(pool, tnode, operator_id, descs) {}
+        : OperatorX<SortLocalState>(pool, tnode, operator_id, descs),
+          _merge_by_exchange(tnode.sort_node.merge_by_exchange),
+          _offset(tnode.sort_node.__isset.offset ? tnode.sort_node.offset : 0) 
{}
+
+Status SortSourceOperatorX::init(const TPlanNode& tnode, RuntimeState* state) {
+    RETURN_IF_ERROR(Base::init(tnode, state));
+    RETURN_IF_ERROR(_vsort_exec_exprs.init(tnode.sort_node.sort_info, _pool));
+    _is_asc_order = tnode.sort_node.sort_info.is_asc_order;
+    _nulls_first = tnode.sort_node.sort_info.nulls_first;
+    return Status::OK();
+}
+
+Status SortSourceOperatorX::prepare(RuntimeState* state) {
+    RETURN_IF_ERROR(Base::prepare(state));
+    if (_child_x) {
+        RETURN_IF_ERROR(_vsort_exec_exprs.prepare(state, _child_x->row_desc(), 
_row_descriptor));
+    }
+    return Status::OK();
+}
+
+Status SortSourceOperatorX::open(RuntimeState* state) {
+    RETURN_IF_ERROR(Base::open(state));
+    if (_child_x) {
+        RETURN_IF_ERROR(_vsort_exec_exprs.open(state));

Review Comment:
   `_vsort_exec_exprs` should be cloned in local state 's `init`



##########
be/src/pipeline/exec/sort_source_operator.cpp:
##########
@@ -28,7 +29,33 @@ SortLocalState::SortLocalState(RuntimeState* state, 
OperatorXBase* parent)
 
 SortSourceOperatorX::SortSourceOperatorX(ObjectPool* pool, const TPlanNode& 
tnode, int operator_id,
                                          const DescriptorTbl& descs)
-        : OperatorX<SortLocalState>(pool, tnode, operator_id, descs) {}
+        : OperatorX<SortLocalState>(pool, tnode, operator_id, descs),
+          _merge_by_exchange(tnode.sort_node.merge_by_exchange),
+          _offset(tnode.sort_node.__isset.offset ? tnode.sort_node.offset : 0) 
{}
+
+Status SortSourceOperatorX::init(const TPlanNode& tnode, RuntimeState* state) {
+    RETURN_IF_ERROR(Base::init(tnode, state));
+    RETURN_IF_ERROR(_vsort_exec_exprs.init(tnode.sort_node.sort_info, _pool));
+    _is_asc_order = tnode.sort_node.sort_info.is_asc_order;
+    _nulls_first = tnode.sort_node.sort_info.nulls_first;
+    return Status::OK();
+}
+
+Status SortSourceOperatorX::prepare(RuntimeState* state) {
+    RETURN_IF_ERROR(Base::prepare(state));
+    if (_child_x) {

Review Comment:
   `_child_x` never should be nullptr.



-- 
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