Coverage Report

Created: 2026-04-10 04:10

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exec/exchange/vdata_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 <gen_cpp/Types_types.h>
21
#include <stdint.h>
22
23
#include <memory>
24
#include <mutex>
25
#include <set>
26
#include <shared_mutex>
27
#include <unordered_map>
28
#include <utility>
29
30
#include "common/be_mock_util.h"
31
#include "common/global_types.h"
32
#include "common/status.h"
33
#include "runtime/runtime_profile.h"
34
35
namespace google {
36
namespace protobuf {
37
class Closure;
38
}
39
} // namespace google
40
41
namespace doris {
42
class RuntimeState;
43
class RowDescriptor;
44
class PTransmitDataParams;
45
class ExchangeLocalState;
46
47
class VDataStreamRecvr;
48
49
class VDataStreamMgr {
50
public:
51
    VDataStreamMgr();
52
    MOCK_FUNCTION ~VDataStreamMgr();
53
54
    std::shared_ptr<VDataStreamRecvr> create_recvr(
55
            RuntimeState* state, RuntimeProfile::HighWaterMarkCounter* memory_used_counter,
56
            const TUniqueId& fragment_instance_id, PlanNodeId dest_node_id, int num_senders,
57
            RuntimeProfile* profile, bool is_merging, size_t data_queue_capacity);
58
59
    MOCK_FUNCTION Status find_recvr(const TUniqueId& fragment_instance_id, PlanNodeId node_id,
60
                                    std::shared_ptr<VDataStreamRecvr>* res,
61
                                    bool acquire_lock = true);
62
63
    Status deregister_recvr(const TUniqueId& fragment_instance_id, PlanNodeId node_id);
64
65
    Status transmit_block(const PTransmitDataParams* request, ::google::protobuf::Closure** done,
66
                          const int64_t wait_for_worker);
67
68
    void cancel(const TUniqueId& fragment_instance_id, Status exec_status);
69
70
private:
71
    std::shared_mutex _lock;
72
    using StreamMap = std::unordered_multimap<uint32_t, std::shared_ptr<VDataStreamRecvr>>;
73
    StreamMap _receiver_map;
74
75
    struct ComparisonOp {
76
        bool operator()(const std::pair<doris::TUniqueId, PlanNodeId>& a,
77
6.32M
                        const std::pair<doris::TUniqueId, PlanNodeId>& b) const {
78
6.32M
            if (a.first.hi < b.first.hi) {
79
2.00M
                return true;
80
4.32M
            } else if (a.first.hi > b.first.hi) {
81
1.15M
                return false;
82
3.16M
            } else if (a.first.lo < b.first.lo) {
83
1.32M
                return true;
84
1.84M
            } else if (a.first.lo > b.first.lo) {
85
1.05M
                return false;
86
1.05M
            }
87
787k
            return a.second < b.second;
88
6.32M
        }
89
    };
90
    using FragmentStreamSet = std::set<std::pair<TUniqueId, PlanNodeId>, ComparisonOp>;
91
    FragmentStreamSet _fragment_stream_set;
92
93
    uint32_t get_hash_value(const TUniqueId& fragment_instance_id, PlanNodeId node_id);
94
};
95
} // namespace doris