Coverage Report

Created: 2026-07-07 16:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/load/channel/adaptive_random_bucket_state.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 <mutex>
22
#include <unordered_map>
23
#include <vector>
24
25
#include "common/status.h"
26
#include "util/uid_util.h"
27
28
namespace doris {
29
30
class AdaptiveRandomBucketState {
31
public:
32
4
    explicit AdaptiveRandomBucketState(UniqueId load_id) : _load_id(load_id) {}
33
34
    Status init_partition(int64_t partition_id, const std::vector<int64_t>& tablets,
35
                          const std::vector<int32_t>& bucket_seqs, int32_t start_tablet_idx);
36
    int64_t current_tablet(int64_t partition_id);
37
    void rotate_by_tablet(int64_t partition_id, int64_t tablet_id);
38
39
private:
40
    struct PartitionState {
41
        int64_t partition_id = -1;
42
        std::vector<int64_t> tablets;
43
        std::vector<int32_t> bucket_seqs;
44
        int32_t initial_tablet_pos = 0;
45
        int32_t tablet_pos = 0;
46
        int64_t current_tablet_id = -1;
47
    };
48
49
    std::mutex _mutex;
50
    UniqueId _load_id;
51
    std::unordered_map<int64_t, PartitionState> _partition_states;
52
};
53
54
} // namespace doris