Coverage Report

Created: 2026-03-14 20:54

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exec/sink/tablet_sink_hash_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 "core/block/block.h"
21
#include "exec/operator/exchange_sink_operator.h"
22
#include "exec/partitioner/partitioner.h"
23
#include "exec/sink/vrow_distribution.h"
24
#include "exec/sink/vtablet_block_convertor.h"
25
#include "exec/sink/vtablet_finder.h"
26
#include "runtime/runtime_state.h"
27
#include "storage/tablet_info.h"
28
29
namespace doris {
30
#include "common/compile_check_begin.h"
31
class TabletSinkHashPartitioner final : public PartitionerBase {
32
public:
33
    TabletSinkHashPartitioner(uint32_t partition_count, int64_t txn_id,
34
                              TOlapTableSchemaParam tablet_sink_schema,
35
                              TOlapTablePartitionParam tablet_sink_partition,
36
                              TOlapTableLocationParam tablet_sink_location,
37
                              const TTupleId& tablet_sink_tuple_id,
38
                              ExchangeSinkLocalState* local_state);
39
40
2
    ~TabletSinkHashPartitioner() override = default;
41
42
    Status init(const std::vector<TExpr>& texprs) override;
43
44
    Status prepare(RuntimeState* state, const RowDescriptor& row_desc) override;
45
46
    Status open(RuntimeState* state) override;
47
48
    Status do_partitioning(RuntimeState* state, Block* block) const override;
49
    // block to create new partition by RPC. return batched data to create.
50
    Status try_cut_in_line(Block& prior_block) const;
51
0
    void finish_cut_in_line() const { _row_distribution._deal_batched = false; }
52
1
    void mark_last_block() const { _row_distribution._deal_batched = true; }
53
54
1
    const std::vector<HashValType>& get_channel_ids() const override { return _hash_vals; }
55
1
    const std::vector<bool>& get_skipped() const { return _skipped; }
56
57
    Status clone(RuntimeState* state, std::unique_ptr<PartitionerBase>& partitioner) override;
58
59
    Status close(RuntimeState* state) override;
60
61
private:
62
1
    static Status empty_callback_function(void* sender, TCreatePartitionResult* result) {
63
1
        return Status::OK();
64
1
    }
65
66
    const int64_t _txn_id = -1;
67
    const TOlapTableSchemaParam _tablet_sink_schema;
68
    const TOlapTablePartitionParam _tablet_sink_partition;
69
    const TOlapTableLocationParam _tablet_sink_location;
70
    const TTupleId _tablet_sink_tuple_id;
71
    mutable ExchangeSinkLocalState* _local_state;
72
    mutable OlapTableLocationParam* _location = nullptr;
73
    mutable VRowDistribution _row_distribution;
74
    mutable VExprContextSPtrs _tablet_sink_expr_ctxs;
75
    mutable std::unique_ptr<VOlapTablePartitionParam> _vpartition = nullptr;
76
    mutable std::unique_ptr<OlapTabletFinder> _tablet_finder = nullptr;
77
    mutable std::shared_ptr<OlapTableSchemaParam> _schema = nullptr;
78
    mutable std::unique_ptr<OlapTableBlockConvertor> _block_convertor = nullptr;
79
    mutable TupleDescriptor* _tablet_sink_tuple_desc = nullptr;
80
    mutable RowDescriptor* _tablet_sink_row_desc = nullptr;
81
    mutable std::vector<RowPartTabletIds> _row_part_tablet_ids;
82
    mutable std::vector<HashValType> _hash_vals;
83
    mutable std::vector<bool> _skipped;
84
};
85
#include "common/compile_check_end.h"
86
87
} // namespace doris