Coverage Report

Created: 2025-10-28 08:40

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
486k
                                                       const std::string& name) {
43
486k
    source_deps.push_back(std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY"));
44
486k
    source_deps.back()->set_shared_state(this);
45
486k
    return source_deps.back().get();
46
486k
}
47
48
void BasicSharedState::create_source_dependencies(int num_sources, int operator_id, int node_id,
49
214k
                                                  const std::string& name) {
50
214k
    source_deps.resize(num_sources, nullptr);
51
1.18M
    for (auto& source_dep : source_deps) {
52
1.18M
        source_dep = std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY");
53
1.18M
        source_dep->set_shared_state(this);
54
1.18M
    }
55
214k
}
56
57
Dependency* BasicSharedState::create_sink_dependency(int dest_id, int node_id,
58
1.42M
                                                     const std::string& name) {
59
1.42M
    sink_deps.push_back(std::make_shared<Dependency>(dest_id, node_id, name + "_DEPENDENCY", true));
60
1.42M
    sink_deps.back()->set_shared_state(this);
61
1.42M
    return sink_deps.back().get();
62
1.42M
}
63
64
6.65M
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
6.65M
    _blocked_task.push_back(task);
69
6.65M
}
70
71
22.3M
void Dependency::set_ready() {
72
22.3M
    if (_ready) {
73
16.0M
        return;
74
16.0M
    }
75
6.27M
    std::vector<std::weak_ptr<PipelineTask>> local_block_task {};
76
6.27M
    {
77
6.27M
        std::unique_lock<std::mutex> lc(_task_lock);
78
6.27M
        if (_ready) {
79
3
            return;
80
3
        }
81
6.27M
        _watcher.stop();
82
6.27M
        _ready = true;
83
6.27M
        local_block_task.swap(_blocked_task);
84
6.27M
    }
85
6.67M
    for (auto task : local_block_task) {
86
6.67M
        if (auto t = task.lock()) {
87
6.67M
            std::unique_lock<std::mutex> lc(_task_lock);
88
6.67M
            THROW_IF_ERROR(t->wake_up(this, lc));
89
6.67M
        }
90
6.67M
    }
91
6.27M
}
92
93
58.4M
Dependency* Dependency::is_blocked_by(std::shared_ptr<PipelineTask> task) {
94
58.4M
    std::unique_lock<std::mutex> lc(_task_lock);
95
58.4M
    auto ready = _ready.load();
96
58.4M
    if (!ready && task) {
97
6.67M
        _add_block_task(task);
98
6.67M
        start_watcher();
99
6.67M
        THROW_IF_ERROR(task->blocked(this, lc));
100
6.67M
    }
101
58.4M
    return ready ? nullptr : this;
102
58.4M
}
103
104
80.4k
std::string Dependency::debug_string(int indentation_level) {
105
80.4k
    fmt::memory_buffer debug_string_buffer;
106
80.4k
    fmt::format_to(debug_string_buffer, "{}{}: id={}, block task = {}, ready={}, _always_ready={}",
107
80.4k
                   std::string(indentation_level * 2, ' '), _name, _node_id, _blocked_task.size(),
108
80.4k
                   _ready, _always_ready);
109
80.4k
    return fmt::to_string(debug_string_buffer);
110
80.4k
}
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
6.66k
void RuntimeFilterTimer::call_timeout() {
122
6.66k
    _parent->set_ready();
123
6.66k
}
124
125
25.5k
void RuntimeFilterTimer::call_ready() {
126
25.5k
    _parent->set_ready();
127
25.5k
}
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
716k
bool RuntimeFilterTimer::should_be_check_timeout() {
133
716k
    if (!_parent->ready() && !_local_runtime_filter_dependencies.empty()) {
134
3.32k
        bool all_ready = true;
135
3.37k
        for (auto& dep : _local_runtime_filter_dependencies) {
136
3.37k
            if (!dep->ready()) {
137
3.12k
                all_ready = false;
138
3.12k
                break;
139
3.12k
            }
140
3.37k
        }
141
3.32k
        if (all_ready) {
142
196
            _local_runtime_filter_dependencies.clear();
143
196
            _registration_time = MonotonicMillis();
144
196
        }
145
3.32k
        return all_ready;
146
3.32k
    }
147
713k
    return true;
148
716k
}
149
150
8
void RuntimeFilterTimerQueue::start() {
151
73.7k
    while (!_stop) {
152
73.7k
        std::unique_lock<std::mutex> lk(cv_m);
153
154
78.6k
        while (_que.empty() && !_stop) {
155
9.83k
            cv.wait_for(lk, std::chrono::seconds(3), [this] { return !_que.empty() || _stop; });
156
4.92k
        }
157
73.7k
        if (_stop) {
158
3
            break;
159
3
        }
160
73.7k
        {
161
73.7k
            std::unique_lock<std::mutex> lc(_que_lock);
162
73.7k
            std::list<std::shared_ptr<pipeline::RuntimeFilterTimer>> new_que;
163
716k
            for (auto& it : _que) {
164
716k
                if (it.use_count() == 1) {
165
                    // `use_count == 1` means this runtime filter has been released
166
716k
                } else if (it->should_be_check_timeout()) {
167
713k
                    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
694k
                        int64_t ms_since_registration = MonotonicMillis() - it->registration_time();
170
694k
                        if (ms_since_registration > it->wait_time_ms()) {
171
6.66k
                            it->call_timeout();
172
687k
                        } else {
173
687k
                            new_que.push_back(std::move(it));
174
687k
                        }
175
694k
                    }
176
713k
                } else {
177
3.12k
                    new_que.push_back(std::move(it));
178
3.12k
                }
179
716k
            }
180
73.7k
            new_que.swap(_que);
181
73.7k
        }
182
73.7k
        std::this_thread::sleep_for(std::chrono::milliseconds(interval));
183
73.7k
    }
184
8
    _shutdown = true;
185
8
}
186
187
642k
void LocalExchangeSharedState::sub_running_sink_operators() {
188
642k
    std::unique_lock<std::mutex> lc(le_lock);
189
642k
    if (exchanger->_running_sink_operators.fetch_sub(1) == 1) {
190
210k
        _set_always_ready();
191
210k
    }
192
642k
}
193
194
1.16M
void LocalExchangeSharedState::sub_running_source_operators() {
195
1.16M
    std::unique_lock<std::mutex> lc(le_lock);
196
1.16M
    if (exchanger->_running_source_operators.fetch_sub(1) == 1) {
197
210k
        _set_always_ready();
198
210k
        exchanger->finalize();
199
210k
    }
200
1.16M
}
201
202
209k
LocalExchangeSharedState::LocalExchangeSharedState(int num_instances) {
203
209k
    source_deps.resize(num_instances, nullptr);
204
209k
    mem_counters.resize(num_instances, nullptr);
205
209k
}
206
207
49
vectorized::MutableColumns AggSharedState::_get_keys_hash_table() {
208
49
    return std::visit(
209
49
            vectorized::Overload {
210
49
                    [&](std::monostate& arg) {
211
0
                        throw doris::Exception(ErrorCode::INTERNAL_ERROR, "uninited hash table");
212
0
                        return vectorized::MutableColumns();
213
0
                    },
214
49
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
49
                        vectorized::MutableColumns key_columns;
216
132
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
83
                            key_columns.emplace_back(
218
83
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
83
                        }
220
49
                        auto& data = *agg_method.hash_table;
221
49
                        bool has_null_key = data.has_null_key_data();
222
49
                        const auto size = data.size() - has_null_key;
223
49
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
49
                        std::vector<KeyType> keys(size);
225
226
49
                        uint32_t num_rows = 0;
227
49
                        auto iter = aggregate_data_container->begin();
228
49
                        {
229
20.5k
                            while (iter != aggregate_data_container->end()) {
230
20.5k
                                keys[num_rows] = iter.get_key<KeyType>();
231
20.5k
                                ++iter;
232
20.5k
                                ++num_rows;
233
20.5k
                            }
234
49
                        }
235
49
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
49
                        if (has_null_key) {
237
2
                            key_columns[0]->insert_data(nullptr, 0);
238
2
                        }
239
49
                        return key_columns;
240
49
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS7_vEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
Line
Count
Source
214
4
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
4
                        vectorized::MutableColumns key_columns;
216
20
                        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
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
8.12k
                            while (iter != aggregate_data_container->end()) {
230
8.11k
                                keys[num_rows] = iter.get_key<KeyType>();
231
8.11k
                                ++iter;
232
8.11k
                                ++num_rows;
233
8.11k
                            }
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_10vectorized15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEESt6vectorINS_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
12
                            while (iter != aggregate_data_container->end()) {
230
8
                                keys[num_rows] = iter.get_key<KeyType>();
231
8
                                ++iter;
232
8
                                ++num_rows;
233
8
                            }
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
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
Line
Count
Source
214
1
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
1
                        vectorized::MutableColumns key_columns;
216
2
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
1
                            key_columns.emplace_back(
218
1
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
1
                        }
220
1
                        auto& data = *agg_method.hash_table;
221
1
                        bool has_null_key = data.has_null_key_data();
222
1
                        const auto size = data.size() - has_null_key;
223
1
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
1
                        std::vector<KeyType> keys(size);
225
226
1
                        uint32_t num_rows = 0;
227
1
                        auto iter = aggregate_data_container->begin();
228
1
                        {
229
6
                            while (iter != aggregate_data_container->end()) {
230
5
                                keys[num_rows] = iter.get_key<KeyType>();
231
5
                                ++iter;
232
5
                                ++num_rows;
233
5
                            }
234
1
                        }
235
1
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
1
                        if (has_null_key) {
237
0
                            key_columns[0]->insert_data(nullptr, 0);
238
0
                        }
239
1
                        return key_columns;
240
1
                    }},
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
2
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
2
                        vectorized::MutableColumns key_columns;
216
4
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
2
                            key_columns.emplace_back(
218
2
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
2
                        }
220
2
                        auto& data = *agg_method.hash_table;
221
2
                        bool has_null_key = data.has_null_key_data();
222
2
                        const auto size = data.size() - has_null_key;
223
2
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
2
                        std::vector<KeyType> keys(size);
225
226
2
                        uint32_t num_rows = 0;
227
2
                        auto iter = aggregate_data_container->begin();
228
2
                        {
229
4
                            while (iter != aggregate_data_container->end()) {
230
2
                                keys[num_rows] = iter.get_key<KeyType>();
231
2
                                ++iter;
232
2
                                ++num_rows;
233
2
                            }
234
2
                        }
235
2
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
2
                        if (has_null_key) {
237
0
                            key_columns[0]->insert_data(nullptr, 0);
238
0
                        }
239
2
                        return key_columns;
240
2
                    }},
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
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIhNS4_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
Line
Count
Source
214
3
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
3
                        vectorized::MutableColumns key_columns;
216
6
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
3
                            key_columns.emplace_back(
218
3
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
3
                        }
220
3
                        auto& data = *agg_method.hash_table;
221
3
                        bool has_null_key = data.has_null_key_data();
222
3
                        const auto size = data.size() - has_null_key;
223
3
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
3
                        std::vector<KeyType> keys(size);
225
226
3
                        uint32_t num_rows = 0;
227
3
                        auto iter = aggregate_data_container->begin();
228
3
                        {
229
30
                            while (iter != aggregate_data_container->end()) {
230
27
                                keys[num_rows] = iter.get_key<KeyType>();
231
27
                                ++iter;
232
27
                                ++num_rows;
233
27
                            }
234
3
                        }
235
3
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
3
                        if (has_null_key) {
237
0
                            key_columns[0]->insert_data(nullptr, 0);
238
0
                        }
239
3
                        return key_columns;
240
3
                    }},
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
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
3.92k
                            while (iter != aggregate_data_container->end()) {
230
3.92k
                                keys[num_rows] = iter.get_key<KeyType>();
231
3.92k
                                ++iter;
232
3.92k
                                ++num_rows;
233
3.92k
                            }
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
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISJ_EESaISM_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
3.93k
                            while (iter != aggregate_data_container->end()) {
230
3.92k
                                keys[num_rows] = iter.get_key<KeyType>();
231
3.92k
                                ++iter;
232
3.92k
                                ++num_rows;
233
3.92k
                            }
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
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISL_EESaISO_EEOT_
Line
Count
Source
214
3
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
3
                        vectorized::MutableColumns key_columns;
216
6
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
3
                            key_columns.emplace_back(
218
3
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
3
                        }
220
3
                        auto& data = *agg_method.hash_table;
221
3
                        bool has_null_key = data.has_null_key_data();
222
3
                        const auto size = data.size() - has_null_key;
223
3
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
3
                        std::vector<KeyType> keys(size);
225
226
3
                        uint32_t num_rows = 0;
227
3
                        auto iter = aggregate_data_container->begin();
228
3
                        {
229
7
                            while (iter != aggregate_data_container->end()) {
230
4
                                keys[num_rows] = iter.get_key<KeyType>();
231
4
                                ++iter;
232
4
                                ++num_rows;
233
4
                            }
234
3
                        }
235
3
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
3
                        if (has_null_key) {
237
1
                            key_columns[0]->insert_data(nullptr, 0);
238
1
                        }
239
3
                        return key_columns;
240
3
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISL_EESaISO_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
21
                            while (iter != aggregate_data_container->end()) {
230
17
                                keys[num_rows] = iter.get_key<KeyType>();
231
17
                                ++iter;
232
17
                                ++num_rows;
233
17
                            }
234
4
                        }
235
4
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
4
                        if (has_null_key) {
237
1
                            key_columns[0]->insert_data(nullptr, 0);
238
1
                        }
239
4
                        return key_columns;
240
4
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISM_EESaISP_EEOT_
Line
Count
Source
214
3
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
3
                        vectorized::MutableColumns key_columns;
216
6
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
3
                            key_columns.emplace_back(
218
3
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
3
                        }
220
3
                        auto& data = *agg_method.hash_table;
221
3
                        bool has_null_key = data.has_null_key_data();
222
3
                        const auto size = data.size() - has_null_key;
223
3
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
3
                        std::vector<KeyType> keys(size);
225
226
3
                        uint32_t num_rows = 0;
227
3
                        auto iter = aggregate_data_container->begin();
228
3
                        {
229
20
                            while (iter != aggregate_data_container->end()) {
230
17
                                keys[num_rows] = iter.get_key<KeyType>();
231
17
                                ++iter;
232
17
                                ++num_rows;
233
17
                            }
234
3
                        }
235
3
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
3
                        if (has_null_key) {
237
0
                            key_columns[0]->insert_data(nullptr, 0);
238
0
                        }
239
3
                        return key_columns;
240
3
                    }},
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
12
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
12
                        vectorized::MutableColumns key_columns;
216
46
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
34
                            key_columns.emplace_back(
218
34
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
34
                        }
220
12
                        auto& data = *agg_method.hash_table;
221
12
                        bool has_null_key = data.has_null_key_data();
222
12
                        const auto size = data.size() - has_null_key;
223
12
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
12
                        std::vector<KeyType> keys(size);
225
226
12
                        uint32_t num_rows = 0;
227
12
                        auto iter = aggregate_data_container->begin();
228
12
                        {
229
4.46k
                            while (iter != aggregate_data_container->end()) {
230
4.45k
                                keys[num_rows] = iter.get_key<KeyType>();
231
4.45k
                                ++iter;
232
4.45k
                                ++num_rows;
233
4.45k
                            }
234
12
                        }
235
12
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
12
                        if (has_null_key) {
237
0
                            key_columns[0]->insert_data(nullptr, 0);
238
0
                        }
239
12
                        return key_columns;
240
12
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136EPc9HashCRC32IS7_EEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
241
49
            agg_data->method_variant);
242
49
}
243
244
49
void AggSharedState::build_limit_heap(size_t hash_table_size) {
245
49
    limit_columns = _get_keys_hash_table();
246
20.5k
    for (size_t i = 0; i < hash_table_size; ++i) {
247
20.4k
        limit_heap.emplace(i, limit_columns, order_directions, null_directions);
248
20.4k
    }
249
20.4k
    while (hash_table_size > limit) {
250
20.3k
        limit_heap.pop();
251
20.3k
        hash_table_size--;
252
20.3k
    }
253
49
    limit_columns_min = limit_heap.top()._row_id;
254
49
}
255
256
bool AggSharedState::do_limit_filter(vectorized::Block* block, size_t num_rows,
257
246
                                     const std::vector<int>* key_locs) {
258
246
    if (num_rows) {
259
246
        cmp_res.resize(num_rows);
260
246
        need_computes.resize(num_rows);
261
246
        memset(need_computes.data(), 0, need_computes.size());
262
246
        memset(cmp_res.data(), 0, cmp_res.size());
263
264
246
        const auto key_size = null_directions.size();
265
725
        for (int i = 0; i < key_size; i++) {
266
479
            block->get_by_position(key_locs ? key_locs->operator[](i) : i)
267
479
                    .column->compare_internal(limit_columns_min, *limit_columns[i],
268
479
                                              null_directions[i], order_directions[i], cmp_res,
269
479
                                              need_computes.data());
270
479
        }
271
272
246
        auto set_computes_arr = [](auto* __restrict res, auto* __restrict computes, size_t rows) {
273
696k
            for (size_t i = 0; i < rows; ++i) {
274
695k
                computes[i] = computes[i] == res[i];
275
695k
            }
276
246
        };
277
246
        set_computes_arr(cmp_res.data(), need_computes.data(), num_rows);
278
279
246
        return std::find(need_computes.begin(), need_computes.end(), 0) != need_computes.end();
280
246
    }
281
282
0
    return false;
283
246
}
284
285
3.11k
Status AggSharedState::reset_hash_table() {
286
3.11k
    return std::visit(
287
3.11k
            vectorized::Overload {
288
3.11k
                    [&](std::monostate& arg) -> Status {
289
0
                        return Status::InternalError("Uninited hash table");
290
0
                    },
291
3.11k
                    [&](auto& agg_method) {
292
3.11k
                        auto& hash_table = *agg_method.hash_table;
293
3.11k
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
3.11k
                        agg_method.arena.clear();
296
3.11k
                        agg_method.inited_iterator = false;
297
298
1.54M
                        hash_table.for_each_mapped([&](auto& mapped) {
299
1.54M
                            if (mapped) {
300
1.54M
                                static_cast<void>(_destroy_agg_status(mapped));
301
1.54M
                                mapped = nullptr;
302
1.54M
                            }
303
1.54M
                        });
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
8
                        hash_table.for_each_mapped([&](auto& mapped) {
299
8
                            if (mapped) {
300
8
                                static_cast<void>(_destroy_agg_status(mapped));
301
8
                                mapped = nullptr;
302
8
                            }
303
8
                        });
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEDaRT_ENKUlSD_E_clIS7_EEDaSD_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEEDaRT_ENKUlSD_E_clIS7_EEDaSD_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEEDaRT_ENKUlSD_E_clIS7_EEDaSD_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEDaRT_ENKUlSE_E_clIS7_EEDaSE_
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEEDaRT_ENKUlSG_E_clISA_EEDaSG_
Line
Count
Source
298
168
                        hash_table.for_each_mapped([&](auto& mapped) {
299
168
                            if (mapped) {
300
168
                                static_cast<void>(_destroy_agg_status(mapped));
301
168
                                mapped = nullptr;
302
168
                            }
303
168
                        });
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
646
                        hash_table.for_each_mapped([&](auto& mapped) {
299
646
                            if (mapped) {
300
646
                                static_cast<void>(_destroy_agg_status(mapped));
301
646
                                mapped = nullptr;
302
646
                            }
303
646
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIhNS4_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_
Line
Count
Source
298
72
                        hash_table.for_each_mapped([&](auto& mapped) {
299
72
                            if (mapped) {
300
72
                                static_cast<void>(_destroy_agg_status(mapped));
301
72
                                mapped = nullptr;
302
72
                            }
303
72
                        });
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberItNS4_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_
Line
Count
Source
298
6.42k
                        hash_table.for_each_mapped([&](auto& mapped) {
299
6.42k
                            if (mapped) {
300
6.42k
                                static_cast<void>(_destroy_agg_status(mapped));
301
6.42k
                                mapped = nullptr;
302
6.42k
                            }
303
6.42k
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_
Line
Count
Source
298
46.2k
                        hash_table.for_each_mapped([&](auto& mapped) {
299
46.2k
                            if (mapped) {
300
46.2k
                                static_cast<void>(_destroy_agg_status(mapped));
301
46.2k
                                mapped = nullptr;
302
46.2k
                            }
303
46.2k
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEDaRT_ENKUlSJ_E_clIS9_EEDaSJ_
Line
Count
Source
298
401k
                        hash_table.for_each_mapped([&](auto& mapped) {
299
401k
                            if (mapped) {
300
401k
                                static_cast<void>(_destroy_agg_status(mapped));
301
401k
                                mapped = nullptr;
302
401k
                            }
303
401k
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEDaRT_ENKUlSJ_E_clIS9_EEDaSJ_
Line
Count
Source
298
37.1k
                        hash_table.for_each_mapped([&](auto& mapped) {
299
37.1k
                            if (mapped) {
300
37.1k
                                static_cast<void>(_destroy_agg_status(mapped));
301
37.1k
                                mapped = nullptr;
302
37.1k
                            }
303
37.1k
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEEDaRT_ENKUlSK_E_clISC_EEDaSK_
Line
Count
Source
298
60
                        hash_table.for_each_mapped([&](auto& mapped) {
299
60
                            if (mapped) {
300
60
                                static_cast<void>(_destroy_agg_status(mapped));
301
60
                                mapped = nullptr;
302
60
                            }
303
60
                        });
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
3.11k
                        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
3.11k
                        aggregate_data_container.reset(new AggregateDataContainer(
312
3.11k
                                sizeof(typename HashTableType::key_type),
313
3.11k
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
3.11k
                                 align_aggregate_states) *
315
3.11k
                                        align_aggregate_states));
316
3.11k
                        agg_method.hash_table.reset(new HashTableType());
317
3.11k
                        return Status::OK();
318
3.11k
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS7_vEEEEEEDaRT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEDaRT_
Line
Count
Source
291
8
                    [&](auto& agg_method) {
292
8
                        auto& hash_table = *agg_method.hash_table;
293
8
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
8
                        agg_method.arena.clear();
296
8
                        agg_method.inited_iterator = false;
297
298
8
                        hash_table.for_each_mapped([&](auto& mapped) {
299
8
                            if (mapped) {
300
8
                                static_cast<void>(_destroy_agg_status(mapped));
301
8
                                mapped = nullptr;
302
8
                            }
303
8
                        });
304
305
8
                        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
8
                        aggregate_data_container.reset(new AggregateDataContainer(
312
8
                                sizeof(typename HashTableType::key_type),
313
8
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
8
                                 align_aggregate_states) *
315
8
                                        align_aggregate_states));
316
8
                        agg_method.hash_table.reset(new HashTableType());
317
8
                        return Status::OK();
318
8
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEDaRT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEEDaRT_
Line
Count
Source
291
52
                    [&](auto& agg_method) {
292
52
                        auto& hash_table = *agg_method.hash_table;
293
52
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
52
                        agg_method.arena.clear();
296
52
                        agg_method.inited_iterator = false;
297
298
52
                        hash_table.for_each_mapped([&](auto& mapped) {
299
52
                            if (mapped) {
300
52
                                static_cast<void>(_destroy_agg_status(mapped));
301
52
                                mapped = nullptr;
302
52
                            }
303
52
                        });
304
305
52
                        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
52
                        aggregate_data_container.reset(new AggregateDataContainer(
312
52
                                sizeof(typename HashTableType::key_type),
313
52
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
52
                                 align_aggregate_states) *
315
52
                                        align_aggregate_states));
316
52
                        agg_method.hash_table.reset(new HashTableType());
317
52
                        return Status::OK();
318
52
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEEDaRT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEDaRT_
Line
Count
Source
291
15
                    [&](auto& agg_method) {
292
15
                        auto& hash_table = *agg_method.hash_table;
293
15
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
15
                        agg_method.arena.clear();
296
15
                        agg_method.inited_iterator = false;
297
298
15
                        hash_table.for_each_mapped([&](auto& mapped) {
299
15
                            if (mapped) {
300
15
                                static_cast<void>(_destroy_agg_status(mapped));
301
15
                                mapped = nullptr;
302
15
                            }
303
15
                        });
304
305
15
                        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
15
                        aggregate_data_container.reset(new AggregateDataContainer(
312
15
                                sizeof(typename HashTableType::key_type),
313
15
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
15
                                 align_aggregate_states) *
315
15
                                        align_aggregate_states));
316
15
                        agg_method.hash_table.reset(new HashTableType());
317
15
                        return Status::OK();
318
15
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEDaRT_
Line
Count
Source
291
184
                    [&](auto& agg_method) {
292
184
                        auto& hash_table = *agg_method.hash_table;
293
184
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
184
                        agg_method.arena.clear();
296
184
                        agg_method.inited_iterator = false;
297
298
184
                        hash_table.for_each_mapped([&](auto& mapped) {
299
184
                            if (mapped) {
300
184
                                static_cast<void>(_destroy_agg_status(mapped));
301
184
                                mapped = nullptr;
302
184
                            }
303
184
                        });
304
305
184
                        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
184
                        aggregate_data_container.reset(new AggregateDataContainer(
312
184
                                sizeof(typename HashTableType::key_type),
313
184
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
184
                                 align_aggregate_states) *
315
184
                                        align_aggregate_states));
316
184
                        agg_method.hash_table.reset(new HashTableType());
317
184
                        return Status::OK();
318
184
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIhNS4_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEDaRT_
Line
Count
Source
291
64
                    [&](auto& agg_method) {
292
64
                        auto& hash_table = *agg_method.hash_table;
293
64
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
64
                        agg_method.arena.clear();
296
64
                        agg_method.inited_iterator = false;
297
298
64
                        hash_table.for_each_mapped([&](auto& mapped) {
299
64
                            if (mapped) {
300
64
                                static_cast<void>(_destroy_agg_status(mapped));
301
64
                                mapped = nullptr;
302
64
                            }
303
64
                        });
304
305
64
                        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
64
                        aggregate_data_container.reset(new AggregateDataContainer(
312
64
                                sizeof(typename HashTableType::key_type),
313
64
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
64
                                 align_aggregate_states) *
315
64
                                        align_aggregate_states));
316
64
                        agg_method.hash_table.reset(new HashTableType());
317
64
                        return Status::OK();
318
64
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberItNS4_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEDaRT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEDaRT_
Line
Count
Source
291
576
                    [&](auto& agg_method) {
292
576
                        auto& hash_table = *agg_method.hash_table;
293
576
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
576
                        agg_method.arena.clear();
296
576
                        agg_method.inited_iterator = false;
297
298
576
                        hash_table.for_each_mapped([&](auto& mapped) {
299
576
                            if (mapped) {
300
576
                                static_cast<void>(_destroy_agg_status(mapped));
301
576
                                mapped = nullptr;
302
576
                            }
303
576
                        });
304
305
576
                        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
576
                        aggregate_data_container.reset(new AggregateDataContainer(
312
576
                                sizeof(typename HashTableType::key_type),
313
576
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
576
                                 align_aggregate_states) *
315
576
                                        align_aggregate_states));
316
576
                        agg_method.hash_table.reset(new HashTableType());
317
576
                        return Status::OK();
318
576
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEDaRT_
Line
Count
Source
291
382
                    [&](auto& agg_method) {
292
382
                        auto& hash_table = *agg_method.hash_table;
293
382
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
382
                        agg_method.arena.clear();
296
382
                        agg_method.inited_iterator = false;
297
298
382
                        hash_table.for_each_mapped([&](auto& mapped) {
299
382
                            if (mapped) {
300
382
                                static_cast<void>(_destroy_agg_status(mapped));
301
382
                                mapped = nullptr;
302
382
                            }
303
382
                        });
304
305
382
                        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
382
                        aggregate_data_container.reset(new AggregateDataContainer(
312
382
                                sizeof(typename HashTableType::key_type),
313
382
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
382
                                 align_aggregate_states) *
315
382
                                        align_aggregate_states));
316
382
                        agg_method.hash_table.reset(new HashTableType());
317
382
                        return Status::OK();
318
382
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEDaRT_
Line
Count
Source
291
1.03k
                    [&](auto& agg_method) {
292
1.03k
                        auto& hash_table = *agg_method.hash_table;
293
1.03k
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
1.03k
                        agg_method.arena.clear();
296
1.03k
                        agg_method.inited_iterator = false;
297
298
1.03k
                        hash_table.for_each_mapped([&](auto& mapped) {
299
1.03k
                            if (mapped) {
300
1.03k
                                static_cast<void>(_destroy_agg_status(mapped));
301
1.03k
                                mapped = nullptr;
302
1.03k
                            }
303
1.03k
                        });
304
305
1.03k
                        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.03k
                        aggregate_data_container.reset(new AggregateDataContainer(
312
1.03k
                                sizeof(typename HashTableType::key_type),
313
1.03k
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
1.03k
                                 align_aggregate_states) *
315
1.03k
                                        align_aggregate_states));
316
1.03k
                        agg_method.hash_table.reset(new HashTableType());
317
1.03k
                        return Status::OK();
318
1.03k
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEDaRT_
Line
Count
Source
291
756
                    [&](auto& agg_method) {
292
756
                        auto& hash_table = *agg_method.hash_table;
293
756
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
756
                        agg_method.arena.clear();
296
756
                        agg_method.inited_iterator = false;
297
298
756
                        hash_table.for_each_mapped([&](auto& mapped) {
299
756
                            if (mapped) {
300
756
                                static_cast<void>(_destroy_agg_status(mapped));
301
756
                                mapped = nullptr;
302
756
                            }
303
756
                        });
304
305
756
                        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
756
                        aggregate_data_container.reset(new AggregateDataContainer(
312
756
                                sizeof(typename HashTableType::key_type),
313
756
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
756
                                 align_aggregate_states) *
315
756
                                        align_aggregate_states));
316
756
                        agg_method.hash_table.reset(new HashTableType());
317
756
                        return Status::OK();
318
756
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEEDaRT_
Line
Count
Source
291
40
                    [&](auto& agg_method) {
292
40
                        auto& hash_table = *agg_method.hash_table;
293
40
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
40
                        agg_method.arena.clear();
296
40
                        agg_method.inited_iterator = false;
297
298
40
                        hash_table.for_each_mapped([&](auto& mapped) {
299
40
                            if (mapped) {
300
40
                                static_cast<void>(_destroy_agg_status(mapped));
301
40
                                mapped = nullptr;
302
40
                            }
303
40
                        });
304
305
40
                        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
40
                        aggregate_data_container.reset(new AggregateDataContainer(
312
40
                                sizeof(typename HashTableType::key_type),
313
40
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
40
                                 align_aggregate_states) *
315
40
                                        align_aggregate_states));
316
40
                        agg_method.hash_table.reset(new HashTableType());
317
40
                        return Status::OK();
318
40
                    }},
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
3.11k
            agg_data->method_variant);
320
3.11k
}
321
322
526
void PartitionedAggSharedState::init_spill_params(size_t spill_partition_count) {
323
526
    partition_count = spill_partition_count;
324
526
    max_partition_index = partition_count - 1;
325
326
17.3k
    for (int i = 0; i < partition_count; ++i) {
327
16.8k
        spill_partitions.emplace_back(std::make_shared<AggSpillPartition>());
328
16.8k
    }
329
526
}
330
331
513
void PartitionedAggSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {
332
16.4k
    for (auto& partition : spill_partitions) {
333
16.4k
        if (partition->spilling_stream_) {
334
0
            partition->spilling_stream_->update_shared_profiles(source_profile);
335
0
        }
336
16.4k
        for (auto& stream : partition->spill_streams_) {
337
2.35k
            if (stream) {
338
2.35k
                stream->update_shared_profiles(source_profile);
339
2.35k
            }
340
2.35k
        }
341
16.4k
    }
342
513
}
343
344
Status AggSpillPartition::get_spill_stream(RuntimeState* state, int node_id,
345
                                           RuntimeProfile* profile,
346
7.43k
                                           vectorized::SpillStreamSPtr& spill_stream) {
347
7.43k
    if (spilling_stream_) {
348
5.03k
        spill_stream = spilling_stream_;
349
5.03k
        return Status::OK();
350
5.03k
    }
351
2.40k
    RETURN_IF_ERROR(ExecEnv::GetInstance()->spill_stream_mgr()->register_spill_stream(
352
2.40k
            state, spilling_stream_, print_id(state->query_id()), "agg", node_id,
353
2.40k
            std::numeric_limits<int32_t>::max(), std::numeric_limits<size_t>::max(), profile));
354
2.40k
    spill_streams_.emplace_back(spilling_stream_);
355
2.40k
    spill_stream = spilling_stream_;
356
2.40k
    return Status::OK();
357
2.40k
}
358
11.3k
void AggSpillPartition::close() {
359
11.3k
    if (spilling_stream_) {
360
1
        spilling_stream_.reset();
361
1
    }
362
11.3k
    for (auto& stream : spill_streams_) {
363
5
        (void)ExecEnv::GetInstance()->spill_stream_mgr()->delete_spill_stream(stream);
364
5
    }
365
11.3k
    spill_streams_.clear();
366
11.3k
}
367
368
615
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
615
    bool false_close = false;
372
615
    if (!is_closed.compare_exchange_strong(false_close, true)) {
373
97
        return;
374
97
    }
375
615
    DCHECK(!false_close && is_closed);
376
11.3k
    for (auto partition : spill_partitions) {
377
11.3k
        partition->close();
378
11.3k
    }
379
518
    spill_partitions.clear();
380
518
}
381
382
14
void SpillSortSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {
383
32
    for (auto& stream : sorted_streams) {
384
32
        if (stream) {
385
32
            stream->update_shared_profiles(source_profile);
386
32
        }
387
32
    }
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.81k
        : multi_cast_data_streamer(std::make_unique<pipeline::MultiCastDataStreamer>(
406
1.81k
                  pool, cast_sender_count, node_id)) {}
407
408
0
void MultiCastSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {}
409
410
123k
int AggSharedState::get_slot_column_id(const vectorized::AggFnEvaluator* evaluator) {
411
123k
    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
123k
    return ((vectorized::VSlotRef*)ctxs[0]->root().get())->column_id();
416
123k
}
417
418
3.72M
Status AggSharedState::_destroy_agg_status(vectorized::AggregateDataPtr data) {
419
8.93M
    for (int i = 0; i < aggregate_evaluators.size(); ++i) {
420
5.20M
        aggregate_evaluators[i]->function()->destroy(data + offsets_of_aggregate_states[i]);
421
5.20M
    }
422
3.72M
    return Status::OK();
423
3.72M
}
424
425
210k
LocalExchangeSharedState::~LocalExchangeSharedState() = default;
426
427
1.15k
Status SetSharedState::update_build_not_ignore_null(const vectorized::VExprContextSPtrs& ctxs) {
428
1.15k
    if (ctxs.size() > build_not_ignore_null.size()) {
429
0
        return Status::InternalError("build_not_ignore_null not initialized");
430
0
    }
431
432
2.65k
    for (int i = 0; i < ctxs.size(); ++i) {
433
1.50k
        build_not_ignore_null[i] = build_not_ignore_null[i] || ctxs[i]->root()->is_nullable();
434
1.50k
    }
435
436
1.15k
    return Status::OK();
437
1.15k
}
438
439
1.14k
size_t SetSharedState::get_hash_table_size() const {
440
1.14k
    size_t hash_table_size = 0;
441
1.14k
    std::visit(
442
1.14k
            [&](auto&& arg) {
443
1.14k
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
1.14k
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
1.14k
                    hash_table_size = arg.hash_table->size();
446
1.14k
                }
447
1.14k
            },
Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRSt9monostateEEDaOT_
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS7_vEEEEEEDaOT_
Line
Count
Source
442
256
            [&](auto&& arg) {
443
256
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
256
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
256
                    hash_table_size = arg.hash_table->size();
446
256
                }
447
256
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized19MethodStringNoCacheI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS7_vEEEEEEDaOT_
Line
Count
Source
442
239
            [&](auto&& arg) {
443
239
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
239
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
239
                    hash_table_size = arg.hash_table->size();
446
239
                }
447
239
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIhNS4_15DataWithNullKeyI9PHHashMapIhNS_14RowRefWithFlagE9HashCRC32IhEEEEEEEEEEDaOT_
Line
Count
Source
442
80
            [&](auto&& arg) {
443
80
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
80
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
80
                    hash_table_size = arg.hash_table->size();
446
80
                }
447
80
            },
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
390
            [&](auto&& arg) {
443
390
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
390
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
390
                    hash_table_size = arg.hash_table->size();
446
390
                }
447
390
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImNS_14RowRefWithFlagE9HashCRC32ImEEEEEEEEEEDaOT_
Line
Count
Source
442
28
            [&](auto&& arg) {
443
28
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
28
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
28
                    hash_table_size = arg.hash_table->size();
446
28
                }
447
28
            },
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
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
            },
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
14
            [&](auto&& arg) {
443
14
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
14
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
14
                    hash_table_size = arg.hash_table->size();
446
14
                }
447
14
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEENS_14RowRefWithFlagE9HashCRC32IS9_EEEEEEDaOT_
Line
Count
Source
442
58
            [&](auto&& arg) {
443
58
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
58
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
58
                    hash_table_size = arg.hash_table->size();
446
58
                }
447
58
            },
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
9
            [&](auto&& arg) {
443
9
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
9
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
9
                    hash_table_size = arg.hash_table->size();
446
9
                }
447
9
            },
448
1.14k
            hash_table_variants->method_variant);
449
1.14k
    return hash_table_size;
450
1.14k
}
451
452
495
Status SetSharedState::hash_table_init() {
453
495
    std::vector<vectorized::DataTypePtr> data_types;
454
1.16k
    for (size_t i = 0; i != child_exprs_lists[0].size(); ++i) {
455
671
        auto& ctx = child_exprs_lists[0][i];
456
671
        auto data_type = ctx->root()->data_type();
457
671
        if (build_not_ignore_null[i]) {
458
511
            data_type = vectorized::make_nullable(data_type);
459
511
        }
460
671
        data_types.emplace_back(std::move(data_type));
461
671
    }
462
495
    return init_hash_method<SetDataVariants>(hash_table_variants.get(), data_types, true);
463
495
}
464
465
void AggSharedState::refresh_top_limit(size_t row_id,
466
52
                                       const vectorized::ColumnRawPtrs& key_columns) {
467
161
    for (int j = 0; j < key_columns.size(); ++j) {
468
109
        limit_columns[j]->insert_from(*key_columns[j], row_id);
469
109
    }
470
52
    limit_heap.emplace(limit_columns[0]->size() - 1, limit_columns, order_directions,
471
52
                       null_directions);
472
473
52
    limit_heap.pop();
474
52
    limit_columns_min = limit_heap.top()._row_id;
475
52
}
476
477
} // namespace doris::pipeline