Coverage Report

Created: 2026-03-12 17:15

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/load/channel/load_stream_mgr.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 <condition_variable>
21
#include <memory>
22
#include <mutex>
23
#include <unordered_map>
24
#include <utility>
25
26
#include "common/compiler_util.h" // IWYU pragma: keep
27
#include "common/status.h"
28
#include "load/channel/load_stream.h"
29
#include "util/threadpool.h"
30
31
namespace doris {
32
33
class POpenStreamSinkRequest;
34
35
class LoadStreamMgr {
36
public:
37
    LoadStreamMgr(uint32_t segment_file_writer_thread_num);
38
    ~LoadStreamMgr();
39
40
    Status open_load_stream(const POpenLoadStreamRequest* request, LoadStream*& load_stream);
41
    void clear_load(UniqueId loadid);
42
12.9k
    void create_token(std::unique_ptr<ThreadPoolToken>& token) {
43
12.9k
        token = _file_writer_thread_pool->new_token(ThreadPool::ExecutionMode::SERIAL);
44
12.9k
    }
45
46
0
    std::vector<std::string> get_all_load_stream_ids() {
47
0
        std::vector<std::string> result;
48
0
        std::lock_guard<std::mutex> lock(_lock);
49
50
0
        for (auto& [id, _] : _load_streams_map) {
51
0
            result.push_back(id.to_string());
52
0
        }
53
0
        return result;
54
0
    }
55
56
    // only used by ut
57
    size_t get_load_stream_num() { return _load_streams_map.size(); }
58
59
38.8k
    FifoThreadPool* heavy_work_pool() { return _heavy_work_pool; }
60
61
20
    void set_heavy_work_pool(FifoThreadPool* pool) { _heavy_work_pool = pool; }
62
63
private:
64
    std::mutex _lock;
65
    std::unordered_map<UniqueId, LoadStreamPtr> _load_streams_map;
66
    std::unique_ptr<ThreadPool> _file_writer_thread_pool;
67
68
    FifoThreadPool* _heavy_work_pool = nullptr;
69
};
70
71
} // namespace doris