Coverage Report

Created: 2025-04-29 20:56

/root/doris/be/src/pipeline/dependency.h
Line
Count
Source (jump to first uncovered line)
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 <concurrentqueue.h>
21
#include <sqltypes.h>
22
23
#include <atomic>
24
#include <functional>
25
#include <memory>
26
#include <mutex>
27
#include <thread>
28
#include <utility>
29
30
#include "common/config.h"
31
#include "common/logging.h"
32
#include "pipeline/common/agg_utils.h"
33
#include "pipeline/common/join_utils.h"
34
#include "pipeline/common/set_utils.h"
35
#include "pipeline/exec/data_queue.h"
36
#include "pipeline/exec/join/process_hash_table_probe.h"
37
#include "util/stack_util.h"
38
#include "vec/common/sort/partition_sorter.h"
39
#include "vec/common/sort/sorter.h"
40
#include "vec/core/block.h"
41
#include "vec/core/types.h"
42
#include "vec/spill/spill_stream.h"
43
44
namespace doris::vectorized {
45
class AggFnEvaluator;
46
class VSlotRef;
47
} // namespace doris::vectorized
48
49
namespace doris::pipeline {
50
#include "common/compile_check_begin.h"
51
class Dependency;
52
class PipelineTask;
53
struct BasicSharedState;
54
using DependencySPtr = std::shared_ptr<Dependency>;
55
class LocalExchangeSourceLocalState;
56
57
static constexpr auto SLOW_DEPENDENCY_THRESHOLD = 60 * 1000L * 1000L * 1000L;
58
static constexpr auto TIME_UNIT_DEPENDENCY_LOG = 30 * 1000L * 1000L * 1000L;
59
static_assert(TIME_UNIT_DEPENDENCY_LOG < SLOW_DEPENDENCY_THRESHOLD);
60
61
struct BasicSharedState {
62
    ENABLE_FACTORY_CREATOR(BasicSharedState)
63
64
    template <class TARGET>
65
1.85M
    TARGET* cast() {
66
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
67
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
68
18.4E
                << " and expect type is" << typeid(TARGET).name();
69
1.85M
        return reinterpret_cast<TARGET*>(this);
70
1.85M
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_19HashJoinSharedStateEEEPT_v
Line
Count
Source
65
203k
    TARGET* cast() {
66
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
67
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
68
18.4E
                << " and expect type is" << typeid(TARGET).name();
69
203k
        return reinterpret_cast<TARGET*>(this);
70
203k
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_30PartitionedHashJoinSharedStateEEEPT_v
Line
Count
Source
65
33.8k
    TARGET* cast() {
66
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
67
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
68
18.4E
                << " and expect type is" << typeid(TARGET).name();
69
33.8k
        return reinterpret_cast<TARGET*>(this);
70
33.8k
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_15SortSharedStateEEEPT_v
Line
Count
Source
65
301k
    TARGET* cast() {
66
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
67
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
68
18.4E
                << " and expect type is" << typeid(TARGET).name();
69
301k
        return reinterpret_cast<TARGET*>(this);
70
301k
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_20SpillSortSharedStateEEEPT_v
Line
Count
Source
65
231k
    TARGET* cast() {
66
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
67
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
68
18.4E
                << " and expect type is" << typeid(TARGET).name();
69
231k
        return reinterpret_cast<TARGET*>(this);
70
231k
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_25NestedLoopJoinSharedStateEEEPT_v
Line
Count
Source
65
15.6k
    TARGET* cast() {
66
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
67
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
68
18.4E
                << " and expect type is" << typeid(TARGET).name();
69
15.6k
        return reinterpret_cast<TARGET*>(this);
70
15.6k
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_19AnalyticSharedStateEEEPT_v
Line
Count
Source
65
18.4k
    TARGET* cast() {
66
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
67
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
68
18.4E
                << " and expect type is" << typeid(TARGET).name();
69
18.4k
        return reinterpret_cast<TARGET*>(this);
70
18.4k
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_14AggSharedStateEEEPT_v
Line
Count
Source
65
256k
    TARGET* cast() {
66
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
67
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
68
18.4E
                << " and expect type is" << typeid(TARGET).name();
69
256k
        return reinterpret_cast<TARGET*>(this);
70
256k
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_25PartitionedAggSharedStateEEEPT_v
Line
Count
Source
65
98.5k
    TARGET* cast() {
66
98.5k
        DCHECK(dynamic_cast<TARGET*>(this))
67
1
                << " Mismatch type! Current type is " << typeid(*this).name()
68
1
                << " and expect type is" << typeid(TARGET).name();
69
98.5k
        return reinterpret_cast<TARGET*>(this);
70
98.5k
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_16UnionSharedStateEEEPT_v
Line
Count
Source
65
11.4k
    TARGET* cast() {
66
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
67
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
68
18.4E
                << " and expect type is" << typeid(TARGET).name();
69
11.4k
        return reinterpret_cast<TARGET*>(this);
70
11.4k
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_28PartitionSortNodeSharedStateEEEPT_v
Line
Count
Source
65
710
    TARGET* cast() {
66
710
        DCHECK(dynamic_cast<TARGET*>(this))
67
0
                << " Mismatch type! Current type is " << typeid(*this).name()
68
0
                << " and expect type is" << typeid(TARGET).name();
69
710
        return reinterpret_cast<TARGET*>(this);
70
710
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_20MultiCastSharedStateEEEPT_v
Line
Count
Source
65
4.37k
    TARGET* cast() {
66
4.37k
        DCHECK(dynamic_cast<TARGET*>(this))
67
0
                << " Mismatch type! Current type is " << typeid(*this).name()
68
0
                << " and expect type is" << typeid(TARGET).name();
69
4.37k
        return reinterpret_cast<TARGET*>(this);
70
4.37k
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_14SetSharedStateEEEPT_v
Line
Count
Source
65
1.88k
    TARGET* cast() {
66
1.88k
        DCHECK(dynamic_cast<TARGET*>(this))
67
1
                << " Mismatch type! Current type is " << typeid(*this).name()
68
1
                << " and expect type is" << typeid(TARGET).name();
69
1.88k
        return reinterpret_cast<TARGET*>(this);
70
1.88k
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_24LocalExchangeSharedStateEEEPT_v
Line
Count
Source
65
485k
    TARGET* cast() {
66
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
67
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
68
18.4E
                << " and expect type is" << typeid(TARGET).name();
69
485k
        return reinterpret_cast<TARGET*>(this);
70
485k
    }
_ZN5doris8pipeline16BasicSharedState4castIS1_EEPT_v
Line
Count
Source
65
191k
    TARGET* cast() {
66
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
67
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
68
18.4E
                << " and expect type is" << typeid(TARGET).name();
69
191k
        return reinterpret_cast<TARGET*>(this);
70
191k
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_16CacheSharedStateEEEPT_v
Line
Count
Source
65
94
    TARGET* cast() {
66
94
        DCHECK(dynamic_cast<TARGET*>(this))
67
0
                << " Mismatch type! Current type is " << typeid(*this).name()
68
0
                << " and expect type is" << typeid(TARGET).name();
69
94
        return reinterpret_cast<TARGET*>(this);
70
94
    }
71
    template <class TARGET>
72
    const TARGET* cast() const {
73
        DCHECK(dynamic_cast<const TARGET*>(this))
74
                << " Mismatch type! Current type is " << typeid(*this).name()
75
                << " and expect type is" << typeid(TARGET).name();
76
        return reinterpret_cast<const TARGET*>(this);
77
    }
78
    std::vector<DependencySPtr> source_deps;
79
    std::vector<DependencySPtr> sink_deps;
80
    int id = 0;
81
    std::set<int> related_op_ids;
82
83
1.22M
    virtual ~BasicSharedState() = default;
84
85
    Dependency* create_source_dependency(int operator_id, int node_id, const std::string& name);
86
    void create_source_dependencies(int num_sources, int operator_id, int node_id,
87
                                    const std::string& name);
88
    Dependency* create_sink_dependency(int dest_id, int node_id, const std::string& name);
89
352k
    std::vector<DependencySPtr> get_dep_by_channel_id(int channel_id) {
90
352k
        DCHECK_LT(channel_id, source_deps.size());
91
352k
        return {source_deps[channel_id]};
92
352k
    }
93
};
94
95
class Dependency : public std::enable_shared_from_this<Dependency> {
96
public:
97
    ENABLE_FACTORY_CREATOR(Dependency);
98
    Dependency(int id, int node_id, std::string name, bool ready = false)
99
4.28M
            : _id(id), _node_id(node_id), _name(std::move(name)), _ready(ready) {}
100
4.29M
    virtual ~Dependency() = default;
101
102
0
    [[nodiscard]] int id() const { return _id; }
103
6.16M
    [[nodiscard]] virtual std::string name() const { return _name; }
104
159k
    BasicSharedState* shared_state() { return _shared_state; }
105
1.81M
    void set_shared_state(BasicSharedState* shared_state) { _shared_state = shared_state; }
106
    virtual std::string debug_string(int indentation_level = 0);
107
641M
    bool ready() const { return _ready; }
108
109
    // Start the watcher. We use it to count how long this dependency block the current pipeline task.
110
4.02M
    void start_watcher() { _watcher.start(); }
111
3.99M
    [[nodiscard]] int64_t watcher_elapse_time() { return _watcher.elapsed_time(); }
112
113
    // Which dependency current pipeline task is blocked by. `nullptr` if this dependency is ready.
114
    [[nodiscard]] Dependency* is_blocked_by(std::shared_ptr<PipelineTask> task = nullptr);
115
    // Notify downstream pipeline tasks this dependency is ready.
116
    void set_ready();
117
419k
    void set_ready_to_read(int channel_id = 0) {
118
419k
        DCHECK_LT(channel_id, _shared_state->source_deps.size()) << debug_string();
119
419k
        _shared_state->source_deps[channel_id]->set_ready();
120
419k
    }
121
384
    void set_ready_to_write() {
122
384
        DCHECK_EQ(_shared_state->sink_deps.size(), 1) << debug_string();
123
384
        _shared_state->sink_deps.front()->set_ready();
124
384
    }
125
126
    // Notify downstream pipeline tasks this dependency is blocked.
127
315M
    void block() {
128
315M
        if (_always_ready) {
129
193k
            return;
130
193k
        }
131
315M
        std::unique_lock<std::mutex> lc(_always_ready_lock);
132
315M
        if (_always_ready) {
133
1
            return;
134
1
        }
135
315M
        _ready = false;
136
315M
    }
137
138
2.00M
    void set_always_ready() {
139
2.00M
        if (_always_ready) {
140
948k
            return;
141
948k
        }
142
1.05M
        std::unique_lock<std::mutex> lc(_always_ready_lock);
143
1.05M
        if (_always_ready) {
144
0
            return;
145
0
        }
146
1.05M
        _always_ready = true;
147
1.05M
        set_ready();
148
1.05M
    }
149
150
protected:
151
    void _add_block_task(std::shared_ptr<PipelineTask> task);
152
153
    const int _id;
154
    const int _node_id;
155
    const std::string _name;
156
    std::atomic<bool> _ready;
157
158
    BasicSharedState* _shared_state = nullptr;
159
    MonotonicStopWatch _watcher;
160
161
    std::mutex _task_lock;
162
    std::vector<std::weak_ptr<PipelineTask>> _blocked_task;
163
164
    // If `_always_ready` is true, `block()` will never block tasks.
165
    std::atomic<bool> _always_ready = false;
166
    std::mutex _always_ready_lock;
167
};
168
169
struct FakeSharedState final : public BasicSharedState {
170
    ENABLE_FACTORY_CREATOR(FakeSharedState)
171
};
172
173
class CountedFinishDependency final : public Dependency {
174
public:
175
    using SharedState = FakeSharedState;
176
    CountedFinishDependency(int id, int node_id, std::string name)
177
127k
            : Dependency(id, node_id, std::move(name), true) {}
178
179
3.23k
    void add() {
180
3.23k
        std::unique_lock<std::mutex> l(_mtx);
181
3.23k
        if (!_counter) {
182
3.23k
            block();
183
3.23k
        }
184
3.23k
        _counter++;
185
3.23k
    }
186
187
3.23k
    void sub() {
188
3.23k
        std::unique_lock<std::mutex> l(_mtx);
189
3.23k
        _counter--;
190
3.23k
        if (!_counter) {
191
3.23k
            set_ready();
192
3.23k
        }
193
3.23k
    }
194
195
    std::string debug_string(int indentation_level = 0) override;
196
197
private:
198
    std::mutex _mtx;
199
    uint32_t _counter = 0;
200
};
201
202
struct RuntimeFilterTimerQueue;
203
class RuntimeFilterTimer {
204
public:
205
    RuntimeFilterTimer(int64_t registration_time, int32_t wait_time_ms,
206
                       std::shared_ptr<Dependency> parent)
207
            : _parent(std::move(parent)),
208
              _registration_time(registration_time),
209
26.2k
              _wait_time_ms(wait_time_ms) {}
210
211
    // Called by runtime filter producer.
212
    void call_ready();
213
214
    // Called by RuntimeFilterTimerQueue which is responsible for checking if this rf is timeout.
215
    void call_timeout();
216
217
1.76M
    int64_t registration_time() const { return _registration_time; }
218
1.76M
    int32_t wait_time_ms() const { return _wait_time_ms; }
219
220
    void set_local_runtime_filter_dependencies(
221
10.9k
            const std::vector<std::shared_ptr<Dependency>>& deps) {
222
10.9k
        _local_runtime_filter_dependencies = deps;
223
10.9k
    }
224
225
    bool should_be_check_timeout();
226
227
private:
228
    friend struct RuntimeFilterTimerQueue;
229
    std::shared_ptr<Dependency> _parent = nullptr;
230
    std::vector<std::shared_ptr<Dependency>> _local_runtime_filter_dependencies;
231
    std::mutex _lock;
232
    int64_t _registration_time;
233
    const int32_t _wait_time_ms;
234
};
235
236
struct RuntimeFilterTimerQueue {
237
    constexpr static int64_t interval = 10;
238
2
    void run() { _thread.detach(); }
239
    void start();
240
241
0
    void stop() {
242
0
        _stop = true;
243
0
        cv.notify_all();
244
0
        wait_for_shutdown();
245
0
    }
246
247
0
    void wait_for_shutdown() const {
248
0
        while (!_shutdown) {
249
0
            std::this_thread::sleep_for(std::chrono::milliseconds(interval));
250
0
        }
251
0
    }
252
253
0
    ~RuntimeFilterTimerQueue() = default;
254
2
    RuntimeFilterTimerQueue() { _thread = std::thread(&RuntimeFilterTimerQueue::start, this); }
255
16.2k
    void push_filter_timer(std::vector<std::shared_ptr<pipeline::RuntimeFilterTimer>>&& filter) {
256
16.2k
        std::unique_lock<std::mutex> lc(_que_lock);
257
16.2k
        _que.insert(_que.end(), filter.begin(), filter.end());
258
16.2k
        cv.notify_all();
259
16.2k
    }
260
261
    std::thread _thread;
262
    std::condition_variable cv;
263
    std::mutex cv_m;
264
    std::mutex _que_lock;
265
    std::atomic_bool _stop = false;
266
    std::atomic_bool _shutdown = false;
267
    std::list<std::shared_ptr<pipeline::RuntimeFilterTimer>> _que;
268
};
269
270
struct AggSharedState : public BasicSharedState {
271
    ENABLE_FACTORY_CREATOR(AggSharedState)
272
public:
273
128k
    AggSharedState() {
274
128k
        agg_data = std::make_unique<AggregatedDataVariants>();
275
128k
        agg_arena_pool = std::make_unique<vectorized::Arena>();
276
128k
    }
277
128k
    ~AggSharedState() override {
278
128k
        if (!probe_expr_ctxs.empty()) {
279
63.8k
            _close_with_serialized_key();
280
64.3k
        } else {
281
64.3k
            _close_without_key();
282
64.3k
        }
283
128k
    }
284
285
    Status reset_hash_table();
286
287
    bool do_limit_filter(vectorized::Block* block, size_t num_rows,
288
                         const std::vector<int>* key_locs = nullptr);
289
    void build_limit_heap(size_t hash_table_size);
290
291
    // We should call this function only at 1st phase.
292
    // 1st phase: is_merge=true, only have one SlotRef.
293
    // 2nd phase: is_merge=false, maybe have multiple exprs.
294
    static int get_slot_column_id(const vectorized::AggFnEvaluator* evaluator);
295
296
    AggregatedDataVariantsUPtr agg_data = nullptr;
297
    std::unique_ptr<AggregateDataContainer> aggregate_data_container;
298
    ArenaUPtr agg_arena_pool;
299
    std::vector<vectorized::AggFnEvaluator*> aggregate_evaluators;
300
    // group by k1,k2
301
    vectorized::VExprContextSPtrs probe_expr_ctxs;
302
    size_t input_num_rows = 0;
303
    std::vector<vectorized::AggregateDataPtr> values;
304
    /// The total size of the row from the aggregate functions.
305
    size_t total_size_of_aggregate_states = 0;
306
    size_t align_aggregate_states = 1;
307
    /// The offset to the n-th aggregate function in a row of aggregate functions.
308
    vectorized::Sizes offsets_of_aggregate_states;
309
    std::vector<size_t> make_nullable_keys;
310
311
    bool agg_data_created_without_key = false;
312
    bool enable_spill = false;
313
    bool reach_limit = false;
314
315
    int64_t limit = -1;
316
    bool do_sort_limit = false;
317
    vectorized::MutableColumns limit_columns;
318
    int limit_columns_min = -1;
319
    vectorized::PaddedPODArray<uint8_t> need_computes;
320
    std::vector<uint8_t> cmp_res;
321
    std::vector<int> order_directions;
322
    std::vector<int> null_directions;
323
324
    struct HeapLimitCursor {
325
        HeapLimitCursor(int row_id, vectorized::MutableColumns& limit_columns,
326
                        std::vector<int>& order_directions, std::vector<int>& null_directions)
327
                : _row_id(row_id),
328
                  _limit_columns(limit_columns),
329
                  _order_directions(order_directions),
330
38.4k
                  _null_directions(null_directions) {}
331
332
        HeapLimitCursor(const HeapLimitCursor& other) = default;
333
334
        HeapLimitCursor(HeapLimitCursor&& other) noexcept
335
                : _row_id(other._row_id),
336
                  _limit_columns(other._limit_columns),
337
                  _order_directions(other._order_directions),
338
246k
                  _null_directions(other._null_directions) {}
339
340
0
        HeapLimitCursor& operator=(const HeapLimitCursor& other) noexcept {
341
0
            _row_id = other._row_id;
342
0
            return *this;
343
0
        }
344
345
474k
        HeapLimitCursor& operator=(HeapLimitCursor&& other) noexcept {
346
474k
            _row_id = other._row_id;
347
474k
            return *this;
348
474k
        }
349
350
431k
        bool operator<(const HeapLimitCursor& rhs) const {
351
778k
            for (int i = 0; i < _limit_columns.size(); ++i) {
352
778k
                const auto& _limit_column = _limit_columns[i];
353
778k
                auto res = _limit_column->compare_at(_row_id, rhs._row_id, *_limit_column,
354
778k
                                                     _null_directions[i]) *
355
778k
                           _order_directions[i];
356
778k
                if (res < 0) {
357
225k
                    return true;
358
553k
                } else if (res > 0) {
359
226k
                    return false;
360
226k
                }
361
778k
            }
362
18.4E
            return false;
363
431k
        }
364
365
        int _row_id;
366
        vectorized::MutableColumns& _limit_columns;
367
        std::vector<int>& _order_directions;
368
        std::vector<int>& _null_directions;
369
    };
370
371
    std::priority_queue<HeapLimitCursor> limit_heap;
372
373
    // Refresh the top limit heap with a new row
374
    void refresh_top_limit(size_t row_id, const vectorized::ColumnRawPtrs& key_columns);
375
376
private:
377
    vectorized::MutableColumns _get_keys_hash_table();
378
379
63.7k
    void _close_with_serialized_key() {
380
63.7k
        std::visit(vectorized::Overload {[&](std::monostate& arg) -> void {
381
                                             // Do nothing
382
0
                                         },
383
63.7k
                                         [&](auto& agg_method) -> void {
384
63.7k
                                             auto& data = *agg_method.hash_table;
385
1.05M
                                             data.for_each_mapped([&](auto& mapped) {
386
1.05M
                                                 if (mapped) {
387
1.05M
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
1.05M
                                                     mapped = nullptr;
389
1.05M
                                                 }
390
1.05M
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS9_vEEEEEEvS3_ENKUlS3_E_clISA_EEDaS3_
Line
Count
Source
385
85.8k
                                             data.for_each_mapped([&](auto& mapped) {
386
85.9k
                                                 if (mapped) {
387
85.9k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
85.9k
                                                     mapped = nullptr;
389
85.9k
                                                 }
390
85.8k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEvS3_ENKUlS3_E_clIS9_EEDaS3_
Line
Count
Source
385
54
                                             data.for_each_mapped([&](auto& mapped) {
386
54
                                                 if (mapped) {
387
54
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
54
                                                     mapped = nullptr;
389
54
                                                 }
390
54
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEvS3_ENKUlS3_E_clIS9_EEDaS3_
Line
Count
Source
385
11
                                             data.for_each_mapped([&](auto& mapped) {
386
11
                                                 if (mapped) {
387
11
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
11
                                                     mapped = nullptr;
389
11
                                                 }
390
11
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEEvS3_ENKUlS3_E_clIS9_EEDaS3_
Line
Count
Source
385
632k
                                             data.for_each_mapped([&](auto& mapped) {
386
632k
                                                 if (mapped) {
387
632k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
632k
                                                     mapped = nullptr;
389
632k
                                                 }
390
632k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEEvS3_ENKUlS3_E_clIS9_EEDaS3_
Line
Count
Source
385
41.4k
                                             data.for_each_mapped([&](auto& mapped) {
386
41.4k
                                                 if (mapped) {
387
41.4k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
41.4k
                                                     mapped = nullptr;
389
41.4k
                                                 }
390
41.4k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorEEEEEEEEEvS3_ENKUlS3_E_clIS9_EEDaS3_
Line
Count
Source
385
2.21k
                                             data.for_each_mapped([&](auto& mapped) {
386
2.21k
                                                 if (mapped) {
387
2.21k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
2.21k
                                                     mapped = nullptr;
389
2.21k
                                                 }
390
2.21k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapISA_Pc9HashCRC32ISA_EEEEEEvS3_ENKUlS3_E_clISC_EEDaS3_
Line
Count
Source
385
47
                                             data.for_each_mapped([&](auto& mapped) {
386
47
                                                 if (mapped) {
387
47
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
47
                                                     mapped = nullptr;
389
47
                                                 }
390
47
                                             });
Unexecuted instantiation: _ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapISA_Pc9HashCRC32ISA_EEEEEEvS3_ENKUlS3_E_clISC_EEDaS3_
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEvS3_ENKUlS3_E_clIS9_EEDaS3_
Line
Count
Source
385
37.6k
                                             data.for_each_mapped([&](auto& mapped) {
386
37.6k
                                                 if (mapped) {
387
37.6k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
37.6k
                                                     mapped = nullptr;
389
37.6k
                                                 }
390
37.6k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEvS3_ENKUlS3_E_clIS9_EEDaS3_
Line
Count
Source
385
80.5k
                                             data.for_each_mapped([&](auto& mapped) {
386
80.5k
                                                 if (mapped) {
387
80.5k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
80.5k
                                                     mapped = nullptr;
389
80.5k
                                                 }
390
80.5k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIhNS6_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEvS3_ENKUlS3_E_clISB_EEDaS3_
Line
Count
Source
385
644
                                             data.for_each_mapped([&](auto& mapped) {
386
644
                                                 if (mapped) {
387
644
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
644
                                                     mapped = nullptr;
389
644
                                                 }
390
644
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberItNS6_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEvS3_ENKUlS3_E_clISB_EEDaS3_
Line
Count
Source
385
524
                                             data.for_each_mapped([&](auto& mapped) {
386
524
                                                 if (mapped) {
387
524
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
524
                                                     mapped = nullptr;
389
524
                                                 }
390
524
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIjNS6_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEvS3_ENKUlS3_E_clISB_EEDaS3_
Line
Count
Source
385
17.2k
                                             data.for_each_mapped([&](auto& mapped) {
386
17.2k
                                                 if (mapped) {
387
17.2k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
17.2k
                                                     mapped = nullptr;
389
17.2k
                                                 }
390
17.2k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberImNS6_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEvS3_ENKUlS3_E_clISB_EEDaS3_
Line
Count
Source
385
6.04k
                                             data.for_each_mapped([&](auto& mapped) {
386
6.04k
                                                 if (mapped) {
387
6.04k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
6.04k
                                                     mapped = nullptr;
389
6.04k
                                                 }
390
6.04k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIjNS6_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEvS3_ENKUlS3_E_clISB_EEDaS3_
Line
Count
Source
385
17.1k
                                             data.for_each_mapped([&](auto& mapped) {
386
17.1k
                                                 if (mapped) {
387
17.1k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
17.1k
                                                     mapped = nullptr;
389
17.1k
                                                 }
390
17.1k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberImNS6_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEvS3_ENKUlS3_E_clISB_EEDaS3_
Line
Count
Source
385
1.58k
                                             data.for_each_mapped([&](auto& mapped) {
386
1.58k
                                                 if (mapped) {
387
1.58k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
1.58k
                                                     mapped = nullptr;
389
1.58k
                                                 }
390
1.58k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIN4wide7integerILm128EjEENS6_15DataWithNullKeyI9PHHashMapISB_Pc9HashCRC32ISB_EEEEEEEEEEvS3_ENKUlS3_E_clISE_EEDaS3_
Line
Count
Source
385
1.53k
                                             data.for_each_mapped([&](auto& mapped) {
386
1.53k
                                                 if (mapped) {
387
1.53k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
1.53k
                                                     mapped = nullptr;
389
1.53k
                                                 }
390
1.53k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIN4wide7integerILm256EjEENS6_15DataWithNullKeyI9PHHashMapISB_Pc9HashCRC32ISB_EEEEEEEEEEvS3_ENKUlS3_E_clISE_EEDaS3_
Line
Count
Source
385
3
                                             data.for_each_mapped([&](auto& mapped) {
386
3
                                                 if (mapped) {
387
3
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
3
                                                     mapped = nullptr;
389
3
                                                 }
390
3
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_19MethodStringNoCacheINS6_15DataWithNullKeyINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorEEEEEEEEEEEEEvS3_ENKUlS3_E_clISB_EEDaS3_
Line
Count
Source
385
7.69k
                                             data.for_each_mapped([&](auto& mapped) {
386
7.69k
                                                 if (mapped) {
387
7.69k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
7.69k
                                                     mapped = nullptr;
389
7.69k
                                                 }
390
7.69k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImEEEEEEvS3_ENKUlS3_E_clIS9_EEDaS3_
Line
Count
Source
385
75.6k
                                             data.for_each_mapped([&](auto& mapped) {
386
75.6k
                                                 if (mapped) {
387
75.6k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
75.6k
                                                     mapped = nullptr;
389
75.6k
                                                 }
390
75.6k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32ISB_EEEEEEvS3_ENKUlS3_E_clISC_EEDaS3_
Line
Count
Source
385
33.1k
                                             data.for_each_mapped([&](auto& mapped) {
386
33.1k
                                                 if (mapped) {
387
33.1k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
33.1k
                                                     mapped = nullptr;
389
33.1k
                                                 }
390
33.1k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32ISB_EEEEEEvS3_ENKUlS3_E_clISC_EEDaS3_
Line
Count
Source
385
14.6k
                                             data.for_each_mapped([&](auto& mapped) {
386
14.6k
                                                 if (mapped) {
387
14.6k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
14.6k
                                                     mapped = nullptr;
389
14.6k
                                                 }
390
14.6k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapINS6_7UInt136EPc9HashCRC32IS9_EEEEEEvS3_ENKUlS3_E_clISA_EEDaS3_
Line
Count
Source
385
3.26k
                                             data.for_each_mapped([&](auto& mapped) {
386
3.26k
                                                 if (mapped) {
387
3.26k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
3.26k
                                                     mapped = nullptr;
389
3.26k
                                                 }
390
3.26k
                                             });
391
63.7k
                                             if (data.has_null_key_data()) {
392
2.50k
                                                 auto st = _destroy_agg_status(
393
2.50k
                                                         data.template get_null_key_data<
394
2.50k
                                                                 vectorized::AggregateDataPtr>());
395
2.50k
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
2.50k
                                             }
399
63.7k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS9_vEEEEEEvS3_
Line
Count
Source
383
9.36k
                                         [&](auto& agg_method) -> void {
384
9.36k
                                             auto& data = *agg_method.hash_table;
385
9.36k
                                             data.for_each_mapped([&](auto& mapped) {
386
9.36k
                                                 if (mapped) {
387
9.36k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
9.36k
                                                     mapped = nullptr;
389
9.36k
                                                 }
390
9.36k
                                             });
391
9.36k
                                             if (data.has_null_key_data()) {
392
0
                                                 auto st = _destroy_agg_status(
393
0
                                                         data.template get_null_key_data<
394
0
                                                                 vectorized::AggregateDataPtr>());
395
0
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
0
                                             }
399
9.36k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEvS3_
Line
Count
Source
383
581
                                         [&](auto& agg_method) -> void {
384
581
                                             auto& data = *agg_method.hash_table;
385
581
                                             data.for_each_mapped([&](auto& mapped) {
386
581
                                                 if (mapped) {
387
581
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
581
                                                     mapped = nullptr;
389
581
                                                 }
390
581
                                             });
391
581
                                             if (data.has_null_key_data()) {
392
0
                                                 auto st = _destroy_agg_status(
393
0
                                                         data.template get_null_key_data<
394
0
                                                                 vectorized::AggregateDataPtr>());
395
0
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
0
                                             }
399
581
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEvS3_
Line
Count
Source
383
48
                                         [&](auto& agg_method) -> void {
384
48
                                             auto& data = *agg_method.hash_table;
385
48
                                             data.for_each_mapped([&](auto& mapped) {
386
48
                                                 if (mapped) {
387
48
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
48
                                                     mapped = nullptr;
389
48
                                                 }
390
48
                                             });
391
48
                                             if (data.has_null_key_data()) {
392
0
                                                 auto st = _destroy_agg_status(
393
0
                                                         data.template get_null_key_data<
394
0
                                                                 vectorized::AggregateDataPtr>());
395
0
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
0
                                             }
399
48
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEEvS3_
Line
Count
Source
383
1.50k
                                         [&](auto& agg_method) -> void {
384
1.50k
                                             auto& data = *agg_method.hash_table;
385
1.50k
                                             data.for_each_mapped([&](auto& mapped) {
386
1.50k
                                                 if (mapped) {
387
1.50k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
1.50k
                                                     mapped = nullptr;
389
1.50k
                                                 }
390
1.50k
                                             });
391
1.50k
                                             if (data.has_null_key_data()) {
392
0
                                                 auto st = _destroy_agg_status(
393
0
                                                         data.template get_null_key_data<
394
0
                                                                 vectorized::AggregateDataPtr>());
395
0
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
0
                                             }
399
1.50k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEEvS3_
Line
Count
Source
383
535
                                         [&](auto& agg_method) -> void {
384
535
                                             auto& data = *agg_method.hash_table;
385
535
                                             data.for_each_mapped([&](auto& mapped) {
386
535
                                                 if (mapped) {
387
535
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
535
                                                     mapped = nullptr;
389
535
                                                 }
390
535
                                             });
391
535
                                             if (data.has_null_key_data()) {
392
0
                                                 auto st = _destroy_agg_status(
393
0
                                                         data.template get_null_key_data<
394
0
                                                                 vectorized::AggregateDataPtr>());
395
0
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
0
                                             }
399
535
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorEEEEEEEEEvS3_
Line
Count
Source
383
808
                                         [&](auto& agg_method) -> void {
384
808
                                             auto& data = *agg_method.hash_table;
385
808
                                             data.for_each_mapped([&](auto& mapped) {
386
808
                                                 if (mapped) {
387
808
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
808
                                                     mapped = nullptr;
389
808
                                                 }
390
808
                                             });
391
808
                                             if (data.has_null_key_data()) {
392
0
                                                 auto st = _destroy_agg_status(
393
0
                                                         data.template get_null_key_data<
394
0
                                                                 vectorized::AggregateDataPtr>());
395
0
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
0
                                             }
399
808
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapISA_Pc9HashCRC32ISA_EEEEEEvS3_
Line
Count
Source
383
125
                                         [&](auto& agg_method) -> void {
384
125
                                             auto& data = *agg_method.hash_table;
385
125
                                             data.for_each_mapped([&](auto& mapped) {
386
125
                                                 if (mapped) {
387
125
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
125
                                                     mapped = nullptr;
389
125
                                                 }
390
125
                                             });
391
125
                                             if (data.has_null_key_data()) {
392
0
                                                 auto st = _destroy_agg_status(
393
0
                                                         data.template get_null_key_data<
394
0
                                                                 vectorized::AggregateDataPtr>());
395
0
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
0
                                             }
399
125
                                         }},
Unexecuted instantiation: _ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapISA_Pc9HashCRC32ISA_EEEEEEvS3_
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEvS3_
Line
Count
Source
383
1.12k
                                         [&](auto& agg_method) -> void {
384
1.12k
                                             auto& data = *agg_method.hash_table;
385
1.12k
                                             data.for_each_mapped([&](auto& mapped) {
386
1.12k
                                                 if (mapped) {
387
1.12k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
1.12k
                                                     mapped = nullptr;
389
1.12k
                                                 }
390
1.12k
                                             });
391
1.12k
                                             if (data.has_null_key_data()) {
392
0
                                                 auto st = _destroy_agg_status(
393
0
                                                         data.template get_null_key_data<
394
0
                                                                 vectorized::AggregateDataPtr>());
395
0
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
0
                                             }
399
1.12k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEvS3_
Line
Count
Source
383
754
                                         [&](auto& agg_method) -> void {
384
754
                                             auto& data = *agg_method.hash_table;
385
754
                                             data.for_each_mapped([&](auto& mapped) {
386
754
                                                 if (mapped) {
387
754
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
754
                                                     mapped = nullptr;
389
754
                                                 }
390
754
                                             });
391
754
                                             if (data.has_null_key_data()) {
392
0
                                                 auto st = _destroy_agg_status(
393
0
                                                         data.template get_null_key_data<
394
0
                                                                 vectorized::AggregateDataPtr>());
395
0
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
0
                                             }
399
754
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIhNS6_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEvS3_
Line
Count
Source
383
1.71k
                                         [&](auto& agg_method) -> void {
384
1.71k
                                             auto& data = *agg_method.hash_table;
385
1.71k
                                             data.for_each_mapped([&](auto& mapped) {
386
1.71k
                                                 if (mapped) {
387
1.71k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
1.71k
                                                     mapped = nullptr;
389
1.71k
                                                 }
390
1.71k
                                             });
391
1.71k
                                             if (data.has_null_key_data()) {
392
520
                                                 auto st = _destroy_agg_status(
393
520
                                                         data.template get_null_key_data<
394
520
                                                                 vectorized::AggregateDataPtr>());
395
520
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
520
                                             }
399
1.71k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberItNS6_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEvS3_
Line
Count
Source
383
762
                                         [&](auto& agg_method) -> void {
384
762
                                             auto& data = *agg_method.hash_table;
385
762
                                             data.for_each_mapped([&](auto& mapped) {
386
762
                                                 if (mapped) {
387
762
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
762
                                                     mapped = nullptr;
389
762
                                                 }
390
762
                                             });
391
762
                                             if (data.has_null_key_data()) {
392
33
                                                 auto st = _destroy_agg_status(
393
33
                                                         data.template get_null_key_data<
394
33
                                                                 vectorized::AggregateDataPtr>());
395
33
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
33
                                             }
399
762
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIjNS6_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEvS3_
Line
Count
Source
383
8.20k
                                         [&](auto& agg_method) -> void {
384
8.20k
                                             auto& data = *agg_method.hash_table;
385
8.20k
                                             data.for_each_mapped([&](auto& mapped) {
386
8.20k
                                                 if (mapped) {
387
8.20k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
8.20k
                                                     mapped = nullptr;
389
8.20k
                                                 }
390
8.20k
                                             });
391
8.20k
                                             if (data.has_null_key_data()) {
392
660
                                                 auto st = _destroy_agg_status(
393
660
                                                         data.template get_null_key_data<
394
660
                                                                 vectorized::AggregateDataPtr>());
395
660
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
660
                                             }
399
8.20k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberImNS6_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEvS3_
Line
Count
Source
383
2.06k
                                         [&](auto& agg_method) -> void {
384
2.06k
                                             auto& data = *agg_method.hash_table;
385
2.06k
                                             data.for_each_mapped([&](auto& mapped) {
386
2.06k
                                                 if (mapped) {
387
2.06k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
2.06k
                                                     mapped = nullptr;
389
2.06k
                                                 }
390
2.06k
                                             });
391
2.06k
                                             if (data.has_null_key_data()) {
392
138
                                                 auto st = _destroy_agg_status(
393
138
                                                         data.template get_null_key_data<
394
138
                                                                 vectorized::AggregateDataPtr>());
395
138
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
138
                                             }
399
2.06k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIjNS6_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEvS3_
Line
Count
Source
383
4.17k
                                         [&](auto& agg_method) -> void {
384
4.17k
                                             auto& data = *agg_method.hash_table;
385
4.17k
                                             data.for_each_mapped([&](auto& mapped) {
386
4.17k
                                                 if (mapped) {
387
4.17k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
4.17k
                                                     mapped = nullptr;
389
4.17k
                                                 }
390
4.17k
                                             });
391
4.17k
                                             if (data.has_null_key_data()) {
392
418
                                                 auto st = _destroy_agg_status(
393
418
                                                         data.template get_null_key_data<
394
418
                                                                 vectorized::AggregateDataPtr>());
395
418
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
418
                                             }
399
4.17k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberImNS6_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEvS3_
Line
Count
Source
383
2.21k
                                         [&](auto& agg_method) -> void {
384
2.21k
                                             auto& data = *agg_method.hash_table;
385
2.21k
                                             data.for_each_mapped([&](auto& mapped) {
386
2.21k
                                                 if (mapped) {
387
2.21k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
2.21k
                                                     mapped = nullptr;
389
2.21k
                                                 }
390
2.21k
                                             });
391
2.21k
                                             if (data.has_null_key_data()) {
392
183
                                                 auto st = _destroy_agg_status(
393
183
                                                         data.template get_null_key_data<
394
183
                                                                 vectorized::AggregateDataPtr>());
395
183
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
183
                                             }
399
2.21k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIN4wide7integerILm128EjEENS6_15DataWithNullKeyI9PHHashMapISB_Pc9HashCRC32ISB_EEEEEEEEEEvS3_
Line
Count
Source
383
2.40k
                                         [&](auto& agg_method) -> void {
384
2.40k
                                             auto& data = *agg_method.hash_table;
385
2.40k
                                             data.for_each_mapped([&](auto& mapped) {
386
2.40k
                                                 if (mapped) {
387
2.40k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
2.40k
                                                     mapped = nullptr;
389
2.40k
                                                 }
390
2.40k
                                             });
391
2.40k
                                             if (data.has_null_key_data()) {
392
150
                                                 auto st = _destroy_agg_status(
393
150
                                                         data.template get_null_key_data<
394
150
                                                                 vectorized::AggregateDataPtr>());
395
150
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
150
                                             }
399
2.40k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIN4wide7integerILm256EjEENS6_15DataWithNullKeyI9PHHashMapISB_Pc9HashCRC32ISB_EEEEEEEEEEvS3_
Line
Count
Source
383
7
                                         [&](auto& agg_method) -> void {
384
7
                                             auto& data = *agg_method.hash_table;
385
7
                                             data.for_each_mapped([&](auto& mapped) {
386
7
                                                 if (mapped) {
387
7
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
7
                                                     mapped = nullptr;
389
7
                                                 }
390
7
                                             });
391
7
                                             if (data.has_null_key_data()) {
392
0
                                                 auto st = _destroy_agg_status(
393
0
                                                         data.template get_null_key_data<
394
0
                                                                 vectorized::AggregateDataPtr>());
395
0
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
0
                                             }
399
7
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_19MethodStringNoCacheINS6_15DataWithNullKeyINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorEEEEEEEEEEEEEvS3_
Line
Count
Source
383
2.83k
                                         [&](auto& agg_method) -> void {
384
2.83k
                                             auto& data = *agg_method.hash_table;
385
2.83k
                                             data.for_each_mapped([&](auto& mapped) {
386
2.83k
                                                 if (mapped) {
387
2.83k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
2.83k
                                                     mapped = nullptr;
389
2.83k
                                                 }
390
2.83k
                                             });
391
2.83k
                                             if (data.has_null_key_data()) {
392
403
                                                 auto st = _destroy_agg_status(
393
403
                                                         data.template get_null_key_data<
394
403
                                                                 vectorized::AggregateDataPtr>());
395
403
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
403
                                             }
399
2.83k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImEEEEEEvS3_
Line
Count
Source
383
835
                                         [&](auto& agg_method) -> void {
384
835
                                             auto& data = *agg_method.hash_table;
385
835
                                             data.for_each_mapped([&](auto& mapped) {
386
835
                                                 if (mapped) {
387
835
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
835
                                                     mapped = nullptr;
389
835
                                                 }
390
835
                                             });
391
835
                                             if (data.has_null_key_data()) {
392
0
                                                 auto st = _destroy_agg_status(
393
0
                                                         data.template get_null_key_data<
394
0
                                                                 vectorized::AggregateDataPtr>());
395
0
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
0
                                             }
399
835
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32ISB_EEEEEEvS3_
Line
Count
Source
383
6.81k
                                         [&](auto& agg_method) -> void {
384
6.81k
                                             auto& data = *agg_method.hash_table;
385
6.81k
                                             data.for_each_mapped([&](auto& mapped) {
386
6.81k
                                                 if (mapped) {
387
6.81k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
6.81k
                                                     mapped = nullptr;
389
6.81k
                                                 }
390
6.81k
                                             });
391
6.81k
                                             if (data.has_null_key_data()) {
392
0
                                                 auto st = _destroy_agg_status(
393
0
                                                         data.template get_null_key_data<
394
0
                                                                 vectorized::AggregateDataPtr>());
395
0
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
0
                                             }
399
6.81k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32ISB_EEEEEEvS3_
Line
Count
Source
383
12.2k
                                         [&](auto& agg_method) -> void {
384
12.2k
                                             auto& data = *agg_method.hash_table;
385
12.2k
                                             data.for_each_mapped([&](auto& mapped) {
386
12.2k
                                                 if (mapped) {
387
12.2k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
12.2k
                                                     mapped = nullptr;
389
12.2k
                                                 }
390
12.2k
                                             });
391
12.2k
                                             if (data.has_null_key_data()) {
392
0
                                                 auto st = _destroy_agg_status(
393
0
                                                         data.template get_null_key_data<
394
0
                                                                 vectorized::AggregateDataPtr>());
395
0
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
0
                                             }
399
12.2k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapINS6_7UInt136EPc9HashCRC32IS9_EEEEEEvS3_
Line
Count
Source
383
4.69k
                                         [&](auto& agg_method) -> void {
384
4.69k
                                             auto& data = *agg_method.hash_table;
385
4.69k
                                             data.for_each_mapped([&](auto& mapped) {
386
4.69k
                                                 if (mapped) {
387
4.69k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
4.69k
                                                     mapped = nullptr;
389
4.69k
                                                 }
390
4.69k
                                             });
391
4.69k
                                             if (data.has_null_key_data()) {
392
0
                                                 auto st = _destroy_agg_status(
393
0
                                                         data.template get_null_key_data<
394
0
                                                                 vectorized::AggregateDataPtr>());
395
0
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
0
                                             }
399
4.69k
                                         }},
400
63.7k
                   agg_data->method_variant);
401
63.7k
    }
402
403
64.3k
    void _close_without_key() {
404
        //because prepare maybe failed, and couldn't create agg data.
405
        //but finally call close to destory agg data, if agg data has bitmapValue
406
        //will be core dump, it's not initialized
407
64.3k
        if (agg_data_created_without_key) {
408
64.3k
            static_cast<void>(_destroy_agg_status(agg_data->without_key));
409
64.3k
            agg_data_created_without_key = false;
410
64.3k
        }
411
64.3k
    }
412
    Status _destroy_agg_status(vectorized::AggregateDataPtr data);
413
};
414
415
struct BasicSpillSharedState {
416
183k
    virtual ~BasicSpillSharedState() = default;
417
418
    // These two counters are shared to spill source operators as the initial value
419
    // of 'SpillWriteFileCurrentBytes' and 'SpillWriteFileCurrentCount'.
420
    // Total bytes of spill data written to disk file(after serialized)
421
    RuntimeProfile::Counter* _spill_write_file_total_size = nullptr;
422
    RuntimeProfile::Counter* _spill_file_total_count = nullptr;
423
424
183k
    void setup_shared_profile(RuntimeProfile* sink_profile) {
425
183k
        _spill_file_total_count =
426
183k
                ADD_COUNTER_WITH_LEVEL(sink_profile, "SpillWriteFileTotalCount", TUnit::UNIT, 1);
427
183k
        _spill_write_file_total_size =
428
183k
                ADD_COUNTER_WITH_LEVEL(sink_profile, "SpillWriteFileBytes", TUnit::BYTES, 1);
429
183k
    }
430
431
    virtual void update_spill_stream_profiles(RuntimeProfile* source_profile) = 0;
432
};
433
434
struct AggSpillPartition;
435
struct PartitionedAggSharedState : public BasicSharedState,
436
                                   public BasicSpillSharedState,
437
                                   public std::enable_shared_from_this<PartitionedAggSharedState> {
438
    ENABLE_FACTORY_CREATOR(PartitionedAggSharedState)
439
440
49.2k
    PartitionedAggSharedState() = default;
441
49.2k
    ~PartitionedAggSharedState() override = default;
442
443
    void update_spill_stream_profiles(RuntimeProfile* source_profile) override;
444
445
    void init_spill_params(size_t spill_partition_count);
446
447
    void close();
448
449
    AggSharedState* in_mem_shared_state = nullptr;
450
    std::shared_ptr<BasicSharedState> in_mem_shared_state_sptr;
451
452
    size_t partition_count;
453
    size_t max_partition_index;
454
    bool is_spilled = false;
455
    std::atomic_bool is_closed = false;
456
    std::deque<std::shared_ptr<AggSpillPartition>> spill_partitions;
457
458
2.13M
    size_t get_partition_index(size_t hash_value) const { return hash_value % partition_count; }
459
};
460
461
struct AggSpillPartition {
462
    static constexpr int64_t AGG_SPILL_FILE_SIZE = 1024 * 1024 * 1024; // 1G
463
464
1.57M
    AggSpillPartition() = default;
465
466
    void close();
467
468
    Status get_spill_stream(RuntimeState* state, int node_id, RuntimeProfile* profile,
469
                            vectorized::SpillStreamSPtr& spilling_stream);
470
471
129k
    Status flush_if_full() {
472
129k
        DCHECK(spilling_stream_);
473
129k
        Status status;
474
        // avoid small spill files
475
129k
        if (spilling_stream_->get_written_bytes() >= AGG_SPILL_FILE_SIZE) {
476
0
            status = spilling_stream_->spill_eof();
477
0
            spilling_stream_.reset();
478
0
        }
479
129k
        return status;
480
129k
    }
481
482
1.00M
    Status finish_current_spilling(bool eos = false) {
483
1.00M
        if (spilling_stream_) {
484
200k
            if (eos || spilling_stream_->get_written_bytes() >= AGG_SPILL_FILE_SIZE) {
485
38.5k
                auto status = spilling_stream_->spill_eof();
486
38.5k
                spilling_stream_.reset();
487
38.5k
                return status;
488
38.5k
            }
489
200k
        }
490
969k
        return Status::OK();
491
1.00M
    }
492
493
    std::deque<vectorized::SpillStreamSPtr> spill_streams_;
494
    vectorized::SpillStreamSPtr spilling_stream_;
495
};
496
using AggSpillPartitionSPtr = std::shared_ptr<AggSpillPartition>;
497
struct SortSharedState : public BasicSharedState {
498
    ENABLE_FACTORY_CREATOR(SortSharedState)
499
public:
500
    std::shared_ptr<vectorized::Sorter> sorter;
501
};
502
503
struct SpillSortSharedState : public BasicSharedState,
504
                              public BasicSpillSharedState,
505
                              public std::enable_shared_from_this<SpillSortSharedState> {
506
    ENABLE_FACTORY_CREATOR(SpillSortSharedState)
507
508
115k
    SpillSortSharedState() = default;
509
115k
    ~SpillSortSharedState() override = default;
510
511
94.9k
    void update_spill_block_batch_row_count(RuntimeState* state, const vectorized::Block* block) {
512
94.9k
        auto rows = block->rows();
513
94.9k
        if (rows > 0 && 0 == avg_row_bytes) {
514
62.3k
            avg_row_bytes = std::max((std::size_t)1, block->bytes() / rows);
515
62.3k
            spill_block_batch_row_count =
516
62.3k
                    (state->spill_sort_batch_bytes() + avg_row_bytes - 1) / avg_row_bytes;
517
62.3k
            LOG(INFO) << "spill sort block batch row count: " << spill_block_batch_row_count;
518
62.3k
        }
519
94.9k
    }
520
521
    void update_spill_stream_profiles(RuntimeProfile* source_profile) override;
522
523
    void close();
524
525
    SortSharedState* in_mem_shared_state = nullptr;
526
    bool enable_spill = false;
527
    bool is_spilled = false;
528
    std::atomic_bool is_closed = false;
529
    std::shared_ptr<BasicSharedState> in_mem_shared_state_sptr;
530
531
    std::deque<vectorized::SpillStreamSPtr> sorted_streams;
532
    size_t avg_row_bytes = 0;
533
    size_t spill_block_batch_row_count;
534
};
535
536
struct UnionSharedState : public BasicSharedState {
537
    ENABLE_FACTORY_CREATOR(UnionSharedState)
538
539
public:
540
2.89k
    UnionSharedState(int child_count = 1) : data_queue(child_count), _child_count(child_count) {};
541
0
    int child_count() const { return _child_count; }
542
    DataQueue data_queue;
543
    const int _child_count;
544
};
545
546
struct CacheSharedState : public BasicSharedState {
547
    ENABLE_FACTORY_CREATOR(CacheSharedState)
548
public:
549
    DataQueue data_queue;
550
};
551
552
class MultiCastDataStreamer;
553
554
struct MultiCastSharedState : public BasicSharedState,
555
                              public BasicSpillSharedState,
556
                              public std::enable_shared_from_this<MultiCastSharedState> {
557
    MultiCastSharedState(ObjectPool* pool, int cast_sender_count, int node_id);
558
    std::unique_ptr<pipeline::MultiCastDataStreamer> multi_cast_data_streamer;
559
560
    void update_spill_stream_profiles(RuntimeProfile* source_profile) override;
561
};
562
563
struct AnalyticSharedState : public BasicSharedState {
564
    ENABLE_FACTORY_CREATOR(AnalyticSharedState)
565
566
public:
567
9.23k
    AnalyticSharedState() = default;
568
    std::queue<vectorized::Block> blocks_buffer;
569
    std::mutex buffer_mutex;
570
    bool sink_eos = false;
571
    std::mutex sink_eos_lock;
572
};
573
574
struct JoinSharedState : public BasicSharedState {
575
    // For some join case, we can apply a short circuit strategy
576
    // 1. _has_null_in_build_side = true
577
    // 2. build side rows is empty, Join op is: inner join/right outer join/left semi/right semi/right anti
578
    bool _has_null_in_build_side = false;
579
    bool short_circuit_for_probe = false;
580
    // for some join, when build side rows is empty, we could return directly by add some additional null data in probe table.
581
    bool empty_right_table_need_probe_dispose = false;
582
    JoinOpVariants join_op_variants;
583
};
584
585
struct HashJoinSharedState : public JoinSharedState {
586
    ENABLE_FACTORY_CREATOR(HashJoinSharedState)
587
133k
    HashJoinSharedState() {
588
133k
        hash_table_variant_vector.push_back(std::make_shared<JoinDataVariants>());
589
133k
    }
590
2.01k
    HashJoinSharedState(int num_instances) {
591
2.01k
        source_deps.resize(num_instances, nullptr);
592
2.01k
        hash_table_variant_vector.resize(num_instances, nullptr);
593
12.9k
        for (int i = 0; i < num_instances; i++) {
594
10.8k
            hash_table_variant_vector[i] = std::make_shared<JoinDataVariants>();
595
10.8k
        }
596
2.01k
    }
597
    std::shared_ptr<vectorized::Arena> arena = std::make_shared<vectorized::Arena>();
598
599
    const std::vector<TupleDescriptor*> build_side_child_desc;
600
    size_t build_exprs_size = 0;
601
    std::shared_ptr<vectorized::Block> build_block;
602
    std::shared_ptr<std::vector<uint32_t>> build_indexes_null;
603
604
    // Used by shared hash table
605
    // For probe operator, hash table in _hash_table_variants is read-only if visited flags is not
606
    // used. (visited flags will be used only in right / full outer join).
607
    //
608
    // For broadcast join, although hash table is read-only, some states in `_hash_table_variants`
609
    // are still could be written. For example, serialized keys will be written in a continuous
610
    // memory in `_hash_table_variants`. So before execution, we should use a local _hash_table_variants
611
    // which has a shared hash table in it.
612
    std::vector<std::shared_ptr<JoinDataVariants>> hash_table_variant_vector;
613
};
614
615
struct PartitionedHashJoinSharedState
616
        : public HashJoinSharedState,
617
          public BasicSpillSharedState,
618
          public std::enable_shared_from_this<PartitionedHashJoinSharedState> {
619
    ENABLE_FACTORY_CREATOR(PartitionedHashJoinSharedState)
620
621
16.8k
    void update_spill_stream_profiles(RuntimeProfile* source_profile) override {
622
538k
        for (auto& stream : spilled_streams) {
623
538k
            if (stream) {
624
538k
                stream->update_shared_profiles(source_profile);
625
538k
            }
626
538k
        }
627
16.8k
    }
628
629
    std::unique_ptr<RuntimeState> inner_runtime_state;
630
    std::shared_ptr<HashJoinSharedState> inner_shared_state;
631
    std::vector<std::unique_ptr<vectorized::MutableBlock>> partitioned_build_blocks;
632
    std::vector<vectorized::SpillStreamSPtr> spilled_streams;
633
    bool need_to_spill = false;
634
};
635
636
struct NestedLoopJoinSharedState : public JoinSharedState {
637
    ENABLE_FACTORY_CREATOR(NestedLoopJoinSharedState)
638
    // if true, left child has no more rows to process
639
    bool left_side_eos = false;
640
    // Visited flags for each row in build side.
641
    vectorized::MutableColumns build_side_visited_flags;
642
    // List of build blocks, constructed in prepare()
643
    vectorized::Blocks build_blocks;
644
};
645
646
struct PartitionSortNodeSharedState : public BasicSharedState {
647
    ENABLE_FACTORY_CREATOR(PartitionSortNodeSharedState)
648
public:
649
    std::queue<vectorized::Block> blocks_buffer;
650
    std::mutex buffer_mutex;
651
    std::vector<std::unique_ptr<vectorized::PartitionSorter>> partition_sorts;
652
    bool sink_eos = false;
653
    std::mutex sink_eos_lock;
654
    std::mutex prepared_finish_lock;
655
};
656
657
struct SetSharedState : public BasicSharedState {
658
    ENABLE_FACTORY_CREATOR(SetSharedState)
659
public:
660
    /// default init
661
    vectorized::Block build_block; // build to source
662
    //record element size in hashtable
663
    int64_t valid_element_in_hash_tbl = 0;
664
    //first: idx mapped to column types
665
    //second: column_id, could point to origin column or cast column
666
    std::unordered_map<int, int> build_col_idx;
667
668
    //// shared static states (shared, decided in prepare/open...)
669
670
    /// init in setup_local_state
671
    std::unique_ptr<SetDataVariants> hash_table_variants =
672
            std::make_unique<SetDataVariants>(); // the real data HERE.
673
    std::vector<bool> build_not_ignore_null;
674
675
    // The SET operator's child might have different nullable attributes.
676
    // If a calculation involves both nullable and non-nullable columns, the final output should be a nullable column
677
    Status update_build_not_ignore_null(const vectorized::VExprContextSPtrs& ctxs);
678
679
    size_t get_hash_table_size() const;
680
    /// init in both upstream side.
681
    //The i-th result expr list refers to the i-th child.
682
    std::vector<vectorized::VExprContextSPtrs> child_exprs_lists;
683
684
    /// init in build side
685
    size_t child_quantity;
686
    vectorized::VExprContextSPtrs build_child_exprs;
687
    std::vector<Dependency*> probe_finished_children_dependency;
688
689
    /// init in probe side
690
    std::vector<vectorized::VExprContextSPtrs> probe_child_exprs_lists;
691
692
    std::atomic<bool> ready_for_read = false;
693
694
    /// called in setup_local_state
695
    Status hash_table_init();
696
};
697
698
enum class ExchangeType : uint8_t {
699
    NOOP = 0,
700
    // Shuffle data by Crc32HashPartitioner<LocalExchangeChannelIds>.
701
    HASH_SHUFFLE = 1,
702
    // Round-robin passthrough data blocks.
703
    PASSTHROUGH = 2,
704
    // Shuffle data by Crc32HashPartitioner<ShuffleChannelIds> (e.g. same as storage engine).
705
    BUCKET_HASH_SHUFFLE = 3,
706
    // Passthrough data blocks to all channels.
707
    BROADCAST = 4,
708
    // Passthrough data to channels evenly in an adaptive way.
709
    ADAPTIVE_PASSTHROUGH = 5,
710
    // Send all data to the first channel.
711
    PASS_TO_ONE = 6,
712
};
713
714
110k
inline std::string get_exchange_type_name(ExchangeType idx) {
715
110k
    switch (idx) {
716
13
    case ExchangeType::NOOP:
717
13
        return "NOOP";
718
4.56k
    case ExchangeType::HASH_SHUFFLE:
719
4.56k
        return "HASH_SHUFFLE";
720
98.8k
    case ExchangeType::PASSTHROUGH:
721
98.8k
        return "PASSTHROUGH";
722
2.10k
    case ExchangeType::BUCKET_HASH_SHUFFLE:
723
2.10k
        return "BUCKET_HASH_SHUFFLE";
724
500
    case ExchangeType::BROADCAST:
725
500
        return "BROADCAST";
726
2.21k
    case ExchangeType::ADAPTIVE_PASSTHROUGH:
727
2.21k
        return "ADAPTIVE_PASSTHROUGH";
728
2.77k
    case ExchangeType::PASS_TO_ONE:
729
2.77k
        return "PASS_TO_ONE";
730
110k
    }
731
0
    throw Exception(Status::FatalError("__builtin_unreachable"));
732
110k
}
733
734
struct DataDistribution {
735
1.70M
    DataDistribution(ExchangeType type) : distribution_type(type) {}
736
    DataDistribution(ExchangeType type, const std::vector<TExpr>& partition_exprs_)
737
75.8k
            : distribution_type(type), partition_exprs(partition_exprs_) {}
738
124k
    DataDistribution(const DataDistribution& other) = default;
739
456k
    bool need_local_exchange() const { return distribution_type != ExchangeType::NOOP; }
740
521k
    DataDistribution& operator=(const DataDistribution& other) = default;
741
    ExchangeType distribution_type;
742
    std::vector<TExpr> partition_exprs;
743
};
744
745
class ExchangerBase;
746
747
struct LocalExchangeSharedState : public BasicSharedState {
748
public:
749
    ENABLE_FACTORY_CREATOR(LocalExchangeSharedState);
750
    LocalExchangeSharedState(int num_instances);
751
    ~LocalExchangeSharedState() override;
752
    std::unique_ptr<ExchangerBase> exchanger {};
753
    std::vector<RuntimeProfile::Counter*> mem_counters;
754
    std::atomic<int64_t> mem_usage = 0;
755
    std::atomic<size_t> _buffer_mem_limit = config::local_exchange_buffer_mem_limit;
756
    // 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.
757
    std::mutex le_lock;
758
    void sub_running_sink_operators();
759
    void sub_running_source_operators();
760
110k
    void _set_always_ready() {
761
683k
        for (auto& dep : source_deps) {
762
683k
            DCHECK(dep);
763
683k
            dep->set_always_ready();
764
683k
        }
765
110k
        for (auto& dep : sink_deps) {
766
110k
            DCHECK(dep);
767
110k
            dep->set_always_ready();
768
110k
        }
769
110k
    }
770
771
143k
    Dependency* get_sink_dep_by_channel_id(int channel_id) { return nullptr; }
772
773
256k
    void set_ready_to_read(int channel_id) {
774
256k
        auto& dep = source_deps[channel_id];
775
18.4E
        DCHECK(dep) << channel_id;
776
256k
        dep->set_ready();
777
256k
    }
778
779
256k
    void add_mem_usage(int channel_id, size_t delta) { mem_counters[channel_id]->update(delta); }
780
781
256k
    void sub_mem_usage(int channel_id, size_t delta) {
782
256k
        mem_counters[channel_id]->update(-(int64_t)delta);
783
256k
    }
784
785
217k
    void add_total_mem_usage(size_t delta) {
786
217k
        if (cast_set<int64_t>(mem_usage.fetch_add(delta) + delta) > _buffer_mem_limit) {
787
16
            sink_deps.front()->block();
788
16
        }
789
217k
    }
790
791
217k
    void sub_total_mem_usage(size_t delta) {
792
217k
        auto prev_usage = mem_usage.fetch_sub(delta);
793
217k
        DCHECK_GE(prev_usage - delta, 0) << "prev_usage: " << prev_usage << " delta: " << delta;
794
217k
        if (cast_set<int64_t>(prev_usage - delta) <= _buffer_mem_limit) {
795
217k
            sink_deps.front()->set_ready();
796
217k
        }
797
217k
    }
798
799
54.8k
    void set_low_memory_mode(RuntimeState* state) {
800
54.8k
        _buffer_mem_limit = std::min<int64_t>(config::local_exchange_buffer_mem_limit,
801
54.8k
                                              state->low_memory_mode_buffer_limit());
802
54.8k
    }
803
};
804
805
#include "common/compile_check_end.h"
806
} // namespace doris::pipeline