Coverage Report

Created: 2025-07-29 08:54

/root/doris/be/src/pipeline/dependency.cpp
Line
Count
Source (jump to first uncovered line)
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 "exprs/runtime_filter.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 "vec/exprs/vectorized_agg_fn.h"
31
#include "vec/exprs/vslot_ref.h"
32
#include "vec/spill/spill_stream_manager.h"
33
34
namespace doris::pipeline {
35
36
Dependency* BasicSharedState::create_source_dependency(int operator_id, int node_id,
37
695k
                                                       std::string name) {
38
695k
    source_deps.push_back(std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY"));
39
695k
    source_deps.back()->set_shared_state(this);
40
695k
    return source_deps.back().get();
41
695k
}
42
43
1.01M
Dependency* BasicSharedState::create_sink_dependency(int dest_id, int node_id, std::string name) {
44
1.01M
    sink_deps.push_back(std::make_shared<Dependency>(dest_id, node_id, name + "_DEPENDENCY", true));
45
1.01M
    sink_deps.back()->set_shared_state(this);
46
1.01M
    return sink_deps.back().get();
47
1.01M
}
48
49
5.80M
void Dependency::_add_block_task(PipelineTask* task) {
50
18.4E
    DCHECK(_blocked_task.empty() || _blocked_task[_blocked_task.size() - 1] != task)
51
18.4E
            << "Duplicate task: " << task->debug_string();
52
5.80M
    _blocked_task.push_back(task);
53
5.80M
}
54
55
28.8M
void Dependency::set_ready() {
56
28.8M
    if (_ready) {
57
23.4M
        return;
58
23.4M
    }
59
5.38M
    _watcher.stop();
60
5.38M
    std::vector<PipelineTask*> local_block_task {};
61
5.38M
    {
62
5.38M
        std::unique_lock<std::mutex> lc(_task_lock);
63
5.38M
        if (_ready) {
64
2
            return;
65
2
        }
66
5.38M
        _ready = true;
67
5.38M
        local_block_task.swap(_blocked_task);
68
5.38M
    }
69
5.81M
    for (auto* task : local_block_task) {
70
5.81M
        task->wake_up();
71
5.81M
    }
72
5.38M
}
73
74
80.3M
Dependency* Dependency::is_blocked_by(PipelineTask* task) {
75
80.3M
    std::unique_lock<std::mutex> lc(_task_lock);
76
80.3M
    auto ready = _ready.load();
77
80.3M
    if (!ready && task) {
78
5.79M
        _add_block_task(task);
79
5.79M
    }
80
80.3M
    return ready ? nullptr : this;
81
80.3M
}
82
83
12
std::string Dependency::debug_string(int indentation_level) {
84
12
    fmt::memory_buffer debug_string_buffer;
85
12
    fmt::format_to(debug_string_buffer,
86
12
                   "{}this={}, {}: id={}, block task = {}, ready={}, _always_ready={}",
87
12
                   std::string(indentation_level * 2, ' '), (void*)this, _name, _node_id,
88
12
                   _blocked_task.size(), _ready, _always_ready);
89
12
    return fmt::to_string(debug_string_buffer);
90
12
}
91
92
0
std::string CountedFinishDependency::debug_string(int indentation_level) {
93
0
    fmt::memory_buffer debug_string_buffer;
94
0
    fmt::format_to(debug_string_buffer,
95
0
                   "{}{}: id={}, block_task={}, ready={}, _always_ready={}, count={}",
96
0
                   std::string(indentation_level * 2, ' '), _name, _node_id, _blocked_task.size(),
97
0
                   _ready, _always_ready, _counter);
98
0
    return fmt::to_string(debug_string_buffer);
99
0
}
100
101
0
std::string RuntimeFilterDependency::debug_string(int indentation_level) {
102
0
    fmt::memory_buffer debug_string_buffer;
103
0
    fmt::format_to(debug_string_buffer, "{}, runtime filter: {}",
104
0
                   Dependency::debug_string(indentation_level), _runtime_filter->formatted_state());
105
0
    return fmt::to_string(debug_string_buffer);
106
0
}
107
108
1.42M
Dependency* RuntimeFilterDependency::is_blocked_by(PipelineTask* task) {
109
1.42M
    std::unique_lock<std::mutex> lc(_task_lock);
110
1.42M
    auto ready = _ready.load();
111
1.42M
    if (!ready && task) {
112
24.1k
        _add_block_task(task);
113
24.1k
        task->_blocked_dep = this;
114
24.1k
    }
115
1.42M
    return ready ? nullptr : this;
116
1.42M
}
117
118
136
void RuntimeFilterTimer::call_timeout() {
119
136
    _parent->set_ready();
120
136
}
121
122
25.7k
void RuntimeFilterTimer::call_ready() {
123
25.7k
    _parent->set_ready();
124
25.7k
}
125
126
// should check rf timeout in two case:
127
// 1. the rf is ready just remove the wait queue
128
// 2. if the rf have local dependency, the rf should start wait when all local dependency is ready
129
1.33M
bool RuntimeFilterTimer::should_be_check_timeout() {
130
1.33M
    if (!_parent->ready() && !_local_runtime_filter_dependencies.empty()) {
131
15.2k
        bool all_ready = true;
132
15.2k
        for (auto& dep : _local_runtime_filter_dependencies) {
133
15.2k
            if (!dep->ready()) {
134
15.2k
                all_ready = false;
135
15.2k
                break;
136
15.2k
            }
137
15.2k
        }
138
15.2k
        if (all_ready) {
139
8
            _local_runtime_filter_dependencies.clear();
140
8
            _registration_time = MonotonicMillis();
141
8
        }
142
15.2k
        return all_ready;
143
15.2k
    }
144
1.32M
    return true;
145
1.33M
}
146
147
8
void RuntimeFilterTimerQueue::start() {
148
174k
    while (!_stop) {
149
174k
        std::unique_lock<std::mutex> lk(cv_m);
150
151
179k
        while (_que.empty() && !_stop) {
152
11.4k
            cv.wait_for(lk, std::chrono::seconds(3), [this] { return !_que.empty() || _stop; });
153
5.71k
        }
154
174k
        if (_stop) {
155
4
            break;
156
4
        }
157
174k
        {
158
174k
            std::unique_lock<std::mutex> lc(_que_lock);
159
174k
            std::list<std::shared_ptr<pipeline::RuntimeFilterTimer>> new_que;
160
1.33M
            for (auto& it : _que) {
161
1.33M
                if (it.use_count() == 1) {
162
                    // `use_count == 1` means this runtime filter has been released
163
1.33M
                } else if (it->should_be_check_timeout()) {
164
1.32M
                    if (it->force_wait_timeout() || it->_parent->is_blocked_by(nullptr)) {
165
                        // This means runtime filter is not ready, so we call timeout or continue to poll this timer.
166
1.29M
                        int64_t ms_since_registration = MonotonicMillis() - it->registration_time();
167
1.29M
                        if (ms_since_registration > it->wait_time_ms()) {
168
136
                            it->call_timeout();
169
1.29M
                        } else {
170
1.29M
                            new_que.push_back(std::move(it));
171
1.29M
                        }
172
1.29M
                    }
173
1.32M
                } else {
174
15.2k
                    new_que.push_back(std::move(it));
175
15.2k
                }
176
1.33M
            }
177
174k
            new_que.swap(_que);
178
174k
        }
179
174k
        std::this_thread::sleep_for(std::chrono::milliseconds(interval));
180
174k
    }
181
8
    _shutdown = true;
182
8
}
183
184
552k
void LocalExchangeSharedState::sub_running_sink_operators() {
185
552k
    std::unique_lock<std::mutex> lc(le_lock);
186
552k
    if (exchanger->_running_sink_operators.fetch_sub(1) == 1) {
187
133k
        _set_always_ready();
188
133k
    }
189
552k
}
190
191
void LocalExchangeSharedState::sub_running_source_operators(
192
840k
        LocalExchangeSourceLocalState& local_state) {
193
840k
    std::unique_lock<std::mutex> lc(le_lock);
194
840k
    if (exchanger->_running_source_operators.fetch_sub(1) == 1) {
195
133k
        _set_always_ready();
196
133k
        exchanger->finalize(local_state);
197
133k
    }
198
840k
}
199
200
133k
LocalExchangeSharedState::LocalExchangeSharedState(int num_instances) {
201
133k
    source_deps.resize(num_instances, nullptr);
202
133k
    mem_counters.resize(num_instances, nullptr);
203
133k
}
204
205
136
vectorized::MutableColumns AggSharedState::_get_keys_hash_table() {
206
136
    return std::visit(
207
136
            vectorized::Overload {
208
136
                    [&](std::monostate& arg) {
209
0
                        throw doris::Exception(ErrorCode::INTERNAL_ERROR, "uninited hash table");
210
0
                        return vectorized::MutableColumns();
211
0
                    },
212
136
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
213
136
                        vectorized::MutableColumns key_columns;
214
340
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
215
204
                            key_columns.emplace_back(
216
204
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
217
204
                        }
218
136
                        auto& data = *agg_method.hash_table;
219
136
                        bool has_null_key = data.has_null_key_data();
220
136
                        const auto size = data.size() - has_null_key;
221
136
                        using KeyType = std::decay_t<decltype(agg_method.iterator->get_first())>;
222
136
                        std::vector<KeyType> keys(size);
223
224
136
                        size_t num_rows = 0;
225
136
                        auto iter = aggregate_data_container->begin();
226
136
                        {
227
51.1k
                            while (iter != aggregate_data_container->end()) {
228
50.9k
                                keys[num_rows] = iter.get_key<KeyType>();
229
50.9k
                                ++iter;
230
50.9k
                                ++num_rows;
231
50.9k
                            }
232
136
                        }
233
136
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
234
136
                        if (has_null_key) {
235
2
                            key_columns[0]->insert_data(nullptr, 0);
236
2
                        }
237
136
                        return key_columns;
238
136
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS7_vELb0EEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
Line
Count
Source
212
32
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
213
32
                        vectorized::MutableColumns key_columns;
214
132
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
215
100
                            key_columns.emplace_back(
216
100
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
217
100
                        }
218
32
                        auto& data = *agg_method.hash_table;
219
32
                        bool has_null_key = data.has_null_key_data();
220
32
                        const auto size = data.size() - has_null_key;
221
32
                        using KeyType = std::decay_t<decltype(agg_method.iterator->get_first())>;
222
32
                        std::vector<KeyType> keys(size);
223
224
32
                        size_t num_rows = 0;
225
32
                        auto iter = aggregate_data_container->begin();
226
32
                        {
227
25.1k
                            while (iter != aggregate_data_container->end()) {
228
25.1k
                                keys[num_rows] = iter.get_key<KeyType>();
229
25.1k
                                ++iter;
230
25.1k
                                ++num_rows;
231
25.1k
                            }
232
32
                        }
233
32
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
234
32
                        if (has_null_key) {
235
0
                            key_columns[0]->insert_data(nullptr, 0);
236
0
                        }
237
32
                        return key_columns;
238
32
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIh9PHHashMapIhPc11DefaultHashIhvELb0EEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIt9PHHashMapItPc11DefaultHashItvELb0EEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjELb0EEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
Line
Count
Source
212
8
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
213
8
                        vectorized::MutableColumns key_columns;
214
16
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
215
8
                            key_columns.emplace_back(
216
8
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
217
8
                        }
218
8
                        auto& data = *agg_method.hash_table;
219
8
                        bool has_null_key = data.has_null_key_data();
220
8
                        const auto size = data.size() - has_null_key;
221
8
                        using KeyType = std::decay_t<decltype(agg_method.iterator->get_first())>;
222
8
                        std::vector<KeyType> keys(size);
223
224
8
                        size_t num_rows = 0;
225
8
                        auto iter = aggregate_data_container->begin();
226
8
                        {
227
24
                            while (iter != aggregate_data_container->end()) {
228
16
                                keys[num_rows] = iter.get_key<KeyType>();
229
16
                                ++iter;
230
16
                                ++num_rows;
231
16
                            }
232
8
                        }
233
8
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
234
8
                        if (has_null_key) {
235
0
                            key_columns[0]->insert_data(nullptr, 0);
236
0
                        }
237
8
                        return key_columns;
238
8
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImELb0EEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
Line
Count
Source
212
10
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
213
10
                        vectorized::MutableColumns key_columns;
214
20
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
215
10
                            key_columns.emplace_back(
216
10
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
217
10
                        }
218
10
                        auto& data = *agg_method.hash_table;
219
10
                        bool has_null_key = data.has_null_key_data();
220
10
                        const auto size = data.size() - has_null_key;
221
10
                        using KeyType = std::decay_t<decltype(agg_method.iterator->get_first())>;
222
10
                        std::vector<KeyType> keys(size);
223
224
10
                        size_t num_rows = 0;
225
10
                        auto iter = aggregate_data_container->begin();
226
10
                        {
227
60
                            while (iter != aggregate_data_container->end()) {
228
50
                                keys[num_rows] = iter.get_key<KeyType>();
229
50
                                ++iter;
230
50
                                ++num_rows;
231
50
                            }
232
10
                        }
233
10
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
234
10
                        if (has_null_key) {
235
0
                            key_columns[0]->insert_data(nullptr, 0);
236
0
                        }
237
10
                        return key_columns;
238
10
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized19MethodStringNoCacheINS_13StringHashMapIPc9AllocatorILb1ELb1ELb0E22DefaultMemoryAllocatorEEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS8_Pc9HashCRC32IS8_ELb0EEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISI_EESaISL_EEOT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEELb0EEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
Line
Count
Source
212
12
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
213
12
                        vectorized::MutableColumns key_columns;
214
24
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
215
12
                            key_columns.emplace_back(
216
12
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
217
12
                        }
218
12
                        auto& data = *agg_method.hash_table;
219
12
                        bool has_null_key = data.has_null_key_data();
220
12
                        const auto size = data.size() - has_null_key;
221
12
                        using KeyType = std::decay_t<decltype(agg_method.iterator->get_first())>;
222
12
                        std::vector<KeyType> keys(size);
223
224
12
                        size_t num_rows = 0;
225
12
                        auto iter = aggregate_data_container->begin();
226
12
                        {
227
24
                            while (iter != aggregate_data_container->end()) {
228
12
                                keys[num_rows] = iter.get_key<KeyType>();
229
12
                                ++iter;
230
12
                                ++num_rows;
231
12
                            }
232
12
                        }
233
12
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
234
12
                        if (has_null_key) {
235
0
                            key_columns[0]->insert_data(nullptr, 0);
236
0
                        }
237
12
                        return key_columns;
238
12
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEELb0EEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
Line
Count
Source
212
10
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
213
10
                        vectorized::MutableColumns key_columns;
214
20
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
215
10
                            key_columns.emplace_back(
216
10
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
217
10
                        }
218
10
                        auto& data = *agg_method.hash_table;
219
10
                        bool has_null_key = data.has_null_key_data();
220
10
                        const auto size = data.size() - has_null_key;
221
10
                        using KeyType = std::decay_t<decltype(agg_method.iterator->get_first())>;
222
10
                        std::vector<KeyType> keys(size);
223
224
10
                        size_t num_rows = 0;
225
10
                        auto iter = aggregate_data_container->begin();
226
10
                        {
227
32
                            while (iter != aggregate_data_container->end()) {
228
22
                                keys[num_rows] = iter.get_key<KeyType>();
229
22
                                ++iter;
230
22
                                ++num_rows;
231
22
                            }
232
10
                        }
233
10
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
234
10
                        if (has_null_key) {
235
0
                            key_columns[0]->insert_data(nullptr, 0);
236
0
                        }
237
10
                        return key_columns;
238
10
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS8_Pc14HashMixWrapperIS8_9HashCRC32IS8_EELb0EEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISK_EESaISN_EEOT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIhNS4_15DataWithNullKeyI9PHHashMapIhPc11DefaultHashIhvELb0EEEEEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
Line
Count
Source
212
6
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
213
6
                        vectorized::MutableColumns key_columns;
214
12
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
215
6
                            key_columns.emplace_back(
216
6
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
217
6
                        }
218
6
                        auto& data = *agg_method.hash_table;
219
6
                        bool has_null_key = data.has_null_key_data();
220
6
                        const auto size = data.size() - has_null_key;
221
6
                        using KeyType = std::decay_t<decltype(agg_method.iterator->get_first())>;
222
6
                        std::vector<KeyType> keys(size);
223
224
6
                        size_t num_rows = 0;
225
6
                        auto iter = aggregate_data_container->begin();
226
6
                        {
227
60
                            while (iter != aggregate_data_container->end()) {
228
54
                                keys[num_rows] = iter.get_key<KeyType>();
229
54
                                ++iter;
230
54
                                ++num_rows;
231
54
                            }
232
6
                        }
233
6
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
234
6
                        if (has_null_key) {
235
0
                            key_columns[0]->insert_data(nullptr, 0);
236
0
                        }
237
6
                        return key_columns;
238
6
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberItNS4_15DataWithNullKeyI9PHHashMapItPc11DefaultHashItvELb0EEEEEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjELb0EEEEEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
Line
Count
Source
212
8
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
213
8
                        vectorized::MutableColumns key_columns;
214
16
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
215
8
                            key_columns.emplace_back(
216
8
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
217
8
                        }
218
8
                        auto& data = *agg_method.hash_table;
219
8
                        bool has_null_key = data.has_null_key_data();
220
8
                        const auto size = data.size() - has_null_key;
221
8
                        using KeyType = std::decay_t<decltype(agg_method.iterator->get_first())>;
222
8
                        std::vector<KeyType> keys(size);
223
224
8
                        size_t num_rows = 0;
225
8
                        auto iter = aggregate_data_container->begin();
226
8
                        {
227
7.85k
                            while (iter != aggregate_data_container->end()) {
228
7.84k
                                keys[num_rows] = iter.get_key<KeyType>();
229
7.84k
                                ++iter;
230
7.84k
                                ++num_rows;
231
7.84k
                            }
232
8
                        }
233
8
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
234
8
                        if (has_null_key) {
235
0
                            key_columns[0]->insert_data(nullptr, 0);
236
0
                        }
237
8
                        return key_columns;
238
8
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImELb0EEEEEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
Line
Count
Source
212
40
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
213
40
                        vectorized::MutableColumns key_columns;
214
80
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
215
40
                            key_columns.emplace_back(
216
40
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
217
40
                        }
218
40
                        auto& data = *agg_method.hash_table;
219
40
                        bool has_null_key = data.has_null_key_data();
220
40
                        const auto size = data.size() - has_null_key;
221
40
                        using KeyType = std::decay_t<decltype(agg_method.iterator->get_first())>;
222
40
                        std::vector<KeyType> keys(size);
223
224
40
                        size_t num_rows = 0;
225
40
                        auto iter = aggregate_data_container->begin();
226
40
                        {
227
17.8k
                            while (iter != aggregate_data_container->end()) {
228
17.7k
                                keys[num_rows] = iter.get_key<KeyType>();
229
17.7k
                                ++iter;
230
17.7k
                                ++num_rows;
231
17.7k
                            }
232
40
                        }
233
40
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
234
40
                        if (has_null_key) {
235
0
                            key_columns[0]->insert_data(nullptr, 0);
236
0
                        }
237
40
                        return key_columns;
238
40
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEELb0EEEEEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISL_EESaISO_EEOT_
Line
Count
Source
212
4
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
213
4
                        vectorized::MutableColumns key_columns;
214
8
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
215
4
                            key_columns.emplace_back(
216
4
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
217
4
                        }
218
4
                        auto& data = *agg_method.hash_table;
219
4
                        bool has_null_key = data.has_null_key_data();
220
4
                        const auto size = data.size() - has_null_key;
221
4
                        using KeyType = std::decay_t<decltype(agg_method.iterator->get_first())>;
222
4
                        std::vector<KeyType> keys(size);
223
224
4
                        size_t num_rows = 0;
225
4
                        auto iter = aggregate_data_container->begin();
226
4
                        {
227
10
                            while (iter != aggregate_data_container->end()) {
228
6
                                keys[num_rows] = iter.get_key<KeyType>();
229
6
                                ++iter;
230
6
                                ++num_rows;
231
6
                            }
232
4
                        }
233
4
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
234
4
                        if (has_null_key) {
235
2
                            key_columns[0]->insert_data(nullptr, 0);
236
2
                        }
237
4
                        return key_columns;
238
4
                    }},
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEELb0EEEEEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISL_EESaISO_EEOT_
Line
Count
Source
212
2
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
213
2
                        vectorized::MutableColumns key_columns;
214
4
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
215
2
                            key_columns.emplace_back(
216
2
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
217
2
                        }
218
2
                        auto& data = *agg_method.hash_table;
219
2
                        bool has_null_key = data.has_null_key_data();
220
2
                        const auto size = data.size() - has_null_key;
221
2
                        using KeyType = std::decay_t<decltype(agg_method.iterator->get_first())>;
222
2
                        std::vector<KeyType> keys(size);
223
224
2
                        size_t num_rows = 0;
225
2
                        auto iter = aggregate_data_container->begin();
226
2
                        {
227
8
                            while (iter != aggregate_data_container->end()) {
228
6
                                keys[num_rows] = iter.get_key<KeyType>();
229
6
                                ++iter;
230
6
                                ++num_rows;
231
6
                            }
232
2
                        }
233
2
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
234
2
                        if (has_null_key) {
235
0
                            key_columns[0]->insert_data(nullptr, 0);
236
0
                        }
237
2
                        return key_columns;
238
2
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_ELb0EEEEEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISM_EESaISP_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc14HashMixWrapperIS9_9HashCRC32IS9_EELb0EEEEEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISO_EESaISR_EEOT_
dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_19MethodStringNoCacheINS4_15DataWithNullKeyINS_13StringHashMapIPc9AllocatorILb1ELb1ELb0E22DefaultMemoryAllocatorEEEEEEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISK_EESaISN_EEOT_
Line
Count
Source
212
4
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
213
4
                        vectorized::MutableColumns key_columns;
214
8
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
215
4
                            key_columns.emplace_back(
216
4
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
217
4
                        }
218
4
                        auto& data = *agg_method.hash_table;
219
4
                        bool has_null_key = data.has_null_key_data();
220
4
                        const auto size = data.size() - has_null_key;
221
4
                        using KeyType = std::decay_t<decltype(agg_method.iterator->get_first())>;
222
4
                        std::vector<KeyType> keys(size);
223
224
4
                        size_t num_rows = 0;
225
4
                        auto iter = aggregate_data_container->begin();
226
4
                        {
227
32
                            while (iter != aggregate_data_container->end()) {
228
28
                                keys[num_rows] = iter.get_key<KeyType>();
229
28
                                ++iter;
230
28
                                ++num_rows;
231
28
                            }
232
4
                        }
233
4
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
234
4
                        if (has_null_key) {
235
0
                            key_columns[0]->insert_data(nullptr, 0);
236
0
                        }
237
4
                        return key_columns;
238
4
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImELb0EELb0EEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImELb0EELb1EEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS9_ELb0EELb0EEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISI_EESaISL_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS9_ELb0EELb1EEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISI_EESaISL_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS9_ELb0EELb0EEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISI_EESaISL_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS9_ELb0EELb1EEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISI_EESaISL_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136EPc9HashCRC32IS7_ELb0EELb0EEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136EPc9HashCRC32IS7_ELb0EELb1EEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEELb0EELb0EEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEELb0EELb1EEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc14HashMixWrapperIS9_9HashCRC32IS9_EELb0EELb0EEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISK_EESaISN_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc14HashMixWrapperIS9_9HashCRC32IS9_EELb0EELb1EEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISK_EESaISN_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc14HashMixWrapperIS9_9HashCRC32IS9_EELb0EELb0EEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISK_EESaISN_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc14HashMixWrapperIS9_9HashCRC32IS9_EELb0EELb1EEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISK_EESaISN_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136EPc14HashMixWrapperIS7_9HashCRC32IS7_EELb0EELb0EEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISI_EESaISL_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136EPc14HashMixWrapperIS7_9HashCRC32IS7_EELb0EELb1EEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISI_EESaISL_EEOT_
239
136
            agg_data->method_variant);
240
136
}
241
242
136
void AggSharedState::build_limit_heap(size_t hash_table_size) {
243
136
    limit_columns = _get_keys_hash_table();
244
50.7k
    for (size_t i = 0; i < hash_table_size; ++i) {
245
50.5k
        limit_heap.emplace(i, limit_columns, order_directions, null_directions);
246
50.5k
    }
247
50.3k
    while (hash_table_size > limit) {
248
50.2k
        limit_heap.pop();
249
50.2k
        hash_table_size--;
250
50.2k
    }
251
136
    limit_columns_min = limit_heap.top()._row_id;
252
136
}
253
254
bool AggSharedState::do_limit_filter(vectorized::Block* block, size_t num_rows,
255
524
                                     const std::vector<int>* key_locs) {
256
524
    if (num_rows) {
257
524
        cmp_res.resize(num_rows);
258
524
        need_computes.resize(num_rows);
259
524
        memset(need_computes.data(), 0, need_computes.size());
260
524
        memset(cmp_res.data(), 0, cmp_res.size());
261
262
524
        const auto key_size = null_directions.size();
263
1.51k
        for (int i = 0; i < key_size; i++) {
264
990
            block->get_by_position(key_locs ? key_locs->operator[](i) : i)
265
990
                    .column->compare_internal(limit_columns_min, *limit_columns[i],
266
990
                                              null_directions[i], order_directions[i], cmp_res,
267
990
                                              need_computes.data());
268
990
        }
269
270
524
        auto set_computes_arr = [](auto* __restrict res, auto* __restrict computes, int rows) {
271
1.40M
            for (int i = 0; i < rows; ++i) {
272
1.40M
                computes[i] = computes[i] == res[i];
273
1.40M
            }
274
524
        };
275
524
        set_computes_arr(cmp_res.data(), need_computes.data(), num_rows);
276
277
524
        return std::find(need_computes.begin(), need_computes.end(), 0) != need_computes.end();
278
524
    }
279
280
0
    return false;
281
524
}
282
283
0
Status AggSharedState::reset_hash_table() {
284
0
    return std::visit(
285
0
            vectorized::Overload {
286
0
                    [&](std::monostate& arg) -> Status {
287
0
                        return Status::InternalError("Uninited hash table");
288
0
                    },
289
0
                    [&](auto& agg_method) {
290
0
                        auto& hash_table = *agg_method.hash_table;
291
0
                        using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
0
                        agg_method.reset();
294
295
0
                        hash_table.for_each_mapped([&](auto& mapped) {
296
0
                            if (mapped) {
297
0
                                static_cast<void>(_destroy_agg_status(mapped));
298
0
                                mapped = nullptr;
299
0
                            }
300
0
                        });
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS7_vELb0EEEEEEDaRT_ENKUlSE_E_clIS8_EEDaSE_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIh9PHHashMapIhPc11DefaultHashIhvELb0EEEEEEDaRT_ENKUlSD_E_clIS7_EEDaSD_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIt9PHHashMapItPc11DefaultHashItvELb0EEEEEEDaRT_ENKUlSD_E_clIS7_EEDaSD_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjELb0EEEEEEDaRT_ENKUlSD_E_clIS7_EEDaSD_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImELb0EEEEEEDaRT_ENKUlSD_E_clIS7_EEDaSD_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized19MethodStringNoCacheINS_13StringHashMapIPc9AllocatorILb1ELb1ELb0E22DefaultMemoryAllocatorEEEEEEEDaRT_ENKUlSE_E_clIS7_EEDaSE_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS8_Pc9HashCRC32IS8_ELb0EEEEEEDaRT_ENKUlSG_E_clISA_EEDaSG_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEELb0EEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEELb0EEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS8_Pc14HashMixWrapperIS8_9HashCRC32IS8_EELb0EEEEEEDaRT_ENKUlSI_E_clISA_EEDaSI_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIhNS4_15DataWithNullKeyI9PHHashMapIhPc11DefaultHashIhvELb0EEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberItNS4_15DataWithNullKeyI9PHHashMapItPc11DefaultHashItvELb0EEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjELb0EEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImELb0EEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEELb0EEEEEEEEEEDaRT_ENKUlSJ_E_clIS9_EEDaSJ_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEELb0EEEEEEEEEEDaRT_ENKUlSJ_E_clIS9_EEDaSJ_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_ELb0EEEEEEEEEEDaRT_ENKUlSK_E_clISC_EEDaSK_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc14HashMixWrapperIS9_9HashCRC32IS9_EELb0EEEEEEEEEEDaRT_ENKUlSM_E_clISC_EEDaSM_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_19MethodStringNoCacheINS4_15DataWithNullKeyINS_13StringHashMapIPc9AllocatorILb1ELb1ELb0E22DefaultMemoryAllocatorEEEEEEEEEEEDaRT_ENKUlSI_E_clIS9_EEDaSI_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImELb0EELb0EEEEEDaRT_ENKUlSD_E_clIS7_EEDaSD_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImELb0EELb1EEEEEDaRT_ENKUlSD_E_clIS7_EEDaSD_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS9_ELb0EELb0EEEEEDaRT_ENKUlSG_E_clISA_EEDaSG_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS9_ELb0EELb1EEEEEDaRT_ENKUlSG_E_clISA_EEDaSG_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS9_ELb0EELb0EEEEEDaRT_ENKUlSG_E_clISA_EEDaSG_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS9_ELb0EELb1EEEEEDaRT_ENKUlSG_E_clISA_EEDaSG_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136EPc9HashCRC32IS7_ELb0EELb0EEEEEDaRT_ENKUlSE_E_clIS8_EEDaSE_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136EPc9HashCRC32IS7_ELb0EELb1EEEEEDaRT_ENKUlSE_E_clIS8_EEDaSE_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEELb0EELb0EEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEELb0EELb1EEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc14HashMixWrapperIS9_9HashCRC32IS9_EELb0EELb0EEEEEDaRT_ENKUlSI_E_clISA_EEDaSI_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc14HashMixWrapperIS9_9HashCRC32IS9_EELb0EELb1EEEEEDaRT_ENKUlSI_E_clISA_EEDaSI_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc14HashMixWrapperIS9_9HashCRC32IS9_EELb0EELb0EEEEEDaRT_ENKUlSI_E_clISA_EEDaSI_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc14HashMixWrapperIS9_9HashCRC32IS9_EELb0EELb1EEEEEDaRT_ENKUlSI_E_clISA_EEDaSI_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136EPc14HashMixWrapperIS7_9HashCRC32IS7_EELb0EELb0EEEEEDaRT_ENKUlSG_E_clIS8_EEDaSG_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136EPc14HashMixWrapperIS7_9HashCRC32IS7_EELb0EELb1EEEEEDaRT_ENKUlSG_E_clIS8_EEDaSG_
301
302
0
                        if (hash_table.has_null_key_data()) {
303
0
                            auto st = _destroy_agg_status(hash_table.template get_null_key_data<
304
0
                                                          vectorized::AggregateDataPtr>());
305
0
                            RETURN_IF_ERROR(st);
306
0
                        }
307
308
0
                        aggregate_data_container.reset(new AggregateDataContainer(
309
0
                                sizeof(typename HashTableType::key_type),
310
0
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
0
                                 align_aggregate_states) *
312
0
                                        align_aggregate_states));
313
0
                        agg_method.hash_table.reset(new HashTableType());
314
0
                        agg_arena_pool.reset(new vectorized::Arena);
315
0
                        return Status::OK();
316
0
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS7_vELb0EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIh9PHHashMapIhPc11DefaultHashIhvELb0EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIt9PHHashMapItPc11DefaultHashItvELb0EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjELb0EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImELb0EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized19MethodStringNoCacheINS_13StringHashMapIPc9AllocatorILb1ELb1ELb0E22DefaultMemoryAllocatorEEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS8_Pc9HashCRC32IS8_ELb0EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEELb0EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEELb0EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS8_Pc14HashMixWrapperIS8_9HashCRC32IS8_EELb0EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIhNS4_15DataWithNullKeyI9PHHashMapIhPc11DefaultHashIhvELb0EEEEEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberItNS4_15DataWithNullKeyI9PHHashMapItPc11DefaultHashItvELb0EEEEEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjELb0EEEEEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImELb0EEEEEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEELb0EEEEEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEELb0EEEEEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_ELb0EEEEEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc14HashMixWrapperIS9_9HashCRC32IS9_EELb0EEEEEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_19MethodStringNoCacheINS4_15DataWithNullKeyINS_13StringHashMapIPc9AllocatorILb1ELb1ELb0E22DefaultMemoryAllocatorEEEEEEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImELb0EELb0EEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImELb0EELb1EEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS9_ELb0EELb0EEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS9_ELb0EELb1EEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS9_ELb0EELb0EEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS9_ELb0EELb1EEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136EPc9HashCRC32IS7_ELb0EELb0EEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136EPc9HashCRC32IS7_ELb0EELb1EEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEELb0EELb0EEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEELb0EELb1EEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc14HashMixWrapperIS9_9HashCRC32IS9_EELb0EELb0EEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc14HashMixWrapperIS9_9HashCRC32IS9_EELb0EELb1EEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc14HashMixWrapperIS9_9HashCRC32IS9_EELb0EELb0EEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc14HashMixWrapperIS9_9HashCRC32IS9_EELb0EELb1EEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136EPc14HashMixWrapperIS7_9HashCRC32IS7_EELb0EELb0EEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136EPc14HashMixWrapperIS7_9HashCRC32IS7_EELb0EELb1EEEEEDaRT_
317
0
            agg_data->method_variant);
318
0
}
319
320
12
void PartitionedAggSharedState::init_spill_params(size_t spill_partition_count_bits) {
321
12
    partition_count_bits = spill_partition_count_bits;
322
12
    partition_count = (1 << spill_partition_count_bits);
323
12
    max_partition_index = partition_count - 1;
324
325
204
    for (int i = 0; i < partition_count; ++i) {
326
192
        spill_partitions.emplace_back(std::make_shared<AggSpillPartition>());
327
192
    }
328
12
}
329
330
Status AggSpillPartition::get_spill_stream(RuntimeState* state, int node_id,
331
                                           RuntimeProfile* profile,
332
0
                                           vectorized::SpillStreamSPtr& spill_stream) {
333
0
    if (spilling_stream_) {
334
0
        spill_stream = spilling_stream_;
335
0
        return Status::OK();
336
0
    }
337
0
    RETURN_IF_ERROR(ExecEnv::GetInstance()->spill_stream_mgr()->register_spill_stream(
338
0
            state, spilling_stream_, print_id(state->query_id()), "agg", node_id,
339
0
            std::numeric_limits<int32_t>::max(), std::numeric_limits<size_t>::max(), profile));
340
0
    spill_streams_.emplace_back(spilling_stream_);
341
0
    spill_stream = spilling_stream_;
342
0
    return Status::OK();
343
0
}
344
192
void AggSpillPartition::close() {
345
192
    if (spilling_stream_) {
346
0
        spilling_stream_.reset();
347
0
    }
348
192
    for (auto& stream : spill_streams_) {
349
0
        (void)ExecEnv::GetInstance()->spill_stream_mgr()->delete_spill_stream(stream);
350
0
    }
351
192
    spill_streams_.clear();
352
192
}
353
354
12
void PartitionedAggSharedState::close() {
355
    // need to use CAS instead of only `if (!is_closed)` statement,
356
    // to avoid concurrent entry of close() both pass the if statement
357
12
    bool false_close = false;
358
12
    if (!is_closed.compare_exchange_strong(false_close, true)) {
359
0
        return;
360
0
    }
361
12
    DCHECK(!false_close && is_closed);
362
192
    for (auto partition : spill_partitions) {
363
192
        partition->close();
364
192
    }
365
12
    spill_partitions.clear();
366
12
}
367
368
0
void SpillSortSharedState::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
0
    bool false_close = false;
372
0
    if (!is_closed.compare_exchange_strong(false_close, true)) {
373
0
        return;
374
0
    }
375
0
    DCHECK(!false_close && is_closed);
376
0
    for (auto& stream : sorted_streams) {
377
0
        (void)ExecEnv::GetInstance()->spill_stream_mgr()->delete_spill_stream(stream);
378
0
    }
379
0
    sorted_streams.clear();
380
0
}
381
382
MultiCastSharedState::MultiCastSharedState(const RowDescriptor& row_desc, ObjectPool* pool,
383
                                           int cast_sender_count)
384
        : multi_cast_data_streamer(std::make_unique<pipeline::MultiCastDataStreamer>(
385
3.64k
                  row_desc, pool, cast_sender_count, true)) {}
386
387
251k
int AggSharedState::get_slot_column_id(const vectorized::AggFnEvaluator* evaluator) {
388
251k
    auto ctxs = evaluator->input_exprs_ctxs();
389
18.4E
    CHECK(ctxs.size() == 1 && ctxs[0]->root()->is_slot_ref())
390
18.4E
            << "input_exprs_ctxs is invalid, input_exprs_ctx[0]="
391
18.4E
            << ctxs[0]->root()->debug_string();
392
251k
    return ((vectorized::VSlotRef*)ctxs[0]->root().get())->column_id();
393
251k
}
394
395
25.5M
Status AggSharedState::_destroy_agg_status(vectorized::AggregateDataPtr data) {
396
57.9M
    for (int i = 0; i < aggregate_evaluators.size(); ++i) {
397
32.3M
        aggregate_evaluators[i]->function()->destroy(data + offsets_of_aggregate_states[i]);
398
32.3M
    }
399
25.5M
    return Status::OK();
400
25.5M
}
401
402
void AggSharedState::refresh_top_limit(size_t row_id,
403
92
                                       const vectorized::ColumnRawPtrs& key_columns) {
404
298
    for (int j = 0; j < key_columns.size(); ++j) {
405
206
        limit_columns[j]->insert_from(*key_columns[j], row_id);
406
206
    }
407
92
    limit_heap.emplace(limit_columns[0]->size() - 1, limit_columns, order_directions,
408
92
                       null_directions);
409
410
92
    limit_heap.pop();
411
92
    limit_columns_min = limit_heap.top()._row_id;
412
92
}
413
414
133k
LocalExchangeSharedState::~LocalExchangeSharedState() = default;
415
416
} // namespace doris::pipeline