Coverage Report

Created: 2026-02-08 22:14

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
422k
                                                       const std::string& name) {
43
422k
    source_deps.push_back(std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY"));
44
422k
    source_deps.back()->set_shared_state(this);
45
422k
    return source_deps.back().get();
46
422k
}
47
48
void BasicSharedState::create_source_dependencies(int num_sources, int operator_id, int node_id,
49
114k
                                                  const std::string& name) {
50
114k
    source_deps.resize(num_sources, nullptr);
51
758k
    for (auto& source_dep : source_deps) {
52
758k
        source_dep = std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY");
53
758k
        source_dep->set_shared_state(this);
54
758k
    }
55
114k
}
56
57
Dependency* BasicSharedState::create_sink_dependency(int dest_id, int node_id,
58
961k
                                                     const std::string& name) {
59
961k
    sink_deps.push_back(std::make_shared<Dependency>(dest_id, node_id, name + "_DEPENDENCY", true));
60
961k
    sink_deps.back()->set_shared_state(this);
61
961k
    return sink_deps.back().get();
62
961k
}
63
64
4.25M
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.25M
    _blocked_task.push_back(task);
69
4.25M
}
70
71
40.0M
void Dependency::set_ready() {
72
40.0M
    if (_ready) {
73
35.7M
        return;
74
35.7M
    }
75
4.26M
    std::vector<std::weak_ptr<PipelineTask>> local_block_task {};
76
4.26M
    {
77
4.26M
        std::unique_lock<std::mutex> lc(_task_lock);
78
4.26M
        if (_ready) {
79
0
            return;
80
0
        }
81
4.26M
        _watcher.stop();
82
4.26M
        _ready = true;
83
4.26M
        local_block_task.swap(_blocked_task);
84
4.26M
    }
85
4.27M
    for (auto task : local_block_task) {
86
4.27M
        if (auto t = task.lock()) {
87
4.27M
            std::unique_lock<std::mutex> lc(_task_lock);
88
4.27M
            THROW_IF_ERROR(t->wake_up(this, lc));
89
4.27M
        }
90
4.27M
    }
91
4.26M
}
92
93
35.1M
Dependency* Dependency::is_blocked_by(std::shared_ptr<PipelineTask> task) {
94
35.1M
    std::unique_lock<std::mutex> lc(_task_lock);
95
35.1M
    auto ready = _ready.load();
96
35.1M
    if (!ready && task) {
97
4.26M
        _add_block_task(task);
98
4.26M
        start_watcher();
99
4.26M
        THROW_IF_ERROR(task->blocked(this, lc));
100
4.26M
    }
101
35.1M
    return ready ? nullptr : this;
102
35.1M
}
103
104
234k
std::string Dependency::debug_string(int indentation_level) {
105
234k
    fmt::memory_buffer debug_string_buffer;
106
234k
    fmt::format_to(debug_string_buffer, "{}{}: id={}, block task = {}, ready={}, _always_ready={}",
107
234k
                   std::string(indentation_level * 2, ' '), _name, _node_id, _blocked_task.size(),
108
234k
                   _ready, _always_ready);
109
234k
    return fmt::to_string(debug_string_buffer);
110
234k
}
111
112
84
std::string CountedFinishDependency::debug_string(int indentation_level) {
113
84
    fmt::memory_buffer debug_string_buffer;
114
84
    fmt::format_to(debug_string_buffer,
115
84
                   "{}{}: id={}, block_task={}, ready={}, _always_ready={}, count={}",
116
84
                   std::string(indentation_level * 2, ' '), _name, _node_id, _blocked_task.size(),
117
84
                   _ready, _always_ready, _counter);
118
84
    return fmt::to_string(debug_string_buffer);
119
84
}
120
121
1.35k
void RuntimeFilterTimer::call_timeout() {
122
1.35k
    _parent->set_ready();
123
1.35k
}
124
125
15.0k
void RuntimeFilterTimer::call_ready() {
126
15.0k
    _parent->set_ready();
127
15.0k
}
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
1.76M
bool RuntimeFilterTimer::should_be_check_timeout() {
133
1.76M
    if (!_parent->ready() && !_local_runtime_filter_dependencies.empty()) {
134
28.3k
        bool all_ready = true;
135
28.3k
        for (auto& dep : _local_runtime_filter_dependencies) {
136
28.3k
            if (!dep->ready()) {
137
28.3k
                all_ready = false;
138
28.3k
                break;
139
28.3k
            }
140
28.3k
        }
141
28.3k
        if (all_ready) {
142
19
            _local_runtime_filter_dependencies.clear();
143
19
            _registration_time = MonotonicMillis();
144
19
        }
145
28.3k
        return all_ready;
146
28.3k
    }
147
1.73M
    return true;
148
1.76M
}
149
150
8
void RuntimeFilterTimerQueue::start() {
151
288k
    while (!_stop) {
152
288k
        std::unique_lock<std::mutex> lk(cv_m);
153
154
290k
        while (_que.empty() && !_stop) {
155
3.69k
            cv.wait_for(lk, std::chrono::seconds(3), [this] { return !_que.empty() || _stop; });
156
1.85k
        }
157
288k
        if (_stop) {
158
3
            break;
159
3
        }
160
288k
        {
161
288k
            std::unique_lock<std::mutex> lc(_que_lock);
162
288k
            std::list<std::shared_ptr<pipeline::RuntimeFilterTimer>> new_que;
163
1.76M
            for (auto& it : _que) {
164
1.76M
                if (it.use_count() == 1) {
165
                    // `use_count == 1` means this runtime filter has been released
166
1.76M
                } else if (it->should_be_check_timeout()) {
167
1.73M
                    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
1.72M
                        int64_t ms_since_registration = MonotonicMillis() - it->registration_time();
170
1.72M
                        if (ms_since_registration > it->wait_time_ms()) {
171
1.35k
                            it->call_timeout();
172
1.72M
                        } else {
173
1.72M
                            new_que.push_back(std::move(it));
174
1.72M
                        }
175
1.72M
                    }
176
1.73M
                } else {
177
28.3k
                    new_que.push_back(std::move(it));
178
28.3k
                }
179
1.76M
            }
180
288k
            new_que.swap(_que);
181
288k
        }
182
288k
        std::this_thread::sleep_for(std::chrono::milliseconds(interval));
183
288k
    }
184
8
    _shutdown = true;
185
8
}
186
187
336k
void LocalExchangeSharedState::sub_running_sink_operators() {
188
336k
    std::unique_lock<std::mutex> lc(le_lock);
189
336k
    if (exchanger->_running_sink_operators.fetch_sub(1) == 1) {
190
113k
        _set_always_ready();
191
113k
    }
192
336k
}
193
194
746k
void LocalExchangeSharedState::sub_running_source_operators() {
195
746k
    std::unique_lock<std::mutex> lc(le_lock);
196
746k
    if (exchanger->_running_source_operators.fetch_sub(1) == 1) {
197
113k
        _set_always_ready();
198
113k
        exchanger->finalize();
199
113k
    }
200
746k
}
201
202
113k
LocalExchangeSharedState::LocalExchangeSharedState(int num_instances) {
203
113k
    source_deps.resize(num_instances, nullptr);
204
113k
    mem_counters.resize(num_instances, nullptr);
205
113k
}
206
207
74
vectorized::MutableColumns AggSharedState::_get_keys_hash_table() {
208
74
    return std::visit(
209
74
            vectorized::Overload {
210
74
                    [&](std::monostate& arg) {
211
0
                        throw doris::Exception(ErrorCode::INTERNAL_ERROR, "uninited hash table");
212
0
                        return vectorized::MutableColumns();
213
0
                    },
214
74
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
74
                        vectorized::MutableColumns key_columns;
216
220
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
146
                            key_columns.emplace_back(
218
146
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
146
                        }
220
74
                        auto& data = *agg_method.hash_table;
221
74
                        bool has_null_key = data.has_null_key_data();
222
74
                        const auto size = data.size() - has_null_key;
223
74
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
74
                        std::vector<KeyType> keys(size);
225
226
74
                        uint32_t num_rows = 0;
227
74
                        auto iter = aggregate_data_container->begin();
228
74
                        {
229
12.3k
                            while (iter != aggregate_data_container->end()) {
230
12.2k
                                keys[num_rows] = iter.get_key<KeyType>();
231
12.2k
                                ++iter;
232
12.2k
                                ++num_rows;
233
12.2k
                            }
234
74
                        }
235
74
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
74
                        if (has_null_key) {
237
2
                            key_columns[0]->insert_data(nullptr, 0);
238
2
                        }
239
74
                        return key_columns;
240
74
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS7_vEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
Line
Count
Source
214
5
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
5
                        vectorized::MutableColumns key_columns;
216
25
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
20
                            key_columns.emplace_back(
218
20
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
20
                        }
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
4.56k
                            while (iter != aggregate_data_container->end()) {
230
4.55k
                                keys[num_rows] = iter.get_key<KeyType>();
231
4.55k
                                ++iter;
232
4.55k
                                ++num_rows;
233
4.55k
                            }
234
5
                        }
235
5
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
5
                        if (has_null_key) {
237
0
                            key_columns[0]->insert_data(nullptr, 0);
238
0
                        }
239
5
                        return key_columns;
240
5
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_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_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
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
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
8
                            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
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_10vectorized15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
Line
Count
Source
214
7
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
7
                        vectorized::MutableColumns key_columns;
216
14
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
7
                            key_columns.emplace_back(
218
7
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
7
                        }
220
7
                        auto& data = *agg_method.hash_table;
221
7
                        bool has_null_key = data.has_null_key_data();
222
7
                        const auto size = data.size() - has_null_key;
223
7
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
7
                        std::vector<KeyType> keys(size);
225
226
7
                        uint32_t num_rows = 0;
227
7
                        auto iter = aggregate_data_container->begin();
228
7
                        {
229
30
                            while (iter != aggregate_data_container->end()) {
230
23
                                keys[num_rows] = iter.get_key<KeyType>();
231
23
                                ++iter;
232
23
                                ++num_rows;
233
23
                            }
234
7
                        }
235
7
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
7
                        if (has_null_key) {
237
0
                            key_columns[0]->insert_data(nullptr, 0);
238
0
                        }
239
7
                        return key_columns;
240
7
                    }},
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
13
                            while (iter != aggregate_data_container->end()) {
230
10
                                keys[num_rows] = iter.get_key<KeyType>();
231
10
                                ++iter;
232
10
                                ++num_rows;
233
10
                            }
234
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
7
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
7
                        vectorized::MutableColumns key_columns;
216
14
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
7
                            key_columns.emplace_back(
218
7
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
7
                        }
220
7
                        auto& data = *agg_method.hash_table;
221
7
                        bool has_null_key = data.has_null_key_data();
222
7
                        const auto size = data.size() - has_null_key;
223
7
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
7
                        std::vector<KeyType> keys(size);
225
226
7
                        uint32_t num_rows = 0;
227
7
                        auto iter = aggregate_data_container->begin();
228
7
                        {
229
2.16k
                            while (iter != aggregate_data_container->end()) {
230
2.15k
                                keys[num_rows] = iter.get_key<KeyType>();
231
2.15k
                                ++iter;
232
2.15k
                                ++num_rows;
233
2.15k
                            }
234
7
                        }
235
7
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
7
                        if (has_null_key) {
237
1
                            key_columns[0]->insert_data(nullptr, 0);
238
1
                        }
239
7
                        return key_columns;
240
7
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISL_EESaISO_EEOT_
Line
Count
Source
214
15
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
15
                        vectorized::MutableColumns key_columns;
216
30
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
15
                            key_columns.emplace_back(
218
15
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
15
                        }
220
15
                        auto& data = *agg_method.hash_table;
221
15
                        bool has_null_key = data.has_null_key_data();
222
15
                        const auto size = data.size() - has_null_key;
223
15
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
15
                        std::vector<KeyType> keys(size);
225
226
15
                        uint32_t num_rows = 0;
227
15
                        auto iter = aggregate_data_container->begin();
228
15
                        {
229
3.23k
                            while (iter != aggregate_data_container->end()) {
230
3.21k
                                keys[num_rows] = iter.get_key<KeyType>();
231
3.21k
                                ++iter;
232
3.21k
                                ++num_rows;
233
3.21k
                            }
234
15
                        }
235
15
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
15
                        if (has_null_key) {
237
1
                            key_columns[0]->insert_data(nullptr, 0);
238
1
                        }
239
15
                        return key_columns;
240
15
                    }},
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
4
                            while (iter != aggregate_data_container->end()) {
230
3
                                keys[num_rows] = iter.get_key<KeyType>();
231
3
                                ++iter;
232
3
                                ++num_rows;
233
3
                            }
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_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapINS4_6UInt72EPc9HashCRC32IS7_EEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
Line
Count
Source
214
2
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
2
                        vectorized::MutableColumns key_columns;
216
6
                        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
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
14
                            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
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
                    }},
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
30
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
30
                        vectorized::MutableColumns key_columns;
216
115
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
85
                            key_columns.emplace_back(
218
85
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
85
                        }
220
30
                        auto& data = *agg_method.hash_table;
221
30
                        bool has_null_key = data.has_null_key_data();
222
30
                        const auto size = data.size() - has_null_key;
223
30
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
30
                        std::vector<KeyType> keys(size);
225
226
30
                        uint32_t num_rows = 0;
227
30
                        auto iter = aggregate_data_container->begin();
228
30
                        {
229
2.27k
                            while (iter != aggregate_data_container->end()) {
230
2.24k
                                keys[num_rows] = iter.get_key<KeyType>();
231
2.24k
                                ++iter;
232
2.24k
                                ++num_rows;
233
2.24k
                            }
234
30
                        }
235
30
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
30
                        if (has_null_key) {
237
0
                            key_columns[0]->insert_data(nullptr, 0);
238
0
                        }
239
30
                        return key_columns;
240
30
                    }},
241
74
            agg_data->method_variant);
242
74
}
243
244
74
void AggSharedState::build_limit_heap(size_t hash_table_size) {
245
74
    limit_columns = _get_keys_hash_table();
246
12.0k
    for (size_t i = 0; i < hash_table_size; ++i) {
247
11.9k
        limit_heap.emplace(i, limit_columns, order_directions, null_directions);
248
11.9k
    }
249
11.9k
    while (hash_table_size > limit) {
250
11.8k
        limit_heap.pop();
251
11.8k
        hash_table_size--;
252
11.8k
    }
253
74
    limit_columns_min = limit_heap.top()._row_id;
254
74
}
255
256
bool AggSharedState::do_limit_filter(vectorized::Block* block, size_t num_rows,
257
274
                                     const std::vector<int>* key_locs) {
258
274
    if (num_rows) {
259
274
        cmp_res.resize(num_rows);
260
274
        need_computes.resize(num_rows);
261
274
        memset(need_computes.data(), 0, need_computes.size());
262
274
        memset(cmp_res.data(), 0, cmp_res.size());
263
264
274
        const auto key_size = null_directions.size();
265
885
        for (int i = 0; i < key_size; i++) {
266
611
            block->get_by_position(key_locs ? key_locs->operator[](i) : i)
267
611
                    .column->compare_internal(limit_columns_min, *limit_columns[i],
268
611
                                              null_directions[i], order_directions[i], cmp_res,
269
611
                                              need_computes.data());
270
611
        }
271
272
274
        auto set_computes_arr = [](auto* __restrict res, auto* __restrict computes, size_t rows) {
273
71.5k
            for (size_t i = 0; i < rows; ++i) {
274
71.2k
                computes[i] = computes[i] == res[i];
275
71.2k
            }
276
274
        };
277
274
        set_computes_arr(cmp_res.data(), need_computes.data(), num_rows);
278
279
274
        return std::find(need_computes.begin(), need_computes.end(), 0) != need_computes.end();
280
274
    }
281
282
0
    return false;
283
274
}
284
285
3.27k
Status AggSharedState::reset_hash_table() {
286
3.27k
    return std::visit(
287
3.27k
            vectorized::Overload {
288
3.27k
                    [&](std::monostate& arg) -> Status {
289
0
                        return Status::InternalError("Uninited hash table");
290
0
                    },
291
3.27k
                    [&](auto& agg_method) {
292
3.27k
                        auto& hash_table = *agg_method.hash_table;
293
3.27k
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
3.27k
                        agg_method.arena.clear();
296
3.27k
                        agg_method.inited_iterator = false;
297
298
1.05M
                        hash_table.for_each_mapped([&](auto& mapped) {
299
1.05M
                            if (mapped) {
300
1.05M
                                _destroy_agg_status(mapped);
301
1.05M
                                mapped = nullptr;
302
1.05M
                            }
303
1.05M
                        });
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
534
                        hash_table.for_each_mapped([&](auto& mapped) {
299
534
                            if (mapped) {
300
534
                                _destroy_agg_status(mapped);
301
534
                                mapped = nullptr;
302
534
                            }
303
534
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEDaRT_ENKUlSD_E_clIS7_EEDaSD_
Line
Count
Source
298
818
                        hash_table.for_each_mapped([&](auto& mapped) {
299
818
                            if (mapped) {
300
818
                                _destroy_agg_status(mapped);
301
818
                                mapped = nullptr;
302
818
                            }
303
818
                        });
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
764
                        hash_table.for_each_mapped([&](auto& mapped) {
299
764
                            if (mapped) {
300
764
                                _destroy_agg_status(mapped);
301
764
                                mapped = nullptr;
302
764
                            }
303
764
                        });
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEDaRT_ENKUlSE_E_clIS7_EEDaSE_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEEDaRT_ENKUlSG_E_clISA_EEDaSG_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEEDaRT_ENKUlSG_E_clISA_EEDaSG_
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Line
Count
Source
298
1.04M
                        hash_table.for_each_mapped([&](auto& mapped) {
299
1.04M
                            if (mapped) {
300
1.04M
                                _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
1.96k
                        hash_table.for_each_mapped([&](auto& mapped) {
299
1.96k
                            if (mapped) {
300
1.96k
                                _destroy_agg_status(mapped);
301
1.96k
                                mapped = nullptr;
302
1.96k
                            }
303
1.96k
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIhNS4_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_
Line
Count
Source
298
58
                        hash_table.for_each_mapped([&](auto& mapped) {
299
58
                            if (mapped) {
300
58
                                _destroy_agg_status(mapped);
301
58
                                mapped = nullptr;
302
58
                            }
303
58
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberItNS4_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_
Line
Count
Source
298
270
                        hash_table.for_each_mapped([&](auto& mapped) {
299
270
                            if (mapped) {
300
270
                                _destroy_agg_status(mapped);
301
270
                                mapped = nullptr;
302
270
                            }
303
270
                        });
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_
Line
Count
Source
298
1.45k
                        hash_table.for_each_mapped([&](auto& mapped) {
299
1.45k
                            if (mapped) {
300
1.45k
                                _destroy_agg_status(mapped);
301
1.45k
                                mapped = nullptr;
302
1.45k
                            }
303
1.45k
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEDaRT_ENKUlSJ_E_clIS9_EEDaSJ_
Line
Count
Source
298
600
                        hash_table.for_each_mapped([&](auto& mapped) {
299
600
                            if (mapped) {
300
600
                                _destroy_agg_status(mapped);
301
600
                                mapped = nullptr;
302
600
                            }
303
600
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEDaRT_ENKUlSJ_E_clIS9_EEDaSJ_
Line
Count
Source
298
2.06k
                        hash_table.for_each_mapped([&](auto& mapped) {
299
2.06k
                            if (mapped) {
300
2.06k
                                _destroy_agg_status(mapped);
301
2.06k
                                mapped = nullptr;
302
2.06k
                            }
303
2.06k
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEEDaRT_ENKUlSK_E_clISC_EEDaSK_
Line
Count
Source
298
204
                        hash_table.for_each_mapped([&](auto& mapped) {
299
204
                            if (mapped) {
300
204
                                _destroy_agg_status(mapped);
301
204
                                mapped = nullptr;
302
204
                            }
303
204
                        });
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
3.27k
                        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
3.27k
                        aggregate_data_container.reset(new AggregateDataContainer(
311
3.27k
                                sizeof(typename HashTableType::key_type),
312
3.27k
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
313
3.27k
                                 align_aggregate_states) *
314
3.27k
                                        align_aggregate_states));
315
3.27k
                        agg_method.hash_table.reset(new HashTableType());
316
3.27k
                        return Status::OK();
317
3.27k
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS7_vEEEEEEDaRT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEDaRT_
Line
Count
Source
291
161
                    [&](auto& agg_method) {
292
161
                        auto& hash_table = *agg_method.hash_table;
293
161
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
161
                        agg_method.arena.clear();
296
161
                        agg_method.inited_iterator = false;
297
298
161
                        hash_table.for_each_mapped([&](auto& mapped) {
299
161
                            if (mapped) {
300
161
                                _destroy_agg_status(mapped);
301
161
                                mapped = nullptr;
302
161
                            }
303
161
                        });
304
305
161
                        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
161
                        aggregate_data_container.reset(new AggregateDataContainer(
311
161
                                sizeof(typename HashTableType::key_type),
312
161
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
313
161
                                 align_aggregate_states) *
314
161
                                        align_aggregate_states));
315
161
                        agg_method.hash_table.reset(new HashTableType());
316
161
                        return Status::OK();
317
161
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEDaRT_
Line
Count
Source
291
188
                    [&](auto& agg_method) {
292
188
                        auto& hash_table = *agg_method.hash_table;
293
188
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
188
                        agg_method.arena.clear();
296
188
                        agg_method.inited_iterator = false;
297
298
188
                        hash_table.for_each_mapped([&](auto& mapped) {
299
188
                            if (mapped) {
300
188
                                _destroy_agg_status(mapped);
301
188
                                mapped = nullptr;
302
188
                            }
303
188
                        });
304
305
188
                        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
188
                        aggregate_data_container.reset(new AggregateDataContainer(
311
188
                                sizeof(typename HashTableType::key_type),
312
188
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
313
188
                                 align_aggregate_states) *
314
188
                                        align_aggregate_states));
315
188
                        agg_method.hash_table.reset(new HashTableType());
316
188
                        return Status::OK();
317
188
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEEDaRT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEEDaRT_
Line
Count
Source
291
216
                    [&](auto& agg_method) {
292
216
                        auto& hash_table = *agg_method.hash_table;
293
216
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
216
                        agg_method.arena.clear();
296
216
                        agg_method.inited_iterator = false;
297
298
216
                        hash_table.for_each_mapped([&](auto& mapped) {
299
216
                            if (mapped) {
300
216
                                _destroy_agg_status(mapped);
301
216
                                mapped = nullptr;
302
216
                            }
303
216
                        });
304
305
216
                        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
216
                        aggregate_data_container.reset(new AggregateDataContainer(
311
216
                                sizeof(typename HashTableType::key_type),
312
216
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
313
216
                                 align_aggregate_states) *
314
216
                                        align_aggregate_states));
315
216
                        agg_method.hash_table.reset(new HashTableType());
316
216
                        return Status::OK();
317
216
                    }},
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
377
                    [&](auto& agg_method) {
292
377
                        auto& hash_table = *agg_method.hash_table;
293
377
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
377
                        agg_method.arena.clear();
296
377
                        agg_method.inited_iterator = false;
297
298
377
                        hash_table.for_each_mapped([&](auto& mapped) {
299
377
                            if (mapped) {
300
377
                                _destroy_agg_status(mapped);
301
377
                                mapped = nullptr;
302
377
                            }
303
377
                        });
304
305
377
                        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
377
                        aggregate_data_container.reset(new AggregateDataContainer(
311
377
                                sizeof(typename HashTableType::key_type),
312
377
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
313
377
                                 align_aggregate_states) *
314
377
                                        align_aggregate_states));
315
377
                        agg_method.hash_table.reset(new HashTableType());
316
377
                        return Status::OK();
317
377
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEDaRT_
Line
Count
Source
291
712
                    [&](auto& agg_method) {
292
712
                        auto& hash_table = *agg_method.hash_table;
293
712
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
712
                        agg_method.arena.clear();
296
712
                        agg_method.inited_iterator = false;
297
298
712
                        hash_table.for_each_mapped([&](auto& mapped) {
299
712
                            if (mapped) {
300
712
                                _destroy_agg_status(mapped);
301
712
                                mapped = nullptr;
302
712
                            }
303
712
                        });
304
305
712
                        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
712
                        aggregate_data_container.reset(new AggregateDataContainer(
311
712
                                sizeof(typename HashTableType::key_type),
312
712
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
313
712
                                 align_aggregate_states) *
314
712
                                        align_aggregate_states));
315
712
                        agg_method.hash_table.reset(new HashTableType());
316
712
                        return Status::OK();
317
712
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIhNS4_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEDaRT_
Line
Count
Source
291
44
                    [&](auto& agg_method) {
292
44
                        auto& hash_table = *agg_method.hash_table;
293
44
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
44
                        agg_method.arena.clear();
296
44
                        agg_method.inited_iterator = false;
297
298
44
                        hash_table.for_each_mapped([&](auto& mapped) {
299
44
                            if (mapped) {
300
44
                                _destroy_agg_status(mapped);
301
44
                                mapped = nullptr;
302
44
                            }
303
44
                        });
304
305
44
                        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
44
                        aggregate_data_container.reset(new AggregateDataContainer(
311
44
                                sizeof(typename HashTableType::key_type),
312
44
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
313
44
                                 align_aggregate_states) *
314
44
                                        align_aggregate_states));
315
44
                        agg_method.hash_table.reset(new HashTableType());
316
44
                        return Status::OK();
317
44
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberItNS4_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEDaRT_
Line
Count
Source
291
58
                    [&](auto& agg_method) {
292
58
                        auto& hash_table = *agg_method.hash_table;
293
58
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
58
                        agg_method.arena.clear();
296
58
                        agg_method.inited_iterator = false;
297
298
58
                        hash_table.for_each_mapped([&](auto& mapped) {
299
58
                            if (mapped) {
300
58
                                _destroy_agg_status(mapped);
301
58
                                mapped = nullptr;
302
58
                            }
303
58
                        });
304
305
58
                        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
58
                        aggregate_data_container.reset(new AggregateDataContainer(
311
58
                                sizeof(typename HashTableType::key_type),
312
58
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
313
58
                                 align_aggregate_states) *
314
58
                                        align_aggregate_states));
315
58
                        agg_method.hash_table.reset(new HashTableType());
316
58
                        return Status::OK();
317
58
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEDaRT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEDaRT_
Line
Count
Source
291
424
                    [&](auto& agg_method) {
292
424
                        auto& hash_table = *agg_method.hash_table;
293
424
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
424
                        agg_method.arena.clear();
296
424
                        agg_method.inited_iterator = false;
297
298
424
                        hash_table.for_each_mapped([&](auto& mapped) {
299
424
                            if (mapped) {
300
424
                                _destroy_agg_status(mapped);
301
424
                                mapped = nullptr;
302
424
                            }
303
424
                        });
304
305
424
                        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
424
                        aggregate_data_container.reset(new AggregateDataContainer(
311
424
                                sizeof(typename HashTableType::key_type),
312
424
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
313
424
                                 align_aggregate_states) *
314
424
                                        align_aggregate_states));
315
424
                        agg_method.hash_table.reset(new HashTableType());
316
424
                        return Status::OK();
317
424
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEDaRT_
Line
Count
Source
291
120
                    [&](auto& agg_method) {
292
120
                        auto& hash_table = *agg_method.hash_table;
293
120
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
120
                        agg_method.arena.clear();
296
120
                        agg_method.inited_iterator = false;
297
298
120
                        hash_table.for_each_mapped([&](auto& mapped) {
299
120
                            if (mapped) {
300
120
                                _destroy_agg_status(mapped);
301
120
                                mapped = nullptr;
302
120
                            }
303
120
                        });
304
305
120
                        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
120
                        aggregate_data_container.reset(new AggregateDataContainer(
311
120
                                sizeof(typename HashTableType::key_type),
312
120
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
313
120
                                 align_aggregate_states) *
314
120
                                        align_aggregate_states));
315
120
                        agg_method.hash_table.reset(new HashTableType());
316
120
                        return Status::OK();
317
120
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEDaRT_
Line
Count
Source
291
914
                    [&](auto& agg_method) {
292
914
                        auto& hash_table = *agg_method.hash_table;
293
914
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
914
                        agg_method.arena.clear();
296
914
                        agg_method.inited_iterator = false;
297
298
914
                        hash_table.for_each_mapped([&](auto& mapped) {
299
914
                            if (mapped) {
300
914
                                _destroy_agg_status(mapped);
301
914
                                mapped = nullptr;
302
914
                            }
303
914
                        });
304
305
914
                        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
914
                        aggregate_data_container.reset(new AggregateDataContainer(
311
914
                                sizeof(typename HashTableType::key_type),
312
914
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
313
914
                                 align_aggregate_states) *
314
914
                                        align_aggregate_states));
315
914
                        agg_method.hash_table.reset(new HashTableType());
316
914
                        return Status::OK();
317
914
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEEDaRT_
Line
Count
Source
291
56
                    [&](auto& agg_method) {
292
56
                        auto& hash_table = *agg_method.hash_table;
293
56
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
56
                        agg_method.arena.clear();
296
56
                        agg_method.inited_iterator = false;
297
298
56
                        hash_table.for_each_mapped([&](auto& mapped) {
299
56
                            if (mapped) {
300
56
                                _destroy_agg_status(mapped);
301
56
                                mapped = nullptr;
302
56
                            }
303
56
                        });
304
305
56
                        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
56
                        aggregate_data_container.reset(new AggregateDataContainer(
311
56
                                sizeof(typename HashTableType::key_type),
312
56
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
313
56
                                 align_aggregate_states) *
314
56
                                        align_aggregate_states));
315
56
                        agg_method.hash_table.reset(new HashTableType());
316
56
                        return Status::OK();
317
56
                    }},
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
3.27k
            agg_data->method_variant);
319
3.27k
}
320
321
338
void PartitionedAggSharedState::init_spill_params(size_t spill_partition_count) {
322
338
    partition_count = spill_partition_count;
323
338
    max_partition_index = partition_count - 1;
324
325
11.1k
    for (int i = 0; i < partition_count; ++i) {
326
10.8k
        spill_partitions.emplace_back(std::make_shared<AggSpillPartition>());
327
10.8k
    }
328
338
}
329
330
326
void PartitionedAggSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {
331
10.4k
    for (auto& partition : spill_partitions) {
332
10.4k
        if (partition->spilling_stream_) {
333
0
            partition->spilling_stream_->update_shared_profiles(source_profile);
334
0
        }
335
10.4k
        for (auto& stream : partition->spill_streams_) {
336
2.25k
            if (stream) {
337
2.25k
                stream->update_shared_profiles(source_profile);
338
2.25k
            }
339
2.25k
        }
340
10.4k
    }
341
326
}
342
343
Status AggSpillPartition::get_spill_stream(RuntimeState* state, int node_id,
344
                                           RuntimeProfile* profile,
345
4.80k
                                           vectorized::SpillStreamSPtr& spill_stream) {
346
4.80k
    if (spilling_stream_) {
347
2.50k
        spill_stream = spilling_stream_;
348
2.50k
        return Status::OK();
349
2.50k
    }
350
2.30k
    RETURN_IF_ERROR(ExecEnv::GetInstance()->spill_stream_mgr()->register_spill_stream(
351
2.30k
            state, spilling_stream_, print_id(state->query_id()), "agg", node_id,
352
2.30k
            std::numeric_limits<int32_t>::max(), std::numeric_limits<size_t>::max(), profile));
353
2.30k
    spill_streams_.emplace_back(spilling_stream_);
354
2.30k
    spill_stream = spilling_stream_;
355
2.30k
    return Status::OK();
356
2.30k
}
357
7.52k
void AggSpillPartition::close() {
358
7.52k
    if (spilling_stream_) {
359
1
        spilling_stream_.reset();
360
1
    }
361
7.52k
    for (auto& stream : spill_streams_) {
362
5
        (void)ExecEnv::GetInstance()->spill_stream_mgr()->delete_spill_stream(stream);
363
5
    }
364
7.52k
    spill_streams_.clear();
365
7.52k
}
366
367
363
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
363
    bool false_close = false;
371
363
    if (!is_closed.compare_exchange_strong(false_close, true)) {
372
32
        return;
373
32
    }
374
363
    DCHECK(!false_close && is_closed);
375
7.51k
    for (auto partition : spill_partitions) {
376
7.51k
        partition->close();
377
7.51k
    }
378
331
    spill_partitions.clear();
379
331
}
380
381
21
void SpillSortSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {
382
68
    for (auto& stream : sorted_streams) {
383
68
        if (stream) {
384
68
            stream->update_shared_profiles(source_profile);
385
68
        }
386
68
    }
387
21
}
388
389
23
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
23
    bool false_close = false;
393
23
    if (!is_closed.compare_exchange_strong(false_close, true)) {
394
1
        return;
395
1
    }
396
23
    DCHECK(!false_close && is_closed);
397
22
    for (auto& stream : sorted_streams) {
398
1
        (void)ExecEnv::GetInstance()->spill_stream_mgr()->delete_spill_stream(stream);
399
1
    }
400
22
    sorted_streams.clear();
401
22
}
402
403
MultiCastSharedState::MultiCastSharedState(ObjectPool* pool, int cast_sender_count, int node_id)
404
2.05k
        : multi_cast_data_streamer(std::make_unique<pipeline::MultiCastDataStreamer>(
405
2.05k
                  pool, cast_sender_count, node_id)) {}
406
407
0
void MultiCastSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {}
408
409
112k
int AggSharedState::get_slot_column_id(const vectorized::AggFnEvaluator* evaluator) {
410
112k
    auto ctxs = evaluator->input_exprs_ctxs();
411
112k
    CHECK(ctxs.size() == 1 && ctxs[0]->root()->is_slot_ref())
412
0
            << "input_exprs_ctxs is invalid, input_exprs_ctx[0]="
413
0
            << ctxs[0]->root()->debug_string();
414
112k
    return ((vectorized::VSlotRef*)ctxs[0]->root().get())->column_id();
415
112k
}
416
417
2.25M
void AggSharedState::_destroy_agg_status(vectorized::AggregateDataPtr data) {
418
4.77M
    for (int i = 0; i < aggregate_evaluators.size(); ++i) {
419
2.51M
        aggregate_evaluators[i]->function()->destroy(data + offsets_of_aggregate_states[i]);
420
2.51M
    }
421
2.25M
}
422
423
113k
LocalExchangeSharedState::~LocalExchangeSharedState() = default;
424
425
12.0k
Status SetSharedState::update_build_not_ignore_null(const vectorized::VExprContextSPtrs& ctxs) {
426
12.0k
    if (ctxs.size() > build_not_ignore_null.size()) {
427
0
        return Status::InternalError("build_not_ignore_null not initialized");
428
0
    }
429
430
99.6k
    for (int i = 0; i < ctxs.size(); ++i) {
431
87.6k
        build_not_ignore_null[i] = build_not_ignore_null[i] || ctxs[i]->root()->is_nullable();
432
87.6k
    }
433
434
12.0k
    return Status::OK();
435
12.0k
}
436
437
19.2k
size_t SetSharedState::get_hash_table_size() const {
438
19.2k
    size_t hash_table_size = 0;
439
19.2k
    std::visit(
440
19.2k
            [&](auto&& arg) {
441
19.2k
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
19.2k
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
19.2k
                    hash_table_size = arg.hash_table->size();
444
19.2k
                }
445
19.2k
            },
Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRSt9monostateEEDaOT_
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS7_vEEEEEEDaOT_
Line
Count
Source
440
17.8k
            [&](auto&& arg) {
441
17.8k
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
17.8k
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
17.8k
                    hash_table_size = arg.hash_table->size();
444
17.8k
                }
445
17.8k
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized19MethodStringNoCacheI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS7_vEEEEEEDaOT_
Line
Count
Source
440
242
            [&](auto&& arg) {
441
242
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
242
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
242
                    hash_table_size = arg.hash_table->size();
444
242
                }
445
242
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_19MethodStringNoCacheINS4_15DataWithNullKeyI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS9_vEEEEEEEEEEDaOT_
Line
Count
Source
440
103
            [&](auto&& arg) {
441
103
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
103
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
103
                    hash_table_size = arg.hash_table->size();
444
103
                }
445
103
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIhNS4_15DataWithNullKeyI9PHHashMapIhNS_14RowRefWithFlagE9HashCRC32IhEEEEEEEEEEDaOT_
Line
Count
Source
440
81
            [&](auto&& arg) {
441
81
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
81
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
81
                    hash_table_size = arg.hash_table->size();
444
81
                }
445
81
            },
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
552
            [&](auto&& arg) {
441
552
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
552
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
552
                    hash_table_size = arg.hash_table->size();
444
552
                }
445
552
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImNS_14RowRefWithFlagE9HashCRC32ImEEEEEEEEEEDaOT_
Line
Count
Source
440
85
            [&](auto&& arg) {
441
85
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
85
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
85
                    hash_table_size = arg.hash_table->size();
444
85
                }
445
85
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_NS_14RowRefWithFlagE9HashCRC32IS9_EEEEEEEEEEDaOT_
Line
Count
Source
440
84
            [&](auto&& arg) {
441
84
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
84
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
84
                    hash_table_size = arg.hash_table->size();
444
84
                }
445
84
            },
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
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_10vectorized15MethodKeysFixedI9PHHashMapINS4_6UInt72ENS_14RowRefWithFlagE9HashCRC32IS7_EEEEEEDaOT_
Line
Count
Source
440
27
            [&](auto&& arg) {
441
27
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
27
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
27
                    hash_table_size = arg.hash_table->size();
444
27
                }
445
27
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodKeysFixedI9PHHashMapINS4_6UInt96ENS_14RowRefWithFlagE9HashCRC32IS7_EEEEEEDaOT_
Line
Count
Source
440
94
            [&](auto&& arg) {
441
94
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
94
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
94
                    hash_table_size = arg.hash_table->size();
444
94
                }
445
94
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt104ENS_14RowRefWithFlagE9HashCRC32IS7_EEEEEEDaOT_
Line
Count
Source
440
36
            [&](auto&& arg) {
441
36
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
36
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
36
                    hash_table_size = arg.hash_table->size();
444
36
                }
445
36
            },
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
38
            [&](auto&& arg) {
441
38
                using HashTableCtxType = std::decay_t<decltype(arg)>;
442
38
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
443
38
                    hash_table_size = arg.hash_table->size();
444
38
                }
445
38
            },
446
19.2k
            hash_table_variants->method_variant);
447
19.2k
    return hash_table_size;
448
19.2k
}
449
450
4.87k
Status SetSharedState::hash_table_init() {
451
4.87k
    std::vector<vectorized::DataTypePtr> data_types;
452
40.0k
    for (size_t i = 0; i != child_exprs_lists[0].size(); ++i) {
453
35.1k
        auto& ctx = child_exprs_lists[0][i];
454
35.1k
        auto data_type = ctx->root()->data_type();
455
35.1k
        if (build_not_ignore_null[i]) {
456
34.8k
            data_type = vectorized::make_nullable(data_type);
457
34.8k
        }
458
35.1k
        data_types.emplace_back(std::move(data_type));
459
35.1k
    }
460
4.87k
    return init_hash_method<SetDataVariants>(hash_table_variants.get(), data_types, true);
461
4.87k
}
462
463
void AggSharedState::refresh_top_limit(size_t row_id,
464
3.12k
                                       const vectorized::ColumnRawPtrs& key_columns) {
465
6.37k
    for (int j = 0; j < key_columns.size(); ++j) {
466
3.25k
        limit_columns[j]->insert_from(*key_columns[j], row_id);
467
3.25k
    }
468
3.12k
    limit_heap.emplace(limit_columns[0]->size() - 1, limit_columns, order_directions,
469
3.12k
                       null_directions);
470
471
3.12k
    limit_heap.pop();
472
3.12k
    limit_columns_min = limit_heap.top()._row_id;
473
3.12k
}
474
475
} // namespace doris::pipeline