Coverage Report

Created: 2026-03-12 17:42

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exec/sink/vtablet_finder.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 <cstdint>
21
#include <map>
22
23
#include "common/status.h"
24
#include "core/block/block.h"
25
#include "exec/common/hash_table/phmap_fwd_decl.h"
26
#include "storage/tablet_info.h"
27
#include "util/bitmap.h"
28
29
namespace doris {
30
#include "common/compile_check_begin.h"
31
32
class OlapTabletFinder {
33
public:
34
    // FIND_TABLET_EVERY_ROW is used for hash distribution info, which indicates that we
35
    // should compute tablet index for every row
36
    // FIND_TABLET_EVERY_BATCH is used for random distribution info, which indicates that we should
37
    // compute tablet index for every row batch
38
    // FIND_TABLET_EVERY_SINK is used for random distribution info when load_to_single_tablet set to true,
39
    // which indicates that we should only compute tablet index in the corresponding partition once for the
40
    // whole time in olap table sink
41
    enum FindTabletMode { FIND_TABLET_EVERY_ROW, FIND_TABLET_EVERY_BATCH, FIND_TABLET_EVERY_SINK };
42
43
    OlapTabletFinder(VOlapTablePartitionParam* vpartition, FindTabletMode mode)
44
68.7k
            : _vpartition(vpartition), _find_tablet_mode(mode), _filter_bitmap(1024) {};
45
46
    Status find_tablets(RuntimeState* state, Block* block, int rows,
47
                        std::vector<VOlapTablePartition*>& partitions,
48
                        std::vector<uint32_t>& tablet_index, std::vector<bool>& skip,
49
                        std::vector<uint32_t>* miss_rows = nullptr);
50
51
0
    bool is_find_tablet_every_sink() {
52
0
        return _find_tablet_mode == FindTabletMode::FIND_TABLET_EVERY_SINK;
53
0
    }
54
55
0
    bool is_single_tablet() { return _partition_to_tablet_map.size() == 1; }
56
57
    // all partitions for multi find-processes of its relative writer.
58
133k
    const flat_hash_set<int64_t>& partition_ids() { return _partition_ids; }
59
60
134k
    int64_t num_filtered_rows() const { return _num_filtered_rows; }
61
62
68.7k
    int64_t num_immutable_partition_filtered_rows() const {
63
68.7k
        return _num_immutable_partition_filtered_rows;
64
68.7k
    }
65
66
39.1k
    Bitmap& filter_bitmap() { return _filter_bitmap; }
67
68
private:
69
    VOlapTablePartitionParam* _vpartition = nullptr;
70
    FindTabletMode _find_tablet_mode;
71
    std::map<VOlapTablePartition*, int64_t> _partition_to_tablet_map;
72
    flat_hash_set<int64_t> _partition_ids;
73
74
    int64_t _num_filtered_rows = 0;
75
    int64_t _num_immutable_partition_filtered_rows = 0;
76
    Bitmap _filter_bitmap;
77
};
78
79
} // namespace doris
80
#include "common/compile_check_end.h"