Coverage Report

Created: 2026-04-13 11:59

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