Coverage Report

Created: 2026-03-26 18:50

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
#include "common/compile_check_begin.h"
29
30
class MergePartitioner final : public PartitionerBase {
31
public:
32
    MergePartitioner(size_t partition_count, const TMergePartitionInfo& merge_info,
33
                     bool use_new_shuffle_hash_method);
34
35
    Status init(const std::vector<TExpr>& texprs) override;
36
    Status prepare(RuntimeState* state, const RowDescriptor& row_desc) override;
37
    Status open(RuntimeState* state) override;
38
    Status close(RuntimeState* state) override;
39
    Status do_partitioning(RuntimeState* state, Block* block) const override;
40
3
    const std::vector<HashValType>& get_channel_ids() const override { return _channel_ids; }
41
    Status clone(RuntimeState* state, std::unique_ptr<PartitionerBase>& partitioner) override;
42
43
private:
44
    void _apply_insert_rebalance(const std::vector<int8_t>& ops,
45
                                 std::vector<uint32_t>& insert_hashes, size_t block_bytes) const;
46
    void _init_insert_scaling(RuntimeState* state);
47
    uint32_t _next_rr_channel() const;
48
    Status _clone_expr_ctxs(RuntimeState* state, const VExprContextSPtrs& src,
49
                            VExprContextSPtrs& dst) const;
50
4
    ShuffleHashMethod _hash_method() const {
51
4
        return _use_new_shuffle_hash_method ? ShuffleHashMethod::CRC32C : ShuffleHashMethod::CRC32;
52
4
    }
53
54
    TMergePartitionInfo _merge_info;
55
    bool _use_new_shuffle_hash_method = false;
56
    bool _insert_random = false;
57
    bool _enable_insert_rebalance = false;
58
    size_t _insert_partition_count = 0;
59
    mutable int64_t _insert_data_processed = 0;
60
    mutable int _insert_writer_count = 1;
61
    int64_t _non_partition_scaling_threshold = 0;
62
    VExprContextSPtrs _operation_expr_ctxs;
63
    std::unique_ptr<PartitionFunction> _insert_partition_function;
64
    std::unique_ptr<PartitionFunction> _delete_partition_function;
65
    mutable std::unique_ptr<SkewedWriterAssigner> _insert_writer_assigner;
66
    mutable std::vector<uint32_t> _channel_ids;
67
    mutable uint32_t _rr_offset = 0;
68
};
69
70
#include "common/compile_check_end.h"
71
} // namespace doris