Coverage Report

Created: 2026-03-12 15:09

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
531k
                                                       const std::string& name) {
43
531k
    source_deps.push_back(std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY"));
44
531k
    source_deps.back()->set_shared_state(this);
45
531k
    return source_deps.back().get();
46
531k
}
47
48
void BasicSharedState::create_source_dependencies(int num_sources, int operator_id, int node_id,
49
109k
                                                  const std::string& name) {
50
109k
    source_deps.resize(num_sources, nullptr);
51
697k
    for (auto& source_dep : source_deps) {
52
697k
        source_dep = std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY");
53
697k
        source_dep->set_shared_state(this);
54
697k
    }
55
109k
}
56
57
Dependency* BasicSharedState::create_sink_dependency(int dest_id, int node_id,
58
1.03M
                                                     const std::string& name) {
59
1.03M
    sink_deps.push_back(std::make_shared<Dependency>(dest_id, node_id, name + "_DEPENDENCY", true));
60
1.03M
    sink_deps.back()->set_shared_state(this);
61
1.03M
    return sink_deps.back().get();
62
1.03M
}
63
64
4.32M
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.32M
    _blocked_task.push_back(task);
69
4.32M
}
70
71
25.2M
void Dependency::set_ready() {
72
25.2M
    if (_ready) {
73
21.8M
        return;
74
21.8M
    }
75
3.43M
    std::vector<std::weak_ptr<PipelineTask>> local_block_task {};
76
3.43M
    {
77
3.43M
        std::unique_lock<std::mutex> lc(_task_lock);
78
3.43M
        if (_ready) {
79
284
            return;
80
284
        }
81
3.43M
        _watcher.stop();
82
3.43M
        _ready = true;
83
3.43M
        local_block_task.swap(_blocked_task);
84
3.43M
    }
85
4.33M
    for (auto task : local_block_task) {
86
4.33M
        if (auto t = task.lock()) {
87
4.33M
            std::unique_lock<std::mutex> lc(_task_lock);
88
4.33M
            THROW_IF_ERROR(t->wake_up(this, lc));
89
4.33M
        }
90
4.33M
    }
91
3.43M
}
92
93
55.7M
Dependency* Dependency::is_blocked_by(std::shared_ptr<PipelineTask> task) {
94
55.7M
    std::unique_lock<std::mutex> lc(_task_lock);
95
55.7M
    auto ready = _ready.load();
96
55.7M
    if (!ready && task) {
97
4.33M
        _add_block_task(task);
98
4.33M
        start_watcher();
99
4.33M
        THROW_IF_ERROR(task->blocked(this, lc));
100
4.33M
    }
101
55.7M
    return ready ? nullptr : this;
102
55.7M
}
103
104
398k
std::string Dependency::debug_string(int indentation_level) {
105
398k
    fmt::memory_buffer debug_string_buffer;
106
398k
    fmt::format_to(debug_string_buffer, "{}{}: id={}, block task = {}, ready={}, _always_ready={}",
107
398k
                   std::string(indentation_level * 2, ' '), _name, _node_id, _blocked_task.size(),
108
398k
                   _ready, _always_ready);
109
398k
    return fmt::to_string(debug_string_buffer);
110
398k
}
111
112
782
std::string CountedFinishDependency::debug_string(int indentation_level) {
113
782
    fmt::memory_buffer debug_string_buffer;
114
782
    fmt::format_to(debug_string_buffer,
115
782
                   "{}{}: id={}, block_task={}, ready={}, _always_ready={}, count={}",
116
782
                   std::string(indentation_level * 2, ' '), _name, _node_id, _blocked_task.size(),
117
782
                   _ready, _always_ready, _counter);
118
782
    return fmt::to_string(debug_string_buffer);
119
782
}
120
121
577
void RuntimeFilterTimer::call_timeout() {
122
577
    _parent->set_ready();
123
577
}
124
125
79.5k
void RuntimeFilterTimer::call_ready() {
126
79.5k
    _parent->set_ready();
127
79.5k
}
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
20.7M
bool RuntimeFilterTimer::should_be_check_timeout() {
133
20.7M
    if (!_parent->ready() && !_local_runtime_filter_dependencies.empty()) {
134
958k
        bool all_ready = true;
135
958k
        for (auto& dep : _local_runtime_filter_dependencies) {
136
958k
            if (!dep->ready()) {
137
958k
                all_ready = false;
138
958k
                break;
139
958k
            }
140
958k
        }
141
958k
        if (all_ready) {
142
9
            _local_runtime_filter_dependencies.clear();
143
9
            _registration_time = MonotonicMillis();
144
9
        }
145
958k
        return all_ready;
146
958k
    }
147
19.7M
    return true;
148
20.7M
}
149
150
8
void RuntimeFilterTimerQueue::start() {
151
302k
    while (!_stop) {
152
302k
        std::unique_lock<std::mutex> lk(cv_m);
153
154
304k
        while (_que.empty() && !_stop) {
155
4.60k
            cv.wait_for(lk, std::chrono::seconds(3), [this] { return !_que.empty() || _stop; });
156
2.30k
        }
157
302k
        if (_stop) {
158
3
            break;
159
3
        }
160
302k
        {
161
302k
            std::unique_lock<std::mutex> lc(_que_lock);
162
302k
            std::list<std::shared_ptr<RuntimeFilterTimer>> new_que;
163
20.7M
            for (auto& it : _que) {
164
20.7M
                if (it.use_count() == 1) {
165
                    // `use_count == 1` means this runtime filter has been released
166
20.7M
                } else if (it->should_be_check_timeout()) {
167
19.7M
                    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
19.6M
                        int64_t ms_since_registration = MonotonicMillis() - it->registration_time();
170
19.6M
                        if (ms_since_registration > it->wait_time_ms()) {
171
577
                            it->call_timeout();
172
19.6M
                        } else {
173
19.6M
                            new_que.push_back(std::move(it));
174
19.6M
                        }
175
19.6M
                    }
176
19.7M
                } else {
177
958k
                    new_que.push_back(std::move(it));
178
958k
                }
179
20.7M
            }
180
302k
            new_que.swap(_que);
181
302k
        }
182
302k
        std::this_thread::sleep_for(std::chrono::milliseconds(interval));
183
302k
    }
184
8
    _shutdown = true;
185
8
}
186
187
340k
void LocalExchangeSharedState::sub_running_sink_operators() {
188
340k
    std::unique_lock<std::mutex> lc(le_lock);
189
340k
    if (exchanger->_running_sink_operators.fetch_sub(1) == 1) {
190
105k
        _set_always_ready();
191
105k
    }
192
340k
}
193
194
681k
void LocalExchangeSharedState::sub_running_source_operators() {
195
681k
    std::unique_lock<std::mutex> lc(le_lock);
196
681k
    if (exchanger->_running_source_operators.fetch_sub(1) == 1) {
197
105k
        _set_always_ready();
198
105k
        exchanger->finalize();
199
105k
    }
200
681k
}
201
202
105k
LocalExchangeSharedState::LocalExchangeSharedState(int num_instances) {
203
105k
    source_deps.resize(num_instances, nullptr);
204
105k
    mem_counters.resize(num_instances, nullptr);
205
105k
}
206
207
291
MutableColumns AggSharedState::_get_keys_hash_table() {
208
291
    return std::visit(
209
291
            Overload {[&](std::monostate& arg) {
210
0
                          throw doris::Exception(ErrorCode::INTERNAL_ERROR, "uninited hash table");
211
0
                          return MutableColumns();
212
0
                      },
213
291
                      [&](auto&& agg_method) -> MutableColumns {
214
291
                          MutableColumns key_columns;
215
1.00k
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
716
                              key_columns.emplace_back(
217
716
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
716
                          }
219
291
                          auto& data = *agg_method.hash_table;
220
291
                          bool has_null_key = data.has_null_key_data();
221
291
                          const auto size = data.size() - has_null_key;
222
291
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
291
                          std::vector<KeyType> keys(size);
224
225
291
                          uint32_t num_rows = 0;
226
291
                          auto iter = aggregate_data_container->begin();
227
291
                          {
228
5.81k
                              while (iter != aggregate_data_container->end()) {
229
5.52k
                                  keys[num_rows] = iter.get_key<KeyType>();
230
5.52k
                                  ++iter;
231
5.52k
                                  ++num_rows;
232
5.52k
                              }
233
291
                          }
234
291
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
291
                          if (has_null_key) {
236
2
                              key_columns[0]->insert_data(nullptr, 0);
237
2
                          }
238
291
                          return key_columns;
239
291
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS5_vEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISE_EESaISH_EEOT_
Line
Count
Source
213
32
                      [&](auto&& agg_method) -> MutableColumns {
214
32
                          MutableColumns key_columns;
215
160
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
128
                              key_columns.emplace_back(
217
128
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
128
                          }
219
32
                          auto& data = *agg_method.hash_table;
220
32
                          bool has_null_key = data.has_null_key_data();
221
32
                          const auto size = data.size() - has_null_key;
222
32
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
32
                          std::vector<KeyType> keys(size);
224
225
32
                          uint32_t num_rows = 0;
226
32
                          auto iter = aggregate_data_container->begin();
227
32
                          {
228
879
                              while (iter != aggregate_data_container->end()) {
229
847
                                  keys[num_rows] = iter.get_key<KeyType>();
230
847
                                  ++iter;
231
847
                                  ++num_rows;
232
847
                              }
233
32
                          }
234
32
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
32
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
32
                          return key_columns;
239
32
                      }},
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_
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISD_EESaISG_EEOT_
Line
Count
Source
213
4
                      [&](auto&& agg_method) -> MutableColumns {
214
4
                          MutableColumns key_columns;
215
8
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
4
                              key_columns.emplace_back(
217
4
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
4
                          }
219
4
                          auto& data = *agg_method.hash_table;
220
4
                          bool has_null_key = data.has_null_key_data();
221
4
                          const auto size = data.size() - has_null_key;
222
4
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
4
                          std::vector<KeyType> keys(size);
224
225
4
                          uint32_t num_rows = 0;
226
4
                          auto iter = aggregate_data_container->begin();
227
4
                          {
228
12
                              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
4
                          }
234
4
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
4
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
4
                          return key_columns;
239
4
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISD_EESaISG_EEOT_
Line
Count
Source
213
1
                      [&](auto&& agg_method) -> MutableColumns {
214
1
                          MutableColumns key_columns;
215
2
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
1
                              key_columns.emplace_back(
217
1
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
1
                          }
219
1
                          auto& data = *agg_method.hash_table;
220
1
                          bool has_null_key = data.has_null_key_data();
221
1
                          const auto size = data.size() - has_null_key;
222
1
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
1
                          std::vector<KeyType> keys(size);
224
225
1
                          uint32_t num_rows = 0;
226
1
                          auto iter = aggregate_data_container->begin();
227
1
                          {
228
6
                              while (iter != aggregate_data_container->end()) {
229
5
                                  keys[num_rows] = iter.get_key<KeyType>();
230
5
                                  ++iter;
231
5
                                  ++num_rows;
232
5
                              }
233
1
                          }
234
1
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
1
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
1
                          return key_columns;
239
1
                      }},
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
12
                              while (iter != aggregate_data_container->end()) {
229
6
                                  keys[num_rows] = iter.get_key<KeyType>();
230
6
                                  ++iter;
231
6
                                  ++num_rows;
232
6
                              }
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
7
                      [&](auto&& agg_method) -> MutableColumns {
214
7
                          MutableColumns key_columns;
215
14
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
7
                              key_columns.emplace_back(
217
7
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
7
                          }
219
7
                          auto& data = *agg_method.hash_table;
220
7
                          bool has_null_key = data.has_null_key_data();
221
7
                          const auto size = data.size() - has_null_key;
222
7
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
7
                          std::vector<KeyType> keys(size);
224
225
7
                          uint32_t num_rows = 0;
226
7
                          auto iter = aggregate_data_container->begin();
227
7
                          {
228
31
                              while (iter != aggregate_data_container->end()) {
229
24
                                  keys[num_rows] = iter.get_key<KeyType>();
230
24
                                  ++iter;
231
24
                                  ++num_rows;
232
24
                              }
233
7
                          }
234
7
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
7
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
7
                          return key_columns;
239
7
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIhNS_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberItNS_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
Line
Count
Source
213
16
                      [&](auto&& agg_method) -> MutableColumns {
214
16
                          MutableColumns key_columns;
215
32
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
16
                              key_columns.emplace_back(
217
16
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
16
                          }
219
16
                          auto& data = *agg_method.hash_table;
220
16
                          bool has_null_key = data.has_null_key_data();
221
16
                          const auto size = data.size() - has_null_key;
222
16
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
16
                          std::vector<KeyType> keys(size);
224
225
16
                          uint32_t num_rows = 0;
226
16
                          auto iter = aggregate_data_container->begin();
227
16
                          {
228
1.00k
                              while (iter != aggregate_data_container->end()) {
229
989
                                  keys[num_rows] = iter.get_key<KeyType>();
230
989
                                  ++iter;
231
989
                                  ++num_rows;
232
989
                              }
233
16
                          }
234
16
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
16
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
16
                          return key_columns;
239
16
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
Line
Count
Source
213
16
                      [&](auto&& agg_method) -> MutableColumns {
214
16
                          MutableColumns key_columns;
215
32
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
16
                              key_columns.emplace_back(
217
16
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
16
                          }
219
16
                          auto& data = *agg_method.hash_table;
220
16
                          bool has_null_key = data.has_null_key_data();
221
16
                          const auto size = data.size() - has_null_key;
222
16
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
16
                          std::vector<KeyType> keys(size);
224
225
16
                          uint32_t num_rows = 0;
226
16
                          auto iter = aggregate_data_container->begin();
227
16
                          {
228
675
                              while (iter != aggregate_data_container->end()) {
229
659
                                  keys[num_rows] = iter.get_key<KeyType>();
230
659
                                  ++iter;
231
659
                                  ++num_rows;
232
659
                              }
233
16
                          }
234
16
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
16
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
16
                          return key_columns;
239
16
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
Line
Count
Source
213
19
                      [&](auto&& agg_method) -> MutableColumns {
214
19
                          MutableColumns key_columns;
215
38
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
19
                              key_columns.emplace_back(
217
19
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
19
                          }
219
19
                          auto& data = *agg_method.hash_table;
220
19
                          bool has_null_key = data.has_null_key_data();
221
19
                          const auto size = data.size() - has_null_key;
222
19
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
19
                          std::vector<KeyType> keys(size);
224
225
19
                          uint32_t num_rows = 0;
226
19
                          auto iter = aggregate_data_container->begin();
227
19
                          {
228
71
                              while (iter != aggregate_data_container->end()) {
229
52
                                  keys[num_rows] = iter.get_key<KeyType>();
230
52
                                  ++iter;
231
52
                                  ++num_rows;
232
52
                              }
233
19
                          }
234
19
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
19
                          if (has_null_key) {
236
1
                              key_columns[0]->insert_data(nullptr, 0);
237
1
                          }
238
19
                          return key_columns;
239
19
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
Line
Count
Source
213
21
                      [&](auto&& agg_method) -> MutableColumns {
214
21
                          MutableColumns key_columns;
215
42
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
21
                              key_columns.emplace_back(
217
21
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
21
                          }
219
21
                          auto& data = *agg_method.hash_table;
220
21
                          bool has_null_key = data.has_null_key_data();
221
21
                          const auto size = data.size() - has_null_key;
222
21
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
21
                          std::vector<KeyType> keys(size);
224
225
21
                          uint32_t num_rows = 0;
226
21
                          auto iter = aggregate_data_container->begin();
227
21
                          {
228
955
                              while (iter != aggregate_data_container->end()) {
229
934
                                  keys[num_rows] = iter.get_key<KeyType>();
230
934
                                  ++iter;
231
934
                                  ++num_rows;
232
934
                              }
233
21
                          }
234
21
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
21
                          if (has_null_key) {
236
1
                              key_columns[0]->insert_data(nullptr, 0);
237
1
                          }
238
21
                          return key_columns;
239
21
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS7_Pc9HashCRC32IS7_EEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISK_EESaISN_EEOT_
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
169
                      [&](auto&& agg_method) -> MutableColumns {
214
169
                          MutableColumns key_columns;
215
667
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
498
                              key_columns.emplace_back(
217
498
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
498
                          }
219
169
                          auto& data = *agg_method.hash_table;
220
169
                          bool has_null_key = data.has_null_key_data();
221
169
                          const auto size = data.size() - has_null_key;
222
169
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
169
                          std::vector<KeyType> keys(size);
224
225
169
                          uint32_t num_rows = 0;
226
169
                          auto iter = aggregate_data_container->begin();
227
169
                          {
228
2.16k
                              while (iter != aggregate_data_container->end()) {
229
1.99k
                                  keys[num_rows] = iter.get_key<KeyType>();
230
1.99k
                                  ++iter;
231
1.99k
                                  ++num_rows;
232
1.99k
                              }
233
169
                          }
234
169
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
169
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
169
                          return key_columns;
239
169
                      }},
240
291
            agg_data->method_variant);
241
291
}
242
243
291
void AggSharedState::build_limit_heap(size_t hash_table_size) {
244
291
    limit_columns = _get_keys_hash_table();
245
5.81k
    for (size_t i = 0; i < hash_table_size; ++i) {
246
5.52k
        limit_heap.emplace(i, limit_columns, order_directions, null_directions);
247
5.52k
    }
248
4.95k
    while (hash_table_size > limit) {
249
4.66k
        limit_heap.pop();
250
4.66k
        hash_table_size--;
251
4.66k
    }
252
291
    limit_columns_min = limit_heap.top()._row_id;
253
291
}
254
255
bool AggSharedState::do_limit_filter(Block* block, size_t num_rows,
256
2.36k
                                     const std::vector<int>* key_locs) {
257
2.36k
    if (num_rows) {
258
2.36k
        cmp_res.resize(num_rows);
259
2.36k
        need_computes.resize(num_rows);
260
2.36k
        memset(need_computes.data(), 0, need_computes.size());
261
2.36k
        memset(cmp_res.data(), 0, cmp_res.size());
262
263
2.36k
        const auto key_size = null_directions.size();
264
8.45k
        for (int i = 0; i < key_size; i++) {
265
6.08k
            block->get_by_position(key_locs ? key_locs->operator[](i) : i)
266
6.08k
                    .column->compare_internal(limit_columns_min, *limit_columns[i],
267
6.08k
                                              null_directions[i], order_directions[i], cmp_res,
268
6.08k
                                              need_computes.data());
269
6.08k
        }
270
271
2.36k
        auto set_computes_arr = [](auto* __restrict res, auto* __restrict computes, size_t rows) {
272
498k
            for (size_t i = 0; i < rows; ++i) {
273
495k
                computes[i] = computes[i] == res[i];
274
495k
            }
275
2.36k
        };
276
2.36k
        set_computes_arr(cmp_res.data(), need_computes.data(), num_rows);
277
278
2.36k
        return std::find(need_computes.begin(), need_computes.end(), 0) != need_computes.end();
279
2.36k
    }
280
281
0
    return false;
282
2.36k
}
283
284
2.24k
Status AggSharedState::reset_hash_table() {
285
2.24k
    return std::visit(
286
2.24k
            Overload {[&](std::monostate& arg) -> Status {
287
0
                          return Status::InternalError("Uninited hash table");
288
0
                      },
289
2.24k
                      [&](auto& agg_method) {
290
2.24k
                          auto& hash_table = *agg_method.hash_table;
291
2.24k
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
2.24k
                          agg_method.arena.clear();
294
2.24k
                          agg_method.inited_iterator = false;
295
296
2.39M
                          hash_table.for_each_mapped([&](auto& mapped) {
297
2.39M
                              if (mapped) {
298
2.39M
                                  _destroy_agg_status(mapped);
299
2.39M
                                  mapped = nullptr;
300
2.39M
                              }
301
2.39M
                          });
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
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
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEDaRT_ENKUlSB_E_clIS5_EEDaSB_
Line
Count
Source
296
654
                          hash_table.for_each_mapped([&](auto& mapped) {
297
654
                              if (mapped) {
298
654
                                  _destroy_agg_status(mapped);
299
654
                                  mapped = nullptr;
300
654
                              }
301
654
                          });
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
236
                          hash_table.for_each_mapped([&](auto& mapped) {
297
236
                              if (mapped) {
298
236
                                  _destroy_agg_status(mapped);
299
236
                                  mapped = nullptr;
300
236
                              }
301
236
                          });
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
244
                          hash_table.for_each_mapped([&](auto& mapped) {
297
244
                              if (mapped) {
298
244
                                  _destroy_agg_status(mapped);
299
244
                                  mapped = nullptr;
300
244
                              }
301
244
                          });
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
702
                          hash_table.for_each_mapped([&](auto& mapped) {
297
702
                              if (mapped) {
298
702
                                  _destroy_agg_status(mapped);
299
702
                                  mapped = nullptr;
300
702
                              }
301
702
                          });
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIhNS_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberItNS_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Line
Count
Source
296
722k
                          hash_table.for_each_mapped([&](auto& mapped) {
297
722k
                              if (mapped) {
298
722k
                                  _destroy_agg_status(mapped);
299
722k
                                  mapped = nullptr;
300
722k
                              }
301
722k
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Line
Count
Source
296
236
                          hash_table.for_each_mapped([&](auto& mapped) {
297
236
                              if (mapped) {
298
236
                                  _destroy_agg_status(mapped);
299
236
                                  mapped = nullptr;
300
236
                              }
301
236
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEDaRT_ENKUlSH_E_clIS7_EEDaSH_
Line
Count
Source
296
615k
                          hash_table.for_each_mapped([&](auto& mapped) {
297
615k
                              if (mapped) {
298
615k
                                  _destroy_agg_status(mapped);
299
615k
                                  mapped = nullptr;
300
615k
                              }
301
615k
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEDaRT_ENKUlSH_E_clIS7_EEDaSH_
Line
Count
Source
296
784
                          hash_table.for_each_mapped([&](auto& mapped) {
297
784
                              if (mapped) {
298
784
                                  _destroy_agg_status(mapped);
299
784
                                  mapped = nullptr;
300
784
                              }
301
784
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS7_Pc9HashCRC32IS7_EEEEEEEEEEDaRT_ENKUlSI_E_clISA_EEDaSI_
Line
Count
Source
296
204
                          hash_table.for_each_mapped([&](auto& mapped) {
297
204
                              if (mapped) {
298
204
                                  _destroy_agg_status(mapped);
299
204
                                  mapped = nullptr;
300
204
                              }
301
204
                          });
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
2.24k
                          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
2.24k
                          aggregate_data_container.reset(new AggregateDataContainer(
309
2.24k
                                  sizeof(typename HashTableType::key_type),
310
2.24k
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
2.24k
                                   align_aggregate_states) *
312
2.24k
                                          align_aggregate_states));
313
2.24k
                          agg_method.hash_table.reset(new HashTableType());
314
2.24k
                          return Status::OK();
315
2.24k
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS5_vEEEEEEDaRT_
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEDaRT_
Line
Count
Source
289
92
                      [&](auto& agg_method) {
290
92
                          auto& hash_table = *agg_method.hash_table;
291
92
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
92
                          agg_method.arena.clear();
294
92
                          agg_method.inited_iterator = false;
295
296
92
                          hash_table.for_each_mapped([&](auto& mapped) {
297
92
                              if (mapped) {
298
92
                                  _destroy_agg_status(mapped);
299
92
                                  mapped = nullptr;
300
92
                              }
301
92
                          });
302
303
92
                          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
92
                          aggregate_data_container.reset(new AggregateDataContainer(
309
92
                                  sizeof(typename HashTableType::key_type),
310
92
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
92
                                   align_aggregate_states) *
312
92
                                          align_aggregate_states));
313
92
                          agg_method.hash_table.reset(new HashTableType());
314
92
                          return Status::OK();
315
92
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEDaRT_
Line
Count
Source
289
156
                      [&](auto& agg_method) {
290
156
                          auto& hash_table = *agg_method.hash_table;
291
156
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
156
                          agg_method.arena.clear();
294
156
                          agg_method.inited_iterator = false;
295
296
156
                          hash_table.for_each_mapped([&](auto& mapped) {
297
156
                              if (mapped) {
298
156
                                  _destroy_agg_status(mapped);
299
156
                                  mapped = nullptr;
300
156
                              }
301
156
                          });
302
303
156
                          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
156
                          aggregate_data_container.reset(new AggregateDataContainer(
309
156
                                  sizeof(typename HashTableType::key_type),
310
156
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
156
                                   align_aggregate_states) *
312
156
                                          align_aggregate_states));
313
156
                          agg_method.hash_table.reset(new HashTableType());
314
156
                          return Status::OK();
315
156
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEEDaRT_
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEEDaRT_
Line
Count
Source
289
66
                      [&](auto& agg_method) {
290
66
                          auto& hash_table = *agg_method.hash_table;
291
66
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
66
                          agg_method.arena.clear();
294
66
                          agg_method.inited_iterator = false;
295
296
66
                          hash_table.for_each_mapped([&](auto& mapped) {
297
66
                              if (mapped) {
298
66
                                  _destroy_agg_status(mapped);
299
66
                                  mapped = nullptr;
300
66
                              }
301
66
                          });
302
303
66
                          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
66
                          aggregate_data_container.reset(new AggregateDataContainer(
309
66
                                  sizeof(typename HashTableType::key_type),
310
66
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
66
                                   align_aggregate_states) *
312
66
                                          align_aggregate_states));
313
66
                          agg_method.hash_table.reset(new HashTableType());
314
66
                          return Status::OK();
315
66
                      }},
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
76
                      [&](auto& agg_method) {
290
76
                          auto& hash_table = *agg_method.hash_table;
291
76
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
76
                          agg_method.arena.clear();
294
76
                          agg_method.inited_iterator = false;
295
296
76
                          hash_table.for_each_mapped([&](auto& mapped) {
297
76
                              if (mapped) {
298
76
                                  _destroy_agg_status(mapped);
299
76
                                  mapped = nullptr;
300
76
                              }
301
76
                          });
302
303
76
                          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
76
                          aggregate_data_container.reset(new AggregateDataContainer(
309
76
                                  sizeof(typename HashTableType::key_type),
310
76
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
76
                                   align_aggregate_states) *
312
76
                                          align_aggregate_states));
313
76
                          agg_method.hash_table.reset(new HashTableType());
314
76
                          return Status::OK();
315
76
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS6_Pc9HashCRC32IS6_EEEEEEDaRT_
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEDaRT_
Line
Count
Source
289
161
                      [&](auto& agg_method) {
290
161
                          auto& hash_table = *agg_method.hash_table;
291
161
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
161
                          agg_method.arena.clear();
294
161
                          agg_method.inited_iterator = false;
295
296
161
                          hash_table.for_each_mapped([&](auto& mapped) {
297
161
                              if (mapped) {
298
161
                                  _destroy_agg_status(mapped);
299
161
                                  mapped = nullptr;
300
161
                              }
301
161
                          });
302
303
161
                          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
161
                          aggregate_data_container.reset(new AggregateDataContainer(
309
161
                                  sizeof(typename HashTableType::key_type),
310
161
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
161
                                   align_aggregate_states) *
312
161
                                          align_aggregate_states));
313
161
                          agg_method.hash_table.reset(new HashTableType());
314
161
                          return Status::OK();
315
161
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEDaRT_
Line
Count
Source
289
236
                      [&](auto& agg_method) {
290
236
                          auto& hash_table = *agg_method.hash_table;
291
236
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
236
                          agg_method.arena.clear();
294
236
                          agg_method.inited_iterator = false;
295
296
236
                          hash_table.for_each_mapped([&](auto& mapped) {
297
236
                              if (mapped) {
298
236
                                  _destroy_agg_status(mapped);
299
236
                                  mapped = nullptr;
300
236
                              }
301
236
                          });
302
303
236
                          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
236
                          aggregate_data_container.reset(new AggregateDataContainer(
309
236
                                  sizeof(typename HashTableType::key_type),
310
236
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
236
                                   align_aggregate_states) *
312
236
                                          align_aggregate_states));
313
236
                          agg_method.hash_table.reset(new HashTableType());
314
236
                          return Status::OK();
315
236
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIhNS_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberItNS_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEDaRT_
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEDaRT_
Line
Count
Source
289
466
                      [&](auto& agg_method) {
290
466
                          auto& hash_table = *agg_method.hash_table;
291
466
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
466
                          agg_method.arena.clear();
294
466
                          agg_method.inited_iterator = false;
295
296
466
                          hash_table.for_each_mapped([&](auto& mapped) {
297
466
                              if (mapped) {
298
466
                                  _destroy_agg_status(mapped);
299
466
                                  mapped = nullptr;
300
466
                              }
301
466
                          });
302
303
466
                          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
466
                          aggregate_data_container.reset(new AggregateDataContainer(
309
466
                                  sizeof(typename HashTableType::key_type),
310
466
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
466
                                   align_aggregate_states) *
312
466
                                          align_aggregate_states));
313
466
                          agg_method.hash_table.reset(new HashTableType());
314
466
                          return Status::OK();
315
466
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEDaRT_
Line
Count
Source
289
72
                      [&](auto& agg_method) {
290
72
                          auto& hash_table = *agg_method.hash_table;
291
72
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
72
                          agg_method.arena.clear();
294
72
                          agg_method.inited_iterator = false;
295
296
72
                          hash_table.for_each_mapped([&](auto& mapped) {
297
72
                              if (mapped) {
298
72
                                  _destroy_agg_status(mapped);
299
72
                                  mapped = nullptr;
300
72
                              }
301
72
                          });
302
303
72
                          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
72
                          aggregate_data_container.reset(new AggregateDataContainer(
309
72
                                  sizeof(typename HashTableType::key_type),
310
72
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
72
                                   align_aggregate_states) *
312
72
                                          align_aggregate_states));
313
72
                          agg_method.hash_table.reset(new HashTableType());
314
72
                          return Status::OK();
315
72
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEDaRT_
Line
Count
Source
289
585
                      [&](auto& agg_method) {
290
585
                          auto& hash_table = *agg_method.hash_table;
291
585
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
585
                          agg_method.arena.clear();
294
585
                          agg_method.inited_iterator = false;
295
296
585
                          hash_table.for_each_mapped([&](auto& mapped) {
297
585
                              if (mapped) {
298
585
                                  _destroy_agg_status(mapped);
299
585
                                  mapped = nullptr;
300
585
                              }
301
585
                          });
302
303
585
                          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
585
                          aggregate_data_container.reset(new AggregateDataContainer(
309
585
                                  sizeof(typename HashTableType::key_type),
310
585
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
585
                                   align_aggregate_states) *
312
585
                                          align_aggregate_states));
313
585
                          agg_method.hash_table.reset(new HashTableType());
314
585
                          return Status::OK();
315
585
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEDaRT_
Line
Count
Source
289
278
                      [&](auto& agg_method) {
290
278
                          auto& hash_table = *agg_method.hash_table;
291
278
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
278
                          agg_method.arena.clear();
294
278
                          agg_method.inited_iterator = false;
295
296
278
                          hash_table.for_each_mapped([&](auto& mapped) {
297
278
                              if (mapped) {
298
278
                                  _destroy_agg_status(mapped);
299
278
                                  mapped = nullptr;
300
278
                              }
301
278
                          });
302
303
278
                          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
278
                          aggregate_data_container.reset(new AggregateDataContainer(
309
278
                                  sizeof(typename HashTableType::key_type),
310
278
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
278
                                   align_aggregate_states) *
312
278
                                          align_aggregate_states));
313
278
                          agg_method.hash_table.reset(new HashTableType());
314
278
                          return Status::OK();
315
278
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS7_Pc9HashCRC32IS7_EEEEEEEEEEDaRT_
Line
Count
Source
289
56
                      [&](auto& agg_method) {
290
56
                          auto& hash_table = *agg_method.hash_table;
291
56
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
56
                          agg_method.arena.clear();
294
56
                          agg_method.inited_iterator = false;
295
296
56
                          hash_table.for_each_mapped([&](auto& mapped) {
297
56
                              if (mapped) {
298
56
                                  _destroy_agg_status(mapped);
299
56
                                  mapped = nullptr;
300
56
                              }
301
56
                          });
302
303
56
                          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
56
                          aggregate_data_container.reset(new AggregateDataContainer(
309
56
                                  sizeof(typename HashTableType::key_type),
310
56
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
56
                                   align_aggregate_states) *
312
56
                                          align_aggregate_states));
313
56
                          agg_method.hash_table.reset(new HashTableType());
314
56
                          return Status::OK();
315
56
                      }},
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
2.24k
            agg_data->method_variant);
317
2.24k
}
318
319
295
void PartitionedAggSharedState::init_spill_params(size_t spill_partition_count) {
320
295
    partition_count = spill_partition_count;
321
295
    max_partition_index = partition_count - 1;
322
323
9.73k
    for (int i = 0; i < partition_count; ++i) {
324
9.44k
        spill_partitions.emplace_back(std::make_shared<AggSpillPartition>());
325
9.44k
    }
326
295
}
327
328
283
void PartitionedAggSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {
329
9.05k
    for (auto& partition : spill_partitions) {
330
9.05k
        if (partition->spilling_stream_) {
331
0
            partition->spilling_stream_->update_shared_profiles(source_profile);
332
0
        }
333
9.05k
        for (auto& stream : partition->spill_streams_) {
334
1.25k
            if (stream) {
335
1.25k
                stream->update_shared_profiles(source_profile);
336
1.25k
            }
337
1.25k
        }
338
9.05k
    }
339
283
}
340
341
Status AggSpillPartition::get_spill_stream(RuntimeState* state, int node_id,
342
20.3k
                                           RuntimeProfile* profile, SpillStreamSPtr& spill_stream) {
343
20.3k
    if (spilling_stream_) {
344
18.9k
        spill_stream = spilling_stream_;
345
18.9k
        return Status::OK();
346
18.9k
    }
347
1.33k
    RETURN_IF_ERROR(ExecEnv::GetInstance()->spill_stream_mgr()->register_spill_stream(
348
1.33k
            state, spilling_stream_, print_id(state->query_id()), "agg", node_id,
349
1.33k
            std::numeric_limits<int32_t>::max(), std::numeric_limits<size_t>::max(), profile));
350
1.33k
    spill_streams_.emplace_back(spilling_stream_);
351
1.33k
    spill_stream = spilling_stream_;
352
1.33k
    return Status::OK();
353
1.33k
}
354
7.47k
void AggSpillPartition::close() {
355
7.47k
    if (spilling_stream_) {
356
1
        spilling_stream_.reset();
357
1
    }
358
7.47k
    for (auto& stream : spill_streams_) {
359
5
        (void)ExecEnv::GetInstance()->spill_stream_mgr()->delete_spill_stream(stream);
360
5
    }
361
7.47k
    spill_streams_.clear();
362
7.47k
}
363
364
302
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
302
    bool false_close = false;
368
302
    if (!is_closed.compare_exchange_strong(false_close, true)) {
369
15
        return;
370
15
    }
371
302
    DCHECK(!false_close && is_closed);
372
7.47k
    for (auto partition : spill_partitions) {
373
7.47k
        partition->close();
374
7.47k
    }
375
287
    spill_partitions.clear();
376
287
}
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
3.16k
                  std::make_unique<MultiCastDataStreamer>(pool, cast_sender_count, node_id)) {}
403
404
0
void MultiCastSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {}
405
406
109k
int AggSharedState::get_slot_column_id(const AggFnEvaluator* evaluator) {
407
109k
    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
109k
    return ((VSlotRef*)ctxs[0]->root().get())->column_id();
412
109k
}
413
414
3.80M
void AggSharedState::_destroy_agg_status(AggregateDataPtr data) {
415
9.21M
    for (int i = 0; i < aggregate_evaluators.size(); ++i) {
416
5.40M
        aggregate_evaluators[i]->function()->destroy(data + offsets_of_aggregate_states[i]);
417
5.40M
    }
418
3.80M
}
419
420
105k
LocalExchangeSharedState::~LocalExchangeSharedState() = default;
421
422
11.9k
Status SetSharedState::update_build_not_ignore_null(const VExprContextSPtrs& ctxs) {
423
11.9k
    if (ctxs.size() > build_not_ignore_null.size()) {
424
0
        return Status::InternalError("build_not_ignore_null not initialized");
425
0
    }
426
427
98.8k
    for (int i = 0; i < ctxs.size(); ++i) {
428
86.8k
        build_not_ignore_null[i] = build_not_ignore_null[i] || ctxs[i]->root()->is_nullable();
429
86.8k
    }
430
431
11.9k
    return Status::OK();
432
11.9k
}
433
434
19.3k
size_t SetSharedState::get_hash_table_size() const {
435
19.3k
    size_t hash_table_size = 0;
436
19.3k
    std::visit(
437
19.3k
            [&](auto&& arg) {
438
19.3k
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
19.3k
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
19.3k
                    hash_table_size = arg.hash_table->size();
441
19.3k
                }
442
19.3k
            },
Unexecuted instantiation: dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRSt9monostateEEDaOT_
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_16MethodSerializedI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS5_vEEEEEEDaOT_
Line
Count
Source
437
17.7k
            [&](auto&& arg) {
438
17.7k
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
17.7k
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
17.7k
                    hash_table_size = arg.hash_table->size();
441
17.7k
                }
442
17.7k
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_19MethodStringNoCacheI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS5_vEEEEEEDaOT_
Line
Count
Source
437
224
            [&](auto&& arg) {
438
224
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
224
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
224
                    hash_table_size = arg.hash_table->size();
441
224
                }
442
224
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_26MethodSingleNullableColumnINS_19MethodStringNoCacheINS_15DataWithNullKeyI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS7_vEEEEEEEEEEDaOT_
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_15MethodOneNumberIhNS_15DataWithNullKeyI9PHHashMapIhNS_14RowRefWithFlagE9HashCRC32IhEEEEEEEEEEDaOT_
Line
Count
Source
437
96
            [&](auto&& arg) {
438
96
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
96
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
96
                    hash_table_size = arg.hash_table->size();
441
96
                }
442
96
            },
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
573
            [&](auto&& arg) {
438
573
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
573
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
573
                    hash_table_size = arg.hash_table->size();
441
573
                }
442
573
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImNS_14RowRefWithFlagE9HashCRC32ImEEEEEEEEEEDaOT_
Line
Count
Source
437
121
            [&](auto&& arg) {
438
121
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
121
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
121
                    hash_table_size = arg.hash_table->size();
441
121
                }
442
121
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS7_NS_14RowRefWithFlagE9HashCRC32IS7_EEEEEEEEEEDaOT_
Line
Count
Source
437
84
            [&](auto&& arg) {
438
84
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
84
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
84
                    hash_table_size = arg.hash_table->size();
441
84
                }
442
84
            },
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
33
            [&](auto&& arg) {
438
33
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
33
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
33
                    hash_table_size = arg.hash_table->size();
441
33
                }
442
33
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodKeysFixedI9PHHashMapINS_6UInt96ENS_14RowRefWithFlagE9HashCRC32IS5_EEEEEEDaOT_
Line
Count
Source
437
42
            [&](auto&& arg) {
438
42
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
42
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
42
                    hash_table_size = arg.hash_table->size();
441
42
                }
442
42
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodKeysFixedI9PHHashMapINS_7UInt104ENS_14RowRefWithFlagE9HashCRC32IS5_EEEEEEDaOT_
Line
Count
Source
437
63
            [&](auto&& arg) {
438
63
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
63
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
63
                    hash_table_size = arg.hash_table->size();
441
63
                }
442
63
            },
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
86
            [&](auto&& arg) {
438
86
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
86
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
86
                    hash_table_size = arg.hash_table->size();
441
86
                }
442
86
            },
443
19.3k
            hash_table_variants->method_variant);
444
19.3k
    return hash_table_size;
445
19.3k
}
446
447
4.91k
Status SetSharedState::hash_table_init() {
448
4.91k
    std::vector<DataTypePtr> data_types;
449
40.1k
    for (size_t i = 0; i != child_exprs_lists[0].size(); ++i) {
450
35.2k
        auto& ctx = child_exprs_lists[0][i];
451
35.2k
        auto data_type = ctx->root()->data_type();
452
35.2k
        if (build_not_ignore_null[i]) {
453
34.9k
            data_type = make_nullable(data_type);
454
34.9k
        }
455
35.2k
        data_types.emplace_back(std::move(data_type));
456
35.2k
    }
457
4.91k
    return init_hash_method<SetDataVariants>(hash_table_variants.get(), data_types, true);
458
4.91k
}
459
460
4.58k
void AggSharedState::refresh_top_limit(size_t row_id, const ColumnRawPtrs& key_columns) {
461
10.0k
    for (int j = 0; j < key_columns.size(); ++j) {
462
5.42k
        limit_columns[j]->insert_from(*key_columns[j], row_id);
463
5.42k
    }
464
4.58k
    limit_heap.emplace(limit_columns[0]->size() - 1, limit_columns, order_directions,
465
4.58k
                       null_directions);
466
467
4.58k
    limit_heap.pop();
468
4.58k
    limit_columns_min = limit_heap.top()._row_id;
469
4.58k
}
470
471
} // namespace doris