Coverage Report

Created: 2026-03-16 12:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exec/pipeline/dependency.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
#ifdef __APPLE__
21
#include <netinet/in.h>
22
#include <sys/_types/_u_int.h>
23
#endif
24
25
#include <concurrentqueue.h>
26
#include <gen_cpp/internal_service.pb.h>
27
#include <sqltypes.h>
28
29
#include <atomic>
30
#include <functional>
31
#include <memory>
32
#include <mutex>
33
#include <thread>
34
#include <utility>
35
36
#include "common/config.h"
37
#include "common/logging.h"
38
#include "core/block/block.h"
39
#include "core/types.h"
40
#include "exec/common/agg_utils.h"
41
#include "exec/common/join_utils.h"
42
#include "exec/common/set_utils.h"
43
#include "exec/operator/data_queue.h"
44
#include "exec/operator/join/process_hash_table_probe.h"
45
#include "exec/sort/partition_sorter.h"
46
#include "exec/sort/sorter.h"
47
#include "exec/spill/spill_file.h"
48
#include "util/brpc_closure.h"
49
#include "util/stack_util.h"
50
51
namespace doris {
52
class AggFnEvaluator;
53
class VSlotRef;
54
} // namespace doris
55
56
namespace doris {
57
#include "common/compile_check_begin.h"
58
class Dependency;
59
class PipelineTask;
60
struct BasicSharedState;
61
using DependencySPtr = std::shared_ptr<Dependency>;
62
class LocalExchangeSourceLocalState;
63
64
static constexpr auto SLOW_DEPENDENCY_THRESHOLD = 60 * 1000L * 1000L * 1000L;
65
static constexpr auto TIME_UNIT_DEPENDENCY_LOG = 30 * 1000L * 1000L * 1000L;
66
static_assert(TIME_UNIT_DEPENDENCY_LOG < SLOW_DEPENDENCY_THRESHOLD);
67
68
struct BasicSharedState {
69
    ENABLE_FACTORY_CREATOR(BasicSharedState)
70
71
    template <class TARGET>
72
2.38M
    TARGET* cast() {
73
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
74
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
75
18.4E
                << " and expect type is" << typeid(TARGET).name();
76
2.38M
        return reinterpret_cast<TARGET*>(this);
77
2.38M
    }
_ZN5doris16BasicSharedState4castINS_19HashJoinSharedStateEEEPT_v
Line
Count
Source
72
302k
    TARGET* cast() {
73
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
74
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
75
18.4E
                << " and expect type is" << typeid(TARGET).name();
76
302k
        return reinterpret_cast<TARGET*>(this);
77
302k
    }
_ZN5doris16BasicSharedState4castINS_30PartitionedHashJoinSharedStateEEEPT_v
Line
Count
Source
72
3
    TARGET* cast() {
73
3
        DCHECK(dynamic_cast<TARGET*>(this))
74
0
                << " Mismatch type! Current type is " << typeid(*this).name()
75
0
                << " and expect type is" << typeid(TARGET).name();
76
3
        return reinterpret_cast<TARGET*>(this);
77
3
    }
_ZN5doris16BasicSharedState4castINS_15SortSharedStateEEEPT_v
Line
Count
Source
72
419k
    TARGET* cast() {
73
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
74
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
75
18.4E
                << " and expect type is" << typeid(TARGET).name();
76
419k
        return reinterpret_cast<TARGET*>(this);
77
419k
    }
_ZN5doris16BasicSharedState4castINS_20SpillSortSharedStateEEEPT_v
Line
Count
Source
72
80
    TARGET* cast() {
73
80
        DCHECK(dynamic_cast<TARGET*>(this))
74
0
                << " Mismatch type! Current type is " << typeid(*this).name()
75
0
                << " and expect type is" << typeid(TARGET).name();
76
80
        return reinterpret_cast<TARGET*>(this);
77
80
    }
_ZN5doris16BasicSharedState4castINS_25NestedLoopJoinSharedStateEEEPT_v
Line
Count
Source
72
12.5k
    TARGET* cast() {
73
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
74
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
75
18.4E
                << " and expect type is" << typeid(TARGET).name();
76
12.5k
        return reinterpret_cast<TARGET*>(this);
77
12.5k
    }
_ZN5doris16BasicSharedState4castINS_19AnalyticSharedStateEEEPT_v
Line
Count
Source
72
15.2k
    TARGET* cast() {
73
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
74
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
75
18.4E
                << " and expect type is" << typeid(TARGET).name();
76
15.2k
        return reinterpret_cast<TARGET*>(this);
77
15.2k
    }
_ZN5doris16BasicSharedState4castINS_14AggSharedStateEEEPT_v
Line
Count
Source
72
245k
    TARGET* cast() {
73
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
74
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
75
18.4E
                << " and expect type is" << typeid(TARGET).name();
76
245k
        return reinterpret_cast<TARGET*>(this);
77
245k
    }
_ZN5doris16BasicSharedState4castINS_25PartitionedAggSharedStateEEEPT_v
Line
Count
Source
72
1.38k
    TARGET* cast() {
73
1.38k
        DCHECK(dynamic_cast<TARGET*>(this))
74
0
                << " Mismatch type! Current type is " << typeid(*this).name()
75
0
                << " and expect type is" << typeid(TARGET).name();
76
1.38k
        return reinterpret_cast<TARGET*>(this);
77
1.38k
    }
_ZN5doris16BasicSharedState4castINS_16UnionSharedStateEEEPT_v
Line
Count
Source
72
9.15k
    TARGET* cast() {
73
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
74
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
75
18.4E
                << " and expect type is" << typeid(TARGET).name();
76
9.15k
        return reinterpret_cast<TARGET*>(this);
77
9.15k
    }
_ZN5doris16BasicSharedState4castINS_28PartitionSortNodeSharedStateEEEPT_v
Line
Count
Source
72
1.06k
    TARGET* cast() {
73
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
74
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
75
18.4E
                << " and expect type is" << typeid(TARGET).name();
76
1.06k
        return reinterpret_cast<TARGET*>(this);
77
1.06k
    }
_ZN5doris16BasicSharedState4castINS_20MultiCastSharedStateEEEPT_v
Line
Count
Source
72
8.82k
    TARGET* cast() {
73
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
74
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
75
18.4E
                << " and expect type is" << typeid(TARGET).name();
76
8.82k
        return reinterpret_cast<TARGET*>(this);
77
8.82k
    }
_ZN5doris16BasicSharedState4castINS_14SetSharedStateEEEPT_v
Line
Count
Source
72
16.2k
    TARGET* cast() {
73
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
74
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
75
18.4E
                << " and expect type is" << typeid(TARGET).name();
76
16.2k
        return reinterpret_cast<TARGET*>(this);
77
16.2k
    }
_ZN5doris16BasicSharedState4castINS_24LocalExchangeSharedStateEEEPT_v
Line
Count
Source
72
937k
    TARGET* cast() {
73
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
74
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
75
18.4E
                << " and expect type is" << typeid(TARGET).name();
76
937k
        return reinterpret_cast<TARGET*>(this);
77
937k
    }
_ZN5doris16BasicSharedState4castIS0_EEPT_v
Line
Count
Source
72
411k
    TARGET* cast() {
73
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
74
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
75
18.4E
                << " and expect type is" << typeid(TARGET).name();
76
411k
        return reinterpret_cast<TARGET*>(this);
77
411k
    }
_ZN5doris16BasicSharedState4castINS_20DataQueueSharedStateEEEPT_v
Line
Count
Source
72
736
    TARGET* cast() {
73
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
74
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
75
18.4E
                << " and expect type is" << typeid(TARGET).name();
76
736
        return reinterpret_cast<TARGET*>(this);
77
736
    }
_ZN5doris16BasicSharedState4castINS_17RecCTESharedStateEEEPT_v
Line
Count
Source
72
448
    TARGET* cast() {
73
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
74
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
75
18.4E
                << " and expect type is" << typeid(TARGET).name();
76
448
        return reinterpret_cast<TARGET*>(this);
77
448
    }
78
    template <class TARGET>
79
    const TARGET* cast() const {
80
        DCHECK(dynamic_cast<const TARGET*>(this))
81
                << " Mismatch type! Current type is " << typeid(*this).name()
82
                << " and expect type is" << typeid(TARGET).name();
83
        return reinterpret_cast<const TARGET*>(this);
84
    }
85
    std::vector<DependencySPtr> source_deps;
86
    std::vector<DependencySPtr> sink_deps;
87
    int id = 0;
88
    std::set<int> related_op_ids;
89
90
1.63M
    virtual ~BasicSharedState() = default;
91
92
    void create_source_dependencies(int num_sources, int operator_id, int node_id,
93
                                    const std::string& name);
94
    Dependency* create_source_dependency(int operator_id, int node_id, const std::string& name);
95
96
    Dependency* create_sink_dependency(int dest_id, int node_id, const std::string& name);
97
653k
    std::vector<DependencySPtr> get_dep_by_channel_id(int channel_id) {
98
653k
        DCHECK_LT(channel_id, source_deps.size());
99
653k
        return {source_deps[channel_id]};
100
653k
    }
101
};
102
103
class Dependency : public std::enable_shared_from_this<Dependency> {
104
public:
105
    ENABLE_FACTORY_CREATOR(Dependency);
106
    Dependency(int id, int node_id, std::string name, bool ready = false)
107
6.19M
            : _id(id), _node_id(node_id), _name(std::move(name)), _ready(ready) {}
108
6.22M
    virtual ~Dependency() = default;
109
110
0
    [[nodiscard]] int id() const { return _id; }
111
7.11M
    [[nodiscard]] virtual std::string name() const { return _name; }
112
313k
    BasicSharedState* shared_state() { return _shared_state; }
113
2.24M
    void set_shared_state(BasicSharedState* shared_state) { _shared_state = shared_state; }
114
    virtual std::string debug_string(int indentation_level = 0);
115
916M
    bool ready() const { return _ready; }
116
117
    // Start the watcher. We use it to count how long this dependency block the current pipeline task.
118
4.31M
    void start_watcher() { _watcher.start(); }
119
9.89M
    [[nodiscard]] int64_t watcher_elapse_time() { return _watcher.elapsed_time(); }
120
121
    // Which dependency current pipeline task is blocked by. `nullptr` if this dependency is ready.
122
    [[nodiscard]] Dependency* is_blocked_by(std::shared_ptr<PipelineTask> task = nullptr);
123
    // Notify downstream pipeline tasks this dependency is ready.
124
    void set_ready();
125
513k
    void set_ready_to_read(int channel_id = 0) {
126
513k
        DCHECK_LT(channel_id, _shared_state->source_deps.size()) << debug_string();
127
513k
        _shared_state->source_deps[channel_id]->set_ready();
128
513k
    }
129
1.14k
    void set_ready_to_write() {
130
1.14k
        DCHECK_EQ(_shared_state->sink_deps.size(), 1) << debug_string();
131
1.14k
        _shared_state->sink_deps.front()->set_ready();
132
1.14k
    }
133
134
    // Notify downstream pipeline tasks this dependency is blocked.
135
1.19M
    void block() {
136
1.19M
        if (_always_ready) {
137
242k
            return;
138
242k
        }
139
948k
        std::unique_lock<std::mutex> lc(_always_ready_lock);
140
948k
        if (_always_ready) {
141
2
            return;
142
2
        }
143
948k
        _ready = false;
144
948k
    }
145
146
3.93M
    void set_always_ready() {
147
3.93M
        if (_always_ready) {
148
1.93M
            return;
149
1.93M
        }
150
2.00M
        std::unique_lock<std::mutex> lc(_always_ready_lock);
151
2.00M
        if (_always_ready) {
152
1
            return;
153
1
        }
154
2.00M
        _always_ready = true;
155
2.00M
        set_ready();
156
2.00M
    }
157
158
protected:
159
    void _add_block_task(std::shared_ptr<PipelineTask> task);
160
161
    const int _id;
162
    const int _node_id;
163
    const std::string _name;
164
    std::atomic<bool> _ready;
165
166
    BasicSharedState* _shared_state = nullptr;
167
    MonotonicStopWatch _watcher;
168
169
    std::mutex _task_lock;
170
    std::vector<std::weak_ptr<PipelineTask>> _blocked_task;
171
172
    // If `_always_ready` is true, `block()` will never block tasks.
173
    std::atomic<bool> _always_ready = false;
174
    std::mutex _always_ready_lock;
175
};
176
177
struct FakeSharedState final : public BasicSharedState {
178
    ENABLE_FACTORY_CREATOR(FakeSharedState)
179
};
180
181
class CountedFinishDependency final : public Dependency {
182
public:
183
    using SharedState = FakeSharedState;
184
    CountedFinishDependency(int id, int node_id, std::string name)
185
205k
            : Dependency(id, node_id, std::move(name), true) {}
186
187
16.8k
    void add(uint32_t count = 1) {
188
16.8k
        std::unique_lock<std::mutex> l(_mtx);
189
16.8k
        if (!_counter) {
190
16.8k
            block();
191
16.8k
        }
192
16.8k
        _counter += count;
193
16.8k
    }
194
195
16.8k
    void sub() {
196
16.8k
        std::unique_lock<std::mutex> l(_mtx);
197
16.8k
        _counter--;
198
16.8k
        if (!_counter) {
199
16.8k
            set_ready();
200
16.8k
        }
201
16.8k
    }
202
203
    std::string debug_string(int indentation_level = 0) override;
204
205
private:
206
    std::mutex _mtx;
207
    uint32_t _counter = 0;
208
};
209
210
struct RuntimeFilterTimerQueue;
211
class RuntimeFilterTimer {
212
public:
213
    RuntimeFilterTimer(int64_t registration_time, int32_t wait_time_ms,
214
                       std::shared_ptr<Dependency> parent, bool force_wait_timeout = false)
215
76.0k
            : _parent(std::move(parent)),
216
76.0k
              _registration_time(registration_time),
217
76.0k
              _wait_time_ms(wait_time_ms),
218
76.0k
              _force_wait_timeout(force_wait_timeout) {}
219
220
    // Called by runtime filter producer.
221
    void call_ready();
222
223
    // Called by RuntimeFilterTimerQueue which is responsible for checking if this rf is timeout.
224
    void call_timeout();
225
226
5.62M
    int64_t registration_time() const { return _registration_time; }
227
5.62M
    int32_t wait_time_ms() const { return _wait_time_ms; }
228
229
    void set_local_runtime_filter_dependencies(
230
6.70k
            const std::vector<std::shared_ptr<Dependency>>& deps) {
231
6.70k
        _local_runtime_filter_dependencies = deps;
232
6.70k
    }
233
234
    bool should_be_check_timeout();
235
236
5.69M
    bool force_wait_timeout() { return _force_wait_timeout; }
237
238
private:
239
    friend struct RuntimeFilterTimerQueue;
240
    std::shared_ptr<Dependency> _parent = nullptr;
241
    std::vector<std::shared_ptr<Dependency>> _local_runtime_filter_dependencies;
242
    std::mutex _lock;
243
    int64_t _registration_time;
244
    const int32_t _wait_time_ms;
245
    // true only for group_commit_scan_operator
246
    bool _force_wait_timeout;
247
};
248
249
struct RuntimeFilterTimerQueue {
250
    constexpr static int64_t interval = 10;
251
8
    void run() { _thread.detach(); }
252
    void start();
253
254
3
    void stop() {
255
3
        _stop = true;
256
3
        cv.notify_all();
257
3
        wait_for_shutdown();
258
3
    }
259
260
3
    void wait_for_shutdown() const {
261
6
        while (!_shutdown) {
262
3
            std::this_thread::sleep_for(std::chrono::milliseconds(interval));
263
3
        }
264
3
    }
265
266
3
    ~RuntimeFilterTimerQueue() = default;
267
8
    RuntimeFilterTimerQueue() { _thread = std::thread(&RuntimeFilterTimerQueue::start, this); }
268
43.9k
    void push_filter_timer(std::vector<std::shared_ptr<RuntimeFilterTimer>>&& filter) {
269
43.9k
        std::unique_lock<std::mutex> lc(_que_lock);
270
43.9k
        _que.insert(_que.end(), filter.begin(), filter.end());
271
43.9k
        cv.notify_all();
272
43.9k
    }
273
274
    std::thread _thread;
275
    std::condition_variable cv;
276
    std::mutex cv_m;
277
    std::mutex _que_lock;
278
    std::atomic_bool _stop = false;
279
    std::atomic_bool _shutdown = false;
280
    std::list<std::shared_ptr<RuntimeFilterTimer>> _que;
281
};
282
283
struct AggSharedState : public BasicSharedState {
284
    ENABLE_FACTORY_CREATOR(AggSharedState)
285
public:
286
123k
    AggSharedState() { agg_data = std::make_unique<AggregatedDataVariants>(); }
287
123k
    ~AggSharedState() override {
288
123k
        if (!probe_expr_ctxs.empty()) {
289
55.8k
            _close_with_serialized_key();
290
67.8k
        } else {
291
67.8k
            _close_without_key();
292
67.8k
        }
293
123k
    }
294
295
    Status reset_hash_table();
296
297
    bool do_limit_filter(Block* block, size_t num_rows, const std::vector<int>* key_locs = nullptr);
298
    void build_limit_heap(size_t hash_table_size);
299
300
    // We should call this function only at 1st phase.
301
    // 1st phase: is_merge=true, only have one SlotRef.
302
    // 2nd phase: is_merge=false, maybe have multiple exprs.
303
    static int get_slot_column_id(const AggFnEvaluator* evaluator);
304
305
    AggregatedDataVariantsUPtr agg_data = nullptr;
306
    std::unique_ptr<AggregateDataContainer> aggregate_data_container;
307
    std::vector<AggFnEvaluator*> aggregate_evaluators;
308
    // group by k1,k2
309
    VExprContextSPtrs probe_expr_ctxs;
310
    size_t input_num_rows = 0;
311
    std::vector<AggregateDataPtr> values;
312
    /// The total size of the row from the aggregate functions.
313
    size_t total_size_of_aggregate_states = 0;
314
    size_t align_aggregate_states = 1;
315
    /// The offset to the n-th aggregate function in a row of aggregate functions.
316
    Sizes offsets_of_aggregate_states;
317
    std::vector<size_t> make_nullable_keys;
318
319
    bool agg_data_created_without_key = false;
320
    bool enable_spill = false;
321
    bool reach_limit = false;
322
323
    int64_t limit = -1;
324
    bool do_sort_limit = false;
325
    MutableColumns limit_columns;
326
    int limit_columns_min = -1;
327
    PaddedPODArray<uint8_t> need_computes;
328
    std::vector<uint8_t> cmp_res;
329
    std::vector<int> order_directions;
330
    std::vector<int> null_directions;
331
332
    struct HeapLimitCursor {
333
        HeapLimitCursor(int row_id, MutableColumns& limit_columns,
334
                        std::vector<int>& order_directions, std::vector<int>& null_directions)
335
9.06k
                : _row_id(row_id),
336
9.06k
                  _limit_columns(limit_columns),
337
9.06k
                  _order_directions(order_directions),
338
9.06k
                  _null_directions(null_directions) {}
339
340
        HeapLimitCursor(const HeapLimitCursor& other) = default;
341
342
        HeapLimitCursor(HeapLimitCursor&& other) noexcept
343
56.8k
                : _row_id(other._row_id),
344
56.8k
                  _limit_columns(other._limit_columns),
345
56.8k
                  _order_directions(other._order_directions),
346
56.8k
                  _null_directions(other._null_directions) {}
347
348
0
        HeapLimitCursor& operator=(const HeapLimitCursor& other) noexcept {
349
0
            _row_id = other._row_id;
350
0
            return *this;
351
0
        }
352
353
144k
        HeapLimitCursor& operator=(HeapLimitCursor&& other) noexcept {
354
144k
            _row_id = other._row_id;
355
144k
            return *this;
356
144k
        }
357
358
128k
        bool operator<(const HeapLimitCursor& rhs) const {
359
151k
            for (int i = 0; i < _limit_columns.size(); ++i) {
360
151k
                const auto& _limit_column = _limit_columns[i];
361
151k
                auto res = _limit_column->compare_at(_row_id, rhs._row_id, *_limit_column,
362
151k
                                                     _null_directions[i]) *
363
151k
                           _order_directions[i];
364
151k
                if (res < 0) {
365
85.0k
                    return true;
366
85.0k
                } else if (res > 0) {
367
43.9k
                    return false;
368
43.9k
                }
369
151k
            }
370
18.4E
            return false;
371
128k
        }
372
373
        int _row_id;
374
        MutableColumns& _limit_columns;
375
        std::vector<int>& _order_directions;
376
        std::vector<int>& _null_directions;
377
    };
378
379
    std::priority_queue<HeapLimitCursor> limit_heap;
380
381
    // Refresh the top limit heap with a new row
382
    void refresh_top_limit(size_t row_id, const ColumnRawPtrs& key_columns);
383
384
    Arena agg_arena_pool;
385
    Arena agg_profile_arena;
386
387
private:
388
    MutableColumns _get_keys_hash_table();
389
390
55.8k
    void _close_with_serialized_key() {
391
55.8k
        std::visit(Overload {[&](std::monostate& arg) -> void {
392
                                 // Do nothing
393
0
                             },
394
55.8k
                             [&](auto& agg_method) -> void {
395
55.8k
                                 auto& data = *agg_method.hash_table;
396
2.28M
                                 data.for_each_mapped([&](auto& mapped) {
397
2.28M
                                     if (mapped) {
398
2.28M
                                         _destroy_agg_status(mapped);
399
2.28M
                                         mapped = nullptr;
400
2.28M
                                     }
401
2.28M
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS9_EEEEEEvS2_ENKUlS2_E_clISA_EEDaS2_
Line
Count
Source
396
4.27k
                                 data.for_each_mapped([&](auto& mapped) {
397
4.27k
                                     if (mapped) {
398
4.27k
                                         _destroy_agg_status(mapped);
399
4.27k
                                         mapped = nullptr;
400
4.27k
                                     }
401
4.27k
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapINS_7UInt136EPc9HashCRC32IS7_EEEEEEvS2_ENKUlS2_E_clIS8_EEDaS2_
Line
Count
Source
396
1.44k
                                 data.for_each_mapped([&](auto& mapped) {
397
1.44k
                                     if (mapped) {
398
1.44k
                                         _destroy_agg_status(mapped);
399
1.44k
                                         mapped = nullptr;
400
1.44k
                                     }
401
1.44k
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS9_EEEEEEvS2_ENKUlS2_E_clISA_EEDaS2_
Line
Count
Source
396
23.7k
                                 data.for_each_mapped([&](auto& mapped) {
397
23.7k
                                     if (mapped) {
398
23.7k
                                         _destroy_agg_status(mapped);
399
23.7k
                                         mapped = nullptr;
400
23.7k
                                     }
401
23.7k
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapINS_7UInt104EPc9HashCRC32IS7_EEEEEEvS2_ENKUlS2_E_clIS8_EEDaS2_
Line
Count
Source
396
547
                                 data.for_each_mapped([&](auto& mapped) {
397
547
                                     if (mapped) {
398
547
                                         _destroy_agg_status(mapped);
399
547
                                         mapped = nullptr;
400
547
                                     }
401
547
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapINS_6UInt96EPc9HashCRC32IS7_EEEEEEvS2_ENKUlS2_E_clIS8_EEDaS2_
Line
Count
Source
396
7.71k
                                 data.for_each_mapped([&](auto& mapped) {
397
7.71k
                                     if (mapped) {
398
7.71k
                                         _destroy_agg_status(mapped);
399
7.71k
                                         mapped = nullptr;
400
7.71k
                                     }
401
7.71k
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapINS_6UInt72EPc9HashCRC32IS7_EEEEEEvS2_ENKUlS2_E_clIS8_EEDaS2_
Line
Count
Source
396
866
                                 data.for_each_mapped([&](auto& mapped) {
397
866
                                     if (mapped) {
398
866
                                         _destroy_agg_status(mapped);
399
866
                                         mapped = nullptr;
400
866
                                     }
401
866
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImEEEEEEvS2_ENKUlS2_E_clIS7_EEDaS2_
Line
Count
Source
396
144k
                                 data.for_each_mapped([&](auto& mapped) {
397
144k
                                     if (mapped) {
398
144k
                                         _destroy_agg_status(mapped);
399
144k
                                         mapped = nullptr;
400
144k
                                     }
401
144k
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_19MethodStringNoCacheINS_15DataWithNullKeyINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEEEEEvS2_ENKUlS2_E_clIS9_EEDaS2_
Line
Count
Source
396
3.26k
                                 data.for_each_mapped([&](auto& mapped) {
397
3.26k
                                     if (mapped) {
398
3.26k
                                         _destroy_agg_status(mapped);
399
3.26k
                                         mapped = nullptr;
400
3.26k
                                     }
401
3.26k
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm256EjEENS_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEEvS2_ENKUlS2_E_clISC_EEDaS2_
Line
Count
Source
396
3
                                 data.for_each_mapped([&](auto& mapped) {
397
3
                                     if (mapped) {
398
3
                                         _destroy_agg_status(mapped);
399
3
                                         mapped = nullptr;
400
3
                                     }
401
3
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEEvS2_ENKUlS2_E_clISC_EEDaS2_
Line
Count
Source
396
111
                                 data.for_each_mapped([&](auto& mapped) {
397
111
                                     if (mapped) {
398
111
                                         _destroy_agg_status(mapped);
399
111
                                         mapped = nullptr;
400
111
                                     }
401
111
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEvS2_ENKUlS2_E_clIS9_EEDaS2_
Line
Count
Source
396
135k
                                 data.for_each_mapped([&](auto& mapped) {
397
135k
                                     if (mapped) {
398
135k
                                         _destroy_agg_status(mapped);
399
135k
                                         mapped = nullptr;
400
135k
                                     }
401
135k
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEvS2_ENKUlS2_E_clIS9_EEDaS2_
Line
Count
Source
396
141k
                                 data.for_each_mapped([&](auto& mapped) {
397
141k
                                     if (mapped) {
398
141k
                                         _destroy_agg_status(mapped);
399
141k
                                         mapped = nullptr;
400
141k
                                     }
401
141k
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEvS2_ENKUlS2_E_clIS9_EEDaS2_
Line
Count
Source
396
122k
                                 data.for_each_mapped([&](auto& mapped) {
397
122k
                                     if (mapped) {
398
122k
                                         _destroy_agg_status(mapped);
399
122k
                                         mapped = nullptr;
400
122k
                                     }
401
122k
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEvS2_ENKUlS2_E_clIS9_EEDaS2_
Line
Count
Source
396
23.5k
                                 data.for_each_mapped([&](auto& mapped) {
397
23.5k
                                     if (mapped) {
398
23.5k
                                         _destroy_agg_status(mapped);
399
23.5k
                                         mapped = nullptr;
400
23.5k
                                     }
401
23.5k
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberItNS_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEvS2_ENKUlS2_E_clIS9_EEDaS2_
Line
Count
Source
396
470
                                 data.for_each_mapped([&](auto& mapped) {
397
470
                                     if (mapped) {
398
470
                                         _destroy_agg_status(mapped);
399
470
                                         mapped = nullptr;
400
470
                                     }
401
470
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIhNS_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEvS2_ENKUlS2_E_clIS9_EEDaS2_
Line
Count
Source
396
1.52k
                                 data.for_each_mapped([&](auto& mapped) {
397
1.52k
                                     if (mapped) {
398
1.52k
                                         _destroy_agg_status(mapped);
399
1.52k
                                         mapped = nullptr;
400
1.52k
                                     }
401
1.52k
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEvS2_ENKUlS2_E_clIS7_EEDaS2_
Line
Count
Source
396
769k
                                 data.for_each_mapped([&](auto& mapped) {
397
769k
                                     if (mapped) {
398
769k
                                         _destroy_agg_status(mapped);
399
769k
                                         mapped = nullptr;
400
769k
                                     }
401
769k
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEvS2_ENKUlS2_E_clIS7_EEDaS2_
Line
Count
Source
396
836k
                                 data.for_each_mapped([&](auto& mapped) {
397
836k
                                     if (mapped) {
398
836k
                                         _destroy_agg_status(mapped);
399
836k
                                         mapped = nullptr;
400
836k
                                     }
401
836k
                                 });
Unexecuted instantiation: _ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEEvS2_ENKUlS2_E_clISA_EEDaS2_
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEEvS2_ENKUlS2_E_clISA_EEDaS2_
Line
Count
Source
396
71
                                 data.for_each_mapped([&](auto& mapped) {
397
71
                                     if (mapped) {
398
71
                                         _destroy_agg_status(mapped);
399
71
                                         mapped = nullptr;
400
71
                                     }
401
71
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEvS2_ENKUlS2_E_clIS7_EEDaS2_
Line
Count
Source
396
1.16k
                                 data.for_each_mapped([&](auto& mapped) {
397
1.16k
                                     if (mapped) {
398
1.16k
                                         _destroy_agg_status(mapped);
399
1.16k
                                         mapped = nullptr;
400
1.16k
                                     }
401
1.16k
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEEvS2_ENKUlS2_E_clIS7_EEDaS2_
Line
Count
Source
396
420
                                 data.for_each_mapped([&](auto& mapped) {
397
420
                                     if (mapped) {
398
420
                                         _destroy_agg_status(mapped);
399
420
                                         mapped = nullptr;
400
420
                                     }
401
420
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEEvS2_ENKUlS2_E_clIS7_EEDaS2_
Line
Count
Source
396
139
                                 data.for_each_mapped([&](auto& mapped) {
397
139
                                     if (mapped) {
398
139
                                         _destroy_agg_status(mapped);
399
139
                                         mapped = nullptr;
400
139
                                     }
401
139
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEvS2_ENKUlS2_E_clIS7_EEDaS2_
Line
Count
Source
396
15
                                 data.for_each_mapped([&](auto& mapped) {
397
15
                                     if (mapped) {
398
15
                                         _destroy_agg_status(mapped);
399
15
                                         mapped = nullptr;
400
15
                                     }
401
15
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEvS2_ENKUlS2_E_clIS7_EEDaS2_
Line
Count
Source
396
253
                                 data.for_each_mapped([&](auto& mapped) {
397
253
                                     if (mapped) {
398
253
                                         _destroy_agg_status(mapped);
399
253
                                         mapped = nullptr;
400
253
                                     }
401
253
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS7_vEEEEEEvS2_ENKUlS2_E_clIS8_EEDaS2_
Line
Count
Source
396
62.6k
                                 data.for_each_mapped([&](auto& mapped) {
397
62.6k
                                     if (mapped) {
398
62.6k
                                         _destroy_agg_status(mapped);
399
62.6k
                                         mapped = nullptr;
400
62.6k
                                     }
401
62.6k
                                 });
402
55.8k
                                 if (data.has_null_key_data()) {
403
932
                                     _destroy_agg_status(
404
932
                                             data.template get_null_key_data<AggregateDataPtr>());
405
932
                                 }
406
55.8k
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS9_EEEEEEvS2_
Line
Count
Source
394
7.53k
                             [&](auto& agg_method) -> void {
395
7.53k
                                 auto& data = *agg_method.hash_table;
396
7.53k
                                 data.for_each_mapped([&](auto& mapped) {
397
7.53k
                                     if (mapped) {
398
7.53k
                                         _destroy_agg_status(mapped);
399
7.53k
                                         mapped = nullptr;
400
7.53k
                                     }
401
7.53k
                                 });
402
7.53k
                                 if (data.has_null_key_data()) {
403
0
                                     _destroy_agg_status(
404
0
                                             data.template get_null_key_data<AggregateDataPtr>());
405
0
                                 }
406
7.53k
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapINS_7UInt136EPc9HashCRC32IS7_EEEEEEvS2_
Line
Count
Source
394
1.62k
                             [&](auto& agg_method) -> void {
395
1.62k
                                 auto& data = *agg_method.hash_table;
396
1.62k
                                 data.for_each_mapped([&](auto& mapped) {
397
1.62k
                                     if (mapped) {
398
1.62k
                                         _destroy_agg_status(mapped);
399
1.62k
                                         mapped = nullptr;
400
1.62k
                                     }
401
1.62k
                                 });
402
1.62k
                                 if (data.has_null_key_data()) {
403
0
                                     _destroy_agg_status(
404
0
                                             data.template get_null_key_data<AggregateDataPtr>());
405
0
                                 }
406
1.62k
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS9_EEEEEEvS2_
Line
Count
Source
394
131
                             [&](auto& agg_method) -> void {
395
131
                                 auto& data = *agg_method.hash_table;
396
131
                                 data.for_each_mapped([&](auto& mapped) {
397
131
                                     if (mapped) {
398
131
                                         _destroy_agg_status(mapped);
399
131
                                         mapped = nullptr;
400
131
                                     }
401
131
                                 });
402
131
                                 if (data.has_null_key_data()) {
403
0
                                     _destroy_agg_status(
404
0
                                             data.template get_null_key_data<AggregateDataPtr>());
405
0
                                 }
406
131
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapINS_7UInt104EPc9HashCRC32IS7_EEEEEEvS2_
Line
Count
Source
394
798
                             [&](auto& agg_method) -> void {
395
798
                                 auto& data = *agg_method.hash_table;
396
798
                                 data.for_each_mapped([&](auto& mapped) {
397
798
                                     if (mapped) {
398
798
                                         _destroy_agg_status(mapped);
399
798
                                         mapped = nullptr;
400
798
                                     }
401
798
                                 });
402
798
                                 if (data.has_null_key_data()) {
403
0
                                     _destroy_agg_status(
404
0
                                             data.template get_null_key_data<AggregateDataPtr>());
405
0
                                 }
406
798
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapINS_6UInt96EPc9HashCRC32IS7_EEEEEEvS2_
Line
Count
Source
394
853
                             [&](auto& agg_method) -> void {
395
853
                                 auto& data = *agg_method.hash_table;
396
853
                                 data.for_each_mapped([&](auto& mapped) {
397
853
                                     if (mapped) {
398
853
                                         _destroy_agg_status(mapped);
399
853
                                         mapped = nullptr;
400
853
                                     }
401
853
                                 });
402
853
                                 if (data.has_null_key_data()) {
403
0
                                     _destroy_agg_status(
404
0
                                             data.template get_null_key_data<AggregateDataPtr>());
405
0
                                 }
406
853
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapINS_6UInt72EPc9HashCRC32IS7_EEEEEEvS2_
Line
Count
Source
394
854
                             [&](auto& agg_method) -> void {
395
854
                                 auto& data = *agg_method.hash_table;
396
854
                                 data.for_each_mapped([&](auto& mapped) {
397
854
                                     if (mapped) {
398
854
                                         _destroy_agg_status(mapped);
399
854
                                         mapped = nullptr;
400
854
                                     }
401
854
                                 });
402
854
                                 if (data.has_null_key_data()) {
403
0
                                     _destroy_agg_status(
404
0
                                             data.template get_null_key_data<AggregateDataPtr>());
405
0
                                 }
406
854
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImEEEEEEvS2_
Line
Count
Source
394
890
                             [&](auto& agg_method) -> void {
395
890
                                 auto& data = *agg_method.hash_table;
396
890
                                 data.for_each_mapped([&](auto& mapped) {
397
890
                                     if (mapped) {
398
890
                                         _destroy_agg_status(mapped);
399
890
                                         mapped = nullptr;
400
890
                                     }
401
890
                                 });
402
890
                                 if (data.has_null_key_data()) {
403
0
                                     _destroy_agg_status(
404
0
                                             data.template get_null_key_data<AggregateDataPtr>());
405
0
                                 }
406
890
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_19MethodStringNoCacheINS_15DataWithNullKeyINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEEEEEvS2_
Line
Count
Source
394
2.32k
                             [&](auto& agg_method) -> void {
395
2.32k
                                 auto& data = *agg_method.hash_table;
396
2.32k
                                 data.for_each_mapped([&](auto& mapped) {
397
2.32k
                                     if (mapped) {
398
2.32k
                                         _destroy_agg_status(mapped);
399
2.32k
                                         mapped = nullptr;
400
2.32k
                                     }
401
2.32k
                                 });
402
2.32k
                                 if (data.has_null_key_data()) {
403
27
                                     _destroy_agg_status(
404
27
                                             data.template get_null_key_data<AggregateDataPtr>());
405
27
                                 }
406
2.32k
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm256EjEENS_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEEvS2_
Line
Count
Source
394
16
                             [&](auto& agg_method) -> void {
395
16
                                 auto& data = *agg_method.hash_table;
396
16
                                 data.for_each_mapped([&](auto& mapped) {
397
16
                                     if (mapped) {
398
16
                                         _destroy_agg_status(mapped);
399
16
                                         mapped = nullptr;
400
16
                                     }
401
16
                                 });
402
16
                                 if (data.has_null_key_data()) {
403
0
                                     _destroy_agg_status(
404
0
                                             data.template get_null_key_data<AggregateDataPtr>());
405
0
                                 }
406
16
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEEvS2_
Line
Count
Source
394
375
                             [&](auto& agg_method) -> void {
395
375
                                 auto& data = *agg_method.hash_table;
396
375
                                 data.for_each_mapped([&](auto& mapped) {
397
375
                                     if (mapped) {
398
375
                                         _destroy_agg_status(mapped);
399
375
                                         mapped = nullptr;
400
375
                                     }
401
375
                                 });
402
375
                                 if (data.has_null_key_data()) {
403
6
                                     _destroy_agg_status(
404
6
                                             data.template get_null_key_data<AggregateDataPtr>());
405
6
                                 }
406
375
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEvS2_
Line
Count
Source
394
6.32k
                             [&](auto& agg_method) -> void {
395
6.32k
                                 auto& data = *agg_method.hash_table;
396
6.32k
                                 data.for_each_mapped([&](auto& mapped) {
397
6.32k
                                     if (mapped) {
398
6.32k
                                         _destroy_agg_status(mapped);
399
6.32k
                                         mapped = nullptr;
400
6.32k
                                     }
401
6.32k
                                 });
402
6.32k
                                 if (data.has_null_key_data()) {
403
105
                                     _destroy_agg_status(
404
105
                                             data.template get_null_key_data<AggregateDataPtr>());
405
105
                                 }
406
6.32k
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEvS2_
Line
Count
Source
394
8.65k
                             [&](auto& agg_method) -> void {
395
8.65k
                                 auto& data = *agg_method.hash_table;
396
8.65k
                                 data.for_each_mapped([&](auto& mapped) {
397
8.65k
                                     if (mapped) {
398
8.65k
                                         _destroy_agg_status(mapped);
399
8.65k
                                         mapped = nullptr;
400
8.65k
                                     }
401
8.65k
                                 });
402
8.65k
                                 if (data.has_null_key_data()) {
403
360
                                     _destroy_agg_status(
404
360
                                             data.template get_null_key_data<AggregateDataPtr>());
405
360
                                 }
406
8.65k
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEvS2_
Line
Count
Source
394
1.11k
                             [&](auto& agg_method) -> void {
395
1.11k
                                 auto& data = *agg_method.hash_table;
396
1.11k
                                 data.for_each_mapped([&](auto& mapped) {
397
1.11k
                                     if (mapped) {
398
1.11k
                                         _destroy_agg_status(mapped);
399
1.11k
                                         mapped = nullptr;
400
1.11k
                                     }
401
1.11k
                                 });
402
1.11k
                                 if (data.has_null_key_data()) {
403
46
                                     _destroy_agg_status(
404
46
                                             data.template get_null_key_data<AggregateDataPtr>());
405
46
                                 }
406
1.11k
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEvS2_
Line
Count
Source
394
1.27k
                             [&](auto& agg_method) -> void {
395
1.27k
                                 auto& data = *agg_method.hash_table;
396
1.27k
                                 data.for_each_mapped([&](auto& mapped) {
397
1.27k
                                     if (mapped) {
398
1.27k
                                         _destroy_agg_status(mapped);
399
1.27k
                                         mapped = nullptr;
400
1.27k
                                     }
401
1.27k
                                 });
402
1.27k
                                 if (data.has_null_key_data()) {
403
14
                                     _destroy_agg_status(
404
14
                                             data.template get_null_key_data<AggregateDataPtr>());
405
14
                                 }
406
1.27k
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberItNS_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEvS2_
Line
Count
Source
394
905
                             [&](auto& agg_method) -> void {
395
905
                                 auto& data = *agg_method.hash_table;
396
905
                                 data.for_each_mapped([&](auto& mapped) {
397
905
                                     if (mapped) {
398
905
                                         _destroy_agg_status(mapped);
399
905
                                         mapped = nullptr;
400
905
                                     }
401
905
                                 });
402
905
                                 if (data.has_null_key_data()) {
403
22
                                     _destroy_agg_status(
404
22
                                             data.template get_null_key_data<AggregateDataPtr>());
405
22
                                 }
406
905
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIhNS_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEvS2_
Line
Count
Source
394
2.58k
                             [&](auto& agg_method) -> void {
395
2.58k
                                 auto& data = *agg_method.hash_table;
396
2.58k
                                 data.for_each_mapped([&](auto& mapped) {
397
2.58k
                                     if (mapped) {
398
2.58k
                                         _destroy_agg_status(mapped);
399
2.58k
                                         mapped = nullptr;
400
2.58k
                                     }
401
2.58k
                                 });
402
2.58k
                                 if (data.has_null_key_data()) {
403
352
                                     _destroy_agg_status(
404
352
                                             data.template get_null_key_data<AggregateDataPtr>());
405
352
                                 }
406
2.58k
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEvS2_
Line
Count
Source
394
1.27k
                             [&](auto& agg_method) -> void {
395
1.27k
                                 auto& data = *agg_method.hash_table;
396
1.27k
                                 data.for_each_mapped([&](auto& mapped) {
397
1.27k
                                     if (mapped) {
398
1.27k
                                         _destroy_agg_status(mapped);
399
1.27k
                                         mapped = nullptr;
400
1.27k
                                     }
401
1.27k
                                 });
402
1.27k
                                 if (data.has_null_key_data()) {
403
0
                                     _destroy_agg_status(
404
0
                                             data.template get_null_key_data<AggregateDataPtr>());
405
0
                                 }
406
1.27k
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEvS2_
Line
Count
Source
394
2.92k
                             [&](auto& agg_method) -> void {
395
2.92k
                                 auto& data = *agg_method.hash_table;
396
2.92k
                                 data.for_each_mapped([&](auto& mapped) {
397
2.92k
                                     if (mapped) {
398
2.92k
                                         _destroy_agg_status(mapped);
399
2.92k
                                         mapped = nullptr;
400
2.92k
                                     }
401
2.92k
                                 });
402
2.92k
                                 if (data.has_null_key_data()) {
403
0
                                     _destroy_agg_status(
404
0
                                             data.template get_null_key_data<AggregateDataPtr>());
405
0
                                 }
406
2.92k
                             }},
Unexecuted instantiation: _ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEEvS2_
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEEvS2_
Line
Count
Source
394
113
                             [&](auto& agg_method) -> void {
395
113
                                 auto& data = *agg_method.hash_table;
396
113
                                 data.for_each_mapped([&](auto& mapped) {
397
113
                                     if (mapped) {
398
113
                                         _destroy_agg_status(mapped);
399
113
                                         mapped = nullptr;
400
113
                                     }
401
113
                                 });
402
113
                                 if (data.has_null_key_data()) {
403
0
                                     _destroy_agg_status(
404
0
                                             data.template get_null_key_data<AggregateDataPtr>());
405
0
                                 }
406
113
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEvS2_
Line
Count
Source
394
709
                             [&](auto& agg_method) -> void {
395
709
                                 auto& data = *agg_method.hash_table;
396
709
                                 data.for_each_mapped([&](auto& mapped) {
397
709
                                     if (mapped) {
398
709
                                         _destroy_agg_status(mapped);
399
709
                                         mapped = nullptr;
400
709
                                     }
401
709
                                 });
402
709
                                 if (data.has_null_key_data()) {
403
0
                                     _destroy_agg_status(
404
0
                                             data.template get_null_key_data<AggregateDataPtr>());
405
0
                                 }
406
709
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEEvS2_
Line
Count
Source
394
201
                             [&](auto& agg_method) -> void {
395
201
                                 auto& data = *agg_method.hash_table;
396
201
                                 data.for_each_mapped([&](auto& mapped) {
397
201
                                     if (mapped) {
398
201
                                         _destroy_agg_status(mapped);
399
201
                                         mapped = nullptr;
400
201
                                     }
401
201
                                 });
402
201
                                 if (data.has_null_key_data()) {
403
0
                                     _destroy_agg_status(
404
0
                                             data.template get_null_key_data<AggregateDataPtr>());
405
0
                                 }
406
201
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEEvS2_
Line
Count
Source
394
335
                             [&](auto& agg_method) -> void {
395
335
                                 auto& data = *agg_method.hash_table;
396
335
                                 data.for_each_mapped([&](auto& mapped) {
397
335
                                     if (mapped) {
398
335
                                         _destroy_agg_status(mapped);
399
335
                                         mapped = nullptr;
400
335
                                     }
401
335
                                 });
402
335
                                 if (data.has_null_key_data()) {
403
0
                                     _destroy_agg_status(
404
0
                                             data.template get_null_key_data<AggregateDataPtr>());
405
0
                                 }
406
335
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEvS2_
Line
Count
Source
394
39
                             [&](auto& agg_method) -> void {
395
39
                                 auto& data = *agg_method.hash_table;
396
39
                                 data.for_each_mapped([&](auto& mapped) {
397
39
                                     if (mapped) {
398
39
                                         _destroy_agg_status(mapped);
399
39
                                         mapped = nullptr;
400
39
                                     }
401
39
                                 });
402
39
                                 if (data.has_null_key_data()) {
403
0
                                     _destroy_agg_status(
404
0
                                             data.template get_null_key_data<AggregateDataPtr>());
405
0
                                 }
406
39
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEvS2_
Line
Count
Source
394
750
                             [&](auto& agg_method) -> void {
395
750
                                 auto& data = *agg_method.hash_table;
396
750
                                 data.for_each_mapped([&](auto& mapped) {
397
750
                                     if (mapped) {
398
750
                                         _destroy_agg_status(mapped);
399
750
                                         mapped = nullptr;
400
750
                                     }
401
750
                                 });
402
750
                                 if (data.has_null_key_data()) {
403
0
                                     _destroy_agg_status(
404
0
                                             data.template get_null_key_data<AggregateDataPtr>());
405
0
                                 }
406
750
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS7_vEEEEEEvS2_
Line
Count
Source
394
13.2k
                             [&](auto& agg_method) -> void {
395
13.2k
                                 auto& data = *agg_method.hash_table;
396
13.2k
                                 data.for_each_mapped([&](auto& mapped) {
397
13.2k
                                     if (mapped) {
398
13.2k
                                         _destroy_agg_status(mapped);
399
13.2k
                                         mapped = nullptr;
400
13.2k
                                     }
401
13.2k
                                 });
402
13.2k
                                 if (data.has_null_key_data()) {
403
0
                                     _destroy_agg_status(
404
0
                                             data.template get_null_key_data<AggregateDataPtr>());
405
0
                                 }
406
13.2k
                             }},
407
55.8k
                   agg_data->method_variant);
408
55.8k
    }
409
410
67.9k
    void _close_without_key() {
411
        //because prepare maybe failed, and couldn't create agg data.
412
        //but finally call close to destory agg data, if agg data has bitmapValue
413
        //will be core dump, it's not initialized
414
67.9k
        if (agg_data_created_without_key) {
415
67.9k
            _destroy_agg_status(agg_data->without_key);
416
67.9k
            agg_data_created_without_key = false;
417
67.9k
        }
418
67.9k
    }
419
    void _destroy_agg_status(AggregateDataPtr data);
420
};
421
422
struct PartitionedAggSharedState : public BasicSharedState,
423
                                   public std::enable_shared_from_this<PartitionedAggSharedState> {
424
    ENABLE_FACTORY_CREATOR(PartitionedAggSharedState)
425
426
714
    PartitionedAggSharedState() = default;
427
714
    ~PartitionedAggSharedState() override = default;
428
429
    void close();
430
431
    AggSharedState* _in_mem_shared_state = nullptr;
432
    std::shared_ptr<BasicSharedState> _in_mem_shared_state_sptr;
433
434
    // partition count is no longer stored in shared state; operators maintain their own
435
    std::atomic<bool> _is_spilled = false;
436
    std::deque<SpillFileSPtr> _spill_partitions;
437
};
438
439
struct SortSharedState : public BasicSharedState {
440
    ENABLE_FACTORY_CREATOR(SortSharedState)
441
public:
442
    std::shared_ptr<Sorter> sorter;
443
};
444
445
struct SpillSortSharedState : public BasicSharedState,
446
                              public std::enable_shared_from_this<SpillSortSharedState> {
447
    ENABLE_FACTORY_CREATOR(SpillSortSharedState)
448
449
45
    SpillSortSharedState() = default;
450
45
    ~SpillSortSharedState() override = default;
451
452
489
    void update_spill_block_batch_row_count(RuntimeState* state, const Block* block) {
453
489
        auto rows = block->rows();
454
489
        if (rows > 0 && 0 == avg_row_bytes) {
455
19
            avg_row_bytes = std::max((std::size_t)1, block->bytes() / rows);
456
19
            spill_block_batch_row_count =
457
19
                    (state->spill_buffer_size_bytes() + avg_row_bytes - 1) / avg_row_bytes;
458
19
            LOG(INFO) << "spill sort block batch row count: " << spill_block_batch_row_count;
459
19
        }
460
489
    }
461
462
    void close();
463
464
    SortSharedState* in_mem_shared_state = nullptr;
465
    bool enable_spill = false;
466
    bool is_spilled = false;
467
    int64_t limit = -1;
468
    int64_t offset = 0;
469
    std::atomic_bool is_closed = false;
470
    std::shared_ptr<BasicSharedState> in_mem_shared_state_sptr;
471
472
    std::deque<SpillFileSPtr> sorted_spill_groups;
473
    size_t avg_row_bytes = 0;
474
    size_t spill_block_batch_row_count;
475
};
476
477
struct UnionSharedState : public BasicSharedState {
478
    ENABLE_FACTORY_CREATOR(UnionSharedState)
479
480
public:
481
2.96k
    UnionSharedState(int child_count = 1) : data_queue(child_count), _child_count(child_count) {};
482
0
    int child_count() const { return _child_count; }
483
    DataQueue data_queue;
484
    const int _child_count;
485
};
486
487
struct DataQueueSharedState : public BasicSharedState {
488
    ENABLE_FACTORY_CREATOR(DataQueueSharedState)
489
public:
490
    DataQueue data_queue;
491
};
492
493
class MultiCastDataStreamer;
494
495
struct MultiCastSharedState : public BasicSharedState,
496
                              public std::enable_shared_from_this<MultiCastSharedState> {
497
    MultiCastSharedState(ObjectPool* pool, int cast_sender_count, int node_id);
498
499
    std::unique_ptr<MultiCastDataStreamer> multi_cast_data_streamer;
500
};
501
502
struct AnalyticSharedState : public BasicSharedState {
503
    ENABLE_FACTORY_CREATOR(AnalyticSharedState)
504
505
public:
506
7.68k
    AnalyticSharedState() = default;
507
    std::queue<Block> blocks_buffer;
508
    std::mutex buffer_mutex;
509
    bool sink_eos = false;
510
    std::mutex sink_eos_lock;
511
    Arena agg_arena_pool;
512
};
513
514
struct JoinSharedState : public BasicSharedState {
515
    // For some join case, we can apply a short circuit strategy
516
    // 1. _has_null_in_build_side = true
517
    // 2. build side rows is empty, Join op is: inner join/right outer join/left semi/right semi/right anti
518
    bool _has_null_in_build_side = false;
519
    bool short_circuit_for_probe = false;
520
    // for some join, when build side rows is empty, we could return directly by add some additional null data in probe table.
521
    bool empty_right_table_need_probe_dispose = false;
522
    JoinOpVariants join_op_variants;
523
};
524
525
struct HashJoinSharedState : public JoinSharedState {
526
    ENABLE_FACTORY_CREATOR(HashJoinSharedState)
527
163k
    HashJoinSharedState() {
528
163k
        hash_table_variant_vector.push_back(std::make_shared<JoinDataVariants>());
529
163k
    }
530
2.66k
    HashJoinSharedState(int num_instances) {
531
2.66k
        source_deps.resize(num_instances, nullptr);
532
2.66k
        hash_table_variant_vector.resize(num_instances, nullptr);
533
15.6k
        for (int i = 0; i < num_instances; i++) {
534
12.9k
            hash_table_variant_vector[i] = std::make_shared<JoinDataVariants>();
535
12.9k
        }
536
2.66k
    }
537
    std::shared_ptr<Arena> arena = std::make_shared<Arena>();
538
539
    const std::vector<TupleDescriptor*> build_side_child_desc;
540
    size_t build_exprs_size = 0;
541
    std::shared_ptr<Block> build_block;
542
    std::shared_ptr<std::vector<uint32_t>> build_indexes_null;
543
544
    // Used by shared hash table
545
    // For probe operator, hash table in _hash_table_variants is read-only if visited flags is not
546
    // used. (visited flags will be used only in right / full outer join).
547
    //
548
    // For broadcast join, although hash table is read-only, some states in `_hash_table_variants`
549
    // are still could be written. For example, serialized keys will be written in a continuous
550
    // memory in `_hash_table_variants`. So before execution, we should use a local _hash_table_variants
551
    // which has a shared hash table in it.
552
    std::vector<std::shared_ptr<JoinDataVariants>> hash_table_variant_vector;
553
554
    // whether left semi join could directly return
555
    // if runtime filters contains local in filter, we can make sure all input rows are matched
556
    // local filter will always be applied, and in filter could guarantee precise filtering
557
    // ATTN: we should disable always_true logic for in filter when we set this flag
558
    bool left_semi_direct_return = false;
559
560
    // ASOF JOIN specific fields
561
    // Whether the inequality is >= or > (true) vs <= or < (false)
562
    bool asof_inequality_is_greater = true;
563
    // Whether the inequality is strict (> or <) vs non-strict (>= or <=)
564
    bool asof_inequality_is_strict = false;
565
566
    // ASOF JOIN pre-sorted index with inline values for O(log K) branchless lookup
567
    // Typed AsofIndexGroups stored in a variant (uint32_t for DateV2, uint64_t for DateTimeV2/TimestampTZ)
568
    AsofIndexVariant asof_index_groups;
569
    // build_row_index -> bucket_id for O(1) reverse lookup
570
    std::vector<uint32_t> asof_build_row_to_bucket;
571
};
572
573
struct PartitionedHashJoinSharedState
574
        : public HashJoinSharedState,
575
          public std::enable_shared_from_this<PartitionedHashJoinSharedState> {
576
    ENABLE_FACTORY_CREATOR(PartitionedHashJoinSharedState)
577
578
    std::unique_ptr<RuntimeState> _inner_runtime_state;
579
    std::shared_ptr<HashJoinSharedState> _inner_shared_state;
580
    std::vector<std::unique_ptr<MutableBlock>> _partitioned_build_blocks;
581
    std::vector<SpillFileSPtr> _spilled_build_groups;
582
    std::atomic<bool> _is_spilled = false;
583
};
584
585
struct NestedLoopJoinSharedState : public JoinSharedState {
586
    ENABLE_FACTORY_CREATOR(NestedLoopJoinSharedState)
587
    // if true, probe child has no more rows to process
588
    bool probe_side_eos = false;
589
    // Visited flags for each row in build side.
590
    MutableColumns build_side_visited_flags;
591
    // List of build blocks, constructed in prepare()
592
    Blocks build_blocks;
593
};
594
595
struct PartitionSortNodeSharedState : public BasicSharedState {
596
    ENABLE_FACTORY_CREATOR(PartitionSortNodeSharedState)
597
public:
598
    std::queue<Block> blocks_buffer;
599
    std::mutex buffer_mutex;
600
    std::vector<std::unique_ptr<PartitionSorter>> partition_sorts;
601
    bool sink_eos = false;
602
    std::mutex sink_eos_lock;
603
    std::mutex prepared_finish_lock;
604
};
605
606
struct SetSharedState : public BasicSharedState {
607
    ENABLE_FACTORY_CREATOR(SetSharedState)
608
public:
609
    /// default init
610
    Block build_block; // build to source
611
    //record element size in hashtable
612
    int64_t valid_element_in_hash_tbl = 0;
613
    //first: idx mapped to column types
614
    //second: column_id, could point to origin column or cast column
615
    std::unordered_map<int, int> build_col_idx;
616
617
    //// shared static states (shared, decided in prepare/open...)
618
619
    /// init in setup_local_state
620
    std::unique_ptr<SetDataVariants> hash_table_variants =
621
            std::make_unique<SetDataVariants>(); // the real data HERE.
622
    std::vector<bool> build_not_ignore_null;
623
624
    // The SET operator's child might have different nullable attributes.
625
    // If a calculation involves both nullable and non-nullable columns, the final output should be a nullable column
626
    Status update_build_not_ignore_null(const VExprContextSPtrs& ctxs);
627
628
    size_t get_hash_table_size() const;
629
    /// init in both upstream side.
630
    //The i-th result expr list refers to the i-th child.
631
    std::vector<VExprContextSPtrs> child_exprs_lists;
632
633
    /// init in build side
634
    size_t child_quantity;
635
    VExprContextSPtrs build_child_exprs;
636
    std::vector<Dependency*> probe_finished_children_dependency;
637
638
    /// init in probe side
639
    std::vector<VExprContextSPtrs> probe_child_exprs_lists;
640
641
    std::atomic<bool> ready_for_read = false;
642
643
    Arena arena;
644
645
    /// called in setup_local_state
646
    Status hash_table_init();
647
};
648
649
enum class ExchangeType : uint8_t {
650
    NOOP = 0,
651
    // Shuffle data by Crc32CHashPartitioner
652
    HASH_SHUFFLE = 1,
653
    // Round-robin passthrough data blocks.
654
    PASSTHROUGH = 2,
655
    // Shuffle data by Crc32HashPartitioner<ShuffleChannelIds> (e.g. same as storage engine).
656
    BUCKET_HASH_SHUFFLE = 3,
657
    // Passthrough data blocks to all channels.
658
    BROADCAST = 4,
659
    // Passthrough data to channels evenly in an adaptive way.
660
    ADAPTIVE_PASSTHROUGH = 5,
661
    // Send all data to the first channel.
662
    PASS_TO_ONE = 6,
663
};
664
665
204k
inline std::string get_exchange_type_name(ExchangeType idx) {
666
204k
    switch (idx) {
667
14
    case ExchangeType::NOOP:
668
14
        return "NOOP";
669
33.4k
    case ExchangeType::HASH_SHUFFLE:
670
33.4k
        return "HASH_SHUFFLE";
671
164k
    case ExchangeType::PASSTHROUGH:
672
164k
        return "PASSTHROUGH";
673
782
    case ExchangeType::BUCKET_HASH_SHUFFLE:
674
782
        return "BUCKET_HASH_SHUFFLE";
675
518
    case ExchangeType::BROADCAST:
676
518
        return "BROADCAST";
677
1.71k
    case ExchangeType::ADAPTIVE_PASSTHROUGH:
678
1.71k
        return "ADAPTIVE_PASSTHROUGH";
679
3.56k
    case ExchangeType::PASS_TO_ONE:
680
3.56k
        return "PASS_TO_ONE";
681
204k
    }
682
0
    throw Exception(Status::FatalError("__builtin_unreachable"));
683
204k
}
684
685
struct DataDistribution {
686
2.14M
    DataDistribution(ExchangeType type) : distribution_type(type) {}
687
    DataDistribution(ExchangeType type, const std::vector<TExpr>& partition_exprs_)
688
245k
            : distribution_type(type), partition_exprs(partition_exprs_) {}
689
224k
    DataDistribution(const DataDistribution& other) = default;
690
685k
    bool need_local_exchange() const { return distribution_type != ExchangeType::NOOP; }
691
623k
    DataDistribution& operator=(const DataDistribution& other) = default;
692
    ExchangeType distribution_type;
693
    std::vector<TExpr> partition_exprs;
694
};
695
696
class ExchangerBase;
697
698
struct LocalExchangeSharedState : public BasicSharedState {
699
public:
700
    ENABLE_FACTORY_CREATOR(LocalExchangeSharedState);
701
    LocalExchangeSharedState(int num_instances);
702
    ~LocalExchangeSharedState() override;
703
    std::unique_ptr<ExchangerBase> exchanger {};
704
    std::vector<RuntimeProfile::Counter*> mem_counters;
705
    std::atomic<int64_t> mem_usage = 0;
706
    std::atomic<size_t> _buffer_mem_limit = config::local_exchange_buffer_mem_limit;
707
    // We need to make sure to add mem_usage first and then enqueue, otherwise sub mem_usage may cause negative mem_usage during concurrent dequeue.
708
    std::mutex le_lock;
709
    void sub_running_sink_operators();
710
    void sub_running_source_operators();
711
204k
    void _set_always_ready() {
712
1.30M
        for (auto& dep : source_deps) {
713
1.30M
            DCHECK(dep);
714
1.30M
            dep->set_always_ready();
715
1.30M
        }
716
205k
        for (auto& dep : sink_deps) {
717
205k
            DCHECK(dep);
718
205k
            dep->set_always_ready();
719
205k
        }
720
204k
    }
721
722
297k
    Dependency* get_sink_dep_by_channel_id(int channel_id) { return nullptr; }
723
724
215k
    void set_ready_to_read(int channel_id) {
725
215k
        auto& dep = source_deps[channel_id];
726
18.4E
        DCHECK(dep) << channel_id;
727
215k
        dep->set_ready();
728
215k
    }
729
730
215k
    void add_mem_usage(int channel_id, size_t delta) { mem_counters[channel_id]->update(delta); }
731
732
215k
    void sub_mem_usage(int channel_id, size_t delta) {
733
215k
        mem_counters[channel_id]->update(-(int64_t)delta);
734
215k
    }
735
736
178k
    void add_total_mem_usage(size_t delta) {
737
178k
        if (cast_set<int64_t>(mem_usage.fetch_add(delta) + delta) > _buffer_mem_limit) {
738
50
            sink_deps.front()->block();
739
50
        }
740
178k
    }
741
742
178k
    void sub_total_mem_usage(size_t delta) {
743
178k
        auto prev_usage = mem_usage.fetch_sub(delta);
744
178k
        DCHECK_GE(prev_usage - delta, 0) << "prev_usage: " << prev_usage << " delta: " << delta;
745
178k
        if (cast_set<int64_t>(prev_usage - delta) <= _buffer_mem_limit) {
746
178k
            sink_deps.front()->set_ready();
747
178k
        }
748
178k
    }
749
750
0
    void set_low_memory_mode(RuntimeState* state) {
751
0
        _buffer_mem_limit = std::min<int64_t>(config::local_exchange_buffer_mem_limit,
752
0
                                              state->low_memory_mode_buffer_limit());
753
0
    }
754
};
755
756
#include "common/compile_check_end.h"
757
} // namespace doris