Coverage Report

Created: 2026-04-13 10:38

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.83M
    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.83M
        return reinterpret_cast<TARGET*>(this);
77
2.83M
    }
_ZN5doris16BasicSharedState4castINS_19HashJoinSharedStateEEEPT_v
Line
Count
Source
72
248k
    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
248k
        return reinterpret_cast<TARGET*>(this);
77
248k
    }
_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
514k
    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
514k
        return reinterpret_cast<TARGET*>(this);
77
514k
    }
_ZN5doris16BasicSharedState4castINS_20SpillSortSharedStateEEEPT_v
Line
Count
Source
72
50
    TARGET* cast() {
73
50
        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
50
        return reinterpret_cast<TARGET*>(this);
77
50
    }
_ZN5doris16BasicSharedState4castINS_25NestedLoopJoinSharedStateEEEPT_v
Line
Count
Source
72
19.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
19.1k
        return reinterpret_cast<TARGET*>(this);
77
19.1k
    }
_ZN5doris16BasicSharedState4castINS_19AnalyticSharedStateEEEPT_v
Line
Count
Source
72
15.4k
    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.4k
        return reinterpret_cast<TARGET*>(this);
77
15.4k
    }
_ZN5doris16BasicSharedState4castINS_14AggSharedStateEEEPT_v
Line
Count
Source
72
270k
    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
270k
        return reinterpret_cast<TARGET*>(this);
77
270k
    }
_ZN5doris16BasicSharedState4castINS_25PartitionedAggSharedStateEEEPT_v
Line
Count
Source
72
50
    TARGET* cast() {
73
50
        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
50
        return reinterpret_cast<TARGET*>(this);
77
50
    }
_ZN5doris16BasicSharedState4castINS_16UnionSharedStateEEEPT_v
Line
Count
Source
72
11.4k
    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.4k
        return reinterpret_cast<TARGET*>(this);
77
11.4k
    }
_ZN5doris16BasicSharedState4castINS_28PartitionSortNodeSharedStateEEEPT_v
Line
Count
Source
72
748
    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
748
        return reinterpret_cast<TARGET*>(this);
77
748
    }
_ZN5doris16BasicSharedState4castINS_20MultiCastSharedStateEEEPT_v
Line
Count
Source
72
16.7k
    TARGET* cast() {
73
18.4E
        DCHECK(dynamic_cast<TARGET*>(this))
74
18.4E
                << " Mismatch type! Current type is " << typeid(*this).name()
75
18.4E
                << " and expect type is" << typeid(TARGET).name();
76
16.7k
        return reinterpret_cast<TARGET*>(this);
77
16.7k
    }
_ZN5doris16BasicSharedState4castINS_14SetSharedStateEEEPT_v
Line
Count
Source
72
17.3k
    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.3k
        return reinterpret_cast<TARGET*>(this);
77
17.3k
    }
_ZN5doris16BasicSharedState4castINS_24LocalExchangeSharedStateEEEPT_v
Line
Count
Source
72
1.18M
    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.18M
        return reinterpret_cast<TARGET*>(this);
77
1.18M
    }
_ZN5doris16BasicSharedState4castIS0_EEPT_v
Line
Count
Source
72
539k
    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
539k
        return reinterpret_cast<TARGET*>(this);
77
539k
    }
_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
453
    TARGET* cast() {
73
453
        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
453
        return reinterpret_cast<TARGET*>(this);
77
453
    }
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.93M
    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
843k
    std::vector<DependencySPtr> get_dep_by_channel_id(int channel_id) {
98
843k
        DCHECK_LT(channel_id, source_deps.size());
99
843k
        return {source_deps[channel_id]};
100
843k
    }
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
7.08M
            : _id(id), _node_id(node_id), _name(std::move(name)), _ready(ready) {}
108
7.13M
    virtual ~Dependency() = default;
109
110
0
    [[nodiscard]] int id() const { return _id; }
111
8.76M
    [[nodiscard]] virtual std::string name() const { return _name; }
112
384k
    BasicSharedState* shared_state() { return _shared_state; }
113
2.65M
    void set_shared_state(BasicSharedState* shared_state) { _shared_state = shared_state; }
114
    virtual std::string debug_string(int indentation_level = 0);
115
998M
    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.46M
    void start_watcher() { _watcher.start(); }
119
9.45M
    [[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
548k
    void set_ready_to_read(int channel_id = 0) {
126
548k
        DCHECK_LT(channel_id, _shared_state->source_deps.size()) << debug_string();
127
548k
        _shared_state->source_deps[channel_id]->set_ready();
128
548k
    }
129
959
    void set_ready_to_write() {
130
959
        DCHECK_EQ(_shared_state->sink_deps.size(), 1) << debug_string();
131
959
        _shared_state->sink_deps.front()->set_ready();
132
959
    }
133
134
    // Notify downstream pipeline tasks this dependency is blocked.
135
1.71M
    void block() {
136
1.71M
        if (_always_ready) {
137
296k
            return;
138
296k
        }
139
1.42M
        std::unique_lock<std::mutex> lc(_always_ready_lock);
140
1.42M
        if (_always_ready) {
141
1
            return;
142
1
        }
143
1.42M
        _ready = false;
144
1.42M
    }
145
146
4.51M
    void set_always_ready() {
147
4.51M
        if (_always_ready) {
148
2.02M
            return;
149
2.02M
        }
150
2.49M
        std::unique_lock<std::mutex> lc(_always_ready_lock);
151
2.49M
        if (_always_ready) {
152
1
            return;
153
1
        }
154
2.49M
        _always_ready = true;
155
2.49M
        set_ready();
156
2.49M
    }
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
177k
            : Dependency(id, node_id, std::move(name), true) {}
186
187
12.9k
    void add(uint32_t count = 1) {
188
12.9k
        std::unique_lock<std::mutex> l(_mtx);
189
12.9k
        if (!_counter) {
190
12.9k
            block();
191
12.9k
        }
192
12.9k
        _counter += count;
193
12.9k
    }
194
195
12.9k
    void sub() {
196
12.9k
        std::unique_lock<std::mutex> l(_mtx);
197
12.9k
        _counter--;
198
12.9k
        if (!_counter) {
199
12.9k
            set_ready();
200
12.9k
        }
201
12.9k
    }
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
41.5k
            : _parent(std::move(parent)),
216
41.5k
              _registration_time(registration_time),
217
41.5k
              _wait_time_ms(wait_time_ms),
218
41.5k
              _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
4.46M
    int64_t registration_time() const { return _registration_time; }
227
4.46M
    int32_t wait_time_ms() const { return _wait_time_ms; }
228
229
    void set_local_runtime_filter_dependencies(
230
5.21k
            const std::vector<std::shared_ptr<Dependency>>& deps) {
231
5.21k
        _local_runtime_filter_dependencies = deps;
232
5.21k
    }
233
234
    bool should_be_check_timeout();
235
236
4.50M
    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
6
    void run() { _thread.detach(); }
252
    void start();
253
254
2
    void stop() {
255
2
        _stop = true;
256
2
        cv.notify_all();
257
2
        wait_for_shutdown();
258
2
    }
259
260
2
    void wait_for_shutdown() const {
261
4
        while (!_shutdown) {
262
2
            std::this_thread::sleep_for(std::chrono::milliseconds(interval));
263
2
        }
264
2
    }
265
266
2
    ~RuntimeFilterTimerQueue() = default;
267
6
    RuntimeFilterTimerQueue() { _thread = std::thread(&RuntimeFilterTimerQueue::start, this); }
268
27.2k
    void push_filter_timer(std::vector<std::shared_ptr<RuntimeFilterTimer>>&& filter) {
269
27.2k
        std::unique_lock<std::mutex> lc(_que_lock);
270
27.2k
        _que.insert(_que.end(), filter.begin(), filter.end());
271
27.2k
        cv.notify_all();
272
27.2k
    }
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
136k
    AggSharedState() { agg_data = std::make_unique<AggregatedDataVariants>(); }
287
136k
    ~AggSharedState() override {
288
136k
        if (!probe_expr_ctxs.empty()) {
289
46.1k
            _close_with_serialized_key();
290
89.8k
        } else {
291
89.8k
            _close_without_key();
292
89.8k
        }
293
136k
    }
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
37.8k
                : _row_id(row_id),
337
37.8k
                  _limit_columns(limit_columns),
338
37.8k
                  _order_directions(order_directions),
339
37.8k
                  _null_directions(null_directions) {}
340
341
        HeapLimitCursor(const HeapLimitCursor& other) = default;
342
343
        HeapLimitCursor(HeapLimitCursor&& other) noexcept
344
242k
                : _row_id(other._row_id),
345
242k
                  _limit_columns(other._limit_columns),
346
242k
                  _order_directions(other._order_directions),
347
242k
                  _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
456k
        HeapLimitCursor& operator=(HeapLimitCursor&& other) noexcept {
355
456k
            _row_id = other._row_id;
356
456k
            return *this;
357
456k
        }
358
359
418k
        bool operator<(const HeapLimitCursor& rhs) const {
360
524k
            for (int i = 0; i < _limit_columns.size(); ++i) {
361
524k
                const auto& _limit_column = _limit_columns[i];
362
524k
                auto res = _limit_column->compare_at(_row_id, rhs._row_id, *_limit_column,
363
524k
                                                     _null_directions[i]) *
364
524k
                           _order_directions[i];
365
524k
                if (res < 0) {
366
228k
                    return true;
367
296k
                } else if (res > 0) {
368
195k
                    return false;
369
195k
                }
370
524k
            }
371
18.4E
            return false;
372
418k
        }
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.0k
    void _close_with_serialized_key() {
392
46.0k
        std::visit(Overload {[&](std::monostate& arg) -> void {
393
                                 // Do nothing
394
0
                             },
395
46.1k
                             [&](auto& agg_method) -> void {
396
46.1k
                                 if (use_simple_count) {
397
                                     // Inline count: mapped slots hold UInt64,
398
                                     // not real agg state pointers. Skip destroy.
399
4.12k
                                     return;
400
4.12k
                                 }
401
41.9k
                                 auto& data = *agg_method.hash_table;
402
1.15M
                                 data.for_each_mapped([&](auto& mapped) {
403
1.15M
                                     if (mapped) {
404
1.15M
                                         _destroy_agg_status(mapped);
405
1.15M
                                         mapped = nullptr;
406
1.15M
                                     }
407
1.15M
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS9_EEEEEEvS2_ENKUlS2_E_clISA_EEDaS2_
Line
Count
Source
402
4.58k
                                 data.for_each_mapped([&](auto& mapped) {
403
4.58k
                                     if (mapped) {
404
4.58k
                                         _destroy_agg_status(mapped);
405
4.58k
                                         mapped = nullptr;
406
4.58k
                                     }
407
4.58k
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapINS_7UInt136EPc9HashCRC32IS7_EEEEEEvS2_ENKUlS2_E_clIS8_EEDaS2_
Line
Count
Source
402
1.43k
                                 data.for_each_mapped([&](auto& mapped) {
403
1.43k
                                     if (mapped) {
404
1.43k
                                         _destroy_agg_status(mapped);
405
1.43k
                                         mapped = nullptr;
406
1.43k
                                     }
407
1.43k
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS9_EEEEEEvS2_ENKUlS2_E_clISA_EEDaS2_
Line
Count
Source
402
13.1k
                                 data.for_each_mapped([&](auto& mapped) {
403
13.1k
                                     if (mapped) {
404
13.1k
                                         _destroy_agg_status(mapped);
405
13.1k
                                         mapped = nullptr;
406
13.1k
                                     }
407
13.1k
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapINS_7UInt104EPc9HashCRC32IS7_EEEEEEvS2_ENKUlS2_E_clIS8_EEDaS2_
Line
Count
Source
402
573
                                 data.for_each_mapped([&](auto& mapped) {
403
573
                                     if (mapped) {
404
573
                                         _destroy_agg_status(mapped);
405
573
                                         mapped = nullptr;
406
573
                                     }
407
573
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapINS_6UInt96EPc9HashCRC32IS7_EEEEEEvS2_ENKUlS2_E_clIS8_EEDaS2_
Line
Count
Source
402
8.92k
                                 data.for_each_mapped([&](auto& mapped) {
403
8.92k
                                     if (mapped) {
404
8.92k
                                         _destroy_agg_status(mapped);
405
8.92k
                                         mapped = nullptr;
406
8.92k
                                     }
407
8.92k
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapINS_6UInt72EPc9HashCRC32IS7_EEEEEEvS2_ENKUlS2_E_clIS8_EEDaS2_
Line
Count
Source
402
781
                                 data.for_each_mapped([&](auto& mapped) {
403
781
                                     if (mapped) {
404
781
                                         _destroy_agg_status(mapped);
405
781
                                         mapped = nullptr;
406
781
                                     }
407
781
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImEEEEEEvS2_ENKUlS2_E_clIS7_EEDaS2_
Line
Count
Source
402
186k
                                 data.for_each_mapped([&](auto& mapped) {
403
186k
                                     if (mapped) {
404
186k
                                         _destroy_agg_status(mapped);
405
186k
                                         mapped = nullptr;
406
186k
                                     }
407
186k
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_19MethodStringNoCacheINS_15DataWithNullKeyINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEEEEEvS2_ENKUlS2_E_clIS9_EEDaS2_
Line
Count
Source
402
4.13k
                                 data.for_each_mapped([&](auto& mapped) {
403
4.13k
                                     if (mapped) {
404
4.13k
                                         _destroy_agg_status(mapped);
405
4.13k
                                         mapped = nullptr;
406
4.13k
                                     }
407
4.13k
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm256EjEENS_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEEvS2_ENKUlS2_E_clISC_EEDaS2_
Line
Count
Source
402
9
                                 data.for_each_mapped([&](auto& mapped) {
403
9
                                     if (mapped) {
404
9
                                         _destroy_agg_status(mapped);
405
9
                                         mapped = nullptr;
406
9
                                     }
407
9
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEEvS2_ENKUlS2_E_clISC_EEDaS2_
Line
Count
Source
402
180
                                 data.for_each_mapped([&](auto& mapped) {
403
180
                                     if (mapped) {
404
180
                                         _destroy_agg_status(mapped);
405
180
                                         mapped = nullptr;
406
180
                                     }
407
180
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEvS2_ENKUlS2_E_clIS9_EEDaS2_
Line
Count
Source
402
115k
                                 data.for_each_mapped([&](auto& mapped) {
403
115k
                                     if (mapped) {
404
115k
                                         _destroy_agg_status(mapped);
405
115k
                                         mapped = nullptr;
406
115k
                                     }
407
115k
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEvS2_ENKUlS2_E_clIS9_EEDaS2_
Line
Count
Source
402
109k
                                 data.for_each_mapped([&](auto& mapped) {
403
109k
                                     if (mapped) {
404
109k
                                         _destroy_agg_status(mapped);
405
109k
                                         mapped = nullptr;
406
109k
                                     }
407
109k
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEvS2_ENKUlS2_E_clIS9_EEDaS2_
Line
Count
Source
402
508
                                 data.for_each_mapped([&](auto& mapped) {
403
508
                                     if (mapped) {
404
508
                                         _destroy_agg_status(mapped);
405
508
                                         mapped = nullptr;
406
508
                                     }
407
508
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEvS2_ENKUlS2_E_clIS9_EEDaS2_
Line
Count
Source
402
13.7k
                                 data.for_each_mapped([&](auto& mapped) {
403
13.7k
                                     if (mapped) {
404
13.7k
                                         _destroy_agg_status(mapped);
405
13.7k
                                         mapped = nullptr;
406
13.7k
                                     }
407
13.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.58k
                                 data.for_each_mapped([&](auto& mapped) {
403
2.58k
                                     if (mapped) {
404
2.58k
                                         _destroy_agg_status(mapped);
405
2.58k
                                         mapped = nullptr;
406
2.58k
                                     }
407
2.58k
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEvS2_ENKUlS2_E_clIS7_EEDaS2_
Line
Count
Source
402
20.2k
                                 data.for_each_mapped([&](auto& mapped) {
403
20.2k
                                     if (mapped) {
404
20.2k
                                         _destroy_agg_status(mapped);
405
20.2k
                                         mapped = nullptr;
406
20.2k
                                     }
407
20.2k
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEvS2_ENKUlS2_E_clIS7_EEDaS2_
Line
Count
Source
402
575k
                                 data.for_each_mapped([&](auto& mapped) {
403
576k
                                     if (mapped) {
404
576k
                                         _destroy_agg_status(mapped);
405
576k
                                         mapped = nullptr;
406
576k
                                     }
407
575k
                                 });
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
93
                                 data.for_each_mapped([&](auto& mapped) {
403
93
                                     if (mapped) {
404
93
                                         _destroy_agg_status(mapped);
405
93
                                         mapped = nullptr;
406
93
                                     }
407
93
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEvS2_ENKUlS2_E_clIS7_EEDaS2_
Line
Count
Source
402
812
                                 data.for_each_mapped([&](auto& mapped) {
403
812
                                     if (mapped) {
404
812
                                         _destroy_agg_status(mapped);
405
812
                                         mapped = nullptr;
406
812
                                     }
407
812
                                 });
_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
4.13k
                                 data.for_each_mapped([&](auto& mapped) {
403
4.13k
                                     if (mapped) {
404
4.13k
                                         _destroy_agg_status(mapped);
405
4.13k
                                         mapped = nullptr;
406
4.13k
                                     }
407
4.13k
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEvS2_ENKUlS2_E_clIS7_EEDaS2_
Line
Count
Source
402
38
                                 data.for_each_mapped([&](auto& mapped) {
403
38
                                     if (mapped) {
404
38
                                         _destroy_agg_status(mapped);
405
38
                                         mapped = nullptr;
406
38
                                     }
407
38
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEvS2_ENKUlS2_E_clIS7_EEDaS2_
Line
Count
Source
402
939
                                 data.for_each_mapped([&](auto& mapped) {
403
939
                                     if (mapped) {
404
938
                                         _destroy_agg_status(mapped);
405
938
                                         mapped = nullptr;
406
938
                                     }
407
939
                                 });
_ZZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS7_vEEEEEEvS2_ENKUlS2_E_clIS8_EEDaS2_
Line
Count
Source
402
80.9k
                                 data.for_each_mapped([&](auto& mapped) {
403
80.9k
                                     if (mapped) {
404
80.9k
                                         _destroy_agg_status(mapped);
405
80.9k
                                         mapped = nullptr;
406
80.9k
                                     }
407
80.9k
                                 });
408
41.9k
                                 if (data.has_null_key_data()) {
409
1.18k
                                     _destroy_agg_status(
410
1.18k
                                             data.template get_null_key_data<AggregateDataPtr>());
411
1.18k
                                 }
412
41.9k
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS9_EEEEEEvS2_
Line
Count
Source
395
2.77k
                             [&](auto& agg_method) -> void {
396
2.77k
                                 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
2.73k
                                 auto& data = *agg_method.hash_table;
402
2.73k
                                 data.for_each_mapped([&](auto& mapped) {
403
2.73k
                                     if (mapped) {
404
2.73k
                                         _destroy_agg_status(mapped);
405
2.73k
                                         mapped = nullptr;
406
2.73k
                                     }
407
2.73k
                                 });
408
2.73k
                                 if (data.has_null_key_data()) {
409
0
                                     _destroy_agg_status(
410
0
                                             data.template get_null_key_data<AggregateDataPtr>());
411
0
                                 }
412
2.73k
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapINS_7UInt136EPc9HashCRC32IS7_EEEEEEvS2_
Line
Count
Source
395
1.92k
                             [&](auto& agg_method) -> void {
396
1.92k
                                 if (use_simple_count) {
397
                                     // Inline count: mapped slots hold UInt64,
398
                                     // not real agg state pointers. Skip destroy.
399
120
                                     return;
400
120
                                 }
401
1.80k
                                 auto& data = *agg_method.hash_table;
402
1.80k
                                 data.for_each_mapped([&](auto& mapped) {
403
1.80k
                                     if (mapped) {
404
1.80k
                                         _destroy_agg_status(mapped);
405
1.80k
                                         mapped = nullptr;
406
1.80k
                                     }
407
1.80k
                                 });
408
1.80k
                                 if (data.has_null_key_data()) {
409
0
                                     _destroy_agg_status(
410
0
                                             data.template get_null_key_data<AggregateDataPtr>());
411
0
                                 }
412
1.80k
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS9_EEEEEEvS2_
Line
Count
Source
395
161
                             [&](auto& agg_method) -> void {
396
161
                                 if (use_simple_count) {
397
                                     // Inline count: mapped slots hold UInt64,
398
                                     // not real agg state pointers. Skip destroy.
399
17
                                     return;
400
17
                                 }
401
144
                                 auto& data = *agg_method.hash_table;
402
144
                                 data.for_each_mapped([&](auto& mapped) {
403
144
                                     if (mapped) {
404
144
                                         _destroy_agg_status(mapped);
405
144
                                         mapped = nullptr;
406
144
                                     }
407
144
                                 });
408
144
                                 if (data.has_null_key_data()) {
409
0
                                     _destroy_agg_status(
410
0
                                             data.template get_null_key_data<AggregateDataPtr>());
411
0
                                 }
412
144
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapINS_7UInt104EPc9HashCRC32IS7_EEEEEEvS2_
Line
Count
Source
395
954
                             [&](auto& agg_method) -> void {
396
954
                                 if (use_simple_count) {
397
                                     // Inline count: mapped slots hold UInt64,
398
                                     // not real agg state pointers. Skip destroy.
399
61
                                     return;
400
61
                                 }
401
893
                                 auto& data = *agg_method.hash_table;
402
893
                                 data.for_each_mapped([&](auto& mapped) {
403
893
                                     if (mapped) {
404
893
                                         _destroy_agg_status(mapped);
405
893
                                         mapped = nullptr;
406
893
                                     }
407
893
                                 });
408
893
                                 if (data.has_null_key_data()) {
409
0
                                     _destroy_agg_status(
410
0
                                             data.template get_null_key_data<AggregateDataPtr>());
411
0
                                 }
412
893
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapINS_6UInt96EPc9HashCRC32IS7_EEEEEEvS2_
Line
Count
Source
395
652
                             [&](auto& agg_method) -> void {
396
652
                                 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
652
                                 auto& data = *agg_method.hash_table;
402
652
                                 data.for_each_mapped([&](auto& mapped) {
403
652
                                     if (mapped) {
404
652
                                         _destroy_agg_status(mapped);
405
652
                                         mapped = nullptr;
406
652
                                     }
407
652
                                 });
408
652
                                 if (data.has_null_key_data()) {
409
0
                                     _destroy_agg_status(
410
0
                                             data.template get_null_key_data<AggregateDataPtr>());
411
0
                                 }
412
652
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapINS_6UInt72EPc9HashCRC32IS7_EEEEEEvS2_
Line
Count
Source
395
1.27k
                             [&](auto& agg_method) -> void {
396
1.27k
                                 if (use_simple_count) {
397
                                     // Inline count: mapped slots hold UInt64,
398
                                     // not real agg state pointers. Skip destroy.
399
75
                                     return;
400
75
                                 }
401
1.19k
                                 auto& data = *agg_method.hash_table;
402
1.19k
                                 data.for_each_mapped([&](auto& mapped) {
403
1.19k
                                     if (mapped) {
404
1.19k
                                         _destroy_agg_status(mapped);
405
1.19k
                                         mapped = nullptr;
406
1.19k
                                     }
407
1.19k
                                 });
408
1.19k
                                 if (data.has_null_key_data()) {
409
0
                                     _destroy_agg_status(
410
0
                                             data.template get_null_key_data<AggregateDataPtr>());
411
0
                                 }
412
1.19k
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImEEEEEEvS2_
Line
Count
Source
395
944
                             [&](auto& agg_method) -> void {
396
944
                                 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
917
                                 auto& data = *agg_method.hash_table;
402
917
                                 data.for_each_mapped([&](auto& mapped) {
403
917
                                     if (mapped) {
404
917
                                         _destroy_agg_status(mapped);
405
917
                                         mapped = nullptr;
406
917
                                     }
407
917
                                 });
408
917
                                 if (data.has_null_key_data()) {
409
0
                                     _destroy_agg_status(
410
0
                                             data.template get_null_key_data<AggregateDataPtr>());
411
0
                                 }
412
917
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_19MethodStringNoCacheINS_15DataWithNullKeyINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEEEEEvS2_
Line
Count
Source
395
3.13k
                             [&](auto& agg_method) -> void {
396
3.13k
                                 if (use_simple_count) {
397
                                     // Inline count: mapped slots hold UInt64,
398
                                     // not real agg state pointers. Skip destroy.
399
613
                                     return;
400
613
                                 }
401
2.51k
                                 auto& data = *agg_method.hash_table;
402
2.51k
                                 data.for_each_mapped([&](auto& mapped) {
403
2.51k
                                     if (mapped) {
404
2.51k
                                         _destroy_agg_status(mapped);
405
2.51k
                                         mapped = nullptr;
406
2.51k
                                     }
407
2.51k
                                 });
408
2.51k
                                 if (data.has_null_key_data()) {
409
57
                                     _destroy_agg_status(
410
57
                                             data.template get_null_key_data<AggregateDataPtr>());
411
57
                                 }
412
2.51k
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm256EjEENS_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEEvS2_
Line
Count
Source
395
12
                             [&](auto& agg_method) -> void {
396
12
                                 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
12
                                 auto& data = *agg_method.hash_table;
402
12
                                 data.for_each_mapped([&](auto& mapped) {
403
12
                                     if (mapped) {
404
12
                                         _destroy_agg_status(mapped);
405
12
                                         mapped = nullptr;
406
12
                                     }
407
12
                                 });
408
12
                                 if (data.has_null_key_data()) {
409
0
                                     _destroy_agg_status(
410
0
                                             data.template get_null_key_data<AggregateDataPtr>());
411
0
                                 }
412
12
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEEvS2_
Line
Count
Source
395
356
                             [&](auto& agg_method) -> void {
396
356
                                 if (use_simple_count) {
397
                                     // Inline count: mapped slots hold UInt64,
398
                                     // not real agg state pointers. Skip destroy.
399
2
                                     return;
400
2
                                 }
401
354
                                 auto& data = *agg_method.hash_table;
402
354
                                 data.for_each_mapped([&](auto& mapped) {
403
354
                                     if (mapped) {
404
354
                                         _destroy_agg_status(mapped);
405
354
                                         mapped = nullptr;
406
354
                                     }
407
354
                                 });
408
354
                                 if (data.has_null_key_data()) {
409
2
                                     _destroy_agg_status(
410
2
                                             data.template get_null_key_data<AggregateDataPtr>());
411
2
                                 }
412
354
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEvS2_
Line
Count
Source
395
5.09k
                             [&](auto& agg_method) -> void {
396
5.09k
                                 if (use_simple_count) {
397
                                     // Inline count: mapped slots hold UInt64,
398
                                     // not real agg state pointers. Skip destroy.
399
773
                                     return;
400
773
                                 }
401
4.32k
                                 auto& data = *agg_method.hash_table;
402
4.32k
                                 data.for_each_mapped([&](auto& mapped) {
403
4.32k
                                     if (mapped) {
404
4.32k
                                         _destroy_agg_status(mapped);
405
4.32k
                                         mapped = nullptr;
406
4.32k
                                     }
407
4.32k
                                 });
408
4.32k
                                 if (data.has_null_key_data()) {
409
152
                                     _destroy_agg_status(
410
152
                                             data.template get_null_key_data<AggregateDataPtr>());
411
152
                                 }
412
4.32k
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEvS2_
Line
Count
Source
395
10.2k
                             [&](auto& agg_method) -> void {
396
10.2k
                                 if (use_simple_count) {
397
                                     // Inline count: mapped slots hold UInt64,
398
                                     // not real agg state pointers. Skip destroy.
399
779
                                     return;
400
779
                                 }
401
9.48k
                                 auto& data = *agg_method.hash_table;
402
9.48k
                                 data.for_each_mapped([&](auto& mapped) {
403
9.48k
                                     if (mapped) {
404
9.48k
                                         _destroy_agg_status(mapped);
405
9.48k
                                         mapped = nullptr;
406
9.48k
                                     }
407
9.48k
                                 });
408
9.48k
                                 if (data.has_null_key_data()) {
409
398
                                     _destroy_agg_status(
410
398
                                             data.template get_null_key_data<AggregateDataPtr>());
411
398
                                 }
412
9.48k
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEvS2_
Line
Count
Source
395
621
                             [&](auto& agg_method) -> void {
396
621
                                 if (use_simple_count) {
397
                                     // Inline count: mapped slots hold UInt64,
398
                                     // not real agg state pointers. Skip destroy.
399
99
                                     return;
400
99
                                 }
401
522
                                 auto& data = *agg_method.hash_table;
402
522
                                 data.for_each_mapped([&](auto& mapped) {
403
522
                                     if (mapped) {
404
522
                                         _destroy_agg_status(mapped);
405
522
                                         mapped = nullptr;
406
522
                                     }
407
522
                                 });
408
522
                                 if (data.has_null_key_data()) {
409
38
                                     _destroy_agg_status(
410
38
                                             data.template get_null_key_data<AggregateDataPtr>());
411
38
                                 }
412
522
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEvS2_
Line
Count
Source
395
913
                             [&](auto& agg_method) -> void {
396
913
                                 if (use_simple_count) {
397
                                     // Inline count: mapped slots hold UInt64,
398
                                     // not real agg state pointers. Skip destroy.
399
13
                                     return;
400
13
                                 }
401
900
                                 auto& data = *agg_method.hash_table;
402
900
                                 data.for_each_mapped([&](auto& mapped) {
403
900
                                     if (mapped) {
404
900
                                         _destroy_agg_status(mapped);
405
900
                                         mapped = nullptr;
406
900
                                     }
407
900
                                 });
408
900
                                 if (data.has_null_key_data()) {
409
14
                                     _destroy_agg_status(
410
14
                                             data.template get_null_key_data<AggregateDataPtr>());
411
14
                                 }
412
900
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberItNS_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEvS2_
Line
Count
Source
395
456
                             [&](auto& agg_method) -> void {
396
456
                                 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
446
                                 auto& data = *agg_method.hash_table;
402
446
                                 data.for_each_mapped([&](auto& mapped) {
403
446
                                     if (mapped) {
404
446
                                         _destroy_agg_status(mapped);
405
446
                                         mapped = nullptr;
406
446
                                     }
407
446
                                 });
408
446
                                 if (data.has_null_key_data()) {
409
21
                                     _destroy_agg_status(
410
21
                                             data.template get_null_key_data<AggregateDataPtr>());
411
21
                                 }
412
446
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIhNS_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEvS2_
Line
Count
Source
395
2.77k
                             [&](auto& agg_method) -> void {
396
2.77k
                                 if (use_simple_count) {
397
                                     // Inline count: mapped slots hold UInt64,
398
                                     // not real agg state pointers. Skip destroy.
399
284
                                     return;
400
284
                                 }
401
2.49k
                                 auto& data = *agg_method.hash_table;
402
2.49k
                                 data.for_each_mapped([&](auto& mapped) {
403
2.49k
                                     if (mapped) {
404
2.49k
                                         _destroy_agg_status(mapped);
405
2.49k
                                         mapped = nullptr;
406
2.49k
                                     }
407
2.49k
                                 });
408
2.49k
                                 if (data.has_null_key_data()) {
409
504
                                     _destroy_agg_status(
410
504
                                             data.template get_null_key_data<AggregateDataPtr>());
411
504
                                 }
412
2.49k
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEvS2_
Line
Count
Source
395
1.36k
                             [&](auto& agg_method) -> void {
396
1.36k
                                 if (use_simple_count) {
397
                                     // Inline count: mapped slots hold UInt64,
398
                                     // not real agg state pointers. Skip destroy.
399
465
                                     return;
400
465
                                 }
401
903
                                 auto& data = *agg_method.hash_table;
402
903
                                 data.for_each_mapped([&](auto& mapped) {
403
903
                                     if (mapped) {
404
903
                                         _destroy_agg_status(mapped);
405
903
                                         mapped = nullptr;
406
903
                                     }
407
903
                                 });
408
903
                                 if (data.has_null_key_data()) {
409
0
                                     _destroy_agg_status(
410
0
                                             data.template get_null_key_data<AggregateDataPtr>());
411
0
                                 }
412
903
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEvS2_
Line
Count
Source
395
2.36k
                             [&](auto& agg_method) -> void {
396
2.36k
                                 if (use_simple_count) {
397
                                     // Inline count: mapped slots hold UInt64,
398
                                     // not real agg state pointers. Skip destroy.
399
45
                                     return;
400
45
                                 }
401
2.31k
                                 auto& data = *agg_method.hash_table;
402
2.31k
                                 data.for_each_mapped([&](auto& mapped) {
403
2.31k
                                     if (mapped) {
404
2.31k
                                         _destroy_agg_status(mapped);
405
2.31k
                                         mapped = nullptr;
406
2.31k
                                     }
407
2.31k
                                 });
408
2.31k
                                 if (data.has_null_key_data()) {
409
0
                                     _destroy_agg_status(
410
0
                                             data.template get_null_key_data<AggregateDataPtr>());
411
0
                                 }
412
2.31k
                             }},
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
114
                             [&](auto& agg_method) -> void {
396
114
                                 if (use_simple_count) {
397
                                     // Inline count: mapped slots hold UInt64,
398
                                     // not real agg state pointers. Skip destroy.
399
7
                                     return;
400
7
                                 }
401
107
                                 auto& data = *agg_method.hash_table;
402
107
                                 data.for_each_mapped([&](auto& mapped) {
403
107
                                     if (mapped) {
404
107
                                         _destroy_agg_status(mapped);
405
107
                                         mapped = nullptr;
406
107
                                     }
407
107
                                 });
408
107
                                 if (data.has_null_key_data()) {
409
0
                                     _destroy_agg_status(
410
0
                                             data.template get_null_key_data<AggregateDataPtr>());
411
0
                                 }
412
107
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEvS2_
Line
Count
Source
395
643
                             [&](auto& agg_method) -> void {
396
643
                                 if (use_simple_count) {
397
                                     // Inline count: mapped slots hold UInt64,
398
                                     // not real agg state pointers. Skip destroy.
399
100
                                     return;
400
100
                                 }
401
543
                                 auto& data = *agg_method.hash_table;
402
543
                                 data.for_each_mapped([&](auto& mapped) {
403
543
                                     if (mapped) {
404
543
                                         _destroy_agg_status(mapped);
405
543
                                         mapped = nullptr;
406
543
                                     }
407
543
                                 });
408
543
                                 if (data.has_null_key_data()) {
409
0
                                     _destroy_agg_status(
410
0
                                             data.template get_null_key_data<AggregateDataPtr>());
411
0
                                 }
412
543
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEEvS2_
Line
Count
Source
395
206
                             [&](auto& agg_method) -> void {
396
206
                                 if (use_simple_count) {
397
                                     // Inline count: mapped slots hold UInt64,
398
                                     // not real agg state pointers. Skip destroy.
399
73
                                     return;
400
73
                                 }
401
133
                                 auto& data = *agg_method.hash_table;
402
133
                                 data.for_each_mapped([&](auto& mapped) {
403
133
                                     if (mapped) {
404
133
                                         _destroy_agg_status(mapped);
405
133
                                         mapped = nullptr;
406
133
                                     }
407
133
                                 });
408
133
                                 if (data.has_null_key_data()) {
409
0
                                     _destroy_agg_status(
410
0
                                             data.template get_null_key_data<AggregateDataPtr>());
411
0
                                 }
412
133
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEEvS2_
Line
Count
Source
395
251
                             [&](auto& agg_method) -> void {
396
251
                                 if (use_simple_count) {
397
                                     // Inline count: mapped slots hold UInt64,
398
                                     // not real agg state pointers. Skip destroy.
399
15
                                     return;
400
15
                                 }
401
236
                                 auto& data = *agg_method.hash_table;
402
236
                                 data.for_each_mapped([&](auto& mapped) {
403
236
                                     if (mapped) {
404
236
                                         _destroy_agg_status(mapped);
405
236
                                         mapped = nullptr;
406
236
                                     }
407
236
                                 });
408
236
                                 if (data.has_null_key_data()) {
409
0
                                     _destroy_agg_status(
410
0
                                             data.template get_null_key_data<AggregateDataPtr>());
411
0
                                 }
412
236
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEvS2_
Line
Count
Source
395
42
                             [&](auto& agg_method) -> void {
396
42
                                 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
42
                                 auto& data = *agg_method.hash_table;
402
42
                                 data.for_each_mapped([&](auto& mapped) {
403
42
                                     if (mapped) {
404
42
                                         _destroy_agg_status(mapped);
405
42
                                         mapped = nullptr;
406
42
                                     }
407
42
                                 });
408
42
                                 if (data.has_null_key_data()) {
409
0
                                     _destroy_agg_status(
410
0
                                             data.template get_null_key_data<AggregateDataPtr>());
411
0
                                 }
412
42
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEvS2_
Line
Count
Source
395
760
                             [&](auto& agg_method) -> void {
396
760
                                 if (use_simple_count) {
397
                                     // Inline count: mapped slots hold UInt64,
398
                                     // not real agg state pointers. Skip destroy.
399
16
                                     return;
400
16
                                 }
401
744
                                 auto& data = *agg_method.hash_table;
402
744
                                 data.for_each_mapped([&](auto& mapped) {
403
744
                                     if (mapped) {
404
744
                                         _destroy_agg_status(mapped);
405
744
                                         mapped = nullptr;
406
744
                                     }
407
744
                                 });
408
744
                                 if (data.has_null_key_data()) {
409
0
                                     _destroy_agg_status(
410
0
                                             data.template get_null_key_data<AggregateDataPtr>());
411
0
                                 }
412
744
                             }},
_ZZN5doris14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS7_vEEEEEEvS2_
Line
Count
Source
395
8.07k
                             [&](auto& agg_method) -> void {
396
8.07k
                                 if (use_simple_count) {
397
                                     // Inline count: mapped slots hold UInt64,
398
                                     // not real agg state pointers. Skip destroy.
399
492
                                     return;
400
492
                                 }
401
7.57k
                                 auto& data = *agg_method.hash_table;
402
7.57k
                                 data.for_each_mapped([&](auto& mapped) {
403
7.57k
                                     if (mapped) {
404
7.57k
                                         _destroy_agg_status(mapped);
405
7.57k
                                         mapped = nullptr;
406
7.57k
                                     }
407
7.57k
                                 });
408
7.57k
                                 if (data.has_null_key_data()) {
409
0
                                     _destroy_agg_status(
410
0
                                             data.template get_null_key_data<AggregateDataPtr>());
411
0
                                 }
412
7.57k
                             }},
413
46.0k
                   agg_data->method_variant);
414
46.0k
    }
415
416
89.9k
    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
90.0k
        if (agg_data_created_without_key) {
421
90.0k
            _destroy_agg_status(agg_data->without_key);
422
90.0k
            agg_data_created_without_key = false;
423
90.0k
        }
424
89.9k
    }
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
50
    PartitionedAggSharedState() = default;
433
50
    ~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
30
    SpillSortSharedState() = default;
456
29
    ~SpillSortSharedState() override = default;
457
458
433
    void update_spill_block_batch_row_count(RuntimeState* state, const Block* block) {
459
433
        auto rows = block->rows();
460
433
        if (rows > 0 && 0 == avg_row_bytes) {
461
15
            avg_row_bytes = std::max((std::size_t)1, block->bytes() / rows);
462
15
            spill_block_batch_row_count =
463
15
                    (state->spill_buffer_size_bytes() + avg_row_bytes - 1) / avg_row_bytes;
464
15
            LOG(INFO) << "spill sort block batch row count: " << spill_block_batch_row_count;
465
15
        }
466
433
    }
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.71k
    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
7.80k
    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
130k
    HashJoinSharedState() {
534
130k
        hash_table_variant_vector.push_back(std::make_shared<JoinDataVariants>());
535
130k
    }
536
3.22k
    HashJoinSharedState(int num_instances) {
537
3.22k
        source_deps.resize(num_instances, nullptr);
538
3.22k
        hash_table_variant_vector.resize(num_instances, nullptr);
539
22.0k
        for (int i = 0; i < num_instances; i++) {
540
18.7k
            hash_table_variant_vector[i] = std::make_shared<JoinDataVariants>();
541
18.7k
        }
542
3.22k
    }
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
226k
inline std::string get_exchange_type_name(ExchangeType idx) {
672
226k
    switch (idx) {
673
14
    case ExchangeType::NOOP:
674
14
        return "NOOP";
675
42.2k
    case ExchangeType::HASH_SHUFFLE:
676
42.2k
        return "HASH_SHUFFLE";
677
175k
    case ExchangeType::PASSTHROUGH:
678
175k
        return "PASSTHROUGH";
679
994
    case ExchangeType::BUCKET_HASH_SHUFFLE:
680
994
        return "BUCKET_HASH_SHUFFLE";
681
670
    case ExchangeType::BROADCAST:
682
670
        return "BROADCAST";
683
1.86k
    case ExchangeType::ADAPTIVE_PASSTHROUGH:
684
1.86k
        return "ADAPTIVE_PASSTHROUGH";
685
5.41k
    case ExchangeType::PASS_TO_ONE:
686
5.41k
        return "PASS_TO_ONE";
687
226k
    }
688
0
    throw Exception(Status::FatalError("__builtin_unreachable"));
689
226k
}
690
691
struct DataDistribution {
692
2.63M
    DataDistribution(ExchangeType type) : distribution_type(type) {}
693
    DataDistribution(ExchangeType type, const std::vector<TExpr>& partition_exprs_)
694
262k
            : distribution_type(type), partition_exprs(partition_exprs_) {}
695
229k
    DataDistribution(const DataDistribution& other) = default;
696
800k
    bool need_local_exchange() const { return distribution_type != ExchangeType::NOOP; }
697
773k
    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
226k
    void _set_always_ready() {
718
1.67M
        for (auto& dep : source_deps) {
719
1.67M
            DCHECK(dep);
720
1.67M
            dep->set_always_ready();
721
1.67M
        }
722
227k
        for (auto& dep : sink_deps) {
723
227k
            DCHECK(dep);
724
227k
            dep->set_always_ready();
725
227k
        }
726
226k
    }
727
728
361k
    Dependency* get_sink_dep_by_channel_id(int channel_id) { return nullptr; }
729
730
252k
    void set_ready_to_read(int channel_id) {
731
252k
        auto& dep = source_deps[channel_id];
732
18.4E
        DCHECK(dep) << channel_id;
733
252k
        dep->set_ready();
734
252k
    }
735
736
252k
    void add_mem_usage(int channel_id, size_t delta) { mem_counters[channel_id]->update(delta); }
737
738
252k
    void sub_mem_usage(int channel_id, size_t delta) {
739
252k
        mem_counters[channel_id]->update(-(int64_t)delta);
740
252k
    }
741
742
219k
    void add_total_mem_usage(size_t delta) {
743
219k
        if (cast_set<int64_t>(mem_usage.fetch_add(delta) + delta) > _buffer_mem_limit) {
744
28
            sink_deps.front()->block();
745
28
        }
746
219k
    }
747
748
219k
    void sub_total_mem_usage(size_t delta) {
749
219k
        auto prev_usage = mem_usage.fetch_sub(delta);
750
219k
        DCHECK_GE(prev_usage - delta, 0) << "prev_usage: " << prev_usage << " delta: " << delta;
751
219k
        if (cast_set<int64_t>(prev_usage - delta) <= _buffer_mem_limit) {
752
219k
            sink_deps.front()->set_ready();
753
219k
        }
754
219k
    }
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