Coverage Report

Created: 2025-05-12 13:45

/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.93M
    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.93M
        return reinterpret_cast<TARGET*>(this);
70
1.93M
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_19HashJoinSharedStateEEEPT_v
Line
Count
Source
65
204k
    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
204k
        return reinterpret_cast<TARGET*>(this);
70
204k
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_30PartitionedHashJoinSharedStateEEEPT_v
Line
Count
Source
65
37.4k
    TARGET* cast() {
66
37.4k
        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
37.4k
        return reinterpret_cast<TARGET*>(this);
70
37.4k
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_15SortSharedStateEEEPT_v
Line
Count
Source
65
332k
    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
332k
        return reinterpret_cast<TARGET*>(this);
70
332k
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_20SpillSortSharedStateEEEPT_v
Line
Count
Source
65
277k
    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
277k
        return reinterpret_cast<TARGET*>(this);
70
277k
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_25NestedLoopJoinSharedStateEEEPT_v
Line
Count
Source
65
15.2k
    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.2k
        return reinterpret_cast<TARGET*>(this);
70
15.2k
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_19AnalyticSharedStateEEEPT_v
Line
Count
Source
65
20.2k
    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
20.2k
        return reinterpret_cast<TARGET*>(this);
70
20.2k
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_14AggSharedStateEEEPT_v
Line
Count
Source
65
251k
    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
251k
        return reinterpret_cast<TARGET*>(this);
70
251k
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_25PartitionedAggSharedStateEEEPT_v
Line
Count
Source
65
100k
    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
100k
        return reinterpret_cast<TARGET*>(this);
70
100k
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_16UnionSharedStateEEEPT_v
Line
Count
Source
65
6.79k
    TARGET* cast() {
66
6.79k
        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
6.79k
        return reinterpret_cast<TARGET*>(this);
70
6.79k
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_28PartitionSortNodeSharedStateEEEPT_v
Line
Count
Source
65
792
    TARGET* cast() {
66
792
        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
792
        return reinterpret_cast<TARGET*>(this);
70
792
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_20MultiCastSharedStateEEEPT_v
Line
Count
Source
65
5.02k
    TARGET* cast() {
66
5.02k
        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
5.02k
        return reinterpret_cast<TARGET*>(this);
70
5.02k
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_14SetSharedStateEEEPT_v
Line
Count
Source
65
2.20k
    TARGET* cast() {
66
2.20k
        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
2.20k
        return reinterpret_cast<TARGET*>(this);
70
2.20k
    }
_ZN5doris8pipeline16BasicSharedState4castINS0_24LocalExchangeSharedStateEEEPT_v
Line
Count
Source
65
479k
    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
479k
        return reinterpret_cast<TARGET*>(this);
70
479k
    }
_ZN5doris8pipeline16BasicSharedState4castIS1_EEPT_v
Line
Count
Source
65
200k
    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
200k
        return reinterpret_cast<TARGET*>(this);
70
200k
    }
_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.26M
    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
348k
    std::vector<DependencySPtr> get_dep_by_channel_id(int channel_id) {
90
348k
        DCHECK_LT(channel_id, source_deps.size());
91
348k
        return {source_deps[channel_id]};
92
348k
    }
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.47M
            : _id(id), _node_id(node_id), _name(std::move(name)), _ready(ready) {}
100
4.47M
    virtual ~Dependency() = default;
101
102
0
    [[nodiscard]] int id() const { return _id; }
103
6.25M
    [[nodiscard]] virtual std::string name() const { return _name; }
104
161k
    BasicSharedState* shared_state() { return _shared_state; }
105
1.89M
    void set_shared_state(BasicSharedState* shared_state) { _shared_state = shared_state; }
106
    virtual std::string debug_string(int indentation_level = 0);
107
711M
    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.91M
    [[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
435k
    void set_ready_to_read(int channel_id = 0) {
118
435k
        DCHECK_LT(channel_id, _shared_state->source_deps.size()) << debug_string();
119
435k
        _shared_state->source_deps[channel_id]->set_ready();
120
435k
    }
121
389
    void set_ready_to_write() {
122
389
        DCHECK_EQ(_shared_state->sink_deps.size(), 1) << debug_string();
123
389
        _shared_state->sink_deps.front()->set_ready();
124
389
    }
125
126
    // Notify downstream pipeline tasks this dependency is blocked.
127
282M
    void block() {
128
282M
        if (_always_ready) {
129
207k
            return;
130
207k
        }
131
282M
        std::unique_lock<std::mutex> lc(_always_ready_lock);
132
282M
        if (_always_ready) {
133
1
            return;
134
1
        }
135
282M
        _ready = false;
136
282M
    }
137
138
2.06M
    void set_always_ready() {
139
2.06M
        if (_always_ready) {
140
980k
            return;
141
980k
        }
142
1.08M
        std::unique_lock<std::mutex> lc(_always_ready_lock);
143
1.08M
        if (_always_ready) {
144
0
            return;
145
0
        }
146
1.08M
        _always_ready = true;
147
1.08M
        set_ready();
148
1.08M
    }
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
128k
            : Dependency(id, node_id, std::move(name), true) {}
178
179
4.72k
    void add() {
180
4.72k
        std::unique_lock<std::mutex> l(_mtx);
181
4.72k
        if (!_counter) {
182
4.72k
            block();
183
4.72k
        }
184
4.72k
        _counter++;
185
4.72k
    }
186
187
4.72k
    void sub() {
188
4.72k
        std::unique_lock<std::mutex> l(_mtx);
189
4.72k
        _counter--;
190
4.72k
        if (!_counter) {
191
4.72k
            set_ready();
192
4.72k
        }
193
4.72k
    }
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
25.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.59M
    int64_t registration_time() const { return _registration_time; }
218
1.59M
    int32_t wait_time_ms() const { return _wait_time_ms; }
219
220
    void set_local_runtime_filter_dependencies(
221
9.07k
            const std::vector<std::shared_ptr<Dependency>>& deps) {
222
9.07k
        _local_runtime_filter_dependencies = deps;
223
9.07k
    }
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
4
    void run() { _thread.detach(); }
239
    void start();
240
241
1
    void stop() {
242
1
        _stop = true;
243
1
        cv.notify_all();
244
1
        wait_for_shutdown();
245
1
    }
246
247
1
    void wait_for_shutdown() const {
248
2
        while (!_shutdown) {
249
1
            std::this_thread::sleep_for(std::chrono::milliseconds(interval));
250
1
        }
251
1
    }
252
253
1
    ~RuntimeFilterTimerQueue() = default;
254
4
    RuntimeFilterTimerQueue() { _thread = std::thread(&RuntimeFilterTimerQueue::start, this); }
255
17.7k
    void push_filter_timer(std::vector<std::shared_ptr<pipeline::RuntimeFilterTimer>>&& filter) {
256
17.7k
        std::unique_lock<std::mutex> lc(_que_lock);
257
17.7k
        _que.insert(_que.end(), filter.begin(), filter.end());
258
17.7k
        cv.notify_all();
259
17.7k
    }
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
126k
    AggSharedState() {
274
126k
        agg_data = std::make_unique<AggregatedDataVariants>();
275
126k
        agg_arena_pool = std::make_unique<vectorized::Arena>();
276
126k
    }
277
125k
    ~AggSharedState() override {
278
125k
        if (!probe_expr_ctxs.empty()) {
279
59.5k
            _close_with_serialized_key();
280
66.4k
        } else {
281
66.4k
            _close_without_key();
282
66.4k
        }
283
125k
    }
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
28.7k
                  _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
188k
                  _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
299k
        HeapLimitCursor& operator=(HeapLimitCursor&& other) noexcept {
346
299k
            _row_id = other._row_id;
347
299k
            return *this;
348
299k
        }
349
350
271k
        bool operator<(const HeapLimitCursor& rhs) const {
351
458k
            for (int i = 0; i < _limit_columns.size(); ++i) {
352
458k
                const auto& _limit_column = _limit_columns[i];
353
458k
                auto res = _limit_column->compare_at(_row_id, rhs._row_id, *_limit_column,
354
458k
                                                     _null_directions[i]) *
355
458k
                           _order_directions[i];
356
458k
                if (res < 0) {
357
133k
                    return true;
358
324k
                } else if (res > 0) {
359
145k
                    return false;
360
145k
                }
361
458k
            }
362
18.4E
            return false;
363
271k
        }
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
59.5k
    void _close_with_serialized_key() {
380
59.5k
        std::visit(vectorized::Overload {[&](std::monostate& arg) -> void {
381
                                             // Do nothing
382
0
                                         },
383
59.5k
                                         [&](auto& agg_method) -> void {
384
59.5k
                                             auto& data = *agg_method.hash_table;
385
1.51M
                                             data.for_each_mapped([&](auto& mapped) {
386
1.51M
                                                 if (mapped) {
387
1.51M
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
1.51M
                                                     mapped = nullptr;
389
1.51M
                                                 }
390
1.51M
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS9_vEEEEEEvS3_ENKUlS3_E_clISA_EEDaS3_
Line
Count
Source
385
81.5k
                                             data.for_each_mapped([&](auto& mapped) {
386
81.5k
                                                 if (mapped) {
387
81.5k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
81.5k
                                                     mapped = nullptr;
389
81.5k
                                                 }
390
81.5k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEvS3_ENKUlS3_E_clIS9_EEDaS3_
Line
Count
Source
385
757
                                             data.for_each_mapped([&](auto& mapped) {
386
757
                                                 if (mapped) {
387
757
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
757
                                                     mapped = nullptr;
389
757
                                                 }
390
757
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEvS3_ENKUlS3_E_clIS9_EEDaS3_
Line
Count
Source
385
30
                                             data.for_each_mapped([&](auto& mapped) {
386
30
                                                 if (mapped) {
387
30
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
30
                                                     mapped = nullptr;
389
30
                                                 }
390
30
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEEvS3_ENKUlS3_E_clIS9_EEDaS3_
Line
Count
Source
385
948k
                                             data.for_each_mapped([&](auto& mapped) {
386
950k
                                                 if (mapped) {
387
950k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
950k
                                                     mapped = nullptr;
389
950k
                                                 }
390
948k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEEvS3_ENKUlS3_E_clIS9_EEDaS3_
Line
Count
Source
385
61.7k
                                             data.for_each_mapped([&](auto& mapped) {
386
61.7k
                                                 if (mapped) {
387
61.7k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
61.7k
                                                     mapped = nullptr;
389
61.7k
                                                 }
390
61.7k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorEEEEEEEEEvS3_ENKUlS3_E_clIS9_EEDaS3_
Line
Count
Source
385
1.30k
                                             data.for_each_mapped([&](auto& mapped) {
386
1.30k
                                                 if (mapped) {
387
1.30k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
1.30k
                                                     mapped = nullptr;
389
1.30k
                                                 }
390
1.30k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapISA_Pc9HashCRC32ISA_EEEEEEvS3_ENKUlS3_E_clISC_EEDaS3_
Line
Count
Source
385
19
                                             data.for_each_mapped([&](auto& mapped) {
386
19
                                                 if (mapped) {
387
19
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
19
                                                     mapped = nullptr;
389
19
                                                 }
390
19
                                             });
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
61.2k
                                             data.for_each_mapped([&](auto& mapped) {
386
61.2k
                                                 if (mapped) {
387
61.2k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
61.2k
                                                     mapped = nullptr;
389
61.2k
                                                 }
390
61.2k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIhNS6_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEvS3_ENKUlS3_E_clISB_EEDaS3_
Line
Count
Source
385
2.09k
                                             data.for_each_mapped([&](auto& mapped) {
386
2.09k
                                                 if (mapped) {
387
2.09k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
2.09k
                                                     mapped = nullptr;
389
2.09k
                                                 }
390
2.09k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberItNS6_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEvS3_ENKUlS3_E_clISB_EEDaS3_
Line
Count
Source
385
878
                                             data.for_each_mapped([&](auto& mapped) {
386
878
                                                 if (mapped) {
387
878
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
878
                                                     mapped = nullptr;
389
878
                                                 }
390
878
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIjNS6_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEvS3_ENKUlS3_E_clISB_EEDaS3_
Line
Count
Source
385
24.1k
                                             data.for_each_mapped([&](auto& mapped) {
386
24.1k
                                                 if (mapped) {
387
24.1k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
24.1k
                                                     mapped = nullptr;
389
24.1k
                                                 }
390
24.1k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberImNS6_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEvS3_ENKUlS3_E_clISB_EEDaS3_
Line
Count
Source
385
9.95k
                                             data.for_each_mapped([&](auto& mapped) {
386
9.95k
                                                 if (mapped) {
387
9.95k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
9.95k
                                                     mapped = nullptr;
389
9.95k
                                                 }
390
9.95k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIjNS6_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEvS3_ENKUlS3_E_clISB_EEDaS3_
Line
Count
Source
385
22.0k
                                             data.for_each_mapped([&](auto& mapped) {
386
22.0k
                                                 if (mapped) {
387
22.0k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
22.0k
                                                     mapped = nullptr;
389
22.0k
                                                 }
390
22.0k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberImNS6_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEvS3_ENKUlS3_E_clISB_EEDaS3_
Line
Count
Source
385
2.18k
                                             data.for_each_mapped([&](auto& mapped) {
386
2.18k
                                                 if (mapped) {
387
2.18k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
2.18k
                                                     mapped = nullptr;
389
2.18k
                                                 }
390
2.18k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIN4wide7integerILm128EjEENS6_15DataWithNullKeyI9PHHashMapISB_Pc9HashCRC32ISB_EEEEEEEEEEvS3_ENKUlS3_E_clISE_EEDaS3_
Line
Count
Source
385
2.84k
                                             data.for_each_mapped([&](auto& mapped) {
386
2.84k
                                                 if (mapped) {
387
2.84k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
2.84k
                                                     mapped = nullptr;
389
2.84k
                                                 }
390
2.84k
                                             });
Unexecuted instantiation: _ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIN4wide7integerILm256EjEENS6_15DataWithNullKeyI9PHHashMapISB_Pc9HashCRC32ISB_EEEEEEEEEEvS3_ENKUlS3_E_clISE_EEDaS3_
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_19MethodStringNoCacheINS6_15DataWithNullKeyINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorEEEEEEEEEEEEEvS3_ENKUlS3_E_clISB_EEDaS3_
Line
Count
Source
385
12.0k
                                             data.for_each_mapped([&](auto& mapped) {
386
12.0k
                                                 if (mapped) {
387
12.0k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
12.0k
                                                     mapped = nullptr;
389
12.0k
                                                 }
390
12.0k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImEEEEEEvS3_ENKUlS3_E_clIS9_EEDaS3_
Line
Count
Source
385
164k
                                             data.for_each_mapped([&](auto& mapped) {
386
164k
                                                 if (mapped) {
387
164k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
164k
                                                     mapped = nullptr;
389
164k
                                                 }
390
164k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32ISB_EEEEEEvS3_ENKUlS3_E_clISC_EEDaS3_
Line
Count
Source
385
58.0k
                                             data.for_each_mapped([&](auto& mapped) {
386
58.1k
                                                 if (mapped) {
387
58.1k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
58.1k
                                                     mapped = nullptr;
389
58.1k
                                                 }
390
58.0k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32ISB_EEEEEEvS3_ENKUlS3_E_clISC_EEDaS3_
Line
Count
Source
385
16.5k
                                             data.for_each_mapped([&](auto& mapped) {
386
16.5k
                                                 if (mapped) {
387
16.5k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
16.5k
                                                     mapped = nullptr;
389
16.5k
                                                 }
390
16.5k
                                             });
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapINS6_7UInt136EPc9HashCRC32IS9_EEEEEEvS3_ENKUlS3_E_clISA_EEDaS3_
Line
Count
Source
385
3.52k
                                             data.for_each_mapped([&](auto& mapped) {
386
3.53k
                                                 if (mapped) {
387
3.53k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
3.53k
                                                     mapped = nullptr;
389
3.53k
                                                 }
390
3.52k
                                             });
391
59.5k
                                             if (data.has_null_key_data()) {
392
2.52k
                                                 auto st = _destroy_agg_status(
393
2.52k
                                                         data.template get_null_key_data<
394
2.52k
                                                                 vectorized::AggregateDataPtr>());
395
2.52k
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
2.52k
                                             }
399
59.5k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS9_vEEEEEEvS3_
Line
Count
Source
383
8.30k
                                         [&](auto& agg_method) -> void {
384
8.30k
                                             auto& data = *agg_method.hash_table;
385
8.30k
                                             data.for_each_mapped([&](auto& mapped) {
386
8.30k
                                                 if (mapped) {
387
8.30k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
8.30k
                                                     mapped = nullptr;
389
8.30k
                                                 }
390
8.30k
                                             });
391
8.30k
                                             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
8.30k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEvS3_
Line
Count
Source
383
615
                                         [&](auto& agg_method) -> void {
384
615
                                             auto& data = *agg_method.hash_table;
385
615
                                             data.for_each_mapped([&](auto& mapped) {
386
615
                                                 if (mapped) {
387
615
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
615
                                                     mapped = nullptr;
389
615
                                                 }
390
615
                                             });
391
615
                                             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
615
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEvS3_
Line
Count
Source
383
84
                                         [&](auto& agg_method) -> void {
384
84
                                             auto& data = *agg_method.hash_table;
385
84
                                             data.for_each_mapped([&](auto& mapped) {
386
84
                                                 if (mapped) {
387
84
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
84
                                                     mapped = nullptr;
389
84
                                                 }
390
84
                                             });
391
84
                                             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
84
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEEvS3_
Line
Count
Source
383
1.61k
                                         [&](auto& agg_method) -> void {
384
1.61k
                                             auto& data = *agg_method.hash_table;
385
1.61k
                                             data.for_each_mapped([&](auto& mapped) {
386
1.61k
                                                 if (mapped) {
387
1.61k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
1.61k
                                                     mapped = nullptr;
389
1.61k
                                                 }
390
1.61k
                                             });
391
1.61k
                                             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.61k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEEvS3_
Line
Count
Source
383
481
                                         [&](auto& agg_method) -> void {
384
481
                                             auto& data = *agg_method.hash_table;
385
481
                                             data.for_each_mapped([&](auto& mapped) {
386
481
                                                 if (mapped) {
387
481
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
481
                                                     mapped = nullptr;
389
481
                                                 }
390
481
                                             });
391
481
                                             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
481
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorEEEEEEEEEvS3_
Line
Count
Source
383
1.03k
                                         [&](auto& agg_method) -> void {
384
1.03k
                                             auto& data = *agg_method.hash_table;
385
1.03k
                                             data.for_each_mapped([&](auto& mapped) {
386
1.03k
                                                 if (mapped) {
387
1.03k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
1.03k
                                                     mapped = nullptr;
389
1.03k
                                                 }
390
1.03k
                                             });
391
1.03k
                                             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.03k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapISA_Pc9HashCRC32ISA_EEEEEEvS3_
Line
Count
Source
383
137
                                         [&](auto& agg_method) -> void {
384
137
                                             auto& data = *agg_method.hash_table;
385
137
                                             data.for_each_mapped([&](auto& mapped) {
386
137
                                                 if (mapped) {
387
137
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
137
                                                     mapped = nullptr;
389
137
                                                 }
390
137
                                             });
391
137
                                             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
137
                                         }},
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.18k
                                         [&](auto& agg_method) -> void {
384
1.18k
                                             auto& data = *agg_method.hash_table;
385
1.18k
                                             data.for_each_mapped([&](auto& mapped) {
386
1.18k
                                                 if (mapped) {
387
1.18k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
1.18k
                                                     mapped = nullptr;
389
1.18k
                                                 }
390
1.18k
                                             });
391
1.18k
                                             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.18k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEvS3_
Line
Count
Source
383
769
                                         [&](auto& agg_method) -> void {
384
769
                                             auto& data = *agg_method.hash_table;
385
769
                                             data.for_each_mapped([&](auto& mapped) {
386
769
                                                 if (mapped) {
387
769
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
769
                                                     mapped = nullptr;
389
769
                                                 }
390
769
                                             });
391
769
                                             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
769
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIhNS6_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEvS3_
Line
Count
Source
383
1.96k
                                         [&](auto& agg_method) -> void {
384
1.96k
                                             auto& data = *agg_method.hash_table;
385
1.96k
                                             data.for_each_mapped([&](auto& mapped) {
386
1.96k
                                                 if (mapped) {
387
1.96k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
1.96k
                                                     mapped = nullptr;
389
1.96k
                                                 }
390
1.96k
                                             });
391
1.96k
                                             if (data.has_null_key_data()) {
392
524
                                                 auto st = _destroy_agg_status(
393
524
                                                         data.template get_null_key_data<
394
524
                                                                 vectorized::AggregateDataPtr>());
395
524
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
524
                                             }
399
1.96k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberItNS6_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEvS3_
Line
Count
Source
383
853
                                         [&](auto& agg_method) -> void {
384
853
                                             auto& data = *agg_method.hash_table;
385
853
                                             data.for_each_mapped([&](auto& mapped) {
386
853
                                                 if (mapped) {
387
853
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
853
                                                     mapped = nullptr;
389
853
                                                 }
390
853
                                             });
391
853
                                             if (data.has_null_key_data()) {
392
43
                                                 auto st = _destroy_agg_status(
393
43
                                                         data.template get_null_key_data<
394
43
                                                                 vectorized::AggregateDataPtr>());
395
43
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
43
                                             }
399
853
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIjNS6_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEvS3_
Line
Count
Source
383
5.69k
                                         [&](auto& agg_method) -> void {
384
5.69k
                                             auto& data = *agg_method.hash_table;
385
5.69k
                                             data.for_each_mapped([&](auto& mapped) {
386
5.69k
                                                 if (mapped) {
387
5.69k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
5.69k
                                                     mapped = nullptr;
389
5.69k
                                                 }
390
5.69k
                                             });
391
5.69k
                                             if (data.has_null_key_data()) {
392
679
                                                 auto st = _destroy_agg_status(
393
679
                                                         data.template get_null_key_data<
394
679
                                                                 vectorized::AggregateDataPtr>());
395
679
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
679
                                             }
399
5.69k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberImNS6_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEvS3_
Line
Count
Source
383
2.36k
                                         [&](auto& agg_method) -> void {
384
2.36k
                                             auto& data = *agg_method.hash_table;
385
2.36k
                                             data.for_each_mapped([&](auto& mapped) {
386
2.36k
                                                 if (mapped) {
387
2.36k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
2.36k
                                                     mapped = nullptr;
389
2.36k
                                                 }
390
2.36k
                                             });
391
2.36k
                                             if (data.has_null_key_data()) {
392
163
                                                 auto st = _destroy_agg_status(
393
163
                                                         data.template get_null_key_data<
394
163
                                                                 vectorized::AggregateDataPtr>());
395
163
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
163
                                             }
399
2.36k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIjNS6_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEvS3_
Line
Count
Source
383
3.79k
                                         [&](auto& agg_method) -> void {
384
3.79k
                                             auto& data = *agg_method.hash_table;
385
3.79k
                                             data.for_each_mapped([&](auto& mapped) {
386
3.79k
                                                 if (mapped) {
387
3.79k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
3.79k
                                                     mapped = nullptr;
389
3.79k
                                                 }
390
3.79k
                                             });
391
3.79k
                                             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
3.79k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberImNS6_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEvS3_
Line
Count
Source
383
2.15k
                                         [&](auto& agg_method) -> void {
384
2.15k
                                             auto& data = *agg_method.hash_table;
385
2.15k
                                             data.for_each_mapped([&](auto& mapped) {
386
2.15k
                                                 if (mapped) {
387
2.15k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
2.15k
                                                     mapped = nullptr;
389
2.15k
                                                 }
390
2.15k
                                             });
391
2.15k
                                             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.15k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIN4wide7integerILm128EjEENS6_15DataWithNullKeyI9PHHashMapISB_Pc9HashCRC32ISB_EEEEEEEEEEvS3_
Line
Count
Source
383
2.76k
                                         [&](auto& agg_method) -> void {
384
2.76k
                                             auto& data = *agg_method.hash_table;
385
2.76k
                                             data.for_each_mapped([&](auto& mapped) {
386
2.76k
                                                 if (mapped) {
387
2.76k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
2.76k
                                                     mapped = nullptr;
389
2.76k
                                                 }
390
2.76k
                                             });
391
2.76k
                                             if (data.has_null_key_data()) {
392
155
                                                 auto st = _destroy_agg_status(
393
155
                                                         data.template get_null_key_data<
394
155
                                                                 vectorized::AggregateDataPtr>());
395
155
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
155
                                             }
399
2.76k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIN4wide7integerILm256EjEENS6_15DataWithNullKeyI9PHHashMapISB_Pc9HashCRC32ISB_EEEEEEEEEEvS3_
Line
Count
Source
383
3
                                         [&](auto& agg_method) -> void {
384
3
                                             auto& data = *agg_method.hash_table;
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
                                             });
391
3
                                             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
3
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_19MethodStringNoCacheINS6_15DataWithNullKeyINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorEEEEEEEEEEEEEvS3_
Line
Count
Source
383
3.39k
                                         [&](auto& agg_method) -> void {
384
3.39k
                                             auto& data = *agg_method.hash_table;
385
3.39k
                                             data.for_each_mapped([&](auto& mapped) {
386
3.39k
                                                 if (mapped) {
387
3.39k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
3.39k
                                                     mapped = nullptr;
389
3.39k
                                                 }
390
3.39k
                                             });
391
3.39k
                                             if (data.has_null_key_data()) {
392
355
                                                 auto st = _destroy_agg_status(
393
355
                                                         data.template get_null_key_data<
394
355
                                                                 vectorized::AggregateDataPtr>());
395
355
                                                 if (!st) {
396
0
                                                     throw Exception(st.code(), st.to_string());
397
0
                                                 }
398
355
                                             }
399
3.39k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImEEEEEEvS3_
Line
Count
Source
383
851
                                         [&](auto& agg_method) -> void {
384
851
                                             auto& data = *agg_method.hash_table;
385
851
                                             data.for_each_mapped([&](auto& mapped) {
386
851
                                                 if (mapped) {
387
851
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
851
                                                     mapped = nullptr;
389
851
                                                 }
390
851
                                             });
391
851
                                             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
851
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32ISB_EEEEEEvS3_
Line
Count
Source
383
7.11k
                                         [&](auto& agg_method) -> void {
384
7.11k
                                             auto& data = *agg_method.hash_table;
385
7.11k
                                             data.for_each_mapped([&](auto& mapped) {
386
7.11k
                                                 if (mapped) {
387
7.11k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
7.11k
                                                     mapped = nullptr;
389
7.11k
                                                 }
390
7.11k
                                             });
391
7.11k
                                             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.11k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32ISB_EEEEEEvS3_
Line
Count
Source
383
9.98k
                                         [&](auto& agg_method) -> void {
384
9.98k
                                             auto& data = *agg_method.hash_table;
385
9.98k
                                             data.for_each_mapped([&](auto& mapped) {
386
9.98k
                                                 if (mapped) {
387
9.98k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
9.98k
                                                     mapped = nullptr;
389
9.98k
                                                 }
390
9.98k
                                             });
391
9.98k
                                             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.98k
                                         }},
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapINS6_7UInt136EPc9HashCRC32IS9_EEEEEEvS3_
Line
Count
Source
383
4.36k
                                         [&](auto& agg_method) -> void {
384
4.36k
                                             auto& data = *agg_method.hash_table;
385
4.36k
                                             data.for_each_mapped([&](auto& mapped) {
386
4.36k
                                                 if (mapped) {
387
4.36k
                                                     static_cast<void>(_destroy_agg_status(mapped));
388
4.36k
                                                     mapped = nullptr;
389
4.36k
                                                 }
390
4.36k
                                             });
391
4.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
4.36k
                                         }},
400
59.5k
                   agg_data->method_variant);
401
59.5k
    }
402
403
66.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
66.4k
        if (agg_data_created_without_key) {
408
66.4k
            static_cast<void>(_destroy_agg_status(agg_data->without_key));
409
66.4k
            agg_data_created_without_key = false;
410
66.4k
        }
411
66.3k
    }
412
    Status _destroy_agg_status(vectorized::AggregateDataPtr data);
413
};
414
415
struct BasicSpillSharedState {
416
209k
    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
209k
    void setup_shared_profile(RuntimeProfile* sink_profile) {
425
209k
        _spill_file_total_count =
426
209k
                ADD_COUNTER_WITH_LEVEL(sink_profile, "SpillWriteFileTotalCount", TUnit::UNIT, 1);
427
209k
        _spill_write_file_total_size =
428
209k
                ADD_COUNTER_WITH_LEVEL(sink_profile, "SpillWriteFileBytes", TUnit::BYTES, 1);
429
209k
    }
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
50.4k
    PartitionedAggSharedState() = default;
441
50.4k
    ~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
1.41M
    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.61M
    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
43.4k
    Status flush_if_full() {
472
43.4k
        DCHECK(spilling_stream_);
473
43.4k
        Status status;
474
        // avoid small spill files
475
43.4k
        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
43.4k
        return status;
480
43.4k
    }
481
482
540k
    Status finish_current_spilling(bool eos = false) {
483
540k
        if (spilling_stream_) {
484
64.5k
            if (eos || spilling_stream_->get_written_bytes() >= AGG_SPILL_FILE_SIZE) {
485
16.6k
                auto status = spilling_stream_->spill_eof();
486
16.6k
                spilling_stream_.reset();
487
16.6k
                return status;
488
16.6k
            }
489
64.5k
        }
490
523k
        return Status::OK();
491
540k
    }
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
138k
    SpillSortSharedState() = default;
509
138k
    ~SpillSortSharedState() override = default;
510
511
92.9k
    void update_spill_block_batch_row_count(RuntimeState* state, const vectorized::Block* block) {
512
92.9k
        auto rows = block->rows();
513
92.9k
        if (rows > 0 && 0 == avg_row_bytes) {
514
68.6k
            avg_row_bytes = std::max((std::size_t)1, block->bytes() / rows);
515
68.6k
            spill_block_batch_row_count =
516
68.6k
                    (state->spill_sort_batch_bytes() + avg_row_bytes - 1) / avg_row_bytes;
517
68.6k
            LOG(INFO) << "spill sort block batch row count: " << spill_block_batch_row_count;
518
68.6k
        }
519
92.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.01k
    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
10.1k
    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
4.48k
    HashJoinSharedState(int num_instances) {
591
4.48k
        source_deps.resize(num_instances, nullptr);
592
4.48k
        hash_table_variant_vector.resize(num_instances, nullptr);
593
17.6k
        for (int i = 0; i < num_instances; i++) {
594
13.1k
            hash_table_variant_vector[i] = std::make_shared<JoinDataVariants>();
595
13.1k
        }
596
4.48k
    }
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
18.6k
    void update_spill_stream_profiles(RuntimeProfile* source_profile) override {
622
596k
        for (auto& stream : spilled_streams) {
623
596k
            if (stream) {
624
596k
                stream->update_shared_profiles(source_profile);
625
596k
            }
626
596k
        }
627
18.6k
    }
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
111k
inline std::string get_exchange_type_name(ExchangeType idx) {
715
111k
    switch (idx) {
716
13
    case ExchangeType::NOOP:
717
13
        return "NOOP";
718
4.63k
    case ExchangeType::HASH_SHUFFLE:
719
4.63k
        return "HASH_SHUFFLE";
720
98.0k
    case ExchangeType::PASSTHROUGH:
721
98.0k
        return "PASSTHROUGH";
722
2.35k
    case ExchangeType::BUCKET_HASH_SHUFFLE:
723
2.35k
        return "BUCKET_HASH_SHUFFLE";
724
348
    case ExchangeType::BROADCAST:
725
348
        return "BROADCAST";
726
2.45k
    case ExchangeType::ADAPTIVE_PASSTHROUGH:
727
2.45k
        return "ADAPTIVE_PASSTHROUGH";
728
3.17k
    case ExchangeType::PASS_TO_ONE:
729
3.17k
        return "PASS_TO_ONE";
730
111k
    }
731
0
    throw Exception(Status::FatalError("__builtin_unreachable"));
732
111k
}
733
734
struct DataDistribution {
735
1.71M
    DataDistribution(ExchangeType type) : distribution_type(type) {}
736
    DataDistribution(ExchangeType type, const std::vector<TExpr>& partition_exprs_)
737
76.6k
            : distribution_type(type), partition_exprs(partition_exprs_) {}
738
126k
    DataDistribution(const DataDistribution& other) = default;
739
462k
    bool need_local_exchange() const { return distribution_type != ExchangeType::NOOP; }
740
526k
    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
671k
        for (auto& dep : source_deps) {
762
671k
            DCHECK(dep);
763
671k
            dep->set_always_ready();
764
671k
        }
765
110k
        for (auto& dep : sink_deps) {
766
110k
            DCHECK(dep);
767
110k
            dep->set_always_ready();
768
110k
        }
769
110k
    }
770
771
144k
    Dependency* get_sink_dep_by_channel_id(int channel_id) { return nullptr; }
772
773
260k
    void set_ready_to_read(int channel_id) {
774
260k
        auto& dep = source_deps[channel_id];
775
18.4E
        DCHECK(dep) << channel_id;
776
260k
        dep->set_ready();
777
260k
    }
778
779
260k
    void add_mem_usage(int channel_id, size_t delta) { mem_counters[channel_id]->update(delta); }
780
781
260k
    void sub_mem_usage(int channel_id, size_t delta) {
782
260k
        mem_counters[channel_id]->update(-(int64_t)delta);
783
260k
    }
784
785
209k
    void add_total_mem_usage(size_t delta) {
786
209k
        if (cast_set<int64_t>(mem_usage.fetch_add(delta) + delta) > _buffer_mem_limit) {
787
16
            sink_deps.front()->block();
788
16
        }
789
209k
    }
790
791
209k
    void sub_total_mem_usage(size_t delta) {
792
209k
        auto prev_usage = mem_usage.fetch_sub(delta);
793
209k
        DCHECK_GE(prev_usage - delta, 0) << "prev_usage: " << prev_usage << " delta: " << delta;
794
209k
        if (cast_set<int64_t>(prev_usage - delta) <= _buffer_mem_limit) {
795
209k
            sink_deps.front()->set_ready();
796
209k
        }
797
209k
    }
798
799
38.6k
    void set_low_memory_mode(RuntimeState* state) {
800
38.6k
        _buffer_mem_limit = std::min<int64_t>(config::local_exchange_buffer_mem_limit,
801
38.6k
                                              state->low_memory_mode_buffer_limit());
802
38.6k
    }
803
};
804
805
#include "common/compile_check_end.h"
806
} // namespace doris::pipeline