Coverage Report

Created: 2025-10-23 14:19

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/doris/be/src/pipeline/dependency.cpp
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
#include "dependency.h"
19
20
#include <memory>
21
#include <mutex>
22
23
#include "common/logging.h"
24
#include "exec/rowid_fetcher.h"
25
#include "pipeline/exec/multi_cast_data_streamer.h"
26
#include "pipeline/pipeline_fragment_context.h"
27
#include "pipeline/pipeline_task.h"
28
#include "runtime/exec_env.h"
29
#include "runtime/memory/mem_tracker.h"
30
#include "runtime_filter/runtime_filter_consumer.h"
31
#include "util/brpc_client_cache.h"
32
#include "vec/exec/scan/file_scanner.h"
33
#include "vec/exprs/vectorized_agg_fn.h"
34
#include "vec/exprs/vslot_ref.h"
35
#include "vec/spill/spill_stream_manager.h"
36
#include "vec/utils/util.hpp"
37
38
namespace doris::pipeline {
39
#include "common/compile_check_begin.h"
40
41
Dependency* BasicSharedState::create_source_dependency(int operator_id, int node_id,
42
483k
                                                       const std::string& name) {
43
483k
    source_deps.push_back(std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY"));
44
483k
    source_deps.back()->set_shared_state(this);
45
483k
    return source_deps.back().get();
46
483k
}
47
48
void BasicSharedState::create_source_dependencies(int num_sources, int operator_id, int node_id,
49
223k
                                                  const std::string& name) {
50
223k
    source_deps.resize(num_sources, nullptr);
51
1.70M
    for (auto& source_dep : source_deps) {
52
1.70M
        source_dep = std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY");
53
1.70M
        source_dep->set_shared_state(this);
54
1.70M
    }
55
223k
}
56
57
Dependency* BasicSharedState::create_sink_dependency(int dest_id, int node_id,
58
1.67M
                                                     const std::string& name) {
59
1.67M
    sink_deps.push_back(std::make_shared<Dependency>(dest_id, node_id, name + "_DEPENDENCY", true));
60
1.67M
    sink_deps.back()->set_shared_state(this);
61
1.67M
    return sink_deps.back().get();
62
1.67M
}
63
64
8.22M
void Dependency::_add_block_task(std::shared_ptr<PipelineTask> task) {
65
18.4E
    DCHECK(_blocked_task.empty() || _blocked_task[_blocked_task.size() - 1].lock() == nullptr ||
66
18.4E
           _blocked_task[_blocked_task.size() - 1].lock().get() != task.get())
67
18.4E
            << "Duplicate task: " << task->debug_string();
68
8.22M
    _blocked_task.push_back(task);
69
8.22M
}
70
71
47.1M
void Dependency::set_ready() {
72
47.1M
    if (_ready) {
73
40.1M
        return;
74
40.1M
    }
75
6.98M
    std::vector<std::weak_ptr<PipelineTask>> local_block_task {};
76
6.98M
    {
77
6.98M
        std::unique_lock<std::mutex> lc(_task_lock);
78
6.98M
        if (_ready) {
79
0
            return;
80
0
        }
81
6.98M
        _watcher.stop();
82
6.98M
        _ready = true;
83
6.98M
        local_block_task.swap(_blocked_task);
84
6.98M
    }
85
8.25M
    for (auto task : local_block_task) {
86
8.25M
        if (auto t = task.lock()) {
87
8.25M
            std::unique_lock<std::mutex> lc(_task_lock);
88
8.25M
            THROW_IF_ERROR(t->wake_up(this, lc));
89
8.25M
        }
90
8.25M
    }
91
6.98M
}
92
93
67.1M
Dependency* Dependency::is_blocked_by(std::shared_ptr<PipelineTask> task) {
94
67.1M
    std::unique_lock<std::mutex> lc(_task_lock);
95
67.1M
    auto ready = _ready.load();
96
67.1M
    if (!ready && task) {
97
8.25M
        _add_block_task(task);
98
8.25M
        start_watcher();
99
8.25M
        THROW_IF_ERROR(task->blocked(this, lc));
100
8.25M
    }
101
67.1M
    return ready ? nullptr : this;
102
67.1M
}
103
104
77.6k
std::string Dependency::debug_string(int indentation_level) {
105
77.6k
    fmt::memory_buffer debug_string_buffer;
106
77.6k
    fmt::format_to(debug_string_buffer, "{}{}: id={}, block task = {}, ready={}, _always_ready={}",
107
77.6k
                   std::string(indentation_level * 2, ' '), _name, _node_id, _blocked_task.size(),
108
77.6k
                   _ready, _always_ready);
109
77.6k
    return fmt::to_string(debug_string_buffer);
110
77.6k
}
111
112
0
std::string CountedFinishDependency::debug_string(int indentation_level) {
113
0
    fmt::memory_buffer debug_string_buffer;
114
0
    fmt::format_to(debug_string_buffer,
115
0
                   "{}{}: id={}, block_task={}, ready={}, _always_ready={}, count={}",
116
0
                   std::string(indentation_level * 2, ' '), _name, _node_id, _blocked_task.size(),
117
0
                   _ready, _always_ready, _counter);
118
0
    return fmt::to_string(debug_string_buffer);
119
0
}
120
121
4.31k
void RuntimeFilterTimer::call_timeout() {
122
4.31k
    _parent->set_ready();
123
4.31k
}
124
125
23.8k
void RuntimeFilterTimer::call_ready() {
126
23.8k
    _parent->set_ready();
127
23.8k
}
128
129
// should check rf timeout in two case:
130
// 1. the rf is ready just remove the wait queue
131
// 2. if the rf have local dependency, the rf should start wait when all local dependency is ready
132
546k
bool RuntimeFilterTimer::should_be_check_timeout() {
133
546k
    if (!_parent->ready() && !_local_runtime_filter_dependencies.empty()) {
134
22.8k
        bool all_ready = true;
135
22.9k
        for (auto& dep : _local_runtime_filter_dependencies) {
136
22.9k
            if (!dep->ready()) {
137
22.7k
                all_ready = false;
138
22.7k
                break;
139
22.7k
            }
140
22.9k
        }
141
22.8k
        if (all_ready) {
142
64
            _local_runtime_filter_dependencies.clear();
143
64
            _registration_time = MonotonicMillis();
144
64
        }
145
22.8k
        return all_ready;
146
22.8k
    }
147
523k
    return true;
148
546k
}
149
150
7
void RuntimeFilterTimerQueue::start() {
151
86.3k
    while (!_stop) {
152
86.3k
        std::unique_lock<std::mutex> lk(cv_m);
153
154
90.9k
        while (_que.empty() && !_stop) {
155
9.26k
            cv.wait_for(lk, std::chrono::seconds(3), [this] { return !_que.empty() || _stop; });
156
4.63k
        }
157
86.3k
        if (_stop) {
158
2
            break;
159
2
        }
160
86.3k
        {
161
86.3k
            std::unique_lock<std::mutex> lc(_que_lock);
162
86.3k
            std::list<std::shared_ptr<pipeline::RuntimeFilterTimer>> new_que;
163
546k
            for (auto& it : _que) {
164
546k
                if (it.use_count() == 1) {
165
                    // `use_count == 1` means this runtime filter has been released
166
546k
                } else if (it->should_be_check_timeout()) {
167
523k
                    if (it->force_wait_timeout() || it->_parent->is_blocked_by()) {
168
                        // This means runtime filter is not ready, so we call timeout or continue to poll this timer.
169
503k
                        int64_t ms_since_registration = MonotonicMillis() - it->registration_time();
170
503k
                        if (ms_since_registration > it->wait_time_ms()) {
171
4.31k
                            it->call_timeout();
172
499k
                        } else {
173
499k
                            new_que.push_back(std::move(it));
174
499k
                        }
175
503k
                    }
176
523k
                } else {
177
22.7k
                    new_que.push_back(std::move(it));
178
22.7k
                }
179
546k
            }
180
86.3k
            new_que.swap(_que);
181
86.3k
        }
182
86.3k
        std::this_thread::sleep_for(std::chrono::milliseconds(interval));
183
86.3k
    }
184
7
    _shutdown = true;
185
7
}
186
187
903k
void LocalExchangeSharedState::sub_running_sink_operators() {
188
903k
    std::unique_lock<std::mutex> lc(le_lock);
189
903k
    if (exchanger->_running_sink_operators.fetch_sub(1) == 1) {
190
221k
        _set_always_ready();
191
221k
    }
192
903k
}
193
194
1.68M
void LocalExchangeSharedState::sub_running_source_operators() {
195
1.68M
    std::unique_lock<std::mutex> lc(le_lock);
196
1.68M
    if (exchanger->_running_source_operators.fetch_sub(1) == 1) {
197
221k
        _set_always_ready();
198
221k
        exchanger->finalize();
199
221k
    }
200
1.68M
}
201
202
220k
LocalExchangeSharedState::LocalExchangeSharedState(int num_instances) {
203
220k
    source_deps.resize(num_instances, nullptr);
204
220k
    mem_counters.resize(num_instances, nullptr);
205
220k
}
206
207
292
vectorized::MutableColumns AggSharedState::_get_keys_hash_table() {
208
292
    return std::visit(
209
292
            vectorized::Overload {
210
292
                    [&](std::monostate& arg) {
211
0
                        throw doris::Exception(ErrorCode::INTERNAL_ERROR, "uninited hash table");
212
0
                        return vectorized::MutableColumns();
213
0
                    },
214
292
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
292
                        vectorized::MutableColumns key_columns;
216
1.00k
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
716
                            key_columns.emplace_back(
218
716
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
716
                        }
220
292
                        auto& data = *agg_method.hash_table;
221
292
                        bool has_null_key = data.has_null_key_data();
222
292
                        const auto size = data.size() - has_null_key;
223
292
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
292
                        std::vector<KeyType> keys(size);
225
226
292
                        uint32_t num_rows = 0;
227
292
                        auto iter = aggregate_data_container->begin();
228
292
                        {
229
58.2k
                            while (iter != aggregate_data_container->end()) {
230
57.9k
                                keys[num_rows] = iter.get_key<KeyType>();
231
57.9k
                                ++iter;
232
57.9k
                                ++num_rows;
233
57.9k
                            }
234
292
                        }
235
292
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
292
                        if (has_null_key) {
237
2
                            key_columns[0]->insert_data(nullptr, 0);
238
2
                        }
239
292
                        return key_columns;
240
292
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS7_vEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
Line
Count
Source
214
32
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
32
                        vectorized::MutableColumns key_columns;
216
160
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
128
                            key_columns.emplace_back(
218
128
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
128
                        }
220
32
                        auto& data = *agg_method.hash_table;
221
32
                        bool has_null_key = data.has_null_key_data();
222
32
                        const auto size = data.size() - has_null_key;
223
32
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
32
                        std::vector<KeyType> keys(size);
225
226
32
                        uint32_t num_rows = 0;
227
32
                        auto iter = aggregate_data_container->begin();
228
32
                        {
229
46.1k
                            while (iter != aggregate_data_container->end()) {
230
46.0k
                                keys[num_rows] = iter.get_key<KeyType>();
231
46.0k
                                ++iter;
232
46.0k
                                ++num_rows;
233
46.0k
                            }
234
32
                        }
235
32
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
32
                        if (has_null_key) {
237
0
                            key_columns[0]->insert_data(nullptr, 0);
238
0
                        }
239
32
                        return key_columns;
240
32
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
Line
Count
Source
214
4
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
4
                        vectorized::MutableColumns key_columns;
216
8
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
4
                            key_columns.emplace_back(
218
4
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
4
                        }
220
4
                        auto& data = *agg_method.hash_table;
221
4
                        bool has_null_key = data.has_null_key_data();
222
4
                        const auto size = data.size() - has_null_key;
223
4
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
4
                        std::vector<KeyType> keys(size);
225
226
4
                        uint32_t num_rows = 0;
227
4
                        auto iter = aggregate_data_container->begin();
228
4
                        {
229
24
                            while (iter != aggregate_data_container->end()) {
230
20
                                keys[num_rows] = iter.get_key<KeyType>();
231
20
                                ++iter;
232
20
                                ++num_rows;
233
20
                            }
234
4
                        }
235
4
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
4
                        if (has_null_key) {
237
0
                            key_columns[0]->insert_data(nullptr, 0);
238
0
                        }
239
4
                        return key_columns;
240
4
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISI_EESaISL_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISI_EESaISL_EEOT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
Line
Count
Source
214
10
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
10
                        vectorized::MutableColumns key_columns;
216
20
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
10
                            key_columns.emplace_back(
218
10
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
10
                        }
220
10
                        auto& data = *agg_method.hash_table;
221
10
                        bool has_null_key = data.has_null_key_data();
222
10
                        const auto size = data.size() - has_null_key;
223
10
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
10
                        std::vector<KeyType> keys(size);
225
226
10
                        uint32_t num_rows = 0;
227
10
                        auto iter = aggregate_data_container->begin();
228
10
                        {
229
20
                            while (iter != aggregate_data_container->end()) {
230
10
                                keys[num_rows] = iter.get_key<KeyType>();
231
10
                                ++iter;
232
10
                                ++num_rows;
233
10
                            }
234
10
                        }
235
10
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
10
                        if (has_null_key) {
237
0
                            key_columns[0]->insert_data(nullptr, 0);
238
0
                        }
239
10
                        return key_columns;
240
10
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
Line
Count
Source
214
5
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
5
                        vectorized::MutableColumns key_columns;
216
10
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
5
                            key_columns.emplace_back(
218
5
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
5
                        }
220
5
                        auto& data = *agg_method.hash_table;
221
5
                        bool has_null_key = data.has_null_key_data();
222
5
                        const auto size = data.size() - has_null_key;
223
5
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
5
                        std::vector<KeyType> keys(size);
225
226
5
                        uint32_t num_rows = 0;
227
5
                        auto iter = aggregate_data_container->begin();
228
5
                        {
229
24
                            while (iter != aggregate_data_container->end()) {
230
19
                                keys[num_rows] = iter.get_key<KeyType>();
231
19
                                ++iter;
232
19
                                ++num_rows;
233
19
                            }
234
5
                        }
235
5
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
5
                        if (has_null_key) {
237
0
                            key_columns[0]->insert_data(nullptr, 0);
238
0
                        }
239
5
                        return key_columns;
240
5
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIhNS4_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberItNS4_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
Line
Count
Source
214
16
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
16
                        vectorized::MutableColumns key_columns;
216
32
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
16
                            key_columns.emplace_back(
218
16
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
16
                        }
220
16
                        auto& data = *agg_method.hash_table;
221
16
                        bool has_null_key = data.has_null_key_data();
222
16
                        const auto size = data.size() - has_null_key;
223
16
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
16
                        std::vector<KeyType> keys(size);
225
226
16
                        uint32_t num_rows = 0;
227
16
                        auto iter = aggregate_data_container->begin();
228
16
                        {
229
1.86k
                            while (iter != aggregate_data_container->end()) {
230
1.85k
                                keys[num_rows] = iter.get_key<KeyType>();
231
1.85k
                                ++iter;
232
1.85k
                                ++num_rows;
233
1.85k
                            }
234
16
                        }
235
16
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
16
                        if (has_null_key) {
237
0
                            key_columns[0]->insert_data(nullptr, 0);
238
0
                        }
239
16
                        return key_columns;
240
16
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
Line
Count
Source
214
16
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
16
                        vectorized::MutableColumns key_columns;
216
32
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
16
                            key_columns.emplace_back(
218
16
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
16
                        }
220
16
                        auto& data = *agg_method.hash_table;
221
16
                        bool has_null_key = data.has_null_key_data();
222
16
                        const auto size = data.size() - has_null_key;
223
16
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
16
                        std::vector<KeyType> keys(size);
225
226
16
                        uint32_t num_rows = 0;
227
16
                        auto iter = aggregate_data_container->begin();
228
16
                        {
229
2.38k
                            while (iter != aggregate_data_container->end()) {
230
2.36k
                                keys[num_rows] = iter.get_key<KeyType>();
231
2.36k
                                ++iter;
232
2.36k
                                ++num_rows;
233
2.36k
                            }
234
16
                        }
235
16
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
16
                        if (has_null_key) {
237
0
                            key_columns[0]->insert_data(nullptr, 0);
238
0
                        }
239
16
                        return key_columns;
240
16
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISL_EESaISO_EEOT_
Line
Count
Source
214
19
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
19
                        vectorized::MutableColumns key_columns;
216
38
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
19
                            key_columns.emplace_back(
218
19
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
19
                        }
220
19
                        auto& data = *agg_method.hash_table;
221
19
                        bool has_null_key = data.has_null_key_data();
222
19
                        const auto size = data.size() - has_null_key;
223
19
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
19
                        std::vector<KeyType> keys(size);
225
226
19
                        uint32_t num_rows = 0;
227
19
                        auto iter = aggregate_data_container->begin();
228
19
                        {
229
70
                            while (iter != aggregate_data_container->end()) {
230
51
                                keys[num_rows] = iter.get_key<KeyType>();
231
51
                                ++iter;
232
51
                                ++num_rows;
233
51
                            }
234
19
                        }
235
19
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
19
                        if (has_null_key) {
237
1
                            key_columns[0]->insert_data(nullptr, 0);
238
1
                        }
239
19
                        return key_columns;
240
19
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISL_EESaISO_EEOT_
Line
Count
Source
214
22
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
22
                        vectorized::MutableColumns key_columns;
216
44
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
22
                            key_columns.emplace_back(
218
22
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
22
                        }
220
22
                        auto& data = *agg_method.hash_table;
221
22
                        bool has_null_key = data.has_null_key_data();
222
22
                        const auto size = data.size() - has_null_key;
223
22
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
22
                        std::vector<KeyType> keys(size);
225
226
22
                        uint32_t num_rows = 0;
227
22
                        auto iter = aggregate_data_container->begin();
228
22
                        {
229
5.04k
                            while (iter != aggregate_data_container->end()) {
230
5.02k
                                keys[num_rows] = iter.get_key<KeyType>();
231
5.02k
                                ++iter;
232
5.02k
                                ++num_rows;
233
5.02k
                            }
234
22
                        }
235
22
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
22
                        if (has_null_key) {
237
1
                            key_columns[0]->insert_data(nullptr, 0);
238
1
                        }
239
22
                        return key_columns;
240
22
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISM_EESaISP_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm256EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISM_EESaISP_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_19MethodStringNoCacheINS4_15DataWithNullKeyINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISK_EESaISN_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS9_EEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISI_EESaISL_EEOT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS9_EEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISI_EESaISL_EEOT_
Line
Count
Source
214
168
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
168
                        vectorized::MutableColumns key_columns;
216
664
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
496
                            key_columns.emplace_back(
218
496
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
496
                        }
220
168
                        auto& data = *agg_method.hash_table;
221
168
                        bool has_null_key = data.has_null_key_data();
222
168
                        const auto size = data.size() - has_null_key;
223
168
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
168
                        std::vector<KeyType> keys(size);
225
226
168
                        uint32_t num_rows = 0;
227
168
                        auto iter = aggregate_data_container->begin();
228
168
                        {
229
2.64k
                            while (iter != aggregate_data_container->end()) {
230
2.48k
                                keys[num_rows] = iter.get_key<KeyType>();
231
2.48k
                                ++iter;
232
2.48k
                                ++num_rows;
233
2.48k
                            }
234
168
                        }
235
168
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
168
                        if (has_null_key) {
237
0
                            key_columns[0]->insert_data(nullptr, 0);
238
0
                        }
239
168
                        return key_columns;
240
168
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136EPc9HashCRC32IS7_EEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
241
292
            agg_data->method_variant);
242
292
}
243
244
292
void AggSharedState::build_limit_heap(size_t hash_table_size) {
245
292
    limit_columns = _get_keys_hash_table();
246
58.6k
    for (size_t i = 0; i < hash_table_size; ++i) {
247
58.3k
        limit_heap.emplace(i, limit_columns, order_directions, null_directions);
248
58.3k
    }
249
59.9k
    while (hash_table_size > limit) {
250
59.6k
        limit_heap.pop();
251
59.6k
        hash_table_size--;
252
59.6k
    }
253
292
    limit_columns_min = limit_heap.top()._row_id;
254
292
}
255
256
bool AggSharedState::do_limit_filter(vectorized::Block* block, size_t num_rows,
257
640
                                     const std::vector<int>* key_locs) {
258
640
    if (num_rows) {
259
640
        cmp_res.resize(num_rows);
260
640
        need_computes.resize(num_rows);
261
640
        memset(need_computes.data(), 0, need_computes.size());
262
640
        memset(cmp_res.data(), 0, cmp_res.size());
263
264
640
        const auto key_size = null_directions.size();
265
2.15k
        for (int i = 0; i < key_size; i++) {
266
1.51k
            block->get_by_position(key_locs ? key_locs->operator[](i) : i)
267
1.51k
                    .column->compare_internal(limit_columns_min, *limit_columns[i],
268
1.51k
                                              null_directions[i], order_directions[i], cmp_res,
269
1.51k
                                              need_computes.data());
270
1.51k
        }
271
272
640
        auto set_computes_arr = [](auto* __restrict res, auto* __restrict computes, size_t rows) {
273
237k
            for (size_t i = 0; i < rows; ++i) {
274
236k
                computes[i] = computes[i] == res[i];
275
236k
            }
276
639
        };
277
640
        set_computes_arr(cmp_res.data(), need_computes.data(), num_rows);
278
279
640
        return std::find(need_computes.begin(), need_computes.end(), 0) != need_computes.end();
280
640
    }
281
282
0
    return false;
283
640
}
284
285
1.52k
Status AggSharedState::reset_hash_table() {
286
1.52k
    return std::visit(
287
1.52k
            vectorized::Overload {
288
1.52k
                    [&](std::monostate& arg) -> Status {
289
0
                        return Status::InternalError("Uninited hash table");
290
0
                    },
291
1.52k
                    [&](auto& agg_method) {
292
1.52k
                        auto& hash_table = *agg_method.hash_table;
293
1.52k
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
1.52k
                        agg_method.arena.clear();
296
1.52k
                        agg_method.inited_iterator = false;
297
298
1.44M
                        hash_table.for_each_mapped([&](auto& mapped) {
299
1.44M
                            if (mapped) {
300
1.44M
                                static_cast<void>(_destroy_agg_status(mapped));
301
1.44M
                                mapped = nullptr;
302
1.44M
                            }
303
1.44M
                        });
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS7_vEEEEEEDaRT_ENKUlSE_E_clIS8_EEDaSE_
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEDaRT_ENKUlSD_E_clIS7_EEDaSD_
Line
Count
Source
298
114
                        hash_table.for_each_mapped([&](auto& mapped) {
299
114
                            if (mapped) {
300
114
                                static_cast<void>(_destroy_agg_status(mapped));
301
114
                                mapped = nullptr;
302
114
                            }
303
114
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEDaRT_ENKUlSD_E_clIS7_EEDaSD_
Line
Count
Source
298
138
                        hash_table.for_each_mapped([&](auto& mapped) {
299
138
                            if (mapped) {
300
138
                                static_cast<void>(_destroy_agg_status(mapped));
301
138
                                mapped = nullptr;
302
138
                            }
303
138
                        });
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEEDaRT_ENKUlSD_E_clIS7_EEDaSD_
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEEDaRT_ENKUlSD_E_clIS7_EEDaSD_
Line
Count
Source
298
288
                        hash_table.for_each_mapped([&](auto& mapped) {
299
288
                            if (mapped) {
300
288
                                static_cast<void>(_destroy_agg_status(mapped));
301
288
                                mapped = nullptr;
302
288
                            }
303
288
                        });
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEDaRT_ENKUlSE_E_clIS7_EEDaSE_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEEDaRT_ENKUlSG_E_clISA_EEDaSG_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEEDaRT_ENKUlSG_E_clISA_EEDaSG_
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Line
Count
Source
298
1.04M
                        hash_table.for_each_mapped([&](auto& mapped) {
299
1.04M
                            if (mapped) {
300
1.04M
                                static_cast<void>(_destroy_agg_status(mapped));
301
1.04M
                                mapped = nullptr;
302
1.04M
                            }
303
1.04M
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Line
Count
Source
298
599
                        hash_table.for_each_mapped([&](auto& mapped) {
299
599
                            if (mapped) {
300
599
                                static_cast<void>(_destroy_agg_status(mapped));
301
599
                                mapped = nullptr;
302
599
                            }
303
599
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIhNS4_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_
Line
Count
Source
298
104
                        hash_table.for_each_mapped([&](auto& mapped) {
299
104
                            if (mapped) {
300
104
                                static_cast<void>(_destroy_agg_status(mapped));
301
104
                                mapped = nullptr;
302
104
                            }
303
104
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberItNS4_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_
Line
Count
Source
298
163
                        hash_table.for_each_mapped([&](auto& mapped) {
299
163
                            if (mapped) {
300
163
                                static_cast<void>(_destroy_agg_status(mapped));
301
163
                                mapped = nullptr;
302
163
                            }
303
163
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_
Line
Count
Source
298
197k
                        hash_table.for_each_mapped([&](auto& mapped) {
299
197k
                            if (mapped) {
300
197k
                                static_cast<void>(_destroy_agg_status(mapped));
301
197k
                                mapped = nullptr;
302
197k
                            }
303
197k
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_
Line
Count
Source
298
224
                        hash_table.for_each_mapped([&](auto& mapped) {
299
224
                            if (mapped) {
300
224
                                static_cast<void>(_destroy_agg_status(mapped));
301
224
                                mapped = nullptr;
302
224
                            }
303
224
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEDaRT_ENKUlSJ_E_clIS9_EEDaSJ_
Line
Count
Source
298
198k
                        hash_table.for_each_mapped([&](auto& mapped) {
299
198k
                            if (mapped) {
300
198k
                                static_cast<void>(_destroy_agg_status(mapped));
301
198k
                                mapped = nullptr;
302
198k
                            }
303
198k
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEDaRT_ENKUlSJ_E_clIS9_EEDaSJ_
Line
Count
Source
298
1.52k
                        hash_table.for_each_mapped([&](auto& mapped) {
299
1.52k
                            if (mapped) {
300
1.52k
                                static_cast<void>(_destroy_agg_status(mapped));
301
1.52k
                                mapped = nullptr;
302
1.52k
                            }
303
1.52k
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEEDaRT_ENKUlSK_E_clISC_EEDaSK_
Line
Count
Source
298
129
                        hash_table.for_each_mapped([&](auto& mapped) {
299
129
                            if (mapped) {
300
129
                                static_cast<void>(_destroy_agg_status(mapped));
301
129
                                mapped = nullptr;
302
129
                            }
303
129
                        });
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm256EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEEDaRT_ENKUlSK_E_clISC_EEDaSK_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_19MethodStringNoCacheINS4_15DataWithNullKeyINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEEEEEDaRT_ENKUlSI_E_clIS9_EEDaSI_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImEEEEEEDaRT_ENKUlSD_E_clIS7_EEDaSD_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS9_EEEEEEDaRT_ENKUlSG_E_clISA_EEDaSG_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS9_EEEEEEDaRT_ENKUlSG_E_clISA_EEDaSG_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136EPc9HashCRC32IS7_EEEEEEDaRT_ENKUlSE_E_clIS8_EEDaSE_
304
305
1.52k
                        if (hash_table.has_null_key_data()) {
306
0
                            auto st = _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                          vectorized::AggregateDataPtr>());
308
0
                            RETURN_IF_ERROR(st);
309
0
                        }
310
311
1.52k
                        aggregate_data_container.reset(new AggregateDataContainer(
312
1.52k
                                sizeof(typename HashTableType::key_type),
313
1.52k
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
1.52k
                                 align_aggregate_states) *
315
1.52k
                                        align_aggregate_states));
316
1.52k
                        agg_method.hash_table.reset(new HashTableType());
317
1.52k
                        return Status::OK();
318
1.52k
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS7_vEEEEEEDaRT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEDaRT_
Line
Count
Source
291
39
                    [&](auto& agg_method) {
292
39
                        auto& hash_table = *agg_method.hash_table;
293
39
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
39
                        agg_method.arena.clear();
296
39
                        agg_method.inited_iterator = false;
297
298
39
                        hash_table.for_each_mapped([&](auto& mapped) {
299
39
                            if (mapped) {
300
39
                                static_cast<void>(_destroy_agg_status(mapped));
301
39
                                mapped = nullptr;
302
39
                            }
303
39
                        });
304
305
39
                        if (hash_table.has_null_key_data()) {
306
0
                            auto st = _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                          vectorized::AggregateDataPtr>());
308
0
                            RETURN_IF_ERROR(st);
309
0
                        }
310
311
39
                        aggregate_data_container.reset(new AggregateDataContainer(
312
39
                                sizeof(typename HashTableType::key_type),
313
39
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
39
                                 align_aggregate_states) *
315
39
                                        align_aggregate_states));
316
39
                        agg_method.hash_table.reset(new HashTableType());
317
39
                        return Status::OK();
318
39
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEDaRT_
Line
Count
Source
291
29
                    [&](auto& agg_method) {
292
29
                        auto& hash_table = *agg_method.hash_table;
293
29
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
29
                        agg_method.arena.clear();
296
29
                        agg_method.inited_iterator = false;
297
298
29
                        hash_table.for_each_mapped([&](auto& mapped) {
299
29
                            if (mapped) {
300
29
                                static_cast<void>(_destroy_agg_status(mapped));
301
29
                                mapped = nullptr;
302
29
                            }
303
29
                        });
304
305
29
                        if (hash_table.has_null_key_data()) {
306
0
                            auto st = _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                          vectorized::AggregateDataPtr>());
308
0
                            RETURN_IF_ERROR(st);
309
0
                        }
310
311
29
                        aggregate_data_container.reset(new AggregateDataContainer(
312
29
                                sizeof(typename HashTableType::key_type),
313
29
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
29
                                 align_aggregate_states) *
315
29
                                        align_aggregate_states));
316
29
                        agg_method.hash_table.reset(new HashTableType());
317
29
                        return Status::OK();
318
29
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEEDaRT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEEDaRT_
Line
Count
Source
291
90
                    [&](auto& agg_method) {
292
90
                        auto& hash_table = *agg_method.hash_table;
293
90
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
90
                        agg_method.arena.clear();
296
90
                        agg_method.inited_iterator = false;
297
298
90
                        hash_table.for_each_mapped([&](auto& mapped) {
299
90
                            if (mapped) {
300
90
                                static_cast<void>(_destroy_agg_status(mapped));
301
90
                                mapped = nullptr;
302
90
                            }
303
90
                        });
304
305
90
                        if (hash_table.has_null_key_data()) {
306
0
                            auto st = _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                          vectorized::AggregateDataPtr>());
308
0
                            RETURN_IF_ERROR(st);
309
0
                        }
310
311
90
                        aggregate_data_container.reset(new AggregateDataContainer(
312
90
                                sizeof(typename HashTableType::key_type),
313
90
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
90
                                 align_aggregate_states) *
315
90
                                        align_aggregate_states));
316
90
                        agg_method.hash_table.reset(new HashTableType());
317
90
                        return Status::OK();
318
90
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEEDaRT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEDaRT_
Line
Count
Source
291
53
                    [&](auto& agg_method) {
292
53
                        auto& hash_table = *agg_method.hash_table;
293
53
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
53
                        agg_method.arena.clear();
296
53
                        agg_method.inited_iterator = false;
297
298
53
                        hash_table.for_each_mapped([&](auto& mapped) {
299
53
                            if (mapped) {
300
53
                                static_cast<void>(_destroy_agg_status(mapped));
301
53
                                mapped = nullptr;
302
53
                            }
303
53
                        });
304
305
53
                        if (hash_table.has_null_key_data()) {
306
0
                            auto st = _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                          vectorized::AggregateDataPtr>());
308
0
                            RETURN_IF_ERROR(st);
309
0
                        }
310
311
53
                        aggregate_data_container.reset(new AggregateDataContainer(
312
53
                                sizeof(typename HashTableType::key_type),
313
53
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
53
                                 align_aggregate_states) *
315
53
                                        align_aggregate_states));
316
53
                        agg_method.hash_table.reset(new HashTableType());
317
53
                        return Status::OK();
318
53
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEDaRT_
Line
Count
Source
291
196
                    [&](auto& agg_method) {
292
196
                        auto& hash_table = *agg_method.hash_table;
293
196
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
196
                        agg_method.arena.clear();
296
196
                        agg_method.inited_iterator = false;
297
298
196
                        hash_table.for_each_mapped([&](auto& mapped) {
299
196
                            if (mapped) {
300
196
                                static_cast<void>(_destroy_agg_status(mapped));
301
196
                                mapped = nullptr;
302
196
                            }
303
196
                        });
304
305
196
                        if (hash_table.has_null_key_data()) {
306
0
                            auto st = _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                          vectorized::AggregateDataPtr>());
308
0
                            RETURN_IF_ERROR(st);
309
0
                        }
310
311
196
                        aggregate_data_container.reset(new AggregateDataContainer(
312
196
                                sizeof(typename HashTableType::key_type),
313
196
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
196
                                 align_aggregate_states) *
315
196
                                        align_aggregate_states));
316
196
                        agg_method.hash_table.reset(new HashTableType());
317
196
                        return Status::OK();
318
196
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIhNS4_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEDaRT_
Line
Count
Source
291
53
                    [&](auto& agg_method) {
292
53
                        auto& hash_table = *agg_method.hash_table;
293
53
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
53
                        agg_method.arena.clear();
296
53
                        agg_method.inited_iterator = false;
297
298
53
                        hash_table.for_each_mapped([&](auto& mapped) {
299
53
                            if (mapped) {
300
53
                                static_cast<void>(_destroy_agg_status(mapped));
301
53
                                mapped = nullptr;
302
53
                            }
303
53
                        });
304
305
53
                        if (hash_table.has_null_key_data()) {
306
0
                            auto st = _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                          vectorized::AggregateDataPtr>());
308
0
                            RETURN_IF_ERROR(st);
309
0
                        }
310
311
53
                        aggregate_data_container.reset(new AggregateDataContainer(
312
53
                                sizeof(typename HashTableType::key_type),
313
53
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
53
                                 align_aggregate_states) *
315
53
                                        align_aggregate_states));
316
53
                        agg_method.hash_table.reset(new HashTableType());
317
53
                        return Status::OK();
318
53
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberItNS4_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEDaRT_
Line
Count
Source
291
53
                    [&](auto& agg_method) {
292
53
                        auto& hash_table = *agg_method.hash_table;
293
53
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
53
                        agg_method.arena.clear();
296
53
                        agg_method.inited_iterator = false;
297
298
53
                        hash_table.for_each_mapped([&](auto& mapped) {
299
53
                            if (mapped) {
300
53
                                static_cast<void>(_destroy_agg_status(mapped));
301
53
                                mapped = nullptr;
302
53
                            }
303
53
                        });
304
305
53
                        if (hash_table.has_null_key_data()) {
306
0
                            auto st = _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                          vectorized::AggregateDataPtr>());
308
0
                            RETURN_IF_ERROR(st);
309
0
                        }
310
311
53
                        aggregate_data_container.reset(new AggregateDataContainer(
312
53
                                sizeof(typename HashTableType::key_type),
313
53
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
53
                                 align_aggregate_states) *
315
53
                                        align_aggregate_states));
316
53
                        agg_method.hash_table.reset(new HashTableType());
317
53
                        return Status::OK();
318
53
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEDaRT_
Line
Count
Source
291
250
                    [&](auto& agg_method) {
292
250
                        auto& hash_table = *agg_method.hash_table;
293
250
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
250
                        agg_method.arena.clear();
296
250
                        agg_method.inited_iterator = false;
297
298
250
                        hash_table.for_each_mapped([&](auto& mapped) {
299
250
                            if (mapped) {
300
250
                                static_cast<void>(_destroy_agg_status(mapped));
301
250
                                mapped = nullptr;
302
250
                            }
303
250
                        });
304
305
250
                        if (hash_table.has_null_key_data()) {
306
0
                            auto st = _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                          vectorized::AggregateDataPtr>());
308
0
                            RETURN_IF_ERROR(st);
309
0
                        }
310
311
250
                        aggregate_data_container.reset(new AggregateDataContainer(
312
250
                                sizeof(typename HashTableType::key_type),
313
250
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
250
                                 align_aggregate_states) *
315
250
                                        align_aggregate_states));
316
250
                        agg_method.hash_table.reset(new HashTableType());
317
250
                        return Status::OK();
318
250
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEDaRT_
Line
Count
Source
291
73
                    [&](auto& agg_method) {
292
73
                        auto& hash_table = *agg_method.hash_table;
293
73
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
73
                        agg_method.arena.clear();
296
73
                        agg_method.inited_iterator = false;
297
298
73
                        hash_table.for_each_mapped([&](auto& mapped) {
299
73
                            if (mapped) {
300
73
                                static_cast<void>(_destroy_agg_status(mapped));
301
73
                                mapped = nullptr;
302
73
                            }
303
73
                        });
304
305
73
                        if (hash_table.has_null_key_data()) {
306
0
                            auto st = _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                          vectorized::AggregateDataPtr>());
308
0
                            RETURN_IF_ERROR(st);
309
0
                        }
310
311
73
                        aggregate_data_container.reset(new AggregateDataContainer(
312
73
                                sizeof(typename HashTableType::key_type),
313
73
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
73
                                 align_aggregate_states) *
315
73
                                        align_aggregate_states));
316
73
                        agg_method.hash_table.reset(new HashTableType());
317
73
                        return Status::OK();
318
73
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEDaRT_
Line
Count
Source
291
396
                    [&](auto& agg_method) {
292
396
                        auto& hash_table = *agg_method.hash_table;
293
396
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
396
                        agg_method.arena.clear();
296
396
                        agg_method.inited_iterator = false;
297
298
396
                        hash_table.for_each_mapped([&](auto& mapped) {
299
396
                            if (mapped) {
300
396
                                static_cast<void>(_destroy_agg_status(mapped));
301
396
                                mapped = nullptr;
302
396
                            }
303
396
                        });
304
305
396
                        if (hash_table.has_null_key_data()) {
306
0
                            auto st = _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                          vectorized::AggregateDataPtr>());
308
0
                            RETURN_IF_ERROR(st);
309
0
                        }
310
311
396
                        aggregate_data_container.reset(new AggregateDataContainer(
312
396
                                sizeof(typename HashTableType::key_type),
313
396
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
396
                                 align_aggregate_states) *
315
396
                                        align_aggregate_states));
316
396
                        agg_method.hash_table.reset(new HashTableType());
317
396
                        return Status::OK();
318
396
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEDaRT_
Line
Count
Source
291
250
                    [&](auto& agg_method) {
292
250
                        auto& hash_table = *agg_method.hash_table;
293
250
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
250
                        agg_method.arena.clear();
296
250
                        agg_method.inited_iterator = false;
297
298
250
                        hash_table.for_each_mapped([&](auto& mapped) {
299
250
                            if (mapped) {
300
250
                                static_cast<void>(_destroy_agg_status(mapped));
301
250
                                mapped = nullptr;
302
250
                            }
303
250
                        });
304
305
250
                        if (hash_table.has_null_key_data()) {
306
0
                            auto st = _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                          vectorized::AggregateDataPtr>());
308
0
                            RETURN_IF_ERROR(st);
309
0
                        }
310
311
250
                        aggregate_data_container.reset(new AggregateDataContainer(
312
250
                                sizeof(typename HashTableType::key_type),
313
250
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
250
                                 align_aggregate_states) *
315
250
                                        align_aggregate_states));
316
250
                        agg_method.hash_table.reset(new HashTableType());
317
250
                        return Status::OK();
318
250
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEEDaRT_
Line
Count
Source
291
42
                    [&](auto& agg_method) {
292
42
                        auto& hash_table = *agg_method.hash_table;
293
42
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
42
                        agg_method.arena.clear();
296
42
                        agg_method.inited_iterator = false;
297
298
42
                        hash_table.for_each_mapped([&](auto& mapped) {
299
42
                            if (mapped) {
300
42
                                static_cast<void>(_destroy_agg_status(mapped));
301
42
                                mapped = nullptr;
302
42
                            }
303
42
                        });
304
305
42
                        if (hash_table.has_null_key_data()) {
306
0
                            auto st = _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                          vectorized::AggregateDataPtr>());
308
0
                            RETURN_IF_ERROR(st);
309
0
                        }
310
311
42
                        aggregate_data_container.reset(new AggregateDataContainer(
312
42
                                sizeof(typename HashTableType::key_type),
313
42
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
42
                                 align_aggregate_states) *
315
42
                                        align_aggregate_states));
316
42
                        agg_method.hash_table.reset(new HashTableType());
317
42
                        return Status::OK();
318
42
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm256EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_19MethodStringNoCacheINS4_15DataWithNullKeyINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS9_EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS9_EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136EPc9HashCRC32IS7_EEEEEEDaRT_
319
1.52k
            agg_data->method_variant);
320
1.52k
}
321
322
196
void PartitionedAggSharedState::init_spill_params(size_t spill_partition_count) {
323
196
    partition_count = spill_partition_count;
324
196
    max_partition_index = partition_count - 1;
325
326
6.46k
    for (int i = 0; i < partition_count; ++i) {
327
6.27k
        spill_partitions.emplace_back(std::make_shared<AggSpillPartition>());
328
6.27k
    }
329
196
}
330
331
185
void PartitionedAggSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {
332
5.92k
    for (auto& partition : spill_partitions) {
333
5.92k
        if (partition->spilling_stream_) {
334
0
            partition->spilling_stream_->update_shared_profiles(source_profile);
335
0
        }
336
5.92k
        for (auto& stream : partition->spill_streams_) {
337
992
            if (stream) {
338
992
                stream->update_shared_profiles(source_profile);
339
992
            }
340
992
        }
341
5.92k
    }
342
185
}
343
344
Status AggSpillPartition::get_spill_stream(RuntimeState* state, int node_id,
345
                                           RuntimeProfile* profile,
346
8.99k
                                           vectorized::SpillStreamSPtr& spill_stream) {
347
8.99k
    if (spilling_stream_) {
348
7.95k
        spill_stream = spilling_stream_;
349
7.95k
        return Status::OK();
350
7.95k
    }
351
1.04k
    RETURN_IF_ERROR(ExecEnv::GetInstance()->spill_stream_mgr()->register_spill_stream(
352
1.04k
            state, spilling_stream_, print_id(state->query_id()), "agg", node_id,
353
1.04k
            std::numeric_limits<int32_t>::max(), std::numeric_limits<size_t>::max(), profile));
354
1.04k
    spill_streams_.emplace_back(spilling_stream_);
355
1.04k
    spill_stream = spilling_stream_;
356
1.04k
    return Status::OK();
357
1.04k
}
358
4.27k
void AggSpillPartition::close() {
359
4.27k
    if (spilling_stream_) {
360
1
        spilling_stream_.reset();
361
1
    }
362
4.27k
    for (auto& stream : spill_streams_) {
363
5
        (void)ExecEnv::GetInstance()->spill_stream_mgr()->delete_spill_stream(stream);
364
5
    }
365
4.27k
    spill_streams_.clear();
366
4.27k
}
367
368
220
void PartitionedAggSharedState::close() {
369
    // need to use CAS instead of only `if (!is_closed)` statement,
370
    // to avoid concurrent entry of close() both pass the if statement
371
220
    bool false_close = false;
372
220
    if (!is_closed.compare_exchange_strong(false_close, true)) {
373
30
        return;
374
30
    }
375
220
    DCHECK(!false_close && is_closed);
376
4.27k
    for (auto partition : spill_partitions) {
377
4.27k
        partition->close();
378
4.27k
    }
379
190
    spill_partitions.clear();
380
190
}
381
382
14
void SpillSortSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {
383
44
    for (auto& stream : sorted_streams) {
384
44
        if (stream) {
385
44
            stream->update_shared_profiles(source_profile);
386
44
        }
387
44
    }
388
14
}
389
390
16
void SpillSortSharedState::close() {
391
    // need to use CAS instead of only `if (!is_closed)` statement,
392
    // to avoid concurrent entry of close() both pass the if statement
393
16
    bool false_close = false;
394
16
    if (!is_closed.compare_exchange_strong(false_close, true)) {
395
1
        return;
396
1
    }
397
16
    DCHECK(!false_close && is_closed);
398
15
    for (auto& stream : sorted_streams) {
399
1
        (void)ExecEnv::GetInstance()->spill_stream_mgr()->delete_spill_stream(stream);
400
1
    }
401
15
    sorted_streams.clear();
402
15
}
403
404
MultiCastSharedState::MultiCastSharedState(ObjectPool* pool, int cast_sender_count, int node_id)
405
1.75k
        : multi_cast_data_streamer(std::make_unique<pipeline::MultiCastDataStreamer>(
406
1.75k
                  pool, cast_sender_count, node_id)) {}
407
408
0
void MultiCastSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {}
409
410
129k
int AggSharedState::get_slot_column_id(const vectorized::AggFnEvaluator* evaluator) {
411
129k
    auto ctxs = evaluator->input_exprs_ctxs();
412
18.4E
    CHECK(ctxs.size() == 1 && ctxs[0]->root()->is_slot_ref())
413
18.4E
            << "input_exprs_ctxs is invalid, input_exprs_ctx[0]="
414
18.4E
            << ctxs[0]->root()->debug_string();
415
129k
    return ((vectorized::VSlotRef*)ctxs[0]->root().get())->column_id();
416
129k
}
417
418
3.51M
Status AggSharedState::_destroy_agg_status(vectorized::AggregateDataPtr data) {
419
8.18M
    for (int i = 0; i < aggregate_evaluators.size(); ++i) {
420
4.66M
        aggregate_evaluators[i]->function()->destroy(data + offsets_of_aggregate_states[i]);
421
4.66M
    }
422
3.51M
    return Status::OK();
423
3.51M
}
424
425
221k
LocalExchangeSharedState::~LocalExchangeSharedState() = default;
426
427
1.41k
Status SetSharedState::update_build_not_ignore_null(const vectorized::VExprContextSPtrs& ctxs) {
428
1.41k
    if (ctxs.size() > build_not_ignore_null.size()) {
429
0
        return Status::InternalError("build_not_ignore_null not initialized");
430
0
    }
431
432
3.56k
    for (int i = 0; i < ctxs.size(); ++i) {
433
2.14k
        build_not_ignore_null[i] = build_not_ignore_null[i] || ctxs[i]->root()->is_nullable();
434
2.14k
    }
435
436
1.41k
    return Status::OK();
437
1.41k
}
438
439
1.41k
size_t SetSharedState::get_hash_table_size() const {
440
1.41k
    size_t hash_table_size = 0;
441
1.41k
    std::visit(
442
1.41k
            [&](auto&& arg) {
443
1.41k
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
1.41k
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
1.41k
                    hash_table_size = arg.hash_table->size();
446
1.41k
                }
447
1.41k
            },
Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRSt9monostateEEDaOT_
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS7_vEEEEEEDaOT_
Line
Count
Source
442
562
            [&](auto&& arg) {
443
562
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
562
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
562
                    hash_table_size = arg.hash_table->size();
446
562
                }
447
562
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized19MethodStringNoCacheI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS7_vEEEEEEDaOT_
Line
Count
Source
442
159
            [&](auto&& arg) {
443
159
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
159
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
159
                    hash_table_size = arg.hash_table->size();
446
159
                }
447
159
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIhNS4_15DataWithNullKeyI9PHHashMapIhNS_14RowRefWithFlagE9HashCRC32IhEEEEEEEEEEDaOT_
Line
Count
Source
442
26
            [&](auto&& arg) {
443
26
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
26
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
26
                    hash_table_size = arg.hash_table->size();
446
26
                }
447
26
            },
Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberItNS4_15DataWithNullKeyI9PHHashMapItNS_14RowRefWithFlagE9HashCRC32ItEEEEEEEEEEDaOT_
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjNS_14RowRefWithFlagE9HashCRC32IjEEEEEEEEEEDaOT_
Line
Count
Source
442
348
            [&](auto&& arg) {
443
348
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
348
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
348
                    hash_table_size = arg.hash_table->size();
446
348
                }
447
348
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImNS_14RowRefWithFlagE9HashCRC32ImEEEEEEEEEEDaOT_
Line
Count
Source
442
136
            [&](auto&& arg) {
443
136
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
136
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
136
                    hash_table_size = arg.hash_table->size();
446
136
                }
447
136
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_NS_14RowRefWithFlagE9HashCRC32IS9_EEEEEEEEEEDaOT_
Line
Count
Source
442
56
            [&](auto&& arg) {
443
56
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
56
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
56
                    hash_table_size = arg.hash_table->size();
446
56
                }
447
56
            },
Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm256EjEENS4_15DataWithNullKeyI9PHHashMapIS9_NS_14RowRefWithFlagE9HashCRC32IS9_EEEEEEEEEEDaOT_
Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodOneNumberIh9PHHashMapIhNS_14RowRefWithFlagE9HashCRC32IhEEEEEEDaOT_
Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodOneNumberIt9PHHashMapItNS_14RowRefWithFlagE9HashCRC32ItEEEEEEDaOT_
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodOneNumberIj9PHHashMapIjNS_14RowRefWithFlagE9HashCRC32IjEEEEEEDaOT_
Line
Count
Source
442
16
            [&](auto&& arg) {
443
16
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
16
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
16
                    hash_table_size = arg.hash_table->size();
446
16
                }
447
16
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodOneNumberIm9PHHashMapImNS_14RowRefWithFlagE9HashCRC32ImEEEEEEDaOT_
Line
Count
Source
442
8
            [&](auto&& arg) {
443
8
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
8
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
8
                    hash_table_size = arg.hash_table->size();
446
8
                }
447
8
            },
Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS8_NS_14RowRefWithFlagE9HashCRC32IS8_EEEEEEDaOT_
Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS8_NS_14RowRefWithFlagE9HashCRC32IS8_EEEEEEDaOT_
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodKeysFixedI9PHHashMapImNS_14RowRefWithFlagE9HashCRC32ImEEEEEEDaOT_
Line
Count
Source
442
12
            [&](auto&& arg) {
443
12
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
12
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
12
                    hash_table_size = arg.hash_table->size();
446
12
                }
447
12
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEENS_14RowRefWithFlagE9HashCRC32IS9_EEEEEEDaOT_
Line
Count
Source
442
32
            [&](auto&& arg) {
443
32
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
32
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
32
                    hash_table_size = arg.hash_table->size();
446
32
                }
447
32
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEENS_14RowRefWithFlagE9HashCRC32IS9_EEEEEEDaOT_
Line
Count
Source
442
2
            [&](auto&& arg) {
443
2
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
2
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
2
                    hash_table_size = arg.hash_table->size();
446
2
                }
447
2
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136ENS_14RowRefWithFlagE9HashCRC32IS7_EEEEEEDaOT_
Line
Count
Source
442
57
            [&](auto&& arg) {
443
57
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
57
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
57
                    hash_table_size = arg.hash_table->size();
446
57
                }
447
57
            },
448
1.41k
            hash_table_variants->method_variant);
449
1.41k
    return hash_table_size;
450
1.41k
}
451
452
647
Status SetSharedState::hash_table_init() {
453
647
    std::vector<vectorized::DataTypePtr> data_types;
454
1.65k
    for (size_t i = 0; i != child_exprs_lists[0].size(); ++i) {
455
1.00k
        auto& ctx = child_exprs_lists[0][i];
456
1.00k
        auto data_type = ctx->root()->data_type();
457
1.00k
        if (build_not_ignore_null[i]) {
458
829
            data_type = vectorized::make_nullable(data_type);
459
829
        }
460
1.00k
        data_types.emplace_back(std::move(data_type));
461
1.00k
    }
462
647
    return init_hash_method<SetDataVariants>(hash_table_variants.get(), data_types, true);
463
647
}
464
465
void AggSharedState::refresh_top_limit(size_t row_id,
466
187
                                       const vectorized::ColumnRawPtrs& key_columns) {
467
434
    for (int j = 0; j < key_columns.size(); ++j) {
468
247
        limit_columns[j]->insert_from(*key_columns[j], row_id);
469
247
    }
470
187
    limit_heap.emplace(limit_columns[0]->size() - 1, limit_columns, order_directions,
471
187
                       null_directions);
472
473
187
    limit_heap.pop();
474
187
    limit_columns_min = limit_heap.top()._row_id;
475
187
}
476
477
} // namespace doris::pipeline