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


##########
be/src/pipeline/exec/repeat_operator.cpp:
##########
@@ -37,9 +38,238 @@ Status RepeatOperator::prepare(doris::RuntimeState* state) {
     return StatefulOperator::prepare(state);
 }
 
-Status RepeatOperator::close(doris::RuntimeState* state) {
-    _child_block.release();
-    return StatefulOperator::close(state);
+RepeatLocalState::RepeatLocalState(RuntimeState* state, OperatorXBase* parent)
+        : Base(state, parent),
+          _child_block(vectorized::Block::create_unique()),
+          _child_source_state(SourceState::DEPEND_ON_SOURCE),
+          _child_eos(false),
+          _repeat_id_idx(0) {}
+
+Status RepeatLocalState::init(RuntimeState* state, LocalStateInfo& info) {
+    RETURN_IF_ERROR(Base::init(state, info));
+    auto& p = _parent->cast<Parent>();
+    _expr_ctxs.resize(p._expr_ctxs.size());
+    for (size_t i = 0; i < _expr_ctxs.size(); i++) {
+        RETURN_IF_ERROR(p._expr_ctxs[i]->clone(state, _expr_ctxs[i]));
+    }
+    return Status::OK();
+}
+
+Status RepeatLocalState::close(RuntimeState* state) {
+    if (_closed) {
+        return Status::OK();
+    }
+    return Base::close(state);
+}
+
+Status RepeatOperatorX::init(const TPlanNode& tnode, RuntimeState* state) {
+    RETURN_IF_ERROR(OperatorXBase::init(tnode, state));
+    
RETURN_IF_ERROR(vectorized::VExpr::create_expr_trees(tnode.repeat_node.exprs, 
_expr_ctxs));
+    return Status::OK();
+}
+
+Status RepeatOperatorX::prepare(RuntimeState* state) {
+    VLOG_CRITICAL << "VRepeatNode::prepare";
+    SCOPED_TIMER(_runtime_profile->total_time_counter());
+
+    RETURN_IF_ERROR(OperatorXBase::prepare(state));
+    _output_tuple_desc = 
state->desc_tbl().get_tuple_descriptor(_output_tuple_id);
+    if (_output_tuple_desc == nullptr) {
+        return Status::InternalError("Failed to get tuple descriptor.");
+    }
+    RETURN_IF_ERROR(vectorized::VExpr::prepare(_expr_ctxs, state, 
_child_x->row_desc()));
+    for (const auto& slot_desc : _output_tuple_desc->slots()) {
+        _output_slots.push_back(slot_desc);
+    }
+
+    return Status::OK();
+}
+
+Status RepeatOperatorX::open(RuntimeState* state) {
+    VLOG_CRITICAL << "VRepeatNode::open";
+    SCOPED_TIMER(_runtime_profile->total_time_counter());
+    RETURN_IF_ERROR(OperatorXBase::open(state));
+    RETURN_IF_ERROR(vectorized::VExpr::open(_expr_ctxs, state));
+    return Status::OK();
+}
+
+RepeatOperatorX::RepeatOperatorX(ObjectPool* pool, const TPlanNode& tnode,
+                                 const DescriptorTbl& descs)
+        : Base(pool, tnode, descs),
+          _slot_id_set_list(tnode.repeat_node.slot_id_set_list),
+          _all_slot_ids(tnode.repeat_node.all_slot_ids),
+          _repeat_id_list(tnode.repeat_node.repeat_id_list),
+          _grouping_list(tnode.repeat_node.grouping_list),
+          _output_tuple_id(tnode.repeat_node.output_tuple_id) {};
+
+bool RepeatOperatorX::need_more_input_data(RuntimeState* state) const {
+    auto& local_state = state->get_local_state(id())->cast<RepeatLocalState>();
+    return !local_state._child_block->rows() && !local_state._child_eos;
+}
+Status RepeatOperatorX::get_block(RuntimeState* state, vectorized::Block* 
block,
+                                  SourceState& source_state) {
+    auto& local_state = state->get_local_state(id())->cast<RepeatLocalState>();
+    if (need_more_input_data(state)) {
+        local_state._child_block->clear_column_data();
+        RETURN_IF_ERROR(_child_x->get_block(state, 
local_state._child_block.get(),

Review Comment:
   ```suggestion
           RETURN_IF_ERROR(_child_x->get_next_after_projects(state, 
local_state._child_block.get(),
   ```



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