github-actions[bot] commented on code in PR #43611:
URL: https://github.com/apache/doris/pull/43611#discussion_r1836177940


##########
be/src/pipeline/exec/nested_loop_join_probe_operator_cross.h:
##########
@@ -0,0 +1,229 @@
+// 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 <stdint.h>

Review Comment:
   warning: inclusion of deprecated C++ header 'stdint.h'; consider using 
'cstdint' instead [modernize-deprecated-headers]
   
   ```suggestion
   #include <cstdint>
   ```
   



##########
be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:
##########
@@ -0,0 +1,718 @@
+// 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 "nested_loop_join_probe_operator_cross.h"
+
+#include <memory>
+
+#include "common/cast_set.h"
+#include "common/exception.h"
+#include "common/status.h"
+#include "pipeline/exec/operator.h"
+#include "vec/columns/column_filter_helper.h"
+#include "vec/core/block.h"
+
+namespace doris {
+class RuntimeState;
+} // namespace doris
+
+namespace doris::pipeline {
+#include "common/compile_check_begin.h"
+NestedLoopJoinProbeLocalStateCross::NestedLoopJoinProbeLocalStateCross(RuntimeState*
 state,
+                                                                       
OperatorXBase* parent)
+        : JoinProbeLocalState<NestedLoopJoinSharedState, 
NestedLoopJoinProbeLocalStateCross>(
+                  state, parent),
+          _matched_rows_done(false),
+          _left_block_pos(0) {}
+
+Status NestedLoopJoinProbeLocalStateCross::init(RuntimeState* state, 
LocalStateInfo& info) {
+    RETURN_IF_ERROR(JoinProbeLocalState::init(state, info));
+    SCOPED_TIMER(exec_time_counter());
+    SCOPED_TIMER(_init_timer);
+    _loop_join_timer = ADD_TIMER(profile(), "LoopGenerateJoin");
+    _output_temp_blocks_timer = ADD_TIMER(profile(), "OutputTempBlocksTime");
+    _update_visited_flags_timer = ADD_TIMER(profile(), 
"UpdateVisitedFlagsTime");
+    _join_conjuncts_evaluation_timer = ADD_TIMER(profile(), 
"JoinConjunctsEvaluationTime");
+    _filtered_by_join_conjuncts_timer = ADD_TIMER(profile(), 
"FilteredByJoinConjunctsTime");
+    _push_loop_join_timer = ADD_TIMER(profile(), "PushLoopGenerateJoin");
+    _insert_probe_timer = ADD_TIMER(profile(), "InsertProbeTimer");
+    _insert_build_timer = ADD_TIMER(profile(), "InsertBuildTimer");
+    _insert_counter = ADD_COUNTER(Base::profile(), "InsertCount", TUnit::UNIT);
+    _insert_build_rows = ADD_COUNTER(Base::profile(), "InsertBuildRows", 
TUnit::UNIT);
+    _push_timer = ADD_TIMER(profile(), "PullTimer");
+    _push_test_timer1 = ADD_TIMER(profile(), "PullTestTimer1");
+    _push_test_timer2 = ADD_TIMER(profile(), "PullTestTimer2");
+    _push_test_timer3 = ADD_TIMER(profile(), "PullTestTimer3");
+    _push_test_timer4 = ADD_TIMER(profile(), "PullTestTimer4");
+    _test1 = ADD_TIMER(profile(), "_test1");
+    _test2 = ADD_TIMER(profile(), "_test2");
+    _test3 = ADD_TIMER(profile(), "_test3");
+    _test4 = ADD_TIMER(profile(), "_test4");
+    _test5 = ADD_TIMER(profile(), "_test5");
+    _test6 = ADD_TIMER(profile(), "_test6");
+    _test7 = ADD_TIMER(profile(), "_test7");
+    _test_ccc1 = ADD_TIMER(profile(), "_test_ccc1");
+    _test_ccc2 = ADD_TIMER(profile(), "_test_ccc2");
+
+    _push_chunk_num = ADD_COUNTER(Base::profile(), "PushChunkNum", 
TUnit::UNIT);
+    _pull_chunk_num = ADD_COUNTER(Base::profile(), "PullChunkNum", 
TUnit::UNIT);
+    _pull_row_nums = ADD_COUNTER(Base::profile(), "PullChunkRows", 
TUnit::UNIT);
+    _push_row_nums = ADD_COUNTER(Base::profile(), "PushChunkRows", 
TUnit::UNIT);
+    _insert_probe_timer2 = ADD_TIMER(Base::profile(), "_insert_probe_timer2");
+    return Status::OK();
+}
+
+Status NestedLoopJoinProbeLocalStateCross::open(RuntimeState* state) {
+    RETURN_IF_ERROR(JoinProbeLocalState::open(state));
+    SCOPED_TIMER(exec_time_counter());
+    SCOPED_TIMER(_open_timer);
+    auto& p = _parent->cast<NestedLoopJoinProbeOperatorXCross>();
+    _join_conjuncts.resize(p._join_conjuncts.size());
+    for (size_t i = 0; i < _join_conjuncts.size(); i++) {
+        RETURN_IF_ERROR(p._join_conjuncts[i]->clone(state, 
_join_conjuncts[i]));
+    }
+    _construct_mutable_join_block();
+    return Status::OK();
+}
+
+Status NestedLoopJoinProbeLocalStateCross::close(RuntimeState* state) {
+    SCOPED_TIMER(exec_time_counter());
+    SCOPED_TIMER(_close_timer);
+    if (_closed) {
+        return Status::OK();
+    }
+    _child_block->clear();
+
+    _tuple_is_null_left_flag_column = nullptr;
+    _tuple_is_null_right_flag_column = nullptr;
+    return JoinProbeLocalState<NestedLoopJoinSharedState,
+                               
NestedLoopJoinProbeLocalStateCross>::close(state);
+}
+
+void NestedLoopJoinProbeLocalStateCross::_reset_with_next_probe_row() {
+    // TODO: need a vector of left block to register the 
_probe_row_visited_flags
+    _current_build_pos = 0;
+    _left_block_pos++;
+}
+
+void 
NestedLoopJoinProbeLocalStateCross::add_tuple_is_null_column(vectorized::Block* 
block) {
+    auto& p = _parent->cast<NestedLoopJoinProbeOperatorXCross>();
+    if (!p._use_specific_projections) {
+        return;
+    }
+    if (p._is_outer_join) {
+        auto p0 = _tuple_is_null_left_flag_column->assume_mutable();
+        auto p1 = _tuple_is_null_right_flag_column->assume_mutable();
+        block->insert({std::move(p0), 
std::make_shared<vectorized::DataTypeUInt8>(),
+                       "left_tuples_is_null"});
+        block->insert({std::move(p1), 
std::make_shared<vectorized::DataTypeUInt8>(),
+                       "right_tuples_is_null"});
+    }
+}
+
+void 
NestedLoopJoinProbeLocalStateCross::_resize_fill_tuple_is_null_column(size_t 
new_size,
+                                                                           
uint8_t left_flag,
+                                                                           
uint8_t right_flag) {
+    auto& p = _parent->cast<NestedLoopJoinProbeOperatorXCross>();
+    if (p._is_outer_join) {
+        
reinterpret_cast<vectorized::ColumnUInt8*>(_tuple_is_null_left_flag_column.get())
+                ->get_data()
+                .resize_fill(new_size, left_flag);
+        
reinterpret_cast<vectorized::ColumnUInt8*>(_tuple_is_null_right_flag_column.get())
+                ->get_data()
+                .resize_fill(new_size, right_flag);
+    }
+}
+
+template <bool BuildSide, bool IsSemi>
+void 
NestedLoopJoinProbeLocalStateCross::_finalize_current_phase(vectorized::Block& 
block,

Review Comment:
   warning: function '_finalize_current_phase' has cognitive complexity of 74 
(threshold 50) [readability-function-cognitive-complexity]
   ```cpp
   void 
NestedLoopJoinProbeLocalStateCross::_finalize_current_phase(vectorized::Block& 
block,
                                            ^
   ```
   <details>
   <summary>Additional context</summary>
   
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:147:** +1, 
including nesting penalty of 0, nesting level increased to 1
   ```cpp
       if constexpr (BuildSide) {
       ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:151:** +2, 
including nesting penalty of 1, nesting level increased to 2
   ```cpp
           for (; i < build_block_sz && column_size < batch_size; i++) {
           ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:151:** +1
   ```cpp
           for (; i < build_block_sz && column_size < batch_size; i++) {
                                     ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:162:** +3, 
including nesting penalty of 2, nesting level increased to 3
   ```cpp
               for (uint32_t j = 0; j < num_rows; j++) {
               ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:163:** +4, 
including nesting penalty of 3, nesting level increased to 4
   ```cpp
                   if constexpr (IsSemi) {
                   ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:164:** +5, 
including nesting penalty of 4, nesting level increased to 5
   ```cpp
                       if (cur_visited_flags[j]) {
                       ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:167:** +1, 
nesting level increased to 4
   ```cpp
                   } else {
                     ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:168:** +5, 
including nesting penalty of 4, nesting level increased to 5
   ```cpp
                       if (!cur_visited_flags[j]) {
                       ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:175:** +3, 
including nesting penalty of 2, nesting level increased to 3
   ```cpp
               for (size_t j = 0; j < p._num_probe_side_columns; ++j) {
               ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:182:** +3, 
including nesting penalty of 2, nesting level increased to 3
   ```cpp
               for (size_t j = 0; j < p._num_build_side_columns; ++j) {
               ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:184:** +4, 
including nesting penalty of 3, nesting level increased to 4
   ```cpp
                   if (!src_column.column->is_nullable() &&
                   ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:184:** +1
   ```cpp
                   if (!src_column.column->is_nullable() &&
                                                         ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:197:** +1, 
nesting level increased to 4
   ```cpp
                   } else {
                     ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:206:** +1, 
nesting level increased to 1
   ```cpp
       } else {
         ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:207:** +2, 
including nesting penalty of 1, nesting level increased to 2
   ```cpp
           if (!p._is_mark_join) {
           ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:210:** +3, 
including nesting penalty of 2, nesting level increased to 3
   ```cpp
               for (int j = _left_block_start_pos;
               ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:212:** +4, 
including nesting penalty of 3, nesting level increased to 4
   ```cpp
                   if (_cur_probe_row_visited_flags[j] == IsSemi) {
                   ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:214:** +5, 
including nesting penalty of 4, nesting level increased to 5
   ```cpp
                       for (size_t i = 0; i < p._num_probe_side_columns; ++i) {
                       ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:217:** +6, 
including nesting penalty of 5, nesting level increased to 6
   ```cpp
                           if (!src_column.column->is_nullable() && 
dst_columns[i]->is_nullable()) {
                           ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:217:** +1
   ```cpp
                           if (!src_column.column->is_nullable() && 
dst_columns[i]->is_nullable()) {
                                                                 ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:226:** +1, 
nesting level increased to 6
   ```cpp
                           } else {
                             ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:232:** +3, 
including nesting penalty of 2, nesting level increased to 3
   ```cpp
               if (new_size > column_size) {
               ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:233:** +4, 
including nesting penalty of 3, nesting level increased to 4
   ```cpp
                   for (size_t i = 0; i < p._num_build_side_columns; ++i) {
                   ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:239:** +1, 
nesting level increased to 2
   ```cpp
           } else {
             ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:243:** +3, 
including nesting penalty of 2, nesting level increased to 3
   ```cpp
               for (int j = _left_block_start_pos;
               ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:247:** +3, 
including nesting penalty of 2, nesting level increased to 3
   ```cpp
               for (size_t i = 0; i < p._num_probe_side_columns; ++i) {
               ^
   ```
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:254:** +3, 
including nesting penalty of 2, nesting level increased to 3
   ```cpp
               for (size_t i = 0; i < p._num_build_side_columns; ++i) {
               ^
   ```
   
   </details>
   



##########
be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:
##########
@@ -0,0 +1,718 @@
+// 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 "nested_loop_join_probe_operator_cross.h"
+
+#include <memory>
+
+#include "common/cast_set.h"
+#include "common/exception.h"
+#include "common/status.h"
+#include "pipeline/exec/operator.h"
+#include "vec/columns/column_filter_helper.h"
+#include "vec/core/block.h"
+
+namespace doris {
+class RuntimeState;
+} // namespace doris
+
+namespace doris::pipeline {
+#include "common/compile_check_begin.h"
+NestedLoopJoinProbeLocalStateCross::NestedLoopJoinProbeLocalStateCross(RuntimeState*
 state,
+                                                                       
OperatorXBase* parent)
+        : JoinProbeLocalState<NestedLoopJoinSharedState, 
NestedLoopJoinProbeLocalStateCross>(
+                  state, parent),
+          _matched_rows_done(false),
+          _left_block_pos(0) {}
+
+Status NestedLoopJoinProbeLocalStateCross::init(RuntimeState* state, 
LocalStateInfo& info) {
+    RETURN_IF_ERROR(JoinProbeLocalState::init(state, info));
+    SCOPED_TIMER(exec_time_counter());
+    SCOPED_TIMER(_init_timer);
+    _loop_join_timer = ADD_TIMER(profile(), "LoopGenerateJoin");
+    _output_temp_blocks_timer = ADD_TIMER(profile(), "OutputTempBlocksTime");
+    _update_visited_flags_timer = ADD_TIMER(profile(), 
"UpdateVisitedFlagsTime");
+    _join_conjuncts_evaluation_timer = ADD_TIMER(profile(), 
"JoinConjunctsEvaluationTime");
+    _filtered_by_join_conjuncts_timer = ADD_TIMER(profile(), 
"FilteredByJoinConjunctsTime");
+    _push_loop_join_timer = ADD_TIMER(profile(), "PushLoopGenerateJoin");
+    _insert_probe_timer = ADD_TIMER(profile(), "InsertProbeTimer");
+    _insert_build_timer = ADD_TIMER(profile(), "InsertBuildTimer");
+    _insert_counter = ADD_COUNTER(Base::profile(), "InsertCount", TUnit::UNIT);
+    _insert_build_rows = ADD_COUNTER(Base::profile(), "InsertBuildRows", 
TUnit::UNIT);
+    _push_timer = ADD_TIMER(profile(), "PullTimer");
+    _push_test_timer1 = ADD_TIMER(profile(), "PullTestTimer1");
+    _push_test_timer2 = ADD_TIMER(profile(), "PullTestTimer2");
+    _push_test_timer3 = ADD_TIMER(profile(), "PullTestTimer3");
+    _push_test_timer4 = ADD_TIMER(profile(), "PullTestTimer4");
+    _test1 = ADD_TIMER(profile(), "_test1");
+    _test2 = ADD_TIMER(profile(), "_test2");
+    _test3 = ADD_TIMER(profile(), "_test3");
+    _test4 = ADD_TIMER(profile(), "_test4");
+    _test5 = ADD_TIMER(profile(), "_test5");
+    _test6 = ADD_TIMER(profile(), "_test6");
+    _test7 = ADD_TIMER(profile(), "_test7");
+    _test_ccc1 = ADD_TIMER(profile(), "_test_ccc1");
+    _test_ccc2 = ADD_TIMER(profile(), "_test_ccc2");
+
+    _push_chunk_num = ADD_COUNTER(Base::profile(), "PushChunkNum", 
TUnit::UNIT);
+    _pull_chunk_num = ADD_COUNTER(Base::profile(), "PullChunkNum", 
TUnit::UNIT);
+    _pull_row_nums = ADD_COUNTER(Base::profile(), "PullChunkRows", 
TUnit::UNIT);
+    _push_row_nums = ADD_COUNTER(Base::profile(), "PushChunkRows", 
TUnit::UNIT);
+    _insert_probe_timer2 = ADD_TIMER(Base::profile(), "_insert_probe_timer2");
+    return Status::OK();
+}
+
+Status NestedLoopJoinProbeLocalStateCross::open(RuntimeState* state) {
+    RETURN_IF_ERROR(JoinProbeLocalState::open(state));
+    SCOPED_TIMER(exec_time_counter());
+    SCOPED_TIMER(_open_timer);
+    auto& p = _parent->cast<NestedLoopJoinProbeOperatorXCross>();
+    _join_conjuncts.resize(p._join_conjuncts.size());
+    for (size_t i = 0; i < _join_conjuncts.size(); i++) {
+        RETURN_IF_ERROR(p._join_conjuncts[i]->clone(state, 
_join_conjuncts[i]));
+    }
+    _construct_mutable_join_block();
+    return Status::OK();
+}
+
+Status NestedLoopJoinProbeLocalStateCross::close(RuntimeState* state) {
+    SCOPED_TIMER(exec_time_counter());
+    SCOPED_TIMER(_close_timer);
+    if (_closed) {
+        return Status::OK();
+    }
+    _child_block->clear();
+
+    _tuple_is_null_left_flag_column = nullptr;
+    _tuple_is_null_right_flag_column = nullptr;
+    return JoinProbeLocalState<NestedLoopJoinSharedState,
+                               
NestedLoopJoinProbeLocalStateCross>::close(state);
+}
+
+void NestedLoopJoinProbeLocalStateCross::_reset_with_next_probe_row() {
+    // TODO: need a vector of left block to register the 
_probe_row_visited_flags
+    _current_build_pos = 0;
+    _left_block_pos++;
+}
+
+void 
NestedLoopJoinProbeLocalStateCross::add_tuple_is_null_column(vectorized::Block* 
block) {
+    auto& p = _parent->cast<NestedLoopJoinProbeOperatorXCross>();
+    if (!p._use_specific_projections) {
+        return;
+    }
+    if (p._is_outer_join) {
+        auto p0 = _tuple_is_null_left_flag_column->assume_mutable();
+        auto p1 = _tuple_is_null_right_flag_column->assume_mutable();
+        block->insert({std::move(p0), 
std::make_shared<vectorized::DataTypeUInt8>(),
+                       "left_tuples_is_null"});
+        block->insert({std::move(p1), 
std::make_shared<vectorized::DataTypeUInt8>(),
+                       "right_tuples_is_null"});
+    }
+}
+
+void 
NestedLoopJoinProbeLocalStateCross::_resize_fill_tuple_is_null_column(size_t 
new_size,
+                                                                           
uint8_t left_flag,
+                                                                           
uint8_t right_flag) {
+    auto& p = _parent->cast<NestedLoopJoinProbeOperatorXCross>();
+    if (p._is_outer_join) {
+        
reinterpret_cast<vectorized::ColumnUInt8*>(_tuple_is_null_left_flag_column.get())
+                ->get_data()
+                .resize_fill(new_size, left_flag);
+        
reinterpret_cast<vectorized::ColumnUInt8*>(_tuple_is_null_right_flag_column.get())
+                ->get_data()
+                .resize_fill(new_size, right_flag);
+    }
+}
+
+template <bool BuildSide, bool IsSemi>
+void 
NestedLoopJoinProbeLocalStateCross::_finalize_current_phase(vectorized::Block& 
block,

Review Comment:
   warning: function '_finalize_current_phase' exceeds recommended 
size/complexity thresholds [readability-function-size]
   ```cpp
   void 
NestedLoopJoinProbeLocalStateCross::_finalize_current_phase(vectorized::Block& 
block,
                                            ^
   ```
   <details>
   <summary>Additional context</summary>
   
   **be/src/pipeline/exec/nested_loop_join_probe_operator_cross.cpp:141:** 120 
lines including whitespace and comments (threshold 80)
   ```cpp
   void 
NestedLoopJoinProbeLocalStateCross::_finalize_current_phase(vectorized::Block& 
block,
                                            ^
   ```
   
   </details>
   



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