Coverage Report

Created: 2026-03-13 12:56

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exec/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 "exec/pipeline/dependency.h"
19
20
#include <memory>
21
#include <mutex>
22
23
#include "common/logging.h"
24
#include "exec/common/util.hpp"
25
#include "exec/operator/multi_cast_data_streamer.h"
26
#include "exec/pipeline/pipeline_fragment_context.h"
27
#include "exec/pipeline/pipeline_task.h"
28
#include "exec/rowid_fetcher.h"
29
#include "exec/runtime_filter/runtime_filter_consumer.h"
30
#include "exec/scan/file_scanner.h"
31
#include "exec/spill/spill_stream_manager.h"
32
#include "exprs/vectorized_agg_fn.h"
33
#include "exprs/vslot_ref.h"
34
#include "runtime/exec_env.h"
35
#include "runtime/memory/mem_tracker.h"
36
#include "util/brpc_client_cache.h"
37
38
namespace doris {
39
#include "common/compile_check_begin.h"
40
41
Dependency* BasicSharedState::create_source_dependency(int operator_id, int node_id,
42
507k
                                                       const std::string& name) {
43
507k
    source_deps.push_back(std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY"));
44
507k
    source_deps.back()->set_shared_state(this);
45
507k
    return source_deps.back().get();
46
507k
}
47
48
void BasicSharedState::create_source_dependencies(int num_sources, int operator_id, int node_id,
49
101k
                                                  const std::string& name) {
50
101k
    source_deps.resize(num_sources, nullptr);
51
666k
    for (auto& source_dep : source_deps) {
52
666k
        source_dep = std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY");
53
666k
        source_dep->set_shared_state(this);
54
666k
    }
55
101k
}
56
57
Dependency* BasicSharedState::create_sink_dependency(int dest_id, int node_id,
58
1.02M
                                                     const std::string& name) {
59
1.02M
    sink_deps.push_back(std::make_shared<Dependency>(dest_id, node_id, name + "_DEPENDENCY", true));
60
1.02M
    sink_deps.back()->set_shared_state(this);
61
1.02M
    return sink_deps.back().get();
62
1.02M
}
63
64
4.33M
void Dependency::_add_block_task(std::shared_ptr<PipelineTask> task) {
65
18.4E
    DCHECK(_blocked_task.empty() || _blocked_task[_blocked_task.size() - 1].lock() == nullptr ||
66
18.4E
           _blocked_task[_blocked_task.size() - 1].lock().get() != task.get())
67
18.4E
            << "Duplicate task: " << task->debug_string();
68
4.33M
    _blocked_task.push_back(task);
69
4.33M
}
70
71
37.7M
void Dependency::set_ready() {
72
37.7M
    if (_ready) {
73
34.7M
        return;
74
34.7M
    }
75
3.00M
    std::vector<std::weak_ptr<PipelineTask>> local_block_task {};
76
3.00M
    {
77
3.00M
        std::unique_lock<std::mutex> lc(_task_lock);
78
3.00M
        if (_ready) {
79
108
            return;
80
108
        }
81
3.00M
        _watcher.stop();
82
3.00M
        _ready = true;
83
3.00M
        local_block_task.swap(_blocked_task);
84
3.00M
    }
85
4.34M
    for (auto task : local_block_task) {
86
4.34M
        if (auto t = task.lock()) {
87
4.34M
            std::unique_lock<std::mutex> lc(_task_lock);
88
4.34M
            THROW_IF_ERROR(t->wake_up(this, lc));
89
4.34M
        }
90
4.34M
    }
91
3.00M
}
92
93
43.5M
Dependency* Dependency::is_blocked_by(std::shared_ptr<PipelineTask> task) {
94
43.5M
    std::unique_lock<std::mutex> lc(_task_lock);
95
43.5M
    auto ready = _ready.load();
96
43.5M
    if (!ready && task) {
97
4.34M
        _add_block_task(task);
98
4.34M
        start_watcher();
99
4.34M
        THROW_IF_ERROR(task->blocked(this, lc));
100
4.34M
    }
101
43.5M
    return ready ? nullptr : this;
102
43.5M
}
103
104
330k
std::string Dependency::debug_string(int indentation_level) {
105
330k
    fmt::memory_buffer debug_string_buffer;
106
330k
    fmt::format_to(debug_string_buffer, "{}{}: id={}, block task = {}, ready={}, _always_ready={}",
107
330k
                   std::string(indentation_level * 2, ' '), _name, _node_id, _blocked_task.size(),
108
330k
                   _ready, _always_ready);
109
330k
    return fmt::to_string(debug_string_buffer);
110
330k
}
111
112
60
std::string CountedFinishDependency::debug_string(int indentation_level) {
113
60
    fmt::memory_buffer debug_string_buffer;
114
60
    fmt::format_to(debug_string_buffer,
115
60
                   "{}{}: id={}, block_task={}, ready={}, _always_ready={}, count={}",
116
60
                   std::string(indentation_level * 2, ' '), _name, _node_id, _blocked_task.size(),
117
60
                   _ready, _always_ready, _counter);
118
60
    return fmt::to_string(debug_string_buffer);
119
60
}
120
121
380
void RuntimeFilterTimer::call_timeout() {
122
380
    _parent->set_ready();
123
380
}
124
125
66.8k
void RuntimeFilterTimer::call_ready() {
126
66.8k
    _parent->set_ready();
127
66.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
7.67M
bool RuntimeFilterTimer::should_be_check_timeout() {
133
7.67M
    if (!_parent->ready() && !_local_runtime_filter_dependencies.empty()) {
134
346k
        bool all_ready = true;
135
346k
        for (auto& dep : _local_runtime_filter_dependencies) {
136
346k
            if (!dep->ready()) {
137
346k
                all_ready = false;
138
346k
                break;
139
346k
            }
140
346k
        }
141
346k
        if (all_ready) {
142
7
            _local_runtime_filter_dependencies.clear();
143
7
            _registration_time = MonotonicMillis();
144
7
        }
145
346k
        return all_ready;
146
346k
    }
147
7.32M
    return true;
148
7.67M
}
149
150
8
void RuntimeFilterTimerQueue::start() {
151
219k
    while (!_stop) {
152
219k
        std::unique_lock<std::mutex> lk(cv_m);
153
154
222k
        while (_que.empty() && !_stop) {
155
5.13k
            cv.wait_for(lk, std::chrono::seconds(3), [this] { return !_que.empty() || _stop; });
156
2.56k
        }
157
219k
        if (_stop) {
158
3
            break;
159
3
        }
160
219k
        {
161
219k
            std::unique_lock<std::mutex> lc(_que_lock);
162
219k
            std::list<std::shared_ptr<RuntimeFilterTimer>> new_que;
163
7.67M
            for (auto& it : _que) {
164
7.67M
                if (it.use_count() == 1) {
165
                    // `use_count == 1` means this runtime filter has been released
166
7.67M
                } else if (it->should_be_check_timeout()) {
167
7.32M
                    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
7.26M
                        int64_t ms_since_registration = MonotonicMillis() - it->registration_time();
170
7.26M
                        if (ms_since_registration > it->wait_time_ms()) {
171
380
                            it->call_timeout();
172
7.26M
                        } else {
173
7.26M
                            new_que.push_back(std::move(it));
174
7.26M
                        }
175
7.26M
                    }
176
7.32M
                } else {
177
346k
                    new_que.push_back(std::move(it));
178
346k
                }
179
7.67M
            }
180
219k
            new_que.swap(_que);
181
219k
        }
182
219k
        std::this_thread::sleep_for(std::chrono::milliseconds(interval));
183
219k
    }
184
8
    _shutdown = true;
185
8
}
186
187
320k
void LocalExchangeSharedState::sub_running_sink_operators() {
188
320k
    std::unique_lock<std::mutex> lc(le_lock);
189
320k
    if (exchanger->_running_sink_operators.fetch_sub(1) == 1) {
190
99.2k
        _set_always_ready();
191
99.2k
    }
192
320k
}
193
194
653k
void LocalExchangeSharedState::sub_running_source_operators() {
195
653k
    std::unique_lock<std::mutex> lc(le_lock);
196
653k
    if (exchanger->_running_source_operators.fetch_sub(1) == 1) {
197
99.2k
        _set_always_ready();
198
99.2k
        exchanger->finalize();
199
99.2k
    }
200
653k
}
201
202
99.1k
LocalExchangeSharedState::LocalExchangeSharedState(int num_instances) {
203
99.1k
    source_deps.resize(num_instances, nullptr);
204
99.1k
    mem_counters.resize(num_instances, nullptr);
205
99.1k
}
206
207
49
MutableColumns AggSharedState::_get_keys_hash_table() {
208
49
    return std::visit(
209
49
            Overload {[&](std::monostate& arg) {
210
0
                          throw doris::Exception(ErrorCode::INTERNAL_ERROR, "uninited hash table");
211
0
                          return MutableColumns();
212
0
                      },
213
49
                      [&](auto&& agg_method) -> MutableColumns {
214
49
                          MutableColumns key_columns;
215
126
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
77
                              key_columns.emplace_back(
217
77
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
77
                          }
219
49
                          auto& data = *agg_method.hash_table;
220
49
                          bool has_null_key = data.has_null_key_data();
221
49
                          const auto size = data.size() - has_null_key;
222
49
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
49
                          std::vector<KeyType> keys(size);
224
225
49
                          uint32_t num_rows = 0;
226
49
                          auto iter = aggregate_data_container->begin();
227
49
                          {
228
8.70k
                              while (iter != aggregate_data_container->end()) {
229
8.65k
                                  keys[num_rows] = iter.get_key<KeyType>();
230
8.65k
                                  ++iter;
231
8.65k
                                  ++num_rows;
232
8.65k
                              }
233
49
                          }
234
49
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
49
                          if (has_null_key) {
236
2
                              key_columns[0]->insert_data(nullptr, 0);
237
2
                          }
238
49
                          return key_columns;
239
49
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS5_vEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISE_EESaISH_EEOT_
Line
Count
Source
213
2
                      [&](auto&& agg_method) -> MutableColumns {
214
2
                          MutableColumns key_columns;
215
10
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
8
                              key_columns.emplace_back(
217
8
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
8
                          }
219
2
                          auto& data = *agg_method.hash_table;
220
2
                          bool has_null_key = data.has_null_key_data();
221
2
                          const auto size = data.size() - has_null_key;
222
2
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
2
                          std::vector<KeyType> keys(size);
224
225
2
                          uint32_t num_rows = 0;
226
2
                          auto iter = aggregate_data_container->begin();
227
2
                          {
228
2.52k
                              while (iter != aggregate_data_container->end()) {
229
2.52k
                                  keys[num_rows] = iter.get_key<KeyType>();
230
2.52k
                                  ++iter;
231
2.52k
                                  ++num_rows;
232
2.52k
                              }
233
2
                          }
234
2
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
2
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
2
                          return key_columns;
239
2
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISD_EESaISG_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISD_EESaISG_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISD_EESaISG_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISD_EESaISG_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISE_EESaISH_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS6_Pc9HashCRC32IS6_EEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS6_Pc9HashCRC32IS6_EEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
Line
Count
Source
213
6
                      [&](auto&& agg_method) -> MutableColumns {
214
6
                          MutableColumns key_columns;
215
12
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
6
                              key_columns.emplace_back(
217
6
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
6
                          }
219
6
                          auto& data = *agg_method.hash_table;
220
6
                          bool has_null_key = data.has_null_key_data();
221
6
                          const auto size = data.size() - has_null_key;
222
6
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
6
                          std::vector<KeyType> keys(size);
224
225
6
                          uint32_t num_rows = 0;
226
6
                          auto iter = aggregate_data_container->begin();
227
6
                          {
228
14
                              while (iter != aggregate_data_container->end()) {
229
8
                                  keys[num_rows] = iter.get_key<KeyType>();
230
8
                                  ++iter;
231
8
                                  ++num_rows;
232
8
                              }
233
6
                          }
234
6
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
6
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
6
                          return key_columns;
239
6
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
Line
Count
Source
213
9
                      [&](auto&& agg_method) -> MutableColumns {
214
9
                          MutableColumns key_columns;
215
18
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
9
                              key_columns.emplace_back(
217
9
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
9
                          }
219
9
                          auto& data = *agg_method.hash_table;
220
9
                          bool has_null_key = data.has_null_key_data();
221
9
                          const auto size = data.size() - has_null_key;
222
9
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
9
                          std::vector<KeyType> keys(size);
224
225
9
                          uint32_t num_rows = 0;
226
9
                          auto iter = aggregate_data_container->begin();
227
9
                          {
228
36
                              while (iter != aggregate_data_container->end()) {
229
27
                                  keys[num_rows] = iter.get_key<KeyType>();
230
27
                                  ++iter;
231
27
                                  ++num_rows;
232
27
                              }
233
9
                          }
234
9
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
9
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
9
                          return key_columns;
239
9
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIhNS_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
Line
Count
Source
213
2
                      [&](auto&& agg_method) -> MutableColumns {
214
2
                          MutableColumns key_columns;
215
4
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
2
                              key_columns.emplace_back(
217
2
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
2
                          }
219
2
                          auto& data = *agg_method.hash_table;
220
2
                          bool has_null_key = data.has_null_key_data();
221
2
                          const auto size = data.size() - has_null_key;
222
2
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
2
                          std::vector<KeyType> keys(size);
224
225
2
                          uint32_t num_rows = 0;
226
2
                          auto iter = aggregate_data_container->begin();
227
2
                          {
228
14
                              while (iter != aggregate_data_container->end()) {
229
12
                                  keys[num_rows] = iter.get_key<KeyType>();
230
12
                                  ++iter;
231
12
                                  ++num_rows;
232
12
                              }
233
2
                          }
234
2
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
2
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
2
                          return key_columns;
239
2
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberItNS_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
Line
Count
Source
213
5
                      [&](auto&& agg_method) -> MutableColumns {
214
5
                          MutableColumns key_columns;
215
10
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
5
                              key_columns.emplace_back(
217
5
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
5
                          }
219
5
                          auto& data = *agg_method.hash_table;
220
5
                          bool has_null_key = data.has_null_key_data();
221
5
                          const auto size = data.size() - has_null_key;
222
5
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
5
                          std::vector<KeyType> keys(size);
224
225
5
                          uint32_t num_rows = 0;
226
5
                          auto iter = aggregate_data_container->begin();
227
5
                          {
228
1.53k
                              while (iter != aggregate_data_container->end()) {
229
1.52k
                                  keys[num_rows] = iter.get_key<KeyType>();
230
1.52k
                                  ++iter;
231
1.52k
                                  ++num_rows;
232
1.52k
                              }
233
5
                          }
234
5
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
5
                          if (has_null_key) {
236
1
                              key_columns[0]->insert_data(nullptr, 0);
237
1
                          }
238
5
                          return key_columns;
239
5
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
Line
Count
Source
213
11
                      [&](auto&& agg_method) -> MutableColumns {
214
11
                          MutableColumns key_columns;
215
22
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
11
                              key_columns.emplace_back(
217
11
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
11
                          }
219
11
                          auto& data = *agg_method.hash_table;
220
11
                          bool has_null_key = data.has_null_key_data();
221
11
                          const auto size = data.size() - has_null_key;
222
11
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
11
                          std::vector<KeyType> keys(size);
224
225
11
                          uint32_t num_rows = 0;
226
11
                          auto iter = aggregate_data_container->begin();
227
11
                          {
228
2.42k
                              while (iter != aggregate_data_container->end()) {
229
2.41k
                                  keys[num_rows] = iter.get_key<KeyType>();
230
2.41k
                                  ++iter;
231
2.41k
                                  ++num_rows;
232
2.41k
                              }
233
11
                          }
234
11
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
11
                          if (has_null_key) {
236
1
                              key_columns[0]->insert_data(nullptr, 0);
237
1
                          }
238
11
                          return key_columns;
239
11
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS7_Pc9HashCRC32IS7_EEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISK_EESaISN_EEOT_
Line
Count
Source
213
2
                      [&](auto&& agg_method) -> MutableColumns {
214
2
                          MutableColumns key_columns;
215
4
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
2
                              key_columns.emplace_back(
217
2
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
2
                          }
219
2
                          auto& data = *agg_method.hash_table;
220
2
                          bool has_null_key = data.has_null_key_data();
221
2
                          const auto size = data.size() - has_null_key;
222
2
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
2
                          std::vector<KeyType> keys(size);
224
225
2
                          uint32_t num_rows = 0;
226
2
                          auto iter = aggregate_data_container->begin();
227
2
                          {
228
9
                              while (iter != aggregate_data_container->end()) {
229
7
                                  keys[num_rows] = iter.get_key<KeyType>();
230
7
                                  ++iter;
231
7
                                  ++num_rows;
232
7
                              }
233
2
                          }
234
2
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
2
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
2
                          return key_columns;
239
2
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm256EjEENS_15DataWithNullKeyI9PHHashMapIS7_Pc9HashCRC32IS7_EEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISK_EESaISN_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_19MethodStringNoCacheINS_15DataWithNullKeyINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISI_EESaISL_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISD_EESaISG_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodKeysFixedI9PHHashMapINS_6UInt72EPc9HashCRC32IS5_EEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISE_EESaISH_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodKeysFixedI9PHHashMapINS_6UInt96EPc9HashCRC32IS5_EEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISE_EESaISH_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodKeysFixedI9PHHashMapINS_7UInt104EPc9HashCRC32IS5_EEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISE_EESaISH_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS7_EEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodKeysFixedI9PHHashMapINS_7UInt136EPc9HashCRC32IS5_EEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISE_EESaISH_EEOT_
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS7_EEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
Line
Count
Source
213
12
                      [&](auto&& agg_method) -> MutableColumns {
214
12
                          MutableColumns key_columns;
215
46
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
34
                              key_columns.emplace_back(
217
34
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
34
                          }
219
12
                          auto& data = *agg_method.hash_table;
220
12
                          bool has_null_key = data.has_null_key_data();
221
12
                          const auto size = data.size() - has_null_key;
222
12
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
12
                          std::vector<KeyType> keys(size);
224
225
12
                          uint32_t num_rows = 0;
226
12
                          auto iter = aggregate_data_container->begin();
227
12
                          {
228
2.15k
                              while (iter != aggregate_data_container->end()) {
229
2.14k
                                  keys[num_rows] = iter.get_key<KeyType>();
230
2.14k
                                  ++iter;
231
2.14k
                                  ++num_rows;
232
2.14k
                              }
233
12
                          }
234
12
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
12
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
12
                          return key_columns;
239
12
                      }},
240
49
            agg_data->method_variant);
241
49
}
242
243
49
void AggSharedState::build_limit_heap(size_t hash_table_size) {
244
49
    limit_columns = _get_keys_hash_table();
245
8.60k
    for (size_t i = 0; i < hash_table_size; ++i) {
246
8.55k
        limit_heap.emplace(i, limit_columns, order_directions, null_directions);
247
8.55k
    }
248
8.52k
    while (hash_table_size > limit) {
249
8.47k
        limit_heap.pop();
250
8.47k
        hash_table_size--;
251
8.47k
    }
252
49
    limit_columns_min = limit_heap.top()._row_id;
253
49
}
254
255
bool AggSharedState::do_limit_filter(Block* block, size_t num_rows,
256
105
                                     const std::vector<int>* key_locs) {
257
105
    if (num_rows) {
258
105
        cmp_res.resize(num_rows);
259
105
        need_computes.resize(num_rows);
260
105
        memset(need_computes.data(), 0, need_computes.size());
261
105
        memset(cmp_res.data(), 0, cmp_res.size());
262
263
105
        const auto key_size = null_directions.size();
264
266
        for (int i = 0; i < key_size; i++) {
265
161
            block->get_by_position(key_locs ? key_locs->operator[](i) : i)
266
161
                    .column->compare_internal(limit_columns_min, *limit_columns[i],
267
161
                                              null_directions[i], order_directions[i], cmp_res,
268
161
                                              need_computes.data());
269
161
        }
270
271
105
        auto set_computes_arr = [](auto* __restrict res, auto* __restrict computes, size_t rows) {
272
26.3k
            for (size_t i = 0; i < rows; ++i) {
273
26.2k
                computes[i] = computes[i] == res[i];
274
26.2k
            }
275
105
        };
276
105
        set_computes_arr(cmp_res.data(), need_computes.data(), num_rows);
277
278
105
        return std::find(need_computes.begin(), need_computes.end(), 0) != need_computes.end();
279
105
    }
280
281
0
    return false;
282
105
}
283
284
6.26k
Status AggSharedState::reset_hash_table() {
285
6.26k
    return std::visit(
286
6.26k
            Overload {[&](std::monostate& arg) -> Status {
287
0
                          return Status::InternalError("Uninited hash table");
288
0
                      },
289
6.26k
                      [&](auto& agg_method) {
290
6.26k
                          auto& hash_table = *agg_method.hash_table;
291
6.26k
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
6.26k
                          agg_method.arena.clear();
294
6.26k
                          agg_method.inited_iterator = false;
295
296
3.18M
                          hash_table.for_each_mapped([&](auto& mapped) {
297
3.18M
                              if (mapped) {
298
3.18M
                                  _destroy_agg_status(mapped);
299
3.18M
                                  mapped = nullptr;
300
3.18M
                              }
301
3.18M
                          });
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS5_vEEEEEEDaRT_ENKUlSC_E_clIS6_EEDaSC_
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEDaRT_ENKUlSB_E_clIS5_EEDaSB_
Line
Count
Source
296
264
                          hash_table.for_each_mapped([&](auto& mapped) {
297
264
                              if (mapped) {
298
264
                                  _destroy_agg_status(mapped);
299
264
                                  mapped = nullptr;
300
264
                              }
301
264
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEDaRT_ENKUlSB_E_clIS5_EEDaSB_
Line
Count
Source
296
624
                          hash_table.for_each_mapped([&](auto& mapped) {
297
624
                              if (mapped) {
298
624
                                  _destroy_agg_status(mapped);
299
624
                                  mapped = nullptr;
300
624
                              }
301
624
                          });
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEEDaRT_ENKUlSB_E_clIS5_EEDaSB_
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEEDaRT_ENKUlSB_E_clIS5_EEDaSB_
Line
Count
Source
296
982
                          hash_table.for_each_mapped([&](auto& mapped) {
297
982
                              if (mapped) {
298
982
                                  _destroy_agg_status(mapped);
299
982
                                  mapped = nullptr;
300
982
                              }
301
982
                          });
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEDaRT_ENKUlSC_E_clIS5_EEDaSC_
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS6_Pc9HashCRC32IS6_EEEEEEDaRT_ENKUlSE_E_clIS8_EEDaSE_
Line
Count
Source
296
996
                          hash_table.for_each_mapped([&](auto& mapped) {
297
996
                              if (mapped) {
298
996
                                  _destroy_agg_status(mapped);
299
996
                                  mapped = nullptr;
300
996
                              }
301
996
                          });
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS6_Pc9HashCRC32IS6_EEEEEEDaRT_ENKUlSE_E_clIS8_EEDaSE_
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEDaRT_ENKUlSD_E_clIS5_EEDaSD_
Line
Count
Source
296
1.04M
                          hash_table.for_each_mapped([&](auto& mapped) {
297
1.04M
                              if (mapped) {
298
1.04M
                                  _destroy_agg_status(mapped);
299
1.04M
                                  mapped = nullptr;
300
1.04M
                              }
301
1.04M
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEDaRT_ENKUlSD_E_clIS5_EEDaSD_
Line
Count
Source
296
3.44k
                          hash_table.for_each_mapped([&](auto& mapped) {
297
3.44k
                              if (mapped) {
298
3.44k
                                  _destroy_agg_status(mapped);
299
3.44k
                                  mapped = nullptr;
300
3.44k
                              }
301
3.44k
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIhNS_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Line
Count
Source
296
8
                          hash_table.for_each_mapped([&](auto& mapped) {
297
8
                              if (mapped) {
298
8
                                  _destroy_agg_status(mapped);
299
8
                                  mapped = nullptr;
300
8
                              }
301
8
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberItNS_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Line
Count
Source
296
294
                          hash_table.for_each_mapped([&](auto& mapped) {
297
294
                              if (mapped) {
298
294
                                  _destroy_agg_status(mapped);
299
294
                                  mapped = nullptr;
300
294
                              }
301
294
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Line
Count
Source
296
1.10M
                          hash_table.for_each_mapped([&](auto& mapped) {
297
1.10M
                              if (mapped) {
298
1.10M
                                  _destroy_agg_status(mapped);
299
1.10M
                                  mapped = nullptr;
300
1.10M
                              }
301
1.10M
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Line
Count
Source
296
1.20k
                          hash_table.for_each_mapped([&](auto& mapped) {
297
1.20k
                              if (mapped) {
298
1.20k
                                  _destroy_agg_status(mapped);
299
1.20k
                                  mapped = nullptr;
300
1.20k
                              }
301
1.20k
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEDaRT_ENKUlSH_E_clIS7_EEDaSH_
Line
Count
Source
296
1.01M
                          hash_table.for_each_mapped([&](auto& mapped) {
297
1.01M
                              if (mapped) {
298
1.01M
                                  _destroy_agg_status(mapped);
299
1.01M
                                  mapped = nullptr;
300
1.01M
                              }
301
1.01M
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEDaRT_ENKUlSH_E_clIS7_EEDaSH_
Line
Count
Source
296
2.01k
                          hash_table.for_each_mapped([&](auto& mapped) {
297
2.01k
                              if (mapped) {
298
2.01k
                                  _destroy_agg_status(mapped);
299
2.01k
                                  mapped = nullptr;
300
2.01k
                              }
301
2.01k
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS7_Pc9HashCRC32IS7_EEEEEEEEEEDaRT_ENKUlSI_E_clISA_EEDaSI_
Line
Count
Source
296
598
                          hash_table.for_each_mapped([&](auto& mapped) {
297
598
                              if (mapped) {
298
598
                                  _destroy_agg_status(mapped);
299
598
                                  mapped = nullptr;
300
598
                              }
301
598
                          });
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm256EjEENS_15DataWithNullKeyI9PHHashMapIS7_Pc9HashCRC32IS7_EEEEEEEEEEDaRT_ENKUlSI_E_clISA_EEDaSI_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_19MethodStringNoCacheINS_15DataWithNullKeyINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEEEEEDaRT_ENKUlSG_E_clIS7_EEDaSG_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImEEEEEEDaRT_ENKUlSB_E_clIS5_EEDaSB_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapINS_6UInt72EPc9HashCRC32IS5_EEEEEEDaRT_ENKUlSC_E_clIS6_EEDaSC_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapINS_6UInt96EPc9HashCRC32IS5_EEEEEEDaRT_ENKUlSC_E_clIS6_EEDaSC_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapINS_7UInt104EPc9HashCRC32IS5_EEEEEEDaRT_ENKUlSC_E_clIS6_EEDaSC_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS7_EEEEEEDaRT_ENKUlSE_E_clIS8_EEDaSE_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapINS_7UInt136EPc9HashCRC32IS5_EEEEEEDaRT_ENKUlSC_E_clIS6_EEDaSC_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS7_EEEEEEDaRT_ENKUlSE_E_clIS8_EEDaSE_
302
303
6.26k
                          if (hash_table.has_null_key_data()) {
304
0
                              _destroy_agg_status(
305
0
                                      hash_table.template get_null_key_data<AggregateDataPtr>());
306
0
                          }
307
308
6.26k
                          aggregate_data_container.reset(new AggregateDataContainer(
309
6.26k
                                  sizeof(typename HashTableType::key_type),
310
6.26k
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
6.26k
                                   align_aggregate_states) *
312
6.26k
                                          align_aggregate_states));
313
6.26k
                          agg_method.hash_table.reset(new HashTableType());
314
6.26k
                          return Status::OK();
315
6.26k
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS5_vEEEEEEDaRT_
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEDaRT_
Line
Count
Source
289
96
                      [&](auto& agg_method) {
290
96
                          auto& hash_table = *agg_method.hash_table;
291
96
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
96
                          agg_method.arena.clear();
294
96
                          agg_method.inited_iterator = false;
295
296
96
                          hash_table.for_each_mapped([&](auto& mapped) {
297
96
                              if (mapped) {
298
96
                                  _destroy_agg_status(mapped);
299
96
                                  mapped = nullptr;
300
96
                              }
301
96
                          });
302
303
96
                          if (hash_table.has_null_key_data()) {
304
0
                              _destroy_agg_status(
305
0
                                      hash_table.template get_null_key_data<AggregateDataPtr>());
306
0
                          }
307
308
96
                          aggregate_data_container.reset(new AggregateDataContainer(
309
96
                                  sizeof(typename HashTableType::key_type),
310
96
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
96
                                   align_aggregate_states) *
312
96
                                          align_aggregate_states));
313
96
                          agg_method.hash_table.reset(new HashTableType());
314
96
                          return Status::OK();
315
96
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEDaRT_
Line
Count
Source
289
148
                      [&](auto& agg_method) {
290
148
                          auto& hash_table = *agg_method.hash_table;
291
148
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
148
                          agg_method.arena.clear();
294
148
                          agg_method.inited_iterator = false;
295
296
148
                          hash_table.for_each_mapped([&](auto& mapped) {
297
148
                              if (mapped) {
298
148
                                  _destroy_agg_status(mapped);
299
148
                                  mapped = nullptr;
300
148
                              }
301
148
                          });
302
303
148
                          if (hash_table.has_null_key_data()) {
304
0
                              _destroy_agg_status(
305
0
                                      hash_table.template get_null_key_data<AggregateDataPtr>());
306
0
                          }
307
308
148
                          aggregate_data_container.reset(new AggregateDataContainer(
309
148
                                  sizeof(typename HashTableType::key_type),
310
148
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
148
                                   align_aggregate_states) *
312
148
                                          align_aggregate_states));
313
148
                          agg_method.hash_table.reset(new HashTableType());
314
148
                          return Status::OK();
315
148
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEEDaRT_
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEEDaRT_
Line
Count
Source
289
282
                      [&](auto& agg_method) {
290
282
                          auto& hash_table = *agg_method.hash_table;
291
282
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
282
                          agg_method.arena.clear();
294
282
                          agg_method.inited_iterator = false;
295
296
282
                          hash_table.for_each_mapped([&](auto& mapped) {
297
282
                              if (mapped) {
298
282
                                  _destroy_agg_status(mapped);
299
282
                                  mapped = nullptr;
300
282
                              }
301
282
                          });
302
303
282
                          if (hash_table.has_null_key_data()) {
304
0
                              _destroy_agg_status(
305
0
                                      hash_table.template get_null_key_data<AggregateDataPtr>());
306
0
                          }
307
308
282
                          aggregate_data_container.reset(new AggregateDataContainer(
309
282
                                  sizeof(typename HashTableType::key_type),
310
282
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
282
                                   align_aggregate_states) *
312
282
                                          align_aggregate_states));
313
282
                          agg_method.hash_table.reset(new HashTableType());
314
282
                          return Status::OK();
315
282
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEDaRT_
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS6_Pc9HashCRC32IS6_EEEEEEDaRT_
Line
Count
Source
289
296
                      [&](auto& agg_method) {
290
296
                          auto& hash_table = *agg_method.hash_table;
291
296
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
296
                          agg_method.arena.clear();
294
296
                          agg_method.inited_iterator = false;
295
296
296
                          hash_table.for_each_mapped([&](auto& mapped) {
297
296
                              if (mapped) {
298
296
                                  _destroy_agg_status(mapped);
299
296
                                  mapped = nullptr;
300
296
                              }
301
296
                          });
302
303
296
                          if (hash_table.has_null_key_data()) {
304
0
                              _destroy_agg_status(
305
0
                                      hash_table.template get_null_key_data<AggregateDataPtr>());
306
0
                          }
307
308
296
                          aggregate_data_container.reset(new AggregateDataContainer(
309
296
                                  sizeof(typename HashTableType::key_type),
310
296
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
296
                                   align_aggregate_states) *
312
296
                                          align_aggregate_states));
313
296
                          agg_method.hash_table.reset(new HashTableType());
314
296
                          return Status::OK();
315
296
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS6_Pc9HashCRC32IS6_EEEEEEDaRT_
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEDaRT_
Line
Count
Source
289
395
                      [&](auto& agg_method) {
290
395
                          auto& hash_table = *agg_method.hash_table;
291
395
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
395
                          agg_method.arena.clear();
294
395
                          agg_method.inited_iterator = false;
295
296
395
                          hash_table.for_each_mapped([&](auto& mapped) {
297
395
                              if (mapped) {
298
395
                                  _destroy_agg_status(mapped);
299
395
                                  mapped = nullptr;
300
395
                              }
301
395
                          });
302
303
395
                          if (hash_table.has_null_key_data()) {
304
0
                              _destroy_agg_status(
305
0
                                      hash_table.template get_null_key_data<AggregateDataPtr>());
306
0
                          }
307
308
395
                          aggregate_data_container.reset(new AggregateDataContainer(
309
395
                                  sizeof(typename HashTableType::key_type),
310
395
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
395
                                   align_aggregate_states) *
312
395
                                          align_aggregate_states));
313
395
                          agg_method.hash_table.reset(new HashTableType());
314
395
                          return Status::OK();
315
395
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEDaRT_
Line
Count
Source
289
1.19k
                      [&](auto& agg_method) {
290
1.19k
                          auto& hash_table = *agg_method.hash_table;
291
1.19k
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
1.19k
                          agg_method.arena.clear();
294
1.19k
                          agg_method.inited_iterator = false;
295
296
1.19k
                          hash_table.for_each_mapped([&](auto& mapped) {
297
1.19k
                              if (mapped) {
298
1.19k
                                  _destroy_agg_status(mapped);
299
1.19k
                                  mapped = nullptr;
300
1.19k
                              }
301
1.19k
                          });
302
303
1.19k
                          if (hash_table.has_null_key_data()) {
304
0
                              _destroy_agg_status(
305
0
                                      hash_table.template get_null_key_data<AggregateDataPtr>());
306
0
                          }
307
308
1.19k
                          aggregate_data_container.reset(new AggregateDataContainer(
309
1.19k
                                  sizeof(typename HashTableType::key_type),
310
1.19k
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
1.19k
                                   align_aggregate_states) *
312
1.19k
                                          align_aggregate_states));
313
1.19k
                          agg_method.hash_table.reset(new HashTableType());
314
1.19k
                          return Status::OK();
315
1.19k
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIhNS_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEDaRT_
Line
Count
Source
289
8
                      [&](auto& agg_method) {
290
8
                          auto& hash_table = *agg_method.hash_table;
291
8
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
8
                          agg_method.arena.clear();
294
8
                          agg_method.inited_iterator = false;
295
296
8
                          hash_table.for_each_mapped([&](auto& mapped) {
297
8
                              if (mapped) {
298
8
                                  _destroy_agg_status(mapped);
299
8
                                  mapped = nullptr;
300
8
                              }
301
8
                          });
302
303
8
                          if (hash_table.has_null_key_data()) {
304
0
                              _destroy_agg_status(
305
0
                                      hash_table.template get_null_key_data<AggregateDataPtr>());
306
0
                          }
307
308
8
                          aggregate_data_container.reset(new AggregateDataContainer(
309
8
                                  sizeof(typename HashTableType::key_type),
310
8
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
8
                                   align_aggregate_states) *
312
8
                                          align_aggregate_states));
313
8
                          agg_method.hash_table.reset(new HashTableType());
314
8
                          return Status::OK();
315
8
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberItNS_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEDaRT_
Line
Count
Source
289
78
                      [&](auto& agg_method) {
290
78
                          auto& hash_table = *agg_method.hash_table;
291
78
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
78
                          agg_method.arena.clear();
294
78
                          agg_method.inited_iterator = false;
295
296
78
                          hash_table.for_each_mapped([&](auto& mapped) {
297
78
                              if (mapped) {
298
78
                                  _destroy_agg_status(mapped);
299
78
                                  mapped = nullptr;
300
78
                              }
301
78
                          });
302
303
78
                          if (hash_table.has_null_key_data()) {
304
0
                              _destroy_agg_status(
305
0
                                      hash_table.template get_null_key_data<AggregateDataPtr>());
306
0
                          }
307
308
78
                          aggregate_data_container.reset(new AggregateDataContainer(
309
78
                                  sizeof(typename HashTableType::key_type),
310
78
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
78
                                   align_aggregate_states) *
312
78
                                          align_aggregate_states));
313
78
                          agg_method.hash_table.reset(new HashTableType());
314
78
                          return Status::OK();
315
78
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEDaRT_
Line
Count
Source
289
986
                      [&](auto& agg_method) {
290
986
                          auto& hash_table = *agg_method.hash_table;
291
986
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
986
                          agg_method.arena.clear();
294
986
                          agg_method.inited_iterator = false;
295
296
986
                          hash_table.for_each_mapped([&](auto& mapped) {
297
986
                              if (mapped) {
298
986
                                  _destroy_agg_status(mapped);
299
986
                                  mapped = nullptr;
300
986
                              }
301
986
                          });
302
303
986
                          if (hash_table.has_null_key_data()) {
304
0
                              _destroy_agg_status(
305
0
                                      hash_table.template get_null_key_data<AggregateDataPtr>());
306
0
                          }
307
308
986
                          aggregate_data_container.reset(new AggregateDataContainer(
309
986
                                  sizeof(typename HashTableType::key_type),
310
986
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
986
                                   align_aggregate_states) *
312
986
                                          align_aggregate_states));
313
986
                          agg_method.hash_table.reset(new HashTableType());
314
986
                          return Status::OK();
315
986
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEDaRT_
Line
Count
Source
289
370
                      [&](auto& agg_method) {
290
370
                          auto& hash_table = *agg_method.hash_table;
291
370
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
370
                          agg_method.arena.clear();
294
370
                          agg_method.inited_iterator = false;
295
296
370
                          hash_table.for_each_mapped([&](auto& mapped) {
297
370
                              if (mapped) {
298
370
                                  _destroy_agg_status(mapped);
299
370
                                  mapped = nullptr;
300
370
                              }
301
370
                          });
302
303
370
                          if (hash_table.has_null_key_data()) {
304
0
                              _destroy_agg_status(
305
0
                                      hash_table.template get_null_key_data<AggregateDataPtr>());
306
0
                          }
307
308
370
                          aggregate_data_container.reset(new AggregateDataContainer(
309
370
                                  sizeof(typename HashTableType::key_type),
310
370
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
370
                                   align_aggregate_states) *
312
370
                                          align_aggregate_states));
313
370
                          agg_method.hash_table.reset(new HashTableType());
314
370
                          return Status::OK();
315
370
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEDaRT_
Line
Count
Source
289
1.37k
                      [&](auto& agg_method) {
290
1.37k
                          auto& hash_table = *agg_method.hash_table;
291
1.37k
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
1.37k
                          agg_method.arena.clear();
294
1.37k
                          agg_method.inited_iterator = false;
295
296
1.37k
                          hash_table.for_each_mapped([&](auto& mapped) {
297
1.37k
                              if (mapped) {
298
1.37k
                                  _destroy_agg_status(mapped);
299
1.37k
                                  mapped = nullptr;
300
1.37k
                              }
301
1.37k
                          });
302
303
1.37k
                          if (hash_table.has_null_key_data()) {
304
0
                              _destroy_agg_status(
305
0
                                      hash_table.template get_null_key_data<AggregateDataPtr>());
306
0
                          }
307
308
1.37k
                          aggregate_data_container.reset(new AggregateDataContainer(
309
1.37k
                                  sizeof(typename HashTableType::key_type),
310
1.37k
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
1.37k
                                   align_aggregate_states) *
312
1.37k
                                          align_aggregate_states));
313
1.37k
                          agg_method.hash_table.reset(new HashTableType());
314
1.37k
                          return Status::OK();
315
1.37k
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEDaRT_
Line
Count
Source
289
837
                      [&](auto& agg_method) {
290
837
                          auto& hash_table = *agg_method.hash_table;
291
837
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
837
                          agg_method.arena.clear();
294
837
                          agg_method.inited_iterator = false;
295
296
837
                          hash_table.for_each_mapped([&](auto& mapped) {
297
837
                              if (mapped) {
298
837
                                  _destroy_agg_status(mapped);
299
837
                                  mapped = nullptr;
300
837
                              }
301
837
                          });
302
303
837
                          if (hash_table.has_null_key_data()) {
304
0
                              _destroy_agg_status(
305
0
                                      hash_table.template get_null_key_data<AggregateDataPtr>());
306
0
                          }
307
308
837
                          aggregate_data_container.reset(new AggregateDataContainer(
309
837
                                  sizeof(typename HashTableType::key_type),
310
837
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
837
                                   align_aggregate_states) *
312
837
                                          align_aggregate_states));
313
837
                          agg_method.hash_table.reset(new HashTableType());
314
837
                          return Status::OK();
315
837
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS7_Pc9HashCRC32IS7_EEEEEEEEEEDaRT_
Line
Count
Source
289
208
                      [&](auto& agg_method) {
290
208
                          auto& hash_table = *agg_method.hash_table;
291
208
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
208
                          agg_method.arena.clear();
294
208
                          agg_method.inited_iterator = false;
295
296
208
                          hash_table.for_each_mapped([&](auto& mapped) {
297
208
                              if (mapped) {
298
208
                                  _destroy_agg_status(mapped);
299
208
                                  mapped = nullptr;
300
208
                              }
301
208
                          });
302
303
208
                          if (hash_table.has_null_key_data()) {
304
0
                              _destroy_agg_status(
305
0
                                      hash_table.template get_null_key_data<AggregateDataPtr>());
306
0
                          }
307
308
208
                          aggregate_data_container.reset(new AggregateDataContainer(
309
208
                                  sizeof(typename HashTableType::key_type),
310
208
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
208
                                   align_aggregate_states) *
312
208
                                          align_aggregate_states));
313
208
                          agg_method.hash_table.reset(new HashTableType());
314
208
                          return Status::OK();
315
208
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm256EjEENS_15DataWithNullKeyI9PHHashMapIS7_Pc9HashCRC32IS7_EEEEEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_19MethodStringNoCacheINS_15DataWithNullKeyINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapINS_6UInt72EPc9HashCRC32IS5_EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapINS_6UInt96EPc9HashCRC32IS5_EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapINS_7UInt104EPc9HashCRC32IS5_EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS7_EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapINS_7UInt136EPc9HashCRC32IS5_EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS7_EEEEEEDaRT_
316
6.26k
            agg_data->method_variant);
317
6.26k
}
318
319
587
void PartitionedAggSharedState::init_spill_params(size_t spill_partition_count) {
320
587
    partition_count = spill_partition_count;
321
587
    max_partition_index = partition_count - 1;
322
323
19.3k
    for (int i = 0; i < partition_count; ++i) {
324
18.7k
        spill_partitions.emplace_back(std::make_shared<AggSpillPartition>());
325
18.7k
    }
326
587
}
327
328
574
void PartitionedAggSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {
329
18.3k
    for (auto& partition : spill_partitions) {
330
18.3k
        if (partition->spilling_stream_) {
331
0
            partition->spilling_stream_->update_shared_profiles(source_profile);
332
0
        }
333
18.3k
        for (auto& stream : partition->spill_streams_) {
334
3.81k
            if (stream) {
335
3.81k
                stream->update_shared_profiles(source_profile);
336
3.81k
            }
337
3.81k
        }
338
18.3k
    }
339
574
}
340
341
Status AggSpillPartition::get_spill_stream(RuntimeState* state, int node_id,
342
37.9k
                                           RuntimeProfile* profile, SpillStreamSPtr& spill_stream) {
343
37.9k
    if (spilling_stream_) {
344
34.1k
        spill_stream = spilling_stream_;
345
34.1k
        return Status::OK();
346
34.1k
    }
347
3.86k
    RETURN_IF_ERROR(ExecEnv::GetInstance()->spill_stream_mgr()->register_spill_stream(
348
3.86k
            state, spilling_stream_, print_id(state->query_id()), "agg", node_id,
349
3.86k
            std::numeric_limits<int32_t>::max(), std::numeric_limits<size_t>::max(), profile));
350
3.86k
    spill_streams_.emplace_back(spilling_stream_);
351
3.86k
    spill_stream = spilling_stream_;
352
3.86k
    return Status::OK();
353
3.86k
}
354
12.5k
void AggSpillPartition::close() {
355
12.5k
    if (spilling_stream_) {
356
1
        spilling_stream_.reset();
357
1
    }
358
12.5k
    for (auto& stream : spill_streams_) {
359
5
        (void)ExecEnv::GetInstance()->spill_stream_mgr()->delete_spill_stream(stream);
360
5
    }
361
12.5k
    spill_streams_.clear();
362
12.5k
}
363
364
653
void PartitionedAggSharedState::close() {
365
    // need to use CAS instead of only `if (!is_closed)` statement,
366
    // to avoid concurrent entry of close() both pass the if statement
367
653
    bool false_close = false;
368
653
    if (!is_closed.compare_exchange_strong(false_close, true)) {
369
74
        return;
370
74
    }
371
653
    DCHECK(!false_close && is_closed);
372
12.5k
    for (auto partition : spill_partitions) {
373
12.5k
        partition->close();
374
12.5k
    }
375
579
    spill_partitions.clear();
376
579
}
377
378
13
void SpillSortSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {
379
28
    for (auto& stream : sorted_streams) {
380
28
        if (stream) {
381
28
            stream->update_shared_profiles(source_profile);
382
28
        }
383
28
    }
384
13
}
385
386
15
void SpillSortSharedState::close() {
387
    // need to use CAS instead of only `if (!is_closed)` statement,
388
    // to avoid concurrent entry of close() both pass the if statement
389
15
    bool false_close = false;
390
15
    if (!is_closed.compare_exchange_strong(false_close, true)) {
391
1
        return;
392
1
    }
393
15
    DCHECK(!false_close && is_closed);
394
14
    for (auto& stream : sorted_streams) {
395
1
        (void)ExecEnv::GetInstance()->spill_stream_mgr()->delete_spill_stream(stream);
396
1
    }
397
14
    sorted_streams.clear();
398
14
}
399
400
MultiCastSharedState::MultiCastSharedState(ObjectPool* pool, int cast_sender_count, int node_id)
401
        : multi_cast_data_streamer(
402
2.61k
                  std::make_unique<MultiCastDataStreamer>(pool, cast_sender_count, node_id)) {}
403
404
0
void MultiCastSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {}
405
406
113k
int AggSharedState::get_slot_column_id(const AggFnEvaluator* evaluator) {
407
113k
    auto ctxs = evaluator->input_exprs_ctxs();
408
18.4E
    CHECK(ctxs.size() == 1 && ctxs[0]->root()->is_slot_ref())
409
18.4E
            << "input_exprs_ctxs is invalid, input_exprs_ctx[0]="
410
18.4E
            << ctxs[0]->root()->debug_string();
411
113k
    return ((VSlotRef*)ctxs[0]->root().get())->column_id();
412
113k
}
413
414
5.52M
void AggSharedState::_destroy_agg_status(AggregateDataPtr data) {
415
14.4M
    for (int i = 0; i < aggregate_evaluators.size(); ++i) {
416
8.90M
        aggregate_evaluators[i]->function()->destroy(data + offsets_of_aggregate_states[i]);
417
8.90M
    }
418
5.52M
}
419
420
99.2k
LocalExchangeSharedState::~LocalExchangeSharedState() = default;
421
422
12.1k
Status SetSharedState::update_build_not_ignore_null(const VExprContextSPtrs& ctxs) {
423
12.1k
    if (ctxs.size() > build_not_ignore_null.size()) {
424
0
        return Status::InternalError("build_not_ignore_null not initialized");
425
0
    }
426
427
100k
    for (int i = 0; i < ctxs.size(); ++i) {
428
88.0k
        build_not_ignore_null[i] = build_not_ignore_null[i] || ctxs[i]->root()->is_nullable();
429
88.0k
    }
430
431
12.1k
    return Status::OK();
432
12.1k
}
433
434
19.5k
size_t SetSharedState::get_hash_table_size() const {
435
19.5k
    size_t hash_table_size = 0;
436
19.5k
    std::visit(
437
19.5k
            [&](auto&& arg) {
438
19.5k
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
19.5k
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
19.5k
                    hash_table_size = arg.hash_table->size();
441
19.5k
                }
442
19.5k
            },
Unexecuted instantiation: dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRSt9monostateEEDaOT_
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_16MethodSerializedI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS5_vEEEEEEDaOT_
Line
Count
Source
437
18.0k
            [&](auto&& arg) {
438
18.0k
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
18.0k
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
18.0k
                    hash_table_size = arg.hash_table->size();
441
18.0k
                }
442
18.0k
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_19MethodStringNoCacheI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS5_vEEEEEEDaOT_
Line
Count
Source
437
137
            [&](auto&& arg) {
438
137
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
137
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
137
                    hash_table_size = arg.hash_table->size();
441
137
                }
442
137
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_26MethodSingleNullableColumnINS_19MethodStringNoCacheINS_15DataWithNullKeyI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS7_vEEEEEEEEEEDaOT_
Line
Count
Source
437
122
            [&](auto&& arg) {
438
122
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
122
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
122
                    hash_table_size = arg.hash_table->size();
441
122
                }
442
122
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIhNS_15DataWithNullKeyI9PHHashMapIhNS_14RowRefWithFlagE9HashCRC32IhEEEEEEEEEEDaOT_
Line
Count
Source
437
78
            [&](auto&& arg) {
438
78
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
78
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
78
                    hash_table_size = arg.hash_table->size();
441
78
                }
442
78
            },
Unexecuted instantiation: dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberItNS_15DataWithNullKeyI9PHHashMapItNS_14RowRefWithFlagE9HashCRC32ItEEEEEEEEEEDaOT_
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjNS_14RowRefWithFlagE9HashCRC32IjEEEEEEEEEEDaOT_
Line
Count
Source
437
250
            [&](auto&& arg) {
438
250
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
250
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
250
                    hash_table_size = arg.hash_table->size();
441
250
                }
442
250
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImNS_14RowRefWithFlagE9HashCRC32ImEEEEEEEEEEDaOT_
Line
Count
Source
437
272
            [&](auto&& arg) {
438
272
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
272
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
272
                    hash_table_size = arg.hash_table->size();
441
272
                }
442
272
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS7_NS_14RowRefWithFlagE9HashCRC32IS7_EEEEEEEEEEDaOT_
Line
Count
Source
437
191
            [&](auto&& arg) {
438
191
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
191
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
191
                    hash_table_size = arg.hash_table->size();
441
191
                }
442
191
            },
Unexecuted instantiation: dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm256EjEENS_15DataWithNullKeyI9PHHashMapIS7_NS_14RowRefWithFlagE9HashCRC32IS7_EEEEEEEEEEDaOT_
Unexecuted instantiation: dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodOneNumberIh9PHHashMapIhNS_14RowRefWithFlagE9HashCRC32IhEEEEEEDaOT_
Unexecuted instantiation: dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodOneNumberIt9PHHashMapItNS_14RowRefWithFlagE9HashCRC32ItEEEEEEDaOT_
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodOneNumberIj9PHHashMapIjNS_14RowRefWithFlagE9HashCRC32IjEEEEEEDaOT_
Line
Count
Source
437
30
            [&](auto&& arg) {
438
30
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
30
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
30
                    hash_table_size = arg.hash_table->size();
441
30
                }
442
30
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodOneNumberIm9PHHashMapImNS_14RowRefWithFlagE9HashCRC32ImEEEEEEDaOT_
Line
Count
Source
437
16
            [&](auto&& arg) {
438
16
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
16
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
16
                    hash_table_size = arg.hash_table->size();
441
16
                }
442
16
            },
Unexecuted instantiation: dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS6_NS_14RowRefWithFlagE9HashCRC32IS6_EEEEEEDaOT_
Unexecuted instantiation: dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS6_NS_14RowRefWithFlagE9HashCRC32IS6_EEEEEEDaOT_
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodKeysFixedI9PHHashMapImNS_14RowRefWithFlagE9HashCRC32ImEEEEEEDaOT_
Line
Count
Source
437
60
            [&](auto&& arg) {
438
60
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
60
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
60
                    hash_table_size = arg.hash_table->size();
441
60
                }
442
60
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodKeysFixedI9PHHashMapINS_6UInt72ENS_14RowRefWithFlagE9HashCRC32IS5_EEEEEEDaOT_
Line
Count
Source
437
45
            [&](auto&& arg) {
438
45
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
45
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
45
                    hash_table_size = arg.hash_table->size();
441
45
                }
442
45
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodKeysFixedI9PHHashMapINS_6UInt96ENS_14RowRefWithFlagE9HashCRC32IS5_EEEEEEDaOT_
Line
Count
Source
437
30
            [&](auto&& arg) {
438
30
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
30
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
30
                    hash_table_size = arg.hash_table->size();
441
30
                }
442
30
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodKeysFixedI9PHHashMapINS_7UInt104ENS_14RowRefWithFlagE9HashCRC32IS5_EEEEEEDaOT_
Line
Count
Source
437
36
            [&](auto&& arg) {
438
36
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
36
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
36
                    hash_table_size = arg.hash_table->size();
441
36
                }
442
36
            },
Unexecuted instantiation: dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEENS_14RowRefWithFlagE9HashCRC32IS7_EEEEEEDaOT_
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEENS_14RowRefWithFlagE9HashCRC32IS7_EEEEEEDaOT_
Line
Count
Source
437
4
            [&](auto&& arg) {
438
4
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
4
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
4
                    hash_table_size = arg.hash_table->size();
441
4
                }
442
4
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodKeysFixedI9PHHashMapINS_7UInt136ENS_14RowRefWithFlagE9HashCRC32IS5_EEEEEEDaOT_
Line
Count
Source
437
194
            [&](auto&& arg) {
438
194
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
194
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
194
                    hash_table_size = arg.hash_table->size();
441
194
                }
442
194
            },
443
19.5k
            hash_table_variants->method_variant);
444
19.5k
    return hash_table_size;
445
19.5k
}
446
447
5.03k
Status SetSharedState::hash_table_init() {
448
5.03k
    std::vector<DataTypePtr> data_types;
449
40.4k
    for (size_t i = 0; i != child_exprs_lists[0].size(); ++i) {
450
35.3k
        auto& ctx = child_exprs_lists[0][i];
451
35.3k
        auto data_type = ctx->root()->data_type();
452
35.3k
        if (build_not_ignore_null[i]) {
453
35.1k
            data_type = make_nullable(data_type);
454
35.1k
        }
455
35.3k
        data_types.emplace_back(std::move(data_type));
456
35.3k
    }
457
5.03k
    return init_hash_method<SetDataVariants>(hash_table_variants.get(), data_types, true);
458
5.03k
}
459
460
2.05k
void AggSharedState::refresh_top_limit(size_t row_id, const ColumnRawPtrs& key_columns) {
461
4.13k
    for (int j = 0; j < key_columns.size(); ++j) {
462
2.07k
        limit_columns[j]->insert_from(*key_columns[j], row_id);
463
2.07k
    }
464
2.05k
    limit_heap.emplace(limit_columns[0]->size() - 1, limit_columns, order_directions,
465
2.05k
                       null_directions);
466
467
2.05k
    limit_heap.pop();
468
2.05k
    limit_columns_min = limit_heap.top()._row_id;
469
2.05k
}
470
471
} // namespace doris