github-actions[bot] commented on code in PR #25846: URL: https://github.com/apache/doris/pull/25846#discussion_r1369982172
########## be/src/pipeline/pipeline_x/local_exchange/local_exchange_sink_operator.cpp: ########## @@ -0,0 +1,82 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "pipeline/pipeline_x/local_exchange/local_exchange_sink_operator.h" + +namespace doris::pipeline { + +Status LocalExchangeSinkLocalState::init(RuntimeState* state, LocalSinkStateInfo& info) { Review Comment: warning: method 'init' can be made static [readability-convert-member-functions-to-static] be/src/pipeline/pipeline_x/local_exchange/local_exchange_sink_operator.h:34: ```diff - Status init(RuntimeState* state, LocalSinkStateInfo& info) override; + static Status init(RuntimeState* state, LocalSinkStateInfo& info) override; ``` ########## be/src/pipeline/pipeline_x/local_exchange/local_exchange_sink_operator.cpp: ########## @@ -0,0 +1,82 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "pipeline/pipeline_x/local_exchange/local_exchange_sink_operator.h" + +namespace doris::pipeline { + +Status LocalExchangeSinkLocalState::init(RuntimeState* state, LocalSinkStateInfo& info) { + RETURN_IF_ERROR(Base::init(state, info)); + SCOPED_TIMER(profile()->total_time_counter()); + SCOPED_TIMER(_open_timer); + _compute_hash_value_timer = ADD_TIMER(profile(), "ComputeHashValueTime"); + _distribute_timer = ADD_TIMER(profile(), "DistributeDataTime"); + auto& p = _parent->cast<LocalExchangeSinkOperatorX>(); + RETURN_IF_ERROR(p._partitioner->clone(state, _partitioner)); + _mutable_block.resize(p._num_partitions); + _shared_state->running_sink_operators++; + return Status::OK(); +} + +Status LocalExchangeSinkLocalState::channel_add_rows(RuntimeState* state, Review Comment: warning: method 'channel_add_rows' can be made static [readability-convert-member-functions-to-static] be/src/pipeline/pipeline_x/local_exchange/local_exchange_sink_operator.h:36: ```diff - Status channel_add_rows(RuntimeState* state, const uint32_t* __restrict channel_ids, + static Status channel_add_rows(RuntimeState* state, const uint32_t* __restrict channel_ids, ``` ########## be/src/pipeline/pipeline_x/local_exchange/local_exchange_sink_operator.cpp: ########## @@ -0,0 +1,82 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "pipeline/pipeline_x/local_exchange/local_exchange_sink_operator.h" + +namespace doris::pipeline { + +Status LocalExchangeSinkLocalState::init(RuntimeState* state, LocalSinkStateInfo& info) { + RETURN_IF_ERROR(Base::init(state, info)); + SCOPED_TIMER(profile()->total_time_counter()); + SCOPED_TIMER(_open_timer); + _compute_hash_value_timer = ADD_TIMER(profile(), "ComputeHashValueTime"); + _distribute_timer = ADD_TIMER(profile(), "DistributeDataTime"); + auto& p = _parent->cast<LocalExchangeSinkOperatorX>(); + RETURN_IF_ERROR(p._partitioner->clone(state, _partitioner)); + _mutable_block.resize(p._num_partitions); + _shared_state->running_sink_operators++; + return Status::OK(); +} + +Status LocalExchangeSinkLocalState::channel_add_rows(RuntimeState* state, + const uint32_t* __restrict channel_ids, + vectorized::Block* block) { + auto& data_queue = _shared_state->data_queue; + std::vector<int> channel2rows[data_queue.size()]; + + auto rows = block->rows(); + for (int i = 0; i < rows; i++) { + channel2rows[channel_ids[i]].emplace_back(i); + } + for (size_t i = 0; i < data_queue.size(); i++) { + if (_mutable_block[i] == nullptr) { + _mutable_block[i] = vectorized::MutableBlock::create_unique(block->clone_empty()); + } + + const int* begin = channel2rows[i].data(); + _mutable_block[i]->add_rows(block, begin, begin + channel2rows[i].size()); + data_queue[i].enqueue(_mutable_block[i]->to_block()); + _mutable_block[i].reset(nullptr); + } + + return Status::OK(); +} + +Status LocalExchangeSinkOperatorX::sink(RuntimeState* state, vectorized::Block* in_block, Review Comment: warning: method 'sink' can be made static [readability-convert-member-functions-to-static] be/src/pipeline/pipeline_x/local_exchange/local_exchange_sink_operator.h:84: ```diff - Status sink(RuntimeState* state, vectorized::Block* in_block, + static Status sink(RuntimeState* state, vectorized::Block* in_block, ``` ########## be/src/pipeline/pipeline_x/local_exchange/local_exchange_sink_operator.h: ########## @@ -0,0 +1,95 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#include "pipeline/pipeline_x/dependency.h" +#include "pipeline/pipeline_x/operator.h" + +namespace doris::pipeline { + +class LocalExchangeSinkOperatorX; +class LocalExchangeSinkLocalState final : public PipelineXSinkLocalState<LocalExchangeDependency> { +public: + using Base = PipelineXSinkLocalState<LocalExchangeDependency>; + ENABLE_FACTORY_CREATOR(LocalExchangeSinkLocalState); + + LocalExchangeSinkLocalState(DataSinkOperatorXBase* parent, RuntimeState* state) + : Base(parent, state) {} + ~LocalExchangeSinkLocalState() override = default; + + Status init(RuntimeState* state, LocalSinkStateInfo& info) override; + + Status channel_add_rows(RuntimeState* state, const uint32_t* __restrict channel_ids, + vectorized::Block* block); + +private: + friend class LocalExchangeSinkOperatorX; + + RuntimeProfile::Counter* _compute_hash_value_timer = nullptr; + RuntimeProfile::Counter* _distribute_timer = nullptr; + std::unique_ptr<vectorized::PartitionerBase> _partitioner; + std::vector<std::unique_ptr<vectorized::MutableBlock>> _mutable_block; +}; + +struct LocalExchangeChannelIds { + uint32_t operator()(uint32_t l, uint32_t r) { return ((uint64_t)l * (uint64_t)r) >> 32; } +}; + +class LocalExchangeSinkOperatorX final : public DataSinkOperatorX<LocalExchangeSinkLocalState> { +public: + using Base = DataSinkOperatorX<LocalExchangeSinkLocalState>; + LocalExchangeSinkOperatorX(int sink_id, int num_partitions, const std::vector<TExpr>& texprs) + : Base(sink_id), _num_partitions(num_partitions), _texprs(texprs) {} + + Status init(const TPlanNode& tnode, RuntimeState* state) override { + return Status::InternalError("{} should not init with TPlanNode", Base::_name); + } + + Status init(const TDataSink& tsink) override { + return Status::InternalError("{} should not init with TPlanNode", Base::_name); + } + + Status init() override { Review Comment: warning: method 'init' can be made static [readability-convert-member-functions-to-static] ```suggestion static Status init() override { ``` ########## be/src/pipeline/pipeline_x/local_exchange/local_exchange_sink_operator.h: ########## @@ -0,0 +1,95 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#include "pipeline/pipeline_x/dependency.h" +#include "pipeline/pipeline_x/operator.h" + +namespace doris::pipeline { + +class LocalExchangeSinkOperatorX; +class LocalExchangeSinkLocalState final : public PipelineXSinkLocalState<LocalExchangeDependency> { +public: + using Base = PipelineXSinkLocalState<LocalExchangeDependency>; + ENABLE_FACTORY_CREATOR(LocalExchangeSinkLocalState); + + LocalExchangeSinkLocalState(DataSinkOperatorXBase* parent, RuntimeState* state) + : Base(parent, state) {} + ~LocalExchangeSinkLocalState() override = default; + + Status init(RuntimeState* state, LocalSinkStateInfo& info) override; + + Status channel_add_rows(RuntimeState* state, const uint32_t* __restrict channel_ids, + vectorized::Block* block); + +private: + friend class LocalExchangeSinkOperatorX; + + RuntimeProfile::Counter* _compute_hash_value_timer = nullptr; + RuntimeProfile::Counter* _distribute_timer = nullptr; + std::unique_ptr<vectorized::PartitionerBase> _partitioner; + std::vector<std::unique_ptr<vectorized::MutableBlock>> _mutable_block; +}; + +struct LocalExchangeChannelIds { + uint32_t operator()(uint32_t l, uint32_t r) { return ((uint64_t)l * (uint64_t)r) >> 32; } Review Comment: warning: 32 is a magic number; consider replacing it with a named constant [readability-magic-numbers] ```cpp uint32_t operator()(uint32_t l, uint32_t r) { return ((uint64_t)l * (uint64_t)r) >> 32; } ^ ``` ########## be/src/pipeline/pipeline_x/local_exchange/local_exchange_sink_operator.h: ########## @@ -0,0 +1,95 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#include "pipeline/pipeline_x/dependency.h" +#include "pipeline/pipeline_x/operator.h" + +namespace doris::pipeline { + +class LocalExchangeSinkOperatorX; +class LocalExchangeSinkLocalState final : public PipelineXSinkLocalState<LocalExchangeDependency> { +public: + using Base = PipelineXSinkLocalState<LocalExchangeDependency>; + ENABLE_FACTORY_CREATOR(LocalExchangeSinkLocalState); + + LocalExchangeSinkLocalState(DataSinkOperatorXBase* parent, RuntimeState* state) + : Base(parent, state) {} + ~LocalExchangeSinkLocalState() override = default; + + Status init(RuntimeState* state, LocalSinkStateInfo& info) override; + + Status channel_add_rows(RuntimeState* state, const uint32_t* __restrict channel_ids, + vectorized::Block* block); + +private: + friend class LocalExchangeSinkOperatorX; + + RuntimeProfile::Counter* _compute_hash_value_timer = nullptr; + RuntimeProfile::Counter* _distribute_timer = nullptr; + std::unique_ptr<vectorized::PartitionerBase> _partitioner; + std::vector<std::unique_ptr<vectorized::MutableBlock>> _mutable_block; +}; + +struct LocalExchangeChannelIds { + uint32_t operator()(uint32_t l, uint32_t r) { return ((uint64_t)l * (uint64_t)r) >> 32; } +}; + +class LocalExchangeSinkOperatorX final : public DataSinkOperatorX<LocalExchangeSinkLocalState> { +public: + using Base = DataSinkOperatorX<LocalExchangeSinkLocalState>; + LocalExchangeSinkOperatorX(int sink_id, int num_partitions, const std::vector<TExpr>& texprs) + : Base(sink_id), _num_partitions(num_partitions), _texprs(texprs) {} + + Status init(const TPlanNode& tnode, RuntimeState* state) override { + return Status::InternalError("{} should not init with TPlanNode", Base::_name); + } + + Status init(const TDataSink& tsink) override { + return Status::InternalError("{} should not init with TPlanNode", Base::_name); + } + + Status init() override { + _name = "LOCAL_EXCHANGE_SINK_OPERATOR"; + _partitioner.reset( + new vectorized::BucketHashPartitioner<LocalExchangeChannelIds>(_num_partitions)); + RETURN_IF_ERROR(_partitioner->init(_texprs)); + return Status::OK(); + } + + Status prepare(RuntimeState* state) override { Review Comment: warning: method 'prepare' can be made static [readability-convert-member-functions-to-static] ```suggestion static Status prepare(RuntimeState* state) override { ``` ########## be/src/pipeline/pipeline_x/local_exchange/local_exchange_sink_operator.h: ########## @@ -0,0 +1,95 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#include "pipeline/pipeline_x/dependency.h" +#include "pipeline/pipeline_x/operator.h" + +namespace doris::pipeline { + +class LocalExchangeSinkOperatorX; +class LocalExchangeSinkLocalState final : public PipelineXSinkLocalState<LocalExchangeDependency> { +public: + using Base = PipelineXSinkLocalState<LocalExchangeDependency>; + ENABLE_FACTORY_CREATOR(LocalExchangeSinkLocalState); + + LocalExchangeSinkLocalState(DataSinkOperatorXBase* parent, RuntimeState* state) + : Base(parent, state) {} + ~LocalExchangeSinkLocalState() override = default; + + Status init(RuntimeState* state, LocalSinkStateInfo& info) override; + + Status channel_add_rows(RuntimeState* state, const uint32_t* __restrict channel_ids, + vectorized::Block* block); + +private: + friend class LocalExchangeSinkOperatorX; + + RuntimeProfile::Counter* _compute_hash_value_timer = nullptr; + RuntimeProfile::Counter* _distribute_timer = nullptr; + std::unique_ptr<vectorized::PartitionerBase> _partitioner; + std::vector<std::unique_ptr<vectorized::MutableBlock>> _mutable_block; +}; + +struct LocalExchangeChannelIds { + uint32_t operator()(uint32_t l, uint32_t r) { return ((uint64_t)l * (uint64_t)r) >> 32; } +}; + +class LocalExchangeSinkOperatorX final : public DataSinkOperatorX<LocalExchangeSinkLocalState> { +public: + using Base = DataSinkOperatorX<LocalExchangeSinkLocalState>; + LocalExchangeSinkOperatorX(int sink_id, int num_partitions, const std::vector<TExpr>& texprs) + : Base(sink_id), _num_partitions(num_partitions), _texprs(texprs) {} + + Status init(const TPlanNode& tnode, RuntimeState* state) override { + return Status::InternalError("{} should not init with TPlanNode", Base::_name); + } + + Status init(const TDataSink& tsink) override { + return Status::InternalError("{} should not init with TPlanNode", Base::_name); + } + + Status init() override { + _name = "LOCAL_EXCHANGE_SINK_OPERATOR"; + _partitioner.reset( + new vectorized::BucketHashPartitioner<LocalExchangeChannelIds>(_num_partitions)); + RETURN_IF_ERROR(_partitioner->init(_texprs)); + return Status::OK(); + } + + Status prepare(RuntimeState* state) override { + RETURN_IF_ERROR(_partitioner->prepare(state, _child_x->row_desc())); + return Status::OK(); + } + + Status open(RuntimeState* state) override { Review Comment: warning: method 'open' can be made static [readability-convert-member-functions-to-static] ```suggestion static Status open(RuntimeState* state) override { ``` ########## be/src/pipeline/pipeline_x/local_exchange/local_exchange_source_operator.cpp: ########## @@ -0,0 +1,63 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "pipeline/pipeline_x/local_exchange/local_exchange_source_operator.h" + +namespace doris::pipeline { + +Status LocalExchangeSourceLocalState::init(RuntimeState* state, LocalStateInfo& info) { + RETURN_IF_ERROR(Base::init(state, info)); + SCOPED_TIMER(profile()->total_time_counter()); + SCOPED_TIMER(_open_timer); + _dependency->set_shared_state(info.local_exchange_state); + _shared_state = (LocalExchangeSharedState*)_dependency->shared_state(); + DCHECK(_shared_state != nullptr); + _channel_id = info.task_idx; + _get_block_failed_counter = + ADD_COUNTER_WITH_LEVEL(profile(), "GetBlockFailedTime", TUnit::UNIT, 1); + return Status::OK(); +} + +Dependency* LocalExchangeSourceOperatorX::wait_for_dependency(RuntimeState* state) { Review Comment: warning: method 'wait_for_dependency' can be made static [readability-convert-member-functions-to-static] be/src/pipeline/pipeline_x/local_exchange/local_exchange_source_operator.h:56: ```diff - Dependency* wait_for_dependency(RuntimeState* state) override; + static Dependency* wait_for_dependency(RuntimeState* state) override; ``` ########## be/src/pipeline/pipeline_x/local_exchange/local_exchange_source_operator.h: ########## @@ -0,0 +1,68 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#include "pipeline/pipeline_x/dependency.h" +#include "pipeline/pipeline_x/operator.h" + +namespace doris::pipeline { + +class LocalExchangeSourceOperatorX; +class LocalExchangeSourceLocalState final : public PipelineXLocalState<LocalExchangeDependency> { +public: + using Base = PipelineXLocalState<LocalExchangeDependency>; + ENABLE_FACTORY_CREATOR(LocalExchangeSourceLocalState); + LocalExchangeSourceLocalState(RuntimeState* state, OperatorXBase* parent) + : Base(state, parent) {} + + Status init(RuntimeState* state, LocalStateInfo& info) override; + +private: + friend class LocalExchangeSourceOperatorX; + + int _channel_id; + RuntimeProfile::Counter* _get_block_failed_counter = nullptr; +}; + +class LocalExchangeSourceOperatorX final : public OperatorX<LocalExchangeSourceLocalState> { +public: + using Base = OperatorX<LocalExchangeSourceLocalState>; + LocalExchangeSourceOperatorX(ObjectPool* pool, int id) : Base(pool, -1, id) {} + Status init(const TPlanNode& tnode, RuntimeState* state) override { Review Comment: warning: method 'init' can be made static [readability-convert-member-functions-to-static] ```suggestion static Status init(const TPlanNode& tnode, RuntimeState* state) override { ``` ########## be/src/pipeline/pipeline_x/local_exchange/local_exchange_source_operator.cpp: ########## @@ -0,0 +1,63 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "pipeline/pipeline_x/local_exchange/local_exchange_source_operator.h" + +namespace doris::pipeline { + +Status LocalExchangeSourceLocalState::init(RuntimeState* state, LocalStateInfo& info) { + RETURN_IF_ERROR(Base::init(state, info)); + SCOPED_TIMER(profile()->total_time_counter()); + SCOPED_TIMER(_open_timer); + _dependency->set_shared_state(info.local_exchange_state); + _shared_state = (LocalExchangeSharedState*)_dependency->shared_state(); + DCHECK(_shared_state != nullptr); + _channel_id = info.task_idx; + _get_block_failed_counter = + ADD_COUNTER_WITH_LEVEL(profile(), "GetBlockFailedTime", TUnit::UNIT, 1); + return Status::OK(); +} + +Dependency* LocalExchangeSourceOperatorX::wait_for_dependency(RuntimeState* state) { + // TODO: + CREATE_LOCAL_STATE_RETURN_NULL_IF_ERROR(local_state); + DCHECK_GT(local_state._shared_state->data_queue.size(), 0); + if (local_state._shared_state->data_queue[local_state._channel_id].size_approx() > 0 || + local_state._shared_state->running_sink_operators == 0) { + return nullptr; + } else { + return local_state._dependency; + } +} + +Status LocalExchangeSourceOperatorX::get_block(RuntimeState* state, vectorized::Block* block, Review Comment: warning: method 'get_block' can be made static [readability-convert-member-functions-to-static] be/src/pipeline/pipeline_x/local_exchange/local_exchange_source_operator.h:58: ```diff - Status get_block(RuntimeState* state, vectorized::Block* block, + static Status get_block(RuntimeState* state, vectorized::Block* block, ``` ########## be/src/pipeline/pipeline_x/local_exchange/local_exchange_source_operator.cpp: ########## @@ -0,0 +1,63 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "pipeline/pipeline_x/local_exchange/local_exchange_source_operator.h" + +namespace doris::pipeline { + +Status LocalExchangeSourceLocalState::init(RuntimeState* state, LocalStateInfo& info) { + RETURN_IF_ERROR(Base::init(state, info)); + SCOPED_TIMER(profile()->total_time_counter()); + SCOPED_TIMER(_open_timer); + _dependency->set_shared_state(info.local_exchange_state); + _shared_state = (LocalExchangeSharedState*)_dependency->shared_state(); + DCHECK(_shared_state != nullptr); + _channel_id = info.task_idx; + _get_block_failed_counter = + ADD_COUNTER_WITH_LEVEL(profile(), "GetBlockFailedTime", TUnit::UNIT, 1); + return Status::OK(); +} + +Dependency* LocalExchangeSourceOperatorX::wait_for_dependency(RuntimeState* state) { + // TODO: + CREATE_LOCAL_STATE_RETURN_NULL_IF_ERROR(local_state); + DCHECK_GT(local_state._shared_state->data_queue.size(), 0); + if (local_state._shared_state->data_queue[local_state._channel_id].size_approx() > 0 || + local_state._shared_state->running_sink_operators == 0) { + return nullptr; + } else { + return local_state._dependency; + } Review Comment: warning: do not use 'else' after 'return' [readability-else-after-return] ```suggestion } return local_state._dependency; ``` ########## be/src/pipeline/pipeline_x/local_exchange/local_exchange_source_operator.h: ########## @@ -0,0 +1,68 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#include "pipeline/pipeline_x/dependency.h" +#include "pipeline/pipeline_x/operator.h" + +namespace doris::pipeline { + +class LocalExchangeSourceOperatorX; +class LocalExchangeSourceLocalState final : public PipelineXLocalState<LocalExchangeDependency> { +public: + using Base = PipelineXLocalState<LocalExchangeDependency>; + ENABLE_FACTORY_CREATOR(LocalExchangeSourceLocalState); + LocalExchangeSourceLocalState(RuntimeState* state, OperatorXBase* parent) + : Base(state, parent) {} + + Status init(RuntimeState* state, LocalStateInfo& info) override; + +private: + friend class LocalExchangeSourceOperatorX; + + int _channel_id; + RuntimeProfile::Counter* _get_block_failed_counter = nullptr; +}; + +class LocalExchangeSourceOperatorX final : public OperatorX<LocalExchangeSourceLocalState> { +public: + using Base = OperatorX<LocalExchangeSourceLocalState>; + LocalExchangeSourceOperatorX(ObjectPool* pool, int id) : Base(pool, -1, id) {} + Status init(const TPlanNode& tnode, RuntimeState* state) override { + _op_name = "LOCAL_EXCHANGE_OPERATOR"; + return Status::OK(); + } + Status prepare(RuntimeState* state) override { return Status::OK(); } Review Comment: warning: method 'prepare' can be made static [readability-convert-member-functions-to-static] ```suggestion static Status prepare(RuntimeState* state) override { return Status::OK(); } ``` ########## be/src/pipeline/pipeline_x/operator.h: ########## @@ -245,14 +247,14 @@ class OperatorXBase : public OperatorBase { [[nodiscard]] OperatorXPtr get_child() { return _child_x; } [[nodiscard]] vectorized::VExprContextSPtrs& conjuncts() { return _conjuncts; } - [[nodiscard]] RowDescriptor& row_descriptor() { return _row_descriptor; } + [[nodiscard]] virtual RowDescriptor& row_descriptor() { return _row_descriptor; } [[nodiscard]] int id() const override { return _id; } [[nodiscard]] int node_id() const { return _node_id; } [[nodiscard]] int64_t limit() const { return _limit; } - [[nodiscard]] const RowDescriptor& row_desc() override { + [[nodiscard]] virtual const RowDescriptor& row_desc() override { Review Comment: warning: 'virtual' is redundant since the function is already declared 'override' [modernize-use-override] ```suggestion [[nodiscard]] const RowDescriptor& row_desc() override { ``` ########## be/src/pipeline/pipeline_x/local_exchange/local_exchange_source_operator.h: ########## @@ -0,0 +1,68 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#include "pipeline/pipeline_x/dependency.h" +#include "pipeline/pipeline_x/operator.h" + +namespace doris::pipeline { + +class LocalExchangeSourceOperatorX; +class LocalExchangeSourceLocalState final : public PipelineXLocalState<LocalExchangeDependency> { +public: + using Base = PipelineXLocalState<LocalExchangeDependency>; + ENABLE_FACTORY_CREATOR(LocalExchangeSourceLocalState); + LocalExchangeSourceLocalState(RuntimeState* state, OperatorXBase* parent) + : Base(state, parent) {} + + Status init(RuntimeState* state, LocalStateInfo& info) override; + +private: + friend class LocalExchangeSourceOperatorX; + + int _channel_id; + RuntimeProfile::Counter* _get_block_failed_counter = nullptr; +}; + +class LocalExchangeSourceOperatorX final : public OperatorX<LocalExchangeSourceLocalState> { +public: + using Base = OperatorX<LocalExchangeSourceLocalState>; + LocalExchangeSourceOperatorX(ObjectPool* pool, int id) : Base(pool, -1, id) {} + Status init(const TPlanNode& tnode, RuntimeState* state) override { + _op_name = "LOCAL_EXCHANGE_OPERATOR"; + return Status::OK(); + } + Status prepare(RuntimeState* state) override { return Status::OK(); } + Status open(RuntimeState* state) override { return Status::OK(); } + const RowDescriptor& intermediate_row_desc() const override { + return _child_x->intermediate_row_desc(); + } + RowDescriptor& row_descriptor() override { return _child_x->row_descriptor(); } + const RowDescriptor& row_desc() override { return _child_x->row_desc(); } + Dependency* wait_for_dependency(RuntimeState* state) override; + + Status get_block(RuntimeState* state, vectorized::Block* block, + SourceState& source_state) override; + + bool is_source() const override { return true; } Review Comment: warning: method 'is_source' can be made static [readability-convert-member-functions-to-static] ```suggestion static bool is_source() override { return true; } ``` ########## be/src/pipeline/pipeline_x/local_exchange/local_exchange_source_operator.h: ########## @@ -0,0 +1,68 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#include "pipeline/pipeline_x/dependency.h" +#include "pipeline/pipeline_x/operator.h" + +namespace doris::pipeline { + +class LocalExchangeSourceOperatorX; +class LocalExchangeSourceLocalState final : public PipelineXLocalState<LocalExchangeDependency> { +public: + using Base = PipelineXLocalState<LocalExchangeDependency>; + ENABLE_FACTORY_CREATOR(LocalExchangeSourceLocalState); + LocalExchangeSourceLocalState(RuntimeState* state, OperatorXBase* parent) + : Base(state, parent) {} + + Status init(RuntimeState* state, LocalStateInfo& info) override; + +private: + friend class LocalExchangeSourceOperatorX; + + int _channel_id; + RuntimeProfile::Counter* _get_block_failed_counter = nullptr; +}; + +class LocalExchangeSourceOperatorX final : public OperatorX<LocalExchangeSourceLocalState> { +public: + using Base = OperatorX<LocalExchangeSourceLocalState>; + LocalExchangeSourceOperatorX(ObjectPool* pool, int id) : Base(pool, -1, id) {} + Status init(const TPlanNode& tnode, RuntimeState* state) override { + _op_name = "LOCAL_EXCHANGE_OPERATOR"; + return Status::OK(); + } + Status prepare(RuntimeState* state) override { return Status::OK(); } + Status open(RuntimeState* state) override { return Status::OK(); } Review Comment: warning: method 'open' can be made static [readability-convert-member-functions-to-static] ```suggestion static Status open(RuntimeState* state) override { return Status::OK(); } ``` -- 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]
