Coverage Report

Created: 2025-07-28 08:25

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