Coverage Report

Created: 2024-11-20 21:05

/root/doris/be/src/vec/runtime/partitioner.cpp
Line
Count
Source (jump to first uncovered line)
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#include "partitioner.h"
19
20
#include "common/cast_set.h"
21
#include "pipeline/local_exchange/local_exchange_sink_operator.h"
22
#include "runtime/thread_context.h"
23
#include "vec/columns/column_const.h"
24
#include "vec/sink/vdata_stream_sender.h"
25
26
namespace doris::vectorized {
27
#include "common/compile_check_begin.h"
28
29
template <typename ChannelIds>
30
0
Status Crc32HashPartitioner<ChannelIds>::do_partitioning(RuntimeState* state, Block* block) const {
31
0
    size_t rows = block->rows();
32
33
0
    if (rows > 0) {
34
0
        auto column_to_keep = block->columns();
35
36
0
        int result_size = cast_set<int>(_partition_expr_ctxs.size());
37
0
        std::vector<int> result(result_size);
38
39
0
        _hash_vals.resize(rows);
40
0
        std::fill(_hash_vals.begin(), _hash_vals.end(), 0);
41
0
        auto* __restrict hashes = _hash_vals.data();
42
0
        { RETURN_IF_ERROR(_get_partition_column_result(block, result)); }
43
0
        for (int j = 0; j < result_size; ++j) {
44
0
            _do_hash(unpack_if_const(block->get_by_position(result[j]).column).first, hashes, j);
45
0
        }
46
47
0
        for (size_t i = 0; i < rows; i++) {
48
0
            hashes[i] = ChannelIds()(hashes[i], _partition_count);
49
0
        }
50
51
0
        { Block::erase_useless_column(block, column_to_keep); }
52
0
    }
53
0
    return Status::OK();
54
0
}
Unexecuted instantiation: _ZNK5doris10vectorized20Crc32HashPartitionerINS0_17ShuffleChannelIdsEE15do_partitioningEPNS_12RuntimeStateEPNS0_5BlockE
Unexecuted instantiation: _ZNK5doris10vectorized20Crc32HashPartitionerINS0_24SpillPartitionChannelIdsEE15do_partitioningEPNS_12RuntimeStateEPNS0_5BlockE
55
56
template <typename ChannelIds>
57
void Crc32HashPartitioner<ChannelIds>::_do_hash(const ColumnPtr& column,
58
0
                                                uint32_t* __restrict result, int idx) const {
59
0
    column->update_crcs_with_value(result, _partition_expr_ctxs[idx]->root()->type().type,
60
0
                                   cast_set<uint32_t>(column->size()));
61
0
}
Unexecuted instantiation: _ZNK5doris10vectorized20Crc32HashPartitionerINS0_17ShuffleChannelIdsEE8_do_hashERKN3COWINS0_7IColumnEE13immutable_ptrIS5_EEPji
Unexecuted instantiation: _ZNK5doris10vectorized20Crc32HashPartitionerINS0_24SpillPartitionChannelIdsEE8_do_hashERKN3COWINS0_7IColumnEE13immutable_ptrIS5_EEPji
62
63
template <typename ChannelIds>
64
Status Crc32HashPartitioner<ChannelIds>::clone(RuntimeState* state,
65
0
                                               std::unique_ptr<PartitionerBase>& partitioner) {
66
0
    auto* new_partitioner = new Crc32HashPartitioner<ChannelIds>(cast_set<int>(_partition_count));
67
0
    partitioner.reset(new_partitioner);
68
0
    new_partitioner->_partition_expr_ctxs.resize(_partition_expr_ctxs.size());
69
0
    for (size_t i = 0; i < _partition_expr_ctxs.size(); i++) {
70
0
        RETURN_IF_ERROR(
71
0
                _partition_expr_ctxs[i]->clone(state, new_partitioner->_partition_expr_ctxs[i]));
72
0
    }
73
0
    return Status::OK();
74
0
}
Unexecuted instantiation: _ZN5doris10vectorized20Crc32HashPartitionerINS0_17ShuffleChannelIdsEE5cloneEPNS_12RuntimeStateERSt10unique_ptrINS0_15PartitionerBaseESt14default_deleteIS7_EE
Unexecuted instantiation: _ZN5doris10vectorized20Crc32HashPartitionerINS0_24SpillPartitionChannelIdsEE5cloneEPNS_12RuntimeStateERSt10unique_ptrINS0_15PartitionerBaseESt14default_deleteIS7_EE
75
76
template class Crc32HashPartitioner<ShuffleChannelIds>;
77
template class Crc32HashPartitioner<SpillPartitionChannelIds>;
78
79
} // namespace doris::vectorized