Coverage Report

Created: 2026-04-15 12:36

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/format/transformer/merge_partitioner.h
Line
Count
Source
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
#pragma once
19
20
#include <gen_cpp/Partitions_types.h>
21
22
#include <string>
23
24
#include "exec/partitioner/partitioner.h"
25
#include "format/transformer/writer_assigner.h"
26
27
namespace doris {
28
29
class MergePartitioner final : public PartitionerBase {
30
public:
31
    MergePartitioner(size_t partition_count, const TMergePartitionInfo& merge_info,
32
                     bool use_new_shuffle_hash_method);
33
34
    Status init(const std::vector<TExpr>& texprs) override;
35
    Status prepare(RuntimeState* state, const RowDescriptor& row_desc) override;
36
    Status open(RuntimeState* state) override;
37
    Status close(RuntimeState* state) override;
38
    Status do_partitioning(RuntimeState* state, Block* block) const override;
39
3
    const std::vector<HashValType>& get_channel_ids() const override { return _channel_ids; }
40
    Status clone(RuntimeState* state, std::unique_ptr<PartitionerBase>& partitioner) override;
41
42
private:
43
    void _apply_insert_rebalance(const std::vector<int8_t>& ops,
44
                                 std::vector<uint32_t>& insert_hashes, size_t block_bytes) const;
45
    void _init_insert_scaling(RuntimeState* state);
46
    uint32_t _next_rr_channel() const;
47
    Status _clone_expr_ctxs(RuntimeState* state, const VExprContextSPtrs& src,
48
                            VExprContextSPtrs& dst) const;
49
4
    ShuffleHashMethod _hash_method() const {
50
4
        return _use_new_shuffle_hash_method ? ShuffleHashMethod::CRC32C : ShuffleHashMethod::CRC32;
51
4
    }
52
53
    TMergePartitionInfo _merge_info;
54
    bool _use_new_shuffle_hash_method = false;
55
    bool _insert_random = false;
56
    bool _enable_insert_rebalance = false;
57
    size_t _insert_partition_count = 0;
58
    mutable int64_t _insert_data_processed = 0;
59
    mutable int _insert_writer_count = 1;
60
    int64_t _non_partition_scaling_threshold = 0;
61
    VExprContextSPtrs _operation_expr_ctxs;
62
    std::unique_ptr<PartitionFunction> _insert_partition_function;
63
    std::unique_ptr<PartitionFunction> _delete_partition_function;
64
    mutable std::unique_ptr<SkewedWriterAssigner> _insert_writer_assigner;
65
    mutable std::vector<uint32_t> _channel_ids;
66
    mutable uint32_t _rr_offset = 0;
67
};
68
69
} // namespace doris