Coverage Report

Created: 2026-03-17 04:10

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
381k
                                                       const std::string& name) {
43
381k
    source_deps.push_back(std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY"));
44
381k
    source_deps.back()->set_shared_state(this);
45
381k
    return source_deps.back().get();
46
381k
}
47
48
void BasicSharedState::create_source_dependencies(int num_sources, int operator_id, int node_id,
49
109k
                                                  const std::string& name) {
50
109k
    source_deps.resize(num_sources, nullptr);
51
664k
    for (auto& source_dep : source_deps) {
52
664k
        source_dep = std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY");
53
664k
        source_dep->set_shared_state(this);
54
664k
    }
55
109k
}
56
57
Dependency* BasicSharedState::create_sink_dependency(int dest_id, int node_id,
58
891k
                                                     const std::string& name) {
59
891k
    sink_deps.push_back(std::make_shared<Dependency>(dest_id, node_id, name + "_DEPENDENCY", true));
60
891k
    sink_deps.back()->set_shared_state(this);
61
891k
    return sink_deps.back().get();
62
891k
}
63
64
3.96M
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
3.96M
    _blocked_task.push_back(task);
69
3.96M
}
70
71
34.0M
void Dependency::set_ready() {
72
34.0M
    if (_ready) {
73
31.4M
        return;
74
31.4M
    }
75
2.54M
    _watcher.stop();
76
2.54M
    std::vector<std::weak_ptr<PipelineTask>> local_block_task {};
77
2.54M
    {
78
2.54M
        std::unique_lock<std::mutex> lc(_task_lock);
79
2.54M
        if (_ready) {
80
26
            return;
81
26
        }
82
2.54M
        _ready = true;
83
2.54M
        local_block_task.swap(_blocked_task);
84
2.54M
    }
85
3.97M
    for (auto task : local_block_task) {
86
3.97M
        if (auto t = task.lock()) {
87
3.97M
            std::unique_lock<std::mutex> lc(_task_lock);
88
3.97M
            THROW_IF_ERROR(t->wake_up(this));
89
3.97M
        }
90
3.97M
    }
91
2.54M
}
92
93
40.3M
Dependency* Dependency::is_blocked_by(std::shared_ptr<PipelineTask> task) {
94
40.3M
    std::unique_lock<std::mutex> lc(_task_lock);
95
40.3M
    auto ready = _ready.load();
96
40.3M
    if (!ready && task) {
97
3.97M
        _add_block_task(task);
98
3.97M
        start_watcher();
99
3.97M
        THROW_IF_ERROR(task->blocked(this));
100
3.97M
    }
101
40.3M
    return ready ? nullptr : this;
102
40.3M
}
103
104
209k
std::string Dependency::debug_string(int indentation_level) {
105
209k
    fmt::memory_buffer debug_string_buffer;
106
209k
    fmt::format_to(debug_string_buffer, "{}{}: id={}, block task = {}, ready={}, _always_ready={}",
107
209k
                   std::string(indentation_level * 2, ' '), _name, _node_id, _blocked_task.size(),
108
209k
                   _ready, _always_ready);
109
209k
    return fmt::to_string(debug_string_buffer);
110
209k
}
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
941
void RuntimeFilterTimer::call_timeout() {
122
941
    _parent->set_ready();
123
941
}
124
125
14.8k
void RuntimeFilterTimer::call_ready() {
126
14.8k
    _parent->set_ready();
127
14.8k
}
128
129
// should check rf timeout in two case:
130
// 1. the rf is ready just remove the wait queue
131
// 2. if the rf have local dependency, the rf should start wait when all local dependency is ready
132
388k
bool RuntimeFilterTimer::should_be_check_timeout() {
133
388k
    if (!_parent->ready() && !_local_runtime_filter_dependencies.empty()) {
134
8.19k
        bool all_ready = true;
135
8.28k
        for (auto& dep : _local_runtime_filter_dependencies) {
136
8.28k
            if (!dep->ready()) {
137
8.11k
                all_ready = false;
138
8.11k
                break;
139
8.11k
            }
140
8.28k
        }
141
8.19k
        if (all_ready) {
142
84
            _local_runtime_filter_dependencies.clear();
143
84
            _registration_time = MonotonicMillis();
144
84
        }
145
8.19k
        return all_ready;
146
8.19k
    }
147
380k
    return true;
148
388k
}
149
150
8
void RuntimeFilterTimerQueue::start() {
151
66.3k
    while (!_stop) {
152
66.3k
        std::unique_lock<std::mutex> lk(cv_m);
153
154
69.4k
        while (_que.empty() && !_stop) {
155
6.31k
            cv.wait_for(lk, std::chrono::seconds(3), [this] { return !_que.empty() || _stop; });
156
3.16k
        }
157
66.3k
        if (_stop) {
158
3
            break;
159
3
        }
160
66.3k
        {
161
66.3k
            std::unique_lock<std::mutex> lc(_que_lock);
162
66.3k
            std::list<std::shared_ptr<pipeline::RuntimeFilterTimer>> new_que;
163
388k
            for (auto& it : _que) {
164
388k
                if (it.use_count() == 1) {
165
                    // `use_count == 1` means this runtime filter has been released
166
388k
                } else if (it->should_be_check_timeout()) {
167
380k
                    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
366k
                        int64_t ms_since_registration = MonotonicMillis() - it->registration_time();
170
366k
                        if (ms_since_registration > it->wait_time_ms()) {
171
941
                            it->call_timeout();
172
365k
                        } else {
173
365k
                            new_que.push_back(std::move(it));
174
365k
                        }
175
366k
                    }
176
380k
                } else {
177
8.11k
                    new_que.push_back(std::move(it));
178
8.11k
                }
179
388k
            }
180
66.3k
            new_que.swap(_que);
181
66.3k
        }
182
66.3k
        std::this_thread::sleep_for(std::chrono::milliseconds(interval));
183
66.3k
    }
184
8
    _shutdown = true;
185
8
}
186
187
296k
void LocalExchangeSharedState::sub_running_sink_operators() {
188
296k
    std::unique_lock<std::mutex> lc(le_lock);
189
296k
    if (exchanger->_running_sink_operators.fetch_sub(1) == 1) {
190
105k
        _set_always_ready();
191
105k
    }
192
296k
}
193
194
650k
void LocalExchangeSharedState::sub_running_source_operators() {
195
650k
    std::unique_lock<std::mutex> lc(le_lock);
196
650k
    if (exchanger->_running_source_operators.fetch_sub(1) == 1) {
197
105k
        _set_always_ready();
198
105k
        exchanger->finalize();
199
105k
    }
200
650k
}
201
202
105k
LocalExchangeSharedState::LocalExchangeSharedState(int num_instances) {
203
105k
    source_deps.resize(num_instances, nullptr);
204
105k
    mem_counters.resize(num_instances, nullptr);
205
105k
}
206
207
138
vectorized::MutableColumns AggSharedState::_get_keys_hash_table() {
208
138
    return std::visit(
209
138
            vectorized::Overload {
210
138
                    [&](std::monostate& arg) {
211
0
                        throw doris::Exception(ErrorCode::INTERNAL_ERROR, "uninited hash table");
212
0
                        return vectorized::MutableColumns();
213
0
                    },
214
138
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
138
                        vectorized::MutableColumns key_columns;
216
443
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
305
                            key_columns.emplace_back(
218
305
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
305
                        }
220
138
                        auto& data = *agg_method.hash_table;
221
138
                        bool has_null_key = data.has_null_key_data();
222
138
                        const auto size = data.size() - has_null_key;
223
138
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
138
                        std::vector<KeyType> keys(size);
225
226
138
                        uint32_t num_rows = 0;
227
138
                        auto iter = aggregate_data_container->begin();
228
138
                        {
229
46.8k
                            while (iter != aggregate_data_container->end()) {
230
46.6k
                                keys[num_rows] = iter.get_key<KeyType>();
231
46.6k
                                ++iter;
232
46.6k
                                ++num_rows;
233
46.6k
                            }
234
138
                        }
235
138
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
138
                        if (has_null_key) {
237
2
                            key_columns[0]->insert_data(nullptr, 0);
238
2
                        }
239
138
                        return key_columns;
240
138
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS7_vEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
Line
Count
Source
214
12
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
12
                        vectorized::MutableColumns key_columns;
216
60
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
48
                            key_columns.emplace_back(
218
48
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
48
                        }
220
12
                        auto& data = *agg_method.hash_table;
221
12
                        bool has_null_key = data.has_null_key_data();
222
12
                        const auto size = data.size() - has_null_key;
223
12
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
12
                        std::vector<KeyType> keys(size);
225
226
12
                        uint32_t num_rows = 0;
227
12
                        auto iter = aggregate_data_container->begin();
228
12
                        {
229
34.3k
                            while (iter != aggregate_data_container->end()) {
230
34.3k
                                keys[num_rows] = iter.get_key<KeyType>();
231
34.3k
                                ++iter;
232
34.3k
                                ++num_rows;
233
34.3k
                            }
234
12
                        }
235
12
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
12
                        if (has_null_key) {
237
0
                            key_columns[0]->insert_data(nullptr, 0);
238
0
                        }
239
12
                        return key_columns;
240
12
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_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
10
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
10
                        vectorized::MutableColumns key_columns;
216
20
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
10
                            key_columns.emplace_back(
218
10
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
10
                        }
220
10
                        auto& data = *agg_method.hash_table;
221
10
                        bool has_null_key = data.has_null_key_data();
222
10
                        const auto size = data.size() - has_null_key;
223
10
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
10
                        std::vector<KeyType> keys(size);
225
226
10
                        uint32_t num_rows = 0;
227
10
                        auto iter = aggregate_data_container->begin();
228
10
                        {
229
20
                            while (iter != aggregate_data_container->end()) {
230
10
                                keys[num_rows] = iter.get_key<KeyType>();
231
10
                                ++iter;
232
10
                                ++num_rows;
233
10
                            }
234
10
                        }
235
10
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
10
                        if (has_null_key) {
237
0
                            key_columns[0]->insert_data(nullptr, 0);
238
0
                        }
239
10
                        return key_columns;
240
10
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
Line
Count
Source
214
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
35
                            while (iter != aggregate_data_container->end()) {
230
28
                                keys[num_rows] = iter.get_key<KeyType>();
231
28
                                ++iter;
232
28
                                ++num_rows;
233
28
                            }
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
2
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
2
                        vectorized::MutableColumns key_columns;
216
4
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
2
                            key_columns.emplace_back(
218
2
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
2
                        }
220
2
                        auto& data = *agg_method.hash_table;
221
2
                        bool has_null_key = data.has_null_key_data();
222
2
                        const auto size = data.size() - has_null_key;
223
2
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
2
                        std::vector<KeyType> keys(size);
225
226
2
                        uint32_t num_rows = 0;
227
2
                        auto iter = aggregate_data_container->begin();
228
2
                        {
229
8
                            while (iter != aggregate_data_container->end()) {
230
6
                                keys[num_rows] = iter.get_key<KeyType>();
231
6
                                ++iter;
232
6
                                ++num_rows;
233
6
                            }
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_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberItNS4_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
Line
Count
Source
214
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.46k
                            while (iter != aggregate_data_container->end()) {
230
2.46k
                                keys[num_rows] = iter.get_key<KeyType>();
231
2.46k
                                ++iter;
232
2.46k
                                ++num_rows;
233
2.46k
                            }
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_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISJ_EESaISM_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.46k
                            while (iter != aggregate_data_container->end()) {
230
2.46k
                                keys[num_rows] = iter.get_key<KeyType>();
231
2.46k
                                ++iter;
232
2.46k
                                ++num_rows;
233
2.46k
                            }
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_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISL_EESaISO_EEOT_
Line
Count
Source
214
9
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
9
                        vectorized::MutableColumns key_columns;
216
18
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
9
                            key_columns.emplace_back(
218
9
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
9
                        }
220
9
                        auto& data = *agg_method.hash_table;
221
9
                        bool has_null_key = data.has_null_key_data();
222
9
                        const auto size = data.size() - has_null_key;
223
9
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
9
                        std::vector<KeyType> keys(size);
225
226
9
                        uint32_t num_rows = 0;
227
9
                        auto iter = aggregate_data_container->begin();
228
9
                        {
229
31
                            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
9
                        }
235
9
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
9
                        if (has_null_key) {
237
1
                            key_columns[0]->insert_data(nullptr, 0);
238
1
                        }
239
9
                        return key_columns;
240
9
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISL_EESaISO_EEOT_
Line
Count
Source
214
14
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
14
                        vectorized::MutableColumns key_columns;
216
28
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
14
                            key_columns.emplace_back(
218
14
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
14
                        }
220
14
                        auto& data = *agg_method.hash_table;
221
14
                        bool has_null_key = data.has_null_key_data();
222
14
                        const auto size = data.size() - has_null_key;
223
14
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
14
                        std::vector<KeyType> keys(size);
225
226
14
                        uint32_t num_rows = 0;
227
14
                        auto iter = aggregate_data_container->begin();
228
14
                        {
229
5.01k
                            while (iter != aggregate_data_container->end()) {
230
5.00k
                                keys[num_rows] = iter.get_key<KeyType>();
231
5.00k
                                ++iter;
232
5.00k
                                ++num_rows;
233
5.00k
                            }
234
14
                        }
235
14
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
14
                        if (has_null_key) {
237
1
                            key_columns[0]->insert_data(nullptr, 0);
238
1
                        }
239
14
                        return key_columns;
240
14
                    }},
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_
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
71
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
215
71
                        vectorized::MutableColumns key_columns;
216
273
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
217
202
                            key_columns.emplace_back(
218
202
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
219
202
                        }
220
71
                        auto& data = *agg_method.hash_table;
221
71
                        bool has_null_key = data.has_null_key_data();
222
71
                        const auto size = data.size() - has_null_key;
223
71
                        using KeyType = std::decay_t<decltype(agg_method)>::Key;
224
71
                        std::vector<KeyType> keys(size);
225
226
71
                        uint32_t num_rows = 0;
227
71
                        auto iter = aggregate_data_container->begin();
228
71
                        {
229
2.40k
                            while (iter != aggregate_data_container->end()) {
230
2.33k
                                keys[num_rows] = iter.get_key<KeyType>();
231
2.33k
                                ++iter;
232
2.33k
                                ++num_rows;
233
2.33k
                            }
234
71
                        }
235
71
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
236
71
                        if (has_null_key) {
237
0
                            key_columns[0]->insert_data(nullptr, 0);
238
0
                        }
239
71
                        return key_columns;
240
71
                    }},
241
138
            agg_data->method_variant);
242
138
}
243
244
138
void AggSharedState::build_limit_heap(size_t hash_table_size) {
245
138
    limit_columns = _get_keys_hash_table();
246
48.5k
    for (size_t i = 0; i < hash_table_size; ++i) {
247
48.3k
        limit_heap.emplace(i, limit_columns, order_directions, null_directions);
248
48.3k
    }
249
49.2k
    while (hash_table_size > limit) {
250
49.0k
        limit_heap.pop();
251
49.0k
        hash_table_size--;
252
49.0k
    }
253
138
    limit_columns_min = limit_heap.top()._row_id;
254
138
}
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
924
        for (int i = 0; i < key_size; i++) {
266
650
            block->get_by_position(key_locs ? key_locs->operator[](i) : i)
267
650
                    .column->compare_internal(limit_columns_min, *limit_columns[i],
268
650
                                              null_directions[i], order_directions[i], cmp_res,
269
650
                                              need_computes.data());
270
650
        }
271
272
274
        auto set_computes_arr = [](auto* __restrict res, auto* __restrict computes, size_t rows) {
273
388k
            for (size_t i = 0; i < rows; ++i) {
274
388k
                computes[i] = computes[i] == res[i];
275
388k
            }
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.07k
Status AggSharedState::reset_hash_table() {
286
3.07k
    return std::visit(
287
3.07k
            vectorized::Overload {
288
3.07k
                    [&](std::monostate& arg) -> Status {
289
0
                        return Status::InternalError("Uninited hash table");
290
0
                    },
291
3.07k
                    [&](auto& agg_method) {
292
3.07k
                        auto& hash_table = *agg_method.hash_table;
293
3.07k
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
3.07k
                        agg_method.arena.clear();
296
3.07k
                        agg_method.inited_iterator = false;
297
298
1.05M
                        hash_table.for_each_mapped([&](auto& mapped) {
299
1.05M
                            if (mapped) {
300
1.05M
                                static_cast<void>(_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_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEDaRT_ENKUlSD_E_clIS7_EEDaSD_
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
462
                        hash_table.for_each_mapped([&](auto& mapped) {
299
462
                            if (mapped) {
300
462
                                static_cast<void>(_destroy_agg_status(mapped));
301
462
                                mapped = nullptr;
302
462
                            }
303
462
                        });
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEDaRT_ENKUlSE_E_clIS7_EEDaSE_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEEDaRT_ENKUlSG_E_clISA_EEDaSG_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEEDaRT_ENKUlSG_E_clISA_EEDaSG_
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Line
Count
Source
298
1.04M
                        hash_table.for_each_mapped([&](auto& mapped) {
299
1.04M
                            if (mapped) {
300
1.04M
                                static_cast<void>(_destroy_agg_status(mapped));
301
1.04M
                                mapped = nullptr;
302
1.04M
                            }
303
1.04M
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Line
Count
Source
298
2.53k
                        hash_table.for_each_mapped([&](auto& mapped) {
299
2.53k
                            if (mapped) {
300
2.53k
                                static_cast<void>(_destroy_agg_status(mapped));
301
2.53k
                                mapped = nullptr;
302
2.53k
                            }
303
2.53k
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIhNS4_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_
Line
Count
Source
298
564
                        hash_table.for_each_mapped([&](auto& mapped) {
299
564
                            if (mapped) {
300
564
                                static_cast<void>(_destroy_agg_status(mapped));
301
564
                                mapped = nullptr;
302
564
                            }
303
564
                        });
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberItNS4_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_
Line
Count
Source
298
524
                        hash_table.for_each_mapped([&](auto& mapped) {
299
524
                            if (mapped) {
300
524
                                static_cast<void>(_destroy_agg_status(mapped));
301
524
                                mapped = nullptr;
302
524
                            }
303
524
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_
Line
Count
Source
298
1.22k
                        hash_table.for_each_mapped([&](auto& mapped) {
299
1.22k
                            if (mapped) {
300
1.22k
                                static_cast<void>(_destroy_agg_status(mapped));
301
1.22k
                                mapped = nullptr;
302
1.22k
                            }
303
1.22k
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEDaRT_ENKUlSJ_E_clIS9_EEDaSJ_
Line
Count
Source
298
1.51k
                        hash_table.for_each_mapped([&](auto& mapped) {
299
1.51k
                            if (mapped) {
300
1.51k
                                static_cast<void>(_destroy_agg_status(mapped));
301
1.51k
                                mapped = nullptr;
302
1.51k
                            }
303
1.51k
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEDaRT_ENKUlSJ_E_clIS9_EEDaSJ_
Line
Count
Source
298
1.06k
                        hash_table.for_each_mapped([&](auto& mapped) {
299
1.06k
                            if (mapped) {
300
1.06k
                                static_cast<void>(_destroy_agg_status(mapped));
301
1.06k
                                mapped = nullptr;
302
1.06k
                            }
303
1.06k
                        });
dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEEDaRT_ENKUlSK_E_clISC_EEDaSK_
Line
Count
Source
298
398
                        hash_table.for_each_mapped([&](auto& mapped) {
299
398
                            if (mapped) {
300
398
                                static_cast<void>(_destroy_agg_status(mapped));
301
398
                                mapped = nullptr;
302
398
                            }
303
398
                        });
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.07k
                        if (hash_table.has_null_key_data()) {
306
0
                            auto st = _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                          vectorized::AggregateDataPtr>());
308
0
                            RETURN_IF_ERROR(st);
309
0
                        }
310
311
3.07k
                        aggregate_data_container.reset(new AggregateDataContainer(
312
3.07k
                                sizeof(typename HashTableType::key_type),
313
3.07k
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
3.07k
                                 align_aggregate_states) *
315
3.07k
                                        align_aggregate_states));
316
3.07k
                        agg_method.hash_table.reset(new HashTableType());
317
3.07k
                        return Status::OK();
318
3.07k
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS7_vEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEDaRT_
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
140
                    [&](auto& agg_method) {
292
140
                        auto& hash_table = *agg_method.hash_table;
293
140
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
140
                        agg_method.arena.clear();
296
140
                        agg_method.inited_iterator = false;
297
298
140
                        hash_table.for_each_mapped([&](auto& mapped) {
299
140
                            if (mapped) {
300
140
                                static_cast<void>(_destroy_agg_status(mapped));
301
140
                                mapped = nullptr;
302
140
                            }
303
140
                        });
304
305
140
                        if (hash_table.has_null_key_data()) {
306
0
                            auto st = _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                          vectorized::AggregateDataPtr>());
308
0
                            RETURN_IF_ERROR(st);
309
0
                        }
310
311
140
                        aggregate_data_container.reset(new AggregateDataContainer(
312
140
                                sizeof(typename HashTableType::key_type),
313
140
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
140
                                 align_aggregate_states) *
315
140
                                        align_aggregate_states));
316
140
                        agg_method.hash_table.reset(new HashTableType());
317
140
                        return Status::OK();
318
140
                    }},
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
235
                    [&](auto& agg_method) {
292
235
                        auto& hash_table = *agg_method.hash_table;
293
235
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
235
                        agg_method.arena.clear();
296
235
                        agg_method.inited_iterator = false;
297
298
235
                        hash_table.for_each_mapped([&](auto& mapped) {
299
235
                            if (mapped) {
300
235
                                static_cast<void>(_destroy_agg_status(mapped));
301
235
                                mapped = nullptr;
302
235
                            }
303
235
                        });
304
305
235
                        if (hash_table.has_null_key_data()) {
306
0
                            auto st = _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                          vectorized::AggregateDataPtr>());
308
0
                            RETURN_IF_ERROR(st);
309
0
                        }
310
311
235
                        aggregate_data_container.reset(new AggregateDataContainer(
312
235
                                sizeof(typename HashTableType::key_type),
313
235
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
235
                                 align_aggregate_states) *
315
235
                                        align_aggregate_states));
316
235
                        agg_method.hash_table.reset(new HashTableType());
317
235
                        return Status::OK();
318
235
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEDaRT_
Line
Count
Source
291
818
                    [&](auto& agg_method) {
292
818
                        auto& hash_table = *agg_method.hash_table;
293
818
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
818
                        agg_method.arena.clear();
296
818
                        agg_method.inited_iterator = false;
297
298
818
                        hash_table.for_each_mapped([&](auto& mapped) {
299
818
                            if (mapped) {
300
818
                                static_cast<void>(_destroy_agg_status(mapped));
301
818
                                mapped = nullptr;
302
818
                            }
303
818
                        });
304
305
818
                        if (hash_table.has_null_key_data()) {
306
0
                            auto st = _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                          vectorized::AggregateDataPtr>());
308
0
                            RETURN_IF_ERROR(st);
309
0
                        }
310
311
818
                        aggregate_data_container.reset(new AggregateDataContainer(
312
818
                                sizeof(typename HashTableType::key_type),
313
818
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
818
                                 align_aggregate_states) *
315
818
                                        align_aggregate_states));
316
818
                        agg_method.hash_table.reset(new HashTableType());
317
818
                        return Status::OK();
318
818
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIhNS4_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEDaRT_
Line
Count
Source
291
262
                    [&](auto& agg_method) {
292
262
                        auto& hash_table = *agg_method.hash_table;
293
262
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
262
                        agg_method.arena.clear();
296
262
                        agg_method.inited_iterator = false;
297
298
262
                        hash_table.for_each_mapped([&](auto& mapped) {
299
262
                            if (mapped) {
300
262
                                static_cast<void>(_destroy_agg_status(mapped));
301
262
                                mapped = nullptr;
302
262
                            }
303
262
                        });
304
305
262
                        if (hash_table.has_null_key_data()) {
306
0
                            auto st = _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                          vectorized::AggregateDataPtr>());
308
0
                            RETURN_IF_ERROR(st);
309
0
                        }
310
311
262
                        aggregate_data_container.reset(new AggregateDataContainer(
312
262
                                sizeof(typename HashTableType::key_type),
313
262
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
262
                                 align_aggregate_states) *
315
262
                                        align_aggregate_states));
316
262
                        agg_method.hash_table.reset(new HashTableType());
317
262
                        return Status::OK();
318
262
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberItNS4_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEDaRT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEDaRT_
Line
Count
Source
291
115
                    [&](auto& agg_method) {
292
115
                        auto& hash_table = *agg_method.hash_table;
293
115
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
115
                        agg_method.arena.clear();
296
115
                        agg_method.inited_iterator = false;
297
298
115
                        hash_table.for_each_mapped([&](auto& mapped) {
299
115
                            if (mapped) {
300
115
                                static_cast<void>(_destroy_agg_status(mapped));
301
115
                                mapped = nullptr;
302
115
                            }
303
115
                        });
304
305
115
                        if (hash_table.has_null_key_data()) {
306
0
                            auto st = _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                          vectorized::AggregateDataPtr>());
308
0
                            RETURN_IF_ERROR(st);
309
0
                        }
310
311
115
                        aggregate_data_container.reset(new AggregateDataContainer(
312
115
                                sizeof(typename HashTableType::key_type),
313
115
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
115
                                 align_aggregate_states) *
315
115
                                        align_aggregate_states));
316
115
                        agg_method.hash_table.reset(new HashTableType());
317
115
                        return Status::OK();
318
115
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEDaRT_
Line
Count
Source
291
370
                    [&](auto& agg_method) {
292
370
                        auto& hash_table = *agg_method.hash_table;
293
370
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
370
                        agg_method.arena.clear();
296
370
                        agg_method.inited_iterator = false;
297
298
370
                        hash_table.for_each_mapped([&](auto& mapped) {
299
370
                            if (mapped) {
300
370
                                static_cast<void>(_destroy_agg_status(mapped));
301
370
                                mapped = nullptr;
302
370
                            }
303
370
                        });
304
305
370
                        if (hash_table.has_null_key_data()) {
306
0
                            auto st = _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                          vectorized::AggregateDataPtr>());
308
0
                            RETURN_IF_ERROR(st);
309
0
                        }
310
311
370
                        aggregate_data_container.reset(new AggregateDataContainer(
312
370
                                sizeof(typename HashTableType::key_type),
313
370
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
370
                                 align_aggregate_states) *
315
370
                                        align_aggregate_states));
316
370
                        agg_method.hash_table.reset(new HashTableType());
317
370
                        return Status::OK();
318
370
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEDaRT_
Line
Count
Source
291
408
                    [&](auto& agg_method) {
292
408
                        auto& hash_table = *agg_method.hash_table;
293
408
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
408
                        agg_method.arena.clear();
296
408
                        agg_method.inited_iterator = false;
297
298
408
                        hash_table.for_each_mapped([&](auto& mapped) {
299
408
                            if (mapped) {
300
408
                                static_cast<void>(_destroy_agg_status(mapped));
301
408
                                mapped = nullptr;
302
408
                            }
303
408
                        });
304
305
408
                        if (hash_table.has_null_key_data()) {
306
0
                            auto st = _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                          vectorized::AggregateDataPtr>());
308
0
                            RETURN_IF_ERROR(st);
309
0
                        }
310
311
408
                        aggregate_data_container.reset(new AggregateDataContainer(
312
408
                                sizeof(typename HashTableType::key_type),
313
408
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
408
                                 align_aggregate_states) *
315
408
                                        align_aggregate_states));
316
408
                        agg_method.hash_table.reset(new HashTableType());
317
408
                        return Status::OK();
318
408
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEDaRT_
Line
Count
Source
291
567
                    [&](auto& agg_method) {
292
567
                        auto& hash_table = *agg_method.hash_table;
293
567
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
567
                        agg_method.arena.clear();
296
567
                        agg_method.inited_iterator = false;
297
298
567
                        hash_table.for_each_mapped([&](auto& mapped) {
299
567
                            if (mapped) {
300
567
                                static_cast<void>(_destroy_agg_status(mapped));
301
567
                                mapped = nullptr;
302
567
                            }
303
567
                        });
304
305
567
                        if (hash_table.has_null_key_data()) {
306
0
                            auto st = _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                          vectorized::AggregateDataPtr>());
308
0
                            RETURN_IF_ERROR(st);
309
0
                        }
310
311
567
                        aggregate_data_container.reset(new AggregateDataContainer(
312
567
                                sizeof(typename HashTableType::key_type),
313
567
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
567
                                 align_aggregate_states) *
315
567
                                        align_aggregate_states));
316
567
                        agg_method.hash_table.reset(new HashTableType());
317
567
                        return Status::OK();
318
567
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEEDaRT_
Line
Count
Source
291
156
                    [&](auto& agg_method) {
292
156
                        auto& hash_table = *agg_method.hash_table;
293
156
                        using HashTableType = std::decay_t<decltype(hash_table)>;
294
295
156
                        agg_method.arena.clear();
296
156
                        agg_method.inited_iterator = false;
297
298
156
                        hash_table.for_each_mapped([&](auto& mapped) {
299
156
                            if (mapped) {
300
156
                                static_cast<void>(_destroy_agg_status(mapped));
301
156
                                mapped = nullptr;
302
156
                            }
303
156
                        });
304
305
156
                        if (hash_table.has_null_key_data()) {
306
0
                            auto st = _destroy_agg_status(hash_table.template get_null_key_data<
307
0
                                                          vectorized::AggregateDataPtr>());
308
0
                            RETURN_IF_ERROR(st);
309
0
                        }
310
311
156
                        aggregate_data_container.reset(new AggregateDataContainer(
312
156
                                sizeof(typename HashTableType::key_type),
313
156
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
314
156
                                 align_aggregate_states) *
315
156
                                        align_aggregate_states));
316
156
                        agg_method.hash_table.reset(new HashTableType());
317
156
                        return Status::OK();
318
156
                    }},
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_
319
3.07k
            agg_data->method_variant);
320
3.07k
}
321
322
318
void PartitionedAggSharedState::init_spill_params(size_t spill_partition_count) {
323
318
    partition_count = spill_partition_count;
324
318
    max_partition_index = partition_count - 1;
325
326
10.4k
    for (int i = 0; i < partition_count; ++i) {
327
10.1k
        spill_partitions.emplace_back(std::make_shared<AggSpillPartition>());
328
10.1k
    }
329
318
}
330
331
305
void PartitionedAggSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {
332
9.78k
    for (auto& partition : spill_partitions) {
333
9.78k
        if (partition->spilling_stream_) {
334
0
            partition->spilling_stream_->update_shared_profiles(source_profile);
335
0
        }
336
9.78k
        for (auto& stream : partition->spill_streams_) {
337
1.98k
            if (stream) {
338
1.98k
                stream->update_shared_profiles(source_profile);
339
1.98k
            }
340
1.98k
        }
341
9.78k
    }
342
305
}
343
344
Status AggSpillPartition::get_spill_stream(RuntimeState* state, int node_id,
345
                                           RuntimeProfile* profile,
346
4.58k
                                           vectorized::SpillStreamSPtr& spill_stream) {
347
4.58k
    if (spilling_stream_) {
348
2.52k
        spill_stream = spilling_stream_;
349
2.52k
        return Status::OK();
350
2.52k
    }
351
2.05k
    RETURN_IF_ERROR(ExecEnv::GetInstance()->spill_stream_mgr()->register_spill_stream(
352
2.05k
            state, spilling_stream_, print_id(state->query_id()), "agg", node_id,
353
2.05k
            std::numeric_limits<int32_t>::max(), std::numeric_limits<size_t>::max(), profile));
354
2.05k
    spill_streams_.emplace_back(spilling_stream_);
355
2.05k
    spill_stream = spilling_stream_;
356
2.05k
    return Status::OK();
357
2.05k
}
358
7.05k
void AggSpillPartition::close() {
359
7.05k
    if (spilling_stream_) {
360
1
        spilling_stream_.reset();
361
1
    }
362
7.05k
    for (auto& stream : spill_streams_) {
363
5
        (void)ExecEnv::GetInstance()->spill_stream_mgr()->delete_spill_stream(stream);
364
5
    }
365
7.05k
    spill_streams_.clear();
366
7.05k
}
367
368
348
void PartitionedAggSharedState::close() {
369
    // need to use CAS instead of only `if (!is_closed)` statement,
370
    // to avoid concurrent entry of close() both pass the if statement
371
348
    bool false_close = false;
372
348
    if (!is_closed.compare_exchange_strong(false_close, true)) {
373
37
        return;
374
37
    }
375
348
    DCHECK(!false_close && is_closed);
376
7.05k
    for (auto partition : spill_partitions) {
377
7.05k
        partition->close();
378
7.05k
    }
379
311
    spill_partitions.clear();
380
311
}
381
382
28
void SpillSortSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {
383
28
    for (auto& stream : sorted_streams) {
384
28
        if (stream) {
385
28
            stream->update_shared_profiles(source_profile);
386
28
        }
387
28
    }
388
28
}
389
390
30
void SpillSortSharedState::close() {
391
    // need to use CAS instead of only `if (!is_closed)` statement,
392
    // to avoid concurrent entry of close() both pass the if statement
393
30
    bool false_close = false;
394
30
    if (!is_closed.compare_exchange_strong(false_close, true)) {
395
1
        return;
396
1
    }
397
30
    DCHECK(!false_close && is_closed);
398
29
    for (auto& stream : sorted_streams) {
399
1
        (void)ExecEnv::GetInstance()->spill_stream_mgr()->delete_spill_stream(stream);
400
1
    }
401
29
    sorted_streams.clear();
402
29
}
403
404
MultiCastSharedState::MultiCastSharedState(ObjectPool* pool, int cast_sender_count, int node_id)
405
1.80k
        : multi_cast_data_streamer(std::make_unique<pipeline::MultiCastDataStreamer>(
406
1.80k
                  pool, cast_sender_count, node_id)) {}
407
408
0
void MultiCastSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {}
409
410
103k
int AggSharedState::get_slot_column_id(const vectorized::AggFnEvaluator* evaluator) {
411
103k
    auto ctxs = evaluator->input_exprs_ctxs();
412
18.4E
    CHECK(ctxs.size() == 1 && ctxs[0]->root()->is_slot_ref())
413
18.4E
            << "input_exprs_ctxs is invalid, input_exprs_ctx[0]="
414
18.4E
            << ctxs[0]->root()->debug_string();
415
103k
    return ((vectorized::VSlotRef*)ctxs[0]->root().get())->column_id();
416
103k
}
417
418
2.37M
Status AggSharedState::_destroy_agg_status(vectorized::AggregateDataPtr data) {
419
5.01M
    for (int i = 0; i < aggregate_evaluators.size(); ++i) {
420
2.63M
        aggregate_evaluators[i]->function()->destroy(data + offsets_of_aggregate_states[i]);
421
2.63M
    }
422
2.37M
    return Status::OK();
423
2.37M
}
424
425
105k
LocalExchangeSharedState::~LocalExchangeSharedState() = default;
426
427
11.9k
Status SetSharedState::update_build_not_ignore_null(const vectorized::VExprContextSPtrs& ctxs) {
428
11.9k
    if (ctxs.size() > build_not_ignore_null.size()) {
429
0
        return Status::InternalError("build_not_ignore_null not initialized");
430
0
    }
431
432
99.4k
    for (int i = 0; i < ctxs.size(); ++i) {
433
87.4k
        build_not_ignore_null[i] = build_not_ignore_null[i] || ctxs[i]->root()->is_nullable();
434
87.4k
    }
435
436
11.9k
    return Status::OK();
437
11.9k
}
438
439
19.0k
size_t SetSharedState::get_hash_table_size() const {
440
19.0k
    size_t hash_table_size = 0;
441
19.0k
    std::visit(
442
19.0k
            [&](auto&& arg) {
443
19.0k
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
19.0k
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
19.0k
                    hash_table_size = arg.hash_table->size();
446
19.0k
                }
447
19.0k
            },
Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRSt9monostateEEDaOT_
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS7_vEEEEEEDaOT_
Line
Count
Source
442
17.9k
            [&](auto&& arg) {
443
17.9k
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
17.9k
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
17.9k
                    hash_table_size = arg.hash_table->size();
446
17.9k
                }
447
17.9k
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized19MethodStringNoCacheI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS7_vEEEEEEDaOT_
Line
Count
Source
442
120
            [&](auto&& arg) {
443
120
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
120
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
120
                    hash_table_size = arg.hash_table->size();
446
120
                }
447
120
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_19MethodStringNoCacheINS4_15DataWithNullKeyI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS9_vEEEEEEEEEEDaOT_
Line
Count
Source
442
200
            [&](auto&& arg) {
443
200
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
200
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
200
                    hash_table_size = arg.hash_table->size();
446
200
                }
447
200
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIhNS4_15DataWithNullKeyI9PHHashMapIhNS_14RowRefWithFlagE9HashCRC32IhEEEEEEEEEEDaOT_
Line
Count
Source
442
87
            [&](auto&& arg) {
443
87
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
87
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
87
                    hash_table_size = arg.hash_table->size();
446
87
                }
447
87
            },
Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberItNS4_15DataWithNullKeyI9PHHashMapItNS_14RowRefWithFlagE9HashCRC32ItEEEEEEEEEEDaOT_
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjNS_14RowRefWithFlagE9HashCRC32IjEEEEEEEEEEDaOT_
Line
Count
Source
442
335
            [&](auto&& arg) {
443
335
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
335
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
335
                    hash_table_size = arg.hash_table->size();
446
335
                }
447
335
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImNS_14RowRefWithFlagE9HashCRC32ImEEEEEEEEEEDaOT_
Line
Count
Source
442
121
            [&](auto&& arg) {
443
121
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
121
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
121
                    hash_table_size = arg.hash_table->size();
446
121
                }
447
121
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_NS_14RowRefWithFlagE9HashCRC32IS9_EEEEEEEEEEDaOT_
Line
Count
Source
442
24
            [&](auto&& arg) {
443
24
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
24
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
24
                    hash_table_size = arg.hash_table->size();
446
24
                }
447
24
            },
Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm256EjEENS4_15DataWithNullKeyI9PHHashMapIS9_NS_14RowRefWithFlagE9HashCRC32IS9_EEEEEEEEEEDaOT_
Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodOneNumberIh9PHHashMapIhNS_14RowRefWithFlagE9HashCRC32IhEEEEEEDaOT_
Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodOneNumberIt9PHHashMapItNS_14RowRefWithFlagE9HashCRC32ItEEEEEEDaOT_
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodOneNumberIj9PHHashMapIjNS_14RowRefWithFlagE9HashCRC32IjEEEEEEDaOT_
Line
Count
Source
442
36
            [&](auto&& arg) {
443
36
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
36
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
36
                    hash_table_size = arg.hash_table->size();
446
36
                }
447
36
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodOneNumberIm9PHHashMapImNS_14RowRefWithFlagE9HashCRC32ImEEEEEEDaOT_
Line
Count
Source
442
16
            [&](auto&& arg) {
443
16
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
16
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
16
                    hash_table_size = arg.hash_table->size();
446
16
                }
447
16
            },
Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS8_NS_14RowRefWithFlagE9HashCRC32IS8_EEEEEEDaOT_
Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS8_NS_14RowRefWithFlagE9HashCRC32IS8_EEEEEEDaOT_
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodKeysFixedI9PHHashMapImNS_14RowRefWithFlagE9HashCRC32ImEEEEEEDaOT_
Line
Count
Source
442
33
            [&](auto&& arg) {
443
33
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
33
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
33
                    hash_table_size = arg.hash_table->size();
446
33
                }
447
33
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodKeysFixedI9PHHashMapINS4_6UInt72ENS_14RowRefWithFlagE9HashCRC32IS7_EEEEEEDaOT_
Line
Count
Source
442
18
            [&](auto&& arg) {
443
18
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
18
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
18
                    hash_table_size = arg.hash_table->size();
446
18
                }
447
18
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodKeysFixedI9PHHashMapINS4_6UInt96ENS_14RowRefWithFlagE9HashCRC32IS7_EEEEEEDaOT_
Line
Count
Source
442
18
            [&](auto&& arg) {
443
18
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
18
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
18
                    hash_table_size = arg.hash_table->size();
446
18
                }
447
18
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt104ENS_14RowRefWithFlagE9HashCRC32IS7_EEEEEEDaOT_
Line
Count
Source
442
44
            [&](auto&& arg) {
443
44
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
44
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
44
                    hash_table_size = arg.hash_table->size();
446
44
                }
447
44
            },
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
442
4
            [&](auto&& arg) {
443
4
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
4
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
4
                    hash_table_size = arg.hash_table->size();
446
4
                }
447
4
            },
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136ENS_14RowRefWithFlagE9HashCRC32IS7_EEEEEEDaOT_
Line
Count
Source
442
86
            [&](auto&& arg) {
443
86
                using HashTableCtxType = std::decay_t<decltype(arg)>;
444
86
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
445
86
                    hash_table_size = arg.hash_table->size();
446
86
                }
447
86
            },
448
19.0k
            hash_table_variants->method_variant);
449
19.0k
    return hash_table_size;
450
19.0k
}
451
452
4.84k
Status SetSharedState::hash_table_init() {
453
4.84k
    std::vector<vectorized::DataTypePtr> data_types;
454
39.9k
    for (size_t i = 0; i != child_exprs_lists[0].size(); ++i) {
455
35.0k
        auto& ctx = child_exprs_lists[0][i];
456
35.0k
        auto data_type = ctx->root()->data_type();
457
35.0k
        if (build_not_ignore_null[i]) {
458
34.6k
            data_type = vectorized::make_nullable(data_type);
459
34.6k
        }
460
35.0k
        data_types.emplace_back(std::move(data_type));
461
35.0k
    }
462
4.84k
    return init_hash_method<SetDataVariants>(hash_table_variants.get(), data_types, true);
463
4.84k
}
464
465
void AggSharedState::refresh_top_limit(size_t row_id,
466
82
                                       const vectorized::ColumnRawPtrs& key_columns) {
467
398
    for (int j = 0; j < key_columns.size(); ++j) {
468
316
        limit_columns[j]->insert_from(*key_columns[j], row_id);
469
316
    }
470
82
    limit_heap.emplace(limit_columns[0]->size() - 1, limit_columns, order_directions,
471
82
                       null_directions);
472
473
82
    limit_heap.pop();
474
82
    limit_columns_min = limit_heap.top()._row_id;
475
82
}
476
477
} // namespace doris::pipeline