Coverage Report

Created: 2026-01-30 12:38

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
407k
                                                       const std::string& name) {
43
407k
    source_deps.push_back(std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY"));
44
407k
    source_deps.back()->set_shared_state(this);
45
407k
    return source_deps.back().get();
46
407k
}
47
48
void BasicSharedState::create_source_dependencies(int num_sources, int operator_id, int node_id,
49
108k
                                                  const std::string& name) {
50
108k
    source_deps.resize(num_sources, nullptr);
51
784k
    for (auto& source_dep : source_deps) {
52
784k
        source_dep = std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY");
53
784k
        source_dep->set_shared_state(this);
54
784k
    }
55
108k
}
56
57
Dependency* BasicSharedState::create_sink_dependency(int dest_id, int node_id,
58
991k
                                                     const std::string& name) {
59
991k
    sink_deps.push_back(std::make_shared<Dependency>(dest_id, node_id, name + "_DEPENDENCY", true));
60
991k
    sink_deps.back()->set_shared_state(this);
61
991k
    return sink_deps.back().get();
62
991k
}
63
64
4.46M
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
4.46M
    _blocked_task.push_back(task);
69
4.46M
}
70
71
19.8M
void Dependency::set_ready() {
72
19.8M
    if (_ready) {
73
15.8M
        return;
74
15.8M
    }
75
4.04M
    std::vector<std::weak_ptr<PipelineTask>> local_block_task {};
76
4.04M
    {
77
4.04M
        std::unique_lock<std::mutex> lc(_task_lock);
78
4.04M
        if (_ready) {
79
0
            return;
80
0
        }
81
4.04M
        _watcher.stop();
82
4.04M
        _ready = true;
83
4.04M
        local_block_task.swap(_blocked_task);
84
4.04M
    }
85
4.48M
    for (auto task : local_block_task) {
86
4.48M
        if (auto t = task.lock()) {
87
4.48M
            std::unique_lock<std::mutex> lc(_task_lock);
88
4.48M
            THROW_IF_ERROR(t->wake_up(this, lc));
89
4.48M
        }
90
4.48M
    }
91
4.04M
}
92
93
34.6M
Dependency* Dependency::is_blocked_by(std::shared_ptr<PipelineTask> task) {
94
34.6M
    std::unique_lock<std::mutex> lc(_task_lock);
95
34.6M
    auto ready = _ready.load();
96
34.6M
    if (!ready && task) {
97
4.48M
        _add_block_task(task);
98
4.48M
        start_watcher();
99
4.48M
        THROW_IF_ERROR(task->blocked(this, lc));
100
4.48M
    }
101
34.6M
    return ready ? nullptr : this;
102
34.6M
}
103
104
235k
std::string Dependency::debug_string(int indentation_level) {
105
235k
    fmt::memory_buffer debug_string_buffer;
106
235k
    fmt::format_to(debug_string_buffer, "{}{}: id={}, block task = {}, ready={}, _always_ready={}",
107
235k
                   std::string(indentation_level * 2, ' '), _name, _node_id, _blocked_task.size(),
108
235k
                   _ready, _always_ready);
109
235k
    return fmt::to_string(debug_string_buffer);
110
235k
}
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.78k
void RuntimeFilterTimer::call_timeout() {
122
4.78k
    _parent->set_ready();
123
4.78k
}
124
125
14.4k
void RuntimeFilterTimer::call_ready() {
126
14.4k
    _parent->set_ready();
127
14.4k
}
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
885k
bool RuntimeFilterTimer::should_be_check_timeout() {
133
885k
    if (!_parent->ready() && !_local_runtime_filter_dependencies.empty()) {
134
2.35k
        bool all_ready = true;
135
2.39k
        for (auto& dep : _local_runtime_filter_dependencies) {
136
2.39k
            if (!dep->ready()) {
137
2.26k
                all_ready = false;
138
2.26k
                break;
139
2.26k
            }
140
2.39k
        }
141
2.35k
        if (all_ready) {
142
87
            _local_runtime_filter_dependencies.clear();
143
87
            _registration_time = MonotonicMillis();
144
87
        }
145
2.35k
        return all_ready;
146
2.35k
    }
147
882k
    return true;
148
885k
}
149
150
8
void RuntimeFilterTimerQueue::start() {
151
188k
    while (!_stop) {
152
188k
        std::unique_lock<std::mutex> lk(cv_m);
153
154
191k
        while (_que.empty() && !_stop) {
155
5.61k
            cv.wait_for(lk, std::chrono::seconds(3), [this] { return !_que.empty() || _stop; });
156
2.80k
        }
157
188k
        if (_stop) {
158
3
            break;
159
3
        }
160
188k
        {
161
188k
            std::unique_lock<std::mutex> lc(_que_lock);
162
188k
            std::list<std::shared_ptr<pipeline::RuntimeFilterTimer>> new_que;
163
885k
            for (auto& it : _que) {
164
885k
                if (it.use_count() == 1) {
165
                    // `use_count == 1` means this runtime filter has been released
166
885k
                } else if (it->should_be_check_timeout()) {
167
883k
                    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
873k
                        int64_t ms_since_registration = MonotonicMillis() - it->registration_time();
170
873k
                        if (ms_since_registration > it->wait_time_ms()) {
171
4.78k
                            it->call_timeout();
172
868k
                        } else {
173
868k
                            new_que.push_back(std::move(it));
174
868k
                        }
175
873k
                    }
176
883k
                } else {
177
2.26k
                    new_que.push_back(std::move(it));
178
2.26k
                }
179
885k
            }
180
188k
            new_que.swap(_que);
181
188k
        }
182
188k
        std::this_thread::sleep_for(std::chrono::milliseconds(interval));
183
188k
    }
184
8
    _shutdown = true;
185
8
}
186
187
321k
void LocalExchangeSharedState::sub_running_sink_operators() {
188
321k
    std::unique_lock<std::mutex> lc(le_lock);
189
321k
    if (exchanger->_running_sink_operators.fetch_sub(1) == 1) {
190
106k
        _set_always_ready();
191
106k
    }
192
321k
}
193
194
770k
void LocalExchangeSharedState::sub_running_source_operators() {
195
770k
    std::unique_lock<std::mutex> lc(le_lock);
196
770k
    if (exchanger->_running_source_operators.fetch_sub(1) == 1) {
197
106k
        _set_always_ready();
198
106k
        exchanger->finalize();
199
106k
    }
200
770k
}
201
202
106k
LocalExchangeSharedState::LocalExchangeSharedState(int num_instances) {
203
106k
    source_deps.resize(num_instances, nullptr);
204
106k
    mem_counters.resize(num_instances, nullptr);
205
106k
}
206
207
58
vectorized::MutableColumns AggSharedState::_get_keys_hash_table() {
208
58
    return std::visit(
209
58
            vectorized::Overload {
210
58
                    [&](std::monostate& arg) {
211
0
                        throw doris::Exception(ErrorCode::INTERNAL_ERROR, "uninited hash table");
212
0
                        return vectorized::MutableColumns();
213
0
                    },
214
58
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
58
                        vectorized::MutableColumns key_columns;
216
158
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
100
                            key_columns.emplace_back(
218
100
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
100
                        }
220
58
                        auto& data = *agg_method.hash_table;
221
58
                        bool has_null_key = data.has_null_key_data();
222
58
                        const auto size = data.size() - has_null_key;
223
58
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
58
                        std::vector<KeyType> keys(size);
225
226
58
                        uint32_t num_rows = 0;
227
58
                        auto iter = aggregate_data_container->begin();
228
58
                        {
229
16.0k
                            while (iter != aggregate_data_container->end()) {
230
16.0k
                                keys[num_rows] = iter.get_key<KeyType>();
231
16.0k
                                ++iter;
232
16.0k
                                ++num_rows;
233
16.0k
                            }
234
58
                        }
235
58
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
58
                        if (has_null_key) {
237
2
                            key_columns[0]->insert_data(nullptr, 0);
238
2
                        }
239
58
                        return key_columns;
240
58
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS7_vEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
Line
Count
Source
214
3
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
3
                        vectorized::MutableColumns key_columns;
216
15
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
12
                            key_columns.emplace_back(
218
12
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
12
                        }
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
8.12k
                            while (iter != aggregate_data_container->end()) {
230
8.12k
                                keys[num_rows] = iter.get_key<KeyType>();
231
8.12k
                                ++iter;
232
8.12k
                                ++num_rows;
233
8.12k
                            }
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_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
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
17
                            while (iter != aggregate_data_container->end()) {
230
14
                                keys[num_rows] = iter.get_key<KeyType>();
231
14
                                ++iter;
232
14
                                ++num_rows;
233
14
                            }
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_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
8
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
8
                        vectorized::MutableColumns key_columns;
216
16
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
8
                            key_columns.emplace_back(
218
8
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
8
                        }
220
8
                        auto& data = *agg_method.hash_table;
221
8
                        bool has_null_key = data.has_null_key_data();
222
8
                        const auto size = data.size() - has_null_key;
223
8
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
8
                        std::vector<KeyType> keys(size);
225
226
8
                        uint32_t num_rows = 0;
227
8
                        auto iter = aggregate_data_container->begin();
228
8
                        {
229
16
                            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
8
                        }
235
8
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
8
                        if (has_null_key) {
237
0
                            key_columns[0]->insert_data(nullptr, 0);
238
0
                        }
239
8
                        return key_columns;
240
8
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
Line
Count
Source
214
6
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
6
                        vectorized::MutableColumns key_columns;
216
12
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
6
                            key_columns.emplace_back(
218
6
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
6
                        }
220
6
                        auto& data = *agg_method.hash_table;
221
6
                        bool has_null_key = data.has_null_key_data();
222
6
                        const auto size = data.size() - has_null_key;
223
6
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
6
                        std::vector<KeyType> keys(size);
225
226
6
                        uint32_t num_rows = 0;
227
6
                        auto iter = aggregate_data_container->begin();
228
6
                        {
229
28
                            while (iter != aggregate_data_container->end()) {
230
22
                                keys[num_rows] = iter.get_key<KeyType>();
231
22
                                ++iter;
232
22
                                ++num_rows;
233
22
                            }
234
6
                        }
235
6
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
6
                        if (has_null_key) {
237
0
                            key_columns[0]->insert_data(nullptr, 0);
238
0
                        }
239
6
                        return key_columns;
240
6
                    }},
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
15
                            while (iter != aggregate_data_container->end()) {
230
12
                                keys[num_rows] = iter.get_key<KeyType>();
231
12
                                ++iter;
232
12
                                ++num_rows;
233
12
                            }
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_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISL_EESaISO_EEOT_
Line
Count
Source
214
6
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
6
                        vectorized::MutableColumns key_columns;
216
12
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
6
                            key_columns.emplace_back(
218
6
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
6
                        }
220
6
                        auto& data = *agg_method.hash_table;
221
6
                        bool has_null_key = data.has_null_key_data();
222
6
                        const auto size = data.size() - has_null_key;
223
6
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
6
                        std::vector<KeyType> keys(size);
225
226
6
                        uint32_t num_rows = 0;
227
6
                        auto iter = aggregate_data_container->begin();
228
6
                        {
229
2.35k
                            while (iter != aggregate_data_container->end()) {
230
2.35k
                                keys[num_rows] = iter.get_key<KeyType>();
231
2.35k
                                ++iter;
232
2.35k
                                ++num_rows;
233
2.35k
                            }
234
6
                        }
235
6
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
6
                        if (has_null_key) {
237
1
                            key_columns[0]->insert_data(nullptr, 0);
238
1
                        }
239
6
                        return key_columns;
240
6
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISL_EESaISO_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
3.26k
                            while (iter != aggregate_data_container->end()) {
230
3.25k
                                keys[num_rows] = iter.get_key<KeyType>();
231
3.25k
                                ++iter;
232
3.25k
                                ++num_rows;
233
3.25k
                            }
234
10
                        }
235
10
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
10
                        if (has_null_key) {
237
1
                            key_columns[0]->insert_data(nullptr, 0);
238
1
                        }
239
10
                        return key_columns;
240
10
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISM_EESaISP_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
5
                            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
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_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_10vectorized15MethodKeysFixedI9PHHashMapINS4_6UInt72EPc9HashCRC32IS7_EEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapINS4_6UInt96EPc9HashCRC32IS7_EEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt104EPc9HashCRC32IS7_EEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS9_EEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISI_EESaISL_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136EPc9HashCRC32IS7_EEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS9_EEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISI_EESaISL_EEOT_
Line
Count
Source
214
18
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
18
                        vectorized::MutableColumns key_columns;
216
69
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
51
                            key_columns.emplace_back(
218
51
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
51
                        }
220
18
                        auto& data = *agg_method.hash_table;
221
18
                        bool has_null_key = data.has_null_key_data();
222
18
                        const auto size = data.size() - has_null_key;
223
18
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
18
                        std::vector<KeyType> keys(size);
225
226
18
                        uint32_t num_rows = 0;
227
18
                        auto iter = aggregate_data_container->begin();
228
18
                        {
229
2.27k
                            while (iter != aggregate_data_container->end()) {
230
2.25k
                                keys[num_rows] = iter.get_key<KeyType>();
231
2.25k
                                ++iter;
232
2.25k
                                ++num_rows;
233
2.25k
                            }
234
18
                        }
235
18
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
18
                        if (has_null_key) {
237
0
                            key_columns[0]->insert_data(nullptr, 0);
238
0
                        }
239
18
                        return key_columns;
240
18
                    }},
241
58
            agg_data->method_variant);
242
58
}
243
244
58
void AggSharedState::build_limit_heap(size_t hash_table_size) {
245
58
    limit_columns = _get_keys_hash_table();
246
15.9k
    for (size_t i = 0; i < hash_table_size; ++i) {
247
15.8k
        limit_heap.emplace(i, limit_columns, order_directions, null_directions);
248
15.8k
    }
249
15.9k
    while (hash_table_size > limit) {
250
15.8k
        limit_heap.pop();
251
15.8k
        hash_table_size--;
252
15.8k
    }
253
58
    limit_columns_min = limit_heap.top()._row_id;
254
58
}
255
256
bool AggSharedState::do_limit_filter(vectorized::Block* block, size_t num_rows,
257
146
                                     const std::vector<int>* key_locs) {
258
146
    if (num_rows) {
259
146
        cmp_res.resize(num_rows);
260
146
        need_computes.resize(num_rows);
261
146
        memset(need_computes.data(), 0, need_computes.size());
262
146
        memset(cmp_res.data(), 0, cmp_res.size());
263
264
146
        const auto key_size = null_directions.size();
265
418
        for (int i = 0; i < key_size; i++) {
266
272
            block->get_by_position(key_locs ? key_locs->operator[](i) : i)
267
272
                    .column->compare_internal(limit_columns_min, *limit_columns[i],
268
272
                                              null_directions[i], order_directions[i], cmp_res,
269
272
                                              need_computes.data());
270
272
        }
271
272
146
        auto set_computes_arr = [](auto* __restrict res, auto* __restrict computes, size_t rows) {
273
54.6k
            for (size_t i = 0; i < rows; ++i) {
274
54.5k
                computes[i] = computes[i] == res[i];
275
54.5k
            }
276
146
        };
277
146
        set_computes_arr(cmp_res.data(), need_computes.data(), num_rows);
278
279
146
        return std::find(need_computes.begin(), need_computes.end(), 0) != need_computes.end();
280
146
    }
281
282
0
    return false;
283
146
}
284
285
5.79k
Status AggSharedState::reset_hash_table() {
286
5.79k
    return std::visit(
287
5.79k
            vectorized::Overload {
288
5.79k
                    [&](std::monostate& arg) -> Status {
289
0
                        return Status::InternalError("Uninited hash table");
290
0
                    },
291
5.79k
                    [&](auto& agg_method) {
292
5.79k
                        auto& hash_table = *agg_method.hash_table;
293
5.79k
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
5.79k
                        agg_method.arena.clear();
296
5.79k
                        agg_method.inited_iterator = false;
297
298
3.19M
                        hash_table.for_each_mapped([&](auto& mapped) {
299
3.19M
                            if (mapped) {
300
3.19M
                                _destroy_agg_status(mapped);
301
3.19M
                                mapped = nullptr;
302
3.19M
                            }
303
3.19M
                        });
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
326
                        hash_table.for_each_mapped([&](auto& mapped) {
299
326
                            if (mapped) {
300
326
                                _destroy_agg_status(mapped);
301
326
                                mapped = nullptr;
302
326
                            }
303
326
                        });
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_
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEEDaRT_ENKUlSD_E_clIS7_EEDaSD_
Line
Count
Source
298
466
                        hash_table.for_each_mapped([&](auto& mapped) {
299
466
                            if (mapped) {
300
466
                                _destroy_agg_status(mapped);
301
466
                                mapped = nullptr;
302
466
                            }
303
466
                        });
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.12M
                        hash_table.for_each_mapped([&](auto& mapped) {
299
1.12M
                            if (mapped) {
300
1.12M
                                _destroy_agg_status(mapped);
301
1.12M
                                mapped = nullptr;
302
1.12M
                            }
303
1.12M
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Line
Count
Source
298
1.30k
                        hash_table.for_each_mapped([&](auto& mapped) {
299
1.30k
                            if (mapped) {
300
1.30k
                                _destroy_agg_status(mapped);
301
1.30k
                                mapped = nullptr;
302
1.30k
                            }
303
1.30k
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIhNS4_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_
Line
Count
Source
298
272
                        hash_table.for_each_mapped([&](auto& mapped) {
299
272
                            if (mapped) {
300
272
                                _destroy_agg_status(mapped);
301
272
                                mapped = nullptr;
302
272
                            }
303
272
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberItNS4_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_
Line
Count
Source
298
292
                        hash_table.for_each_mapped([&](auto& mapped) {
299
292
                            if (mapped) {
300
292
                                _destroy_agg_status(mapped);
301
292
                                mapped = nullptr;
302
292
                            }
303
292
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_
Line
Count
Source
298
398k
                        hash_table.for_each_mapped([&](auto& mapped) {
299
398k
                            if (mapped) {
300
398k
                                _destroy_agg_status(mapped);
301
398k
                                mapped = nullptr;
302
398k
                            }
303
398k
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_
Line
Count
Source
298
44.4k
                        hash_table.for_each_mapped([&](auto& mapped) {
299
44.4k
                            if (mapped) {
300
44.4k
                                _destroy_agg_status(mapped);
301
44.4k
                                mapped = nullptr;
302
44.4k
                            }
303
44.4k
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEDaRT_ENKUlSJ_E_clIS9_EEDaSJ_
Line
Count
Source
298
1.58M
                        hash_table.for_each_mapped([&](auto& mapped) {
299
1.58M
                            if (mapped) {
300
1.58M
                                _destroy_agg_status(mapped);
301
1.58M
                                mapped = nullptr;
302
1.58M
                            }
303
1.58M
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEDaRT_ENKUlSJ_E_clIS9_EEDaSJ_
Line
Count
Source
298
44.6k
                        hash_table.for_each_mapped([&](auto& mapped) {
299
44.6k
                            if (mapped) {
300
44.6k
                                _destroy_agg_status(mapped);
301
44.6k
                                mapped = nullptr;
302
44.6k
                            }
303
44.6k
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEEDaRT_ENKUlSK_E_clISC_EEDaSK_
Line
Count
Source
298
370
                        hash_table.for_each_mapped([&](auto& mapped) {
299
370
                            if (mapped) {
300
370
                                _destroy_agg_status(mapped);
301
370
                                mapped = nullptr;
302
370
                            }
303
370
                        });
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_10vectorized15MethodKeysFixedI9PHHashMapINS4_6UInt72EPc9HashCRC32IS7_EEEEEEDaRT_ENKUlSE_E_clIS8_EEDaSE_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapINS4_6UInt96EPc9HashCRC32IS7_EEEEEEDaRT_ENKUlSE_E_clIS8_EEDaSE_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt104EPc9HashCRC32IS7_EEEEEEDaRT_ENKUlSE_E_clIS8_EEDaSE_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS9_EEEEEEDaRT_ENKUlSG_E_clISA_EEDaSG_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136EPc9HashCRC32IS7_EEEEEEDaRT_ENKUlSE_E_clIS8_EEDaSE_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS9_EEEEEEDaRT_ENKUlSG_E_clISA_EEDaSG_
304
305
5.79k
                        if (hash_table.has_null_key_data()) {
306
0
                            _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                vectorized::AggregateDataPtr>());
308
0
                        }
309
310
5.79k
                        aggregate_data_container.reset(new AggregateDataContainer(
311
5.79k
                                sizeof(typename HashTableType::key_type),
312
5.79k
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
313
5.79k
                                 align_aggregate_states) *
314
5.79k
                                        align_aggregate_states));
315
5.79k
                        agg_method.hash_table.reset(new HashTableType());
316
5.79k
                        return Status::OK();
317
5.79k
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS7_vEEEEEEDaRT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEDaRT_
Line
Count
Source
291
118
                    [&](auto& agg_method) {
292
118
                        auto& hash_table = *agg_method.hash_table;
293
118
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
118
                        agg_method.arena.clear();
296
118
                        agg_method.inited_iterator = false;
297
298
118
                        hash_table.for_each_mapped([&](auto& mapped) {
299
118
                            if (mapped) {
300
118
                                _destroy_agg_status(mapped);
301
118
                                mapped = nullptr;
302
118
                            }
303
118
                        });
304
305
118
                        if (hash_table.has_null_key_data()) {
306
0
                            _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                vectorized::AggregateDataPtr>());
308
0
                        }
309
310
118
                        aggregate_data_container.reset(new AggregateDataContainer(
311
118
                                sizeof(typename HashTableType::key_type),
312
118
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
313
118
                                 align_aggregate_states) *
314
118
                                        align_aggregate_states));
315
118
                        agg_method.hash_table.reset(new HashTableType());
316
118
                        return Status::OK();
317
118
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEEDaRT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEEDaRT_
Line
Count
Source
291
142
                    [&](auto& agg_method) {
292
142
                        auto& hash_table = *agg_method.hash_table;
293
142
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
142
                        agg_method.arena.clear();
296
142
                        agg_method.inited_iterator = false;
297
298
142
                        hash_table.for_each_mapped([&](auto& mapped) {
299
142
                            if (mapped) {
300
142
                                _destroy_agg_status(mapped);
301
142
                                mapped = nullptr;
302
142
                            }
303
142
                        });
304
305
142
                        if (hash_table.has_null_key_data()) {
306
0
                            _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                vectorized::AggregateDataPtr>());
308
0
                        }
309
310
142
                        aggregate_data_container.reset(new AggregateDataContainer(
311
142
                                sizeof(typename HashTableType::key_type),
312
142
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
313
142
                                 align_aggregate_states) *
314
142
                                        align_aggregate_states));
315
142
                        agg_method.hash_table.reset(new HashTableType());
316
142
                        return Status::OK();
317
142
                    }},
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
374
                    [&](auto& agg_method) {
292
374
                        auto& hash_table = *agg_method.hash_table;
293
374
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
374
                        agg_method.arena.clear();
296
374
                        agg_method.inited_iterator = false;
297
298
374
                        hash_table.for_each_mapped([&](auto& mapped) {
299
374
                            if (mapped) {
300
374
                                _destroy_agg_status(mapped);
301
374
                                mapped = nullptr;
302
374
                            }
303
374
                        });
304
305
374
                        if (hash_table.has_null_key_data()) {
306
0
                            _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                vectorized::AggregateDataPtr>());
308
0
                        }
309
310
374
                        aggregate_data_container.reset(new AggregateDataContainer(
311
374
                                sizeof(typename HashTableType::key_type),
312
374
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
313
374
                                 align_aggregate_states) *
314
374
                                        align_aggregate_states));
315
374
                        agg_method.hash_table.reset(new HashTableType());
316
374
                        return Status::OK();
317
374
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEDaRT_
Line
Count
Source
291
482
                    [&](auto& agg_method) {
292
482
                        auto& hash_table = *agg_method.hash_table;
293
482
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
482
                        agg_method.arena.clear();
296
482
                        agg_method.inited_iterator = false;
297
298
482
                        hash_table.for_each_mapped([&](auto& mapped) {
299
482
                            if (mapped) {
300
482
                                _destroy_agg_status(mapped);
301
482
                                mapped = nullptr;
302
482
                            }
303
482
                        });
304
305
482
                        if (hash_table.has_null_key_data()) {
306
0
                            _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                vectorized::AggregateDataPtr>());
308
0
                        }
309
310
482
                        aggregate_data_container.reset(new AggregateDataContainer(
311
482
                                sizeof(typename HashTableType::key_type),
312
482
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
313
482
                                 align_aggregate_states) *
314
482
                                        align_aggregate_states));
315
482
                        agg_method.hash_table.reset(new HashTableType());
316
482
                        return Status::OK();
317
482
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIhNS4_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEDaRT_
Line
Count
Source
291
130
                    [&](auto& agg_method) {
292
130
                        auto& hash_table = *agg_method.hash_table;
293
130
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
130
                        agg_method.arena.clear();
296
130
                        agg_method.inited_iterator = false;
297
298
130
                        hash_table.for_each_mapped([&](auto& mapped) {
299
130
                            if (mapped) {
300
130
                                _destroy_agg_status(mapped);
301
130
                                mapped = nullptr;
302
130
                            }
303
130
                        });
304
305
130
                        if (hash_table.has_null_key_data()) {
306
0
                            _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                vectorized::AggregateDataPtr>());
308
0
                        }
309
310
130
                        aggregate_data_container.reset(new AggregateDataContainer(
311
130
                                sizeof(typename HashTableType::key_type),
312
130
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
313
130
                                 align_aggregate_states) *
314
130
                                        align_aggregate_states));
315
130
                        agg_method.hash_table.reset(new HashTableType());
316
130
                        return Status::OK();
317
130
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberItNS4_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEDaRT_
Line
Count
Source
291
104
                    [&](auto& agg_method) {
292
104
                        auto& hash_table = *agg_method.hash_table;
293
104
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
104
                        agg_method.arena.clear();
296
104
                        agg_method.inited_iterator = false;
297
298
104
                        hash_table.for_each_mapped([&](auto& mapped) {
299
104
                            if (mapped) {
300
104
                                _destroy_agg_status(mapped);
301
104
                                mapped = nullptr;
302
104
                            }
303
104
                        });
304
305
104
                        if (hash_table.has_null_key_data()) {
306
0
                            _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                vectorized::AggregateDataPtr>());
308
0
                        }
309
310
104
                        aggregate_data_container.reset(new AggregateDataContainer(
311
104
                                sizeof(typename HashTableType::key_type),
312
104
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
313
104
                                 align_aggregate_states) *
314
104
                                        align_aggregate_states));
315
104
                        agg_method.hash_table.reset(new HashTableType());
316
104
                        return Status::OK();
317
104
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEDaRT_
Line
Count
Source
291
562
                    [&](auto& agg_method) {
292
562
                        auto& hash_table = *agg_method.hash_table;
293
562
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
562
                        agg_method.arena.clear();
296
562
                        agg_method.inited_iterator = false;
297
298
562
                        hash_table.for_each_mapped([&](auto& mapped) {
299
562
                            if (mapped) {
300
562
                                _destroy_agg_status(mapped);
301
562
                                mapped = nullptr;
302
562
                            }
303
562
                        });
304
305
562
                        if (hash_table.has_null_key_data()) {
306
0
                            _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                vectorized::AggregateDataPtr>());
308
0
                        }
309
310
562
                        aggregate_data_container.reset(new AggregateDataContainer(
311
562
                                sizeof(typename HashTableType::key_type),
312
562
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
313
562
                                 align_aggregate_states) *
314
562
                                        align_aggregate_states));
315
562
                        agg_method.hash_table.reset(new HashTableType());
316
562
                        return Status::OK();
317
562
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEDaRT_
Line
Count
Source
291
586
                    [&](auto& agg_method) {
292
586
                        auto& hash_table = *agg_method.hash_table;
293
586
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
586
                        agg_method.arena.clear();
296
586
                        agg_method.inited_iterator = false;
297
298
586
                        hash_table.for_each_mapped([&](auto& mapped) {
299
586
                            if (mapped) {
300
586
                                _destroy_agg_status(mapped);
301
586
                                mapped = nullptr;
302
586
                            }
303
586
                        });
304
305
586
                        if (hash_table.has_null_key_data()) {
306
0
                            _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                vectorized::AggregateDataPtr>());
308
0
                        }
309
310
586
                        aggregate_data_container.reset(new AggregateDataContainer(
311
586
                                sizeof(typename HashTableType::key_type),
312
586
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
313
586
                                 align_aggregate_states) *
314
586
                                        align_aggregate_states));
315
586
                        agg_method.hash_table.reset(new HashTableType());
316
586
                        return Status::OK();
317
586
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEDaRT_
Line
Count
Source
291
2.05k
                    [&](auto& agg_method) {
292
2.05k
                        auto& hash_table = *agg_method.hash_table;
293
2.05k
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
2.05k
                        agg_method.arena.clear();
296
2.05k
                        agg_method.inited_iterator = false;
297
298
2.05k
                        hash_table.for_each_mapped([&](auto& mapped) {
299
2.05k
                            if (mapped) {
300
2.05k
                                _destroy_agg_status(mapped);
301
2.05k
                                mapped = nullptr;
302
2.05k
                            }
303
2.05k
                        });
304
305
2.05k
                        if (hash_table.has_null_key_data()) {
306
0
                            _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                vectorized::AggregateDataPtr>());
308
0
                        }
309
310
2.05k
                        aggregate_data_container.reset(new AggregateDataContainer(
311
2.05k
                                sizeof(typename HashTableType::key_type),
312
2.05k
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
313
2.05k
                                 align_aggregate_states) *
314
2.05k
                                        align_aggregate_states));
315
2.05k
                        agg_method.hash_table.reset(new HashTableType());
316
2.05k
                        return Status::OK();
317
2.05k
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEDaRT_
Line
Count
Source
291
1.08k
                    [&](auto& agg_method) {
292
1.08k
                        auto& hash_table = *agg_method.hash_table;
293
1.08k
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
1.08k
                        agg_method.arena.clear();
296
1.08k
                        agg_method.inited_iterator = false;
297
298
1.08k
                        hash_table.for_each_mapped([&](auto& mapped) {
299
1.08k
                            if (mapped) {
300
1.08k
                                _destroy_agg_status(mapped);
301
1.08k
                                mapped = nullptr;
302
1.08k
                            }
303
1.08k
                        });
304
305
1.08k
                        if (hash_table.has_null_key_data()) {
306
0
                            _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                vectorized::AggregateDataPtr>());
308
0
                        }
309
310
1.08k
                        aggregate_data_container.reset(new AggregateDataContainer(
311
1.08k
                                sizeof(typename HashTableType::key_type),
312
1.08k
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
313
1.08k
                                 align_aggregate_states) *
314
1.08k
                                        align_aggregate_states));
315
1.08k
                        agg_method.hash_table.reset(new HashTableType());
316
1.08k
                        return Status::OK();
317
1.08k
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEEDaRT_
Line
Count
Source
291
168
                    [&](auto& agg_method) {
292
168
                        auto& hash_table = *agg_method.hash_table;
293
168
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
168
                        agg_method.arena.clear();
296
168
                        agg_method.inited_iterator = false;
297
298
168
                        hash_table.for_each_mapped([&](auto& mapped) {
299
168
                            if (mapped) {
300
168
                                _destroy_agg_status(mapped);
301
168
                                mapped = nullptr;
302
168
                            }
303
168
                        });
304
305
168
                        if (hash_table.has_null_key_data()) {
306
0
                            _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                vectorized::AggregateDataPtr>());
308
0
                        }
309
310
168
                        aggregate_data_container.reset(new AggregateDataContainer(
311
168
                                sizeof(typename HashTableType::key_type),
312
168
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
313
168
                                 align_aggregate_states) *
314
168
                                        align_aggregate_states));
315
168
                        agg_method.hash_table.reset(new HashTableType());
316
168
                        return Status::OK();
317
168
                    }},
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_10vectorized15MethodKeysFixedI9PHHashMapINS4_6UInt72EPc9HashCRC32IS7_EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapINS4_6UInt96EPc9HashCRC32IS7_EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt104EPc9HashCRC32IS7_EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS9_EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136EPc9HashCRC32IS7_EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS9_EEEEEEDaRT_
318
5.79k
            agg_data->method_variant);
319
5.79k
}
320
321
725
void PartitionedAggSharedState::init_spill_params(size_t spill_partition_count) {
322
725
    partition_count = spill_partition_count;
323
725
    max_partition_index = partition_count - 1;
324
325
23.9k
    for (int i = 0; i < partition_count; ++i) {
326
23.2k
        spill_partitions.emplace_back(std::make_shared<AggSpillPartition>());
327
23.2k
    }
328
725
}
329
330
714
void PartitionedAggSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {
331
22.8k
    for (auto& partition : spill_partitions) {
332
22.8k
        if (partition->spilling_stream_) {
333
0
            partition->spilling_stream_->update_shared_profiles(source_profile);
334
0
        }
335
22.8k
        for (auto& stream : partition->spill_streams_) {
336
3.34k
            if (stream) {
337
3.34k
                stream->update_shared_profiles(source_profile);
338
3.34k
            }
339
3.34k
        }
340
22.8k
    }
341
714
}
342
343
Status AggSpillPartition::get_spill_stream(RuntimeState* state, int node_id,
344
                                           RuntimeProfile* profile,
345
36.3k
                                           vectorized::SpillStreamSPtr& spill_stream) {
346
36.3k
    if (spilling_stream_) {
347
32.9k
        spill_stream = spilling_stream_;
348
32.9k
        return Status::OK();
349
32.9k
    }
350
3.39k
    RETURN_IF_ERROR(ExecEnv::GetInstance()->spill_stream_mgr()->register_spill_stream(
351
3.39k
            state, spilling_stream_, print_id(state->query_id()), "agg", node_id,
352
3.39k
            std::numeric_limits<int32_t>::max(), std::numeric_limits<size_t>::max(), profile));
353
3.39k
    spill_streams_.emplace_back(spilling_stream_);
354
3.39k
    spill_stream = spilling_stream_;
355
3.39k
    return Status::OK();
356
3.39k
}
357
16.0k
void AggSpillPartition::close() {
358
16.0k
    if (spilling_stream_) {
359
1
        spilling_stream_.reset();
360
1
    }
361
16.0k
    for (auto& stream : spill_streams_) {
362
5
        (void)ExecEnv::GetInstance()->spill_stream_mgr()->delete_spill_stream(stream);
363
5
    }
364
16.0k
    spill_streams_.clear();
365
16.0k
}
366
367
834
void PartitionedAggSharedState::close() {
368
    // need to use CAS instead of only `if (!is_closed)` statement,
369
    // to avoid concurrent entry of close() both pass the if statement
370
834
    bool false_close = false;
371
834
    if (!is_closed.compare_exchange_strong(false_close, true)) {
372
115
        return;
373
115
    }
374
834
    DCHECK(!false_close && is_closed);
375
16.0k
    for (auto partition : spill_partitions) {
376
16.0k
        partition->close();
377
16.0k
    }
378
719
    spill_partitions.clear();
379
719
}
380
381
13
void SpillSortSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {
382
28
    for (auto& stream : sorted_streams) {
383
28
        if (stream) {
384
28
            stream->update_shared_profiles(source_profile);
385
28
        }
386
28
    }
387
13
}
388
389
15
void SpillSortSharedState::close() {
390
    // need to use CAS instead of only `if (!is_closed)` statement,
391
    // to avoid concurrent entry of close() both pass the if statement
392
15
    bool false_close = false;
393
15
    if (!is_closed.compare_exchange_strong(false_close, true)) {
394
1
        return;
395
1
    }
396
15
    DCHECK(!false_close && is_closed);
397
14
    for (auto& stream : sorted_streams) {
398
1
        (void)ExecEnv::GetInstance()->spill_stream_mgr()->delete_spill_stream(stream);
399
1
    }
400
14
    sorted_streams.clear();
401
14
}
402
403
MultiCastSharedState::MultiCastSharedState(ObjectPool* pool, int cast_sender_count, int node_id)
404
2.22k
        : multi_cast_data_streamer(std::make_unique<pipeline::MultiCastDataStreamer>(
405
2.22k
                  pool, cast_sender_count, node_id)) {}
406
407
0
void MultiCastSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {}
408
409
115k
int AggSharedState::get_slot_column_id(const vectorized::AggFnEvaluator* evaluator) {
410
115k
    auto ctxs = evaluator->input_exprs_ctxs();
411
18.4E
    CHECK(ctxs.size() == 1 && ctxs[0]->root()->is_slot_ref())
412
18.4E
            << "input_exprs_ctxs is invalid, input_exprs_ctx[0]="
413
18.4E
            << ctxs[0]->root()->debug_string();
414
115k
    return ((vectorized::VSlotRef*)ctxs[0]->root().get())->column_id();
415
115k
}
416
417
4.65M
void AggSharedState::_destroy_agg_status(vectorized::AggregateDataPtr data) {
418
11.8M
    for (int i = 0; i < aggregate_evaluators.size(); ++i) {
419
7.18M
        aggregate_evaluators[i]->function()->destroy(data + offsets_of_aggregate_states[i]);
420
7.18M
    }
421
4.65M
}
422
423
106k
LocalExchangeSharedState::~LocalExchangeSharedState() = default;
424
425
1.36k
Status SetSharedState::update_build_not_ignore_null(const vectorized::VExprContextSPtrs& ctxs) {
426
1.36k
    if (ctxs.size() > build_not_ignore_null.size()) {
427
0
        return Status::InternalError("build_not_ignore_null not initialized");
428
0
    }
429
430
3.38k
    for (int i = 0; i < ctxs.size(); ++i) {
431
2.01k
        build_not_ignore_null[i] = build_not_ignore_null[i] || ctxs[i]->root()->is_nullable();
432
2.01k
    }
433
434
1.36k
    return Status::OK();
435
1.36k
}
436
437
2.18k
size_t SetSharedState::get_hash_table_size() const {
438
2.18k
    size_t hash_table_size = 0;
439
2.18k
    std::visit(
440
2.18k
            [&](auto&& arg) {
441
2.18k
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
2.18k
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
2.18k
                    hash_table_size = arg.hash_table->size();
444
2.18k
                }
445
2.18k
            },
Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRSt9monostateEEDaOT_
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS7_vEEEEEEDaOT_
Line
Count
Source
440
739
            [&](auto&& arg) {
441
739
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
739
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
739
                    hash_table_size = arg.hash_table->size();
444
739
                }
445
739
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized19MethodStringNoCacheI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS7_vEEEEEEDaOT_
Line
Count
Source
440
146
            [&](auto&& arg) {
441
146
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
146
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
146
                    hash_table_size = arg.hash_table->size();
444
146
                }
445
146
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_19MethodStringNoCacheINS4_15DataWithNullKeyI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS9_vEEEEEEEEEEDaOT_
Line
Count
Source
440
250
            [&](auto&& arg) {
441
250
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
250
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
250
                    hash_table_size = arg.hash_table->size();
444
250
                }
445
250
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIhNS4_15DataWithNullKeyI9PHHashMapIhNS_14RowRefWithFlagE9HashCRC32IhEEEEEEEEEEDaOT_
Line
Count
Source
440
57
            [&](auto&& arg) {
441
57
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
57
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
57
                    hash_table_size = arg.hash_table->size();
444
57
                }
445
57
            },
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
440
574
            [&](auto&& arg) {
441
574
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
574
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
574
                    hash_table_size = arg.hash_table->size();
444
574
                }
445
574
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImNS_14RowRefWithFlagE9HashCRC32ImEEEEEEEEEEDaOT_
Line
Count
Source
440
106
            [&](auto&& arg) {
441
106
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
106
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
106
                    hash_table_size = arg.hash_table->size();
444
106
                }
445
106
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_NS_14RowRefWithFlagE9HashCRC32IS9_EEEEEEEEEEDaOT_
Line
Count
Source
440
48
            [&](auto&& arg) {
441
48
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
48
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
48
                    hash_table_size = arg.hash_table->size();
444
48
                }
445
48
            },
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
440
30
            [&](auto&& arg) {
441
30
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
30
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
30
                    hash_table_size = arg.hash_table->size();
444
30
                }
445
30
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodOneNumberIm9PHHashMapImNS_14RowRefWithFlagE9HashCRC32ImEEEEEEDaOT_
Line
Count
Source
440
16
            [&](auto&& arg) {
441
16
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
16
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
16
                    hash_table_size = arg.hash_table->size();
444
16
                }
445
16
            },
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
440
21
            [&](auto&& arg) {
441
21
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
21
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
21
                    hash_table_size = arg.hash_table->size();
444
21
                }
445
21
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodKeysFixedI9PHHashMapINS4_6UInt72ENS_14RowRefWithFlagE9HashCRC32IS7_EEEEEEDaOT_
Line
Count
Source
440
57
            [&](auto&& arg) {
441
57
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
57
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
57
                    hash_table_size = arg.hash_table->size();
444
57
                }
445
57
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodKeysFixedI9PHHashMapINS4_6UInt96ENS_14RowRefWithFlagE9HashCRC32IS7_EEEEEEDaOT_
Line
Count
Source
440
42
            [&](auto&& arg) {
441
42
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
42
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
42
                    hash_table_size = arg.hash_table->size();
444
42
                }
445
42
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt104ENS_14RowRefWithFlagE9HashCRC32IS7_EEEEEEDaOT_
Line
Count
Source
440
45
            [&](auto&& arg) {
441
45
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
45
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
45
                    hash_table_size = arg.hash_table->size();
444
45
                }
445
45
            },
Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEENS_14RowRefWithFlagE9HashCRC32IS9_EEEEEEDaOT_
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEENS_14RowRefWithFlagE9HashCRC32IS9_EEEEEEDaOT_
Line
Count
Source
440
4
            [&](auto&& arg) {
441
4
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
4
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
4
                    hash_table_size = arg.hash_table->size();
444
4
                }
445
4
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136ENS_14RowRefWithFlagE9HashCRC32IS7_EEEEEEDaOT_
Line
Count
Source
440
50
            [&](auto&& arg) {
441
50
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
50
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
50
                    hash_table_size = arg.hash_table->size();
444
50
                }
445
50
            },
446
2.18k
            hash_table_variants->method_variant);
447
2.18k
    return hash_table_size;
448
2.18k
}
449
450
629
Status SetSharedState::hash_table_init() {
451
629
    std::vector<vectorized::DataTypePtr> data_types;
452
1.59k
    for (size_t i = 0; i != child_exprs_lists[0].size(); ++i) {
453
962
        auto& ctx = child_exprs_lists[0][i];
454
962
        auto data_type = ctx->root()->data_type();
455
962
        if (build_not_ignore_null[i]) {
456
705
            data_type = vectorized::make_nullable(data_type);
457
705
        }
458
962
        data_types.emplace_back(std::move(data_type));
459
962
    }
460
629
    return init_hash_method<SetDataVariants>(hash_table_variants.get(), data_types, true);
461
629
}
462
463
void AggSharedState::refresh_top_limit(size_t row_id,
464
4.12k
                                       const vectorized::ColumnRawPtrs& key_columns) {
465
8.28k
    for (int j = 0; j < key_columns.size(); ++j) {
466
4.16k
        limit_columns[j]->insert_from(*key_columns[j], row_id);
467
4.16k
    }
468
4.12k
    limit_heap.emplace(limit_columns[0]->size() - 1, limit_columns, order_directions,
469
4.12k
                       null_directions);
470
471
4.12k
    limit_heap.pop();
472
4.12k
    limit_columns_min = limit_heap.top()._row_id;
473
4.12k
}
474
475
} // namespace doris::pipeline