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


##########
be/src/pipeline/exec/exchange_sink_operator.cpp:
##########
@@ -211,6 +206,28 @@ Status ExchangeSinkLocalState::init(RuntimeState* state, 
LocalSinkStateInfo& inf
         }
         _exchange_sink_dependency->add_child(deps_for_channels);
     }
+    if (p._part_type == TPartitionType::HASH_PARTITIONED) {
+        _partition_count = channels.size();
+        _partitioner.reset(new vectorized::HashPartitioner(channels.size()));
+        RETURN_IF_ERROR(_partitioner->init(p._texprs));
+        RETURN_IF_ERROR(_partitioner->prepare(state, p._row_desc));
+    } else if (p._part_type == 
TPartitionType::BUCKET_SHFFULE_HASH_PARTITIONED) {
+        _partition_count = channel_shared_ptrs.size();
+        _partitioner.reset(new 
vectorized::BucketHashPartitioner(channel_shared_ptrs.size()));
+        RETURN_IF_ERROR(_partitioner->init(p._texprs));
+        RETURN_IF_ERROR(_partitioner->prepare(state, p._row_desc));
+    }
+
+    return Status::OK();
+}
+
+Status ExchangeSinkLocalState::open(RuntimeState* state) {

Review Comment:
   warning: method 'open' can be made static 
[readability-convert-member-functions-to-static]
   
   be/src/pipeline/exec/exchange_sink_operator.h:135:
   ```diff
   -     Status open(RuntimeState* state) override;
   +     static Status open(RuntimeState* state) override;
   ```
   



##########
be/src/vec/runtime/partitioner.cpp:
##########
@@ -0,0 +1,72 @@
+// 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 "partitioner.h"
+
+#include "runtime/thread_context.h"
+#include "vec/columns/column_const.h"
+
+namespace doris::vectorized {
+
+template <typename HashValueType>
+Status Partitioner<HashValueType>::do_partitioning(RuntimeState* state, Block* 
block,
+                                                   MemTracker* mem_tracker) 
const {
+    // will only copy schema
+    // we don't want send temp columns
+    auto column_to_keep = block->columns();
+
+    int result_size = _partition_expr_ctxs.size();
+    int result[result_size];
+
+    // vectorized calculate hash
+    int rows = block->rows();
+    _hash_vals.resize(rows);
+    auto* __restrict hashes = _hash_vals.data();
+
+    if (rows > 0) {
+        {
+            SCOPED_CONSUME_MEM_TRACKER(mem_tracker);
+            RETURN_IF_ERROR(_get_partition_column_result(block, result));
+        }
+        // result[j] means column index, i means rows index, here to calculate 
the xxhash value
+        for (int j = 0; j < result_size; ++j) {
+            // complex type most not implement get_data_at() method which 
column_const will call
+            
_do_hash(unpack_if_const(block->get_by_position(result[j]).column).first, 
hashes, j);
+        }
+
+        for (int i = 0; i < rows; i++) {
+            hashes[i] = hashes[i] % _partition_count;
+        }
+
+        {
+            SCOPED_CONSUME_MEM_TRACKER(mem_tracker);
+            Block::erase_useless_column(block, column_to_keep);
+        }
+    }
+    return Status::OK();
+}
+
+void BucketHashPartitioner::_do_hash(const ColumnPtr& column, uint32_t* 
result, int idx) const {
+    column->update_crcs_with_value(result, 
_partition_expr_ctxs[idx]->root()->type().type,
+                                   column->size());
+}
+
+void HashPartitioner::_do_hash(const ColumnPtr& column, uint64_t* result, int 
/*idx*/) const {

Review Comment:
   warning: method '_do_hash' can be made static 
[readability-convert-member-functions-to-static]
   
   ```suggestion
   static void HashPartitioner::_do_hash(const ColumnPtr& column, uint64_t* 
result, int /*idx*/) {
   ```
   



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