Coverage Report

Created: 2026-03-14 13:33

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
522k
                                                       const std::string& name) {
43
522k
    source_deps.push_back(std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY"));
44
522k
    source_deps.back()->set_shared_state(this);
45
522k
    return source_deps.back().get();
46
522k
}
47
48
void BasicSharedState::create_source_dependencies(int num_sources, int operator_id, int node_id,
49
104k
                                                  const std::string& name) {
50
104k
    source_deps.resize(num_sources, nullptr);
51
745k
    for (auto& source_dep : source_deps) {
52
745k
        source_dep = std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY");
53
745k
        source_dep->set_shared_state(this);
54
745k
    }
55
104k
}
56
57
Dependency* BasicSharedState::create_sink_dependency(int dest_id, int node_id,
58
1.06M
                                                     const std::string& name) {
59
1.06M
    sink_deps.push_back(std::make_shared<Dependency>(dest_id, node_id, name + "_DEPENDENCY", true));
60
1.06M
    sink_deps.back()->set_shared_state(this);
61
1.06M
    return sink_deps.back().get();
62
1.06M
}
63
64
4.55M
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.55M
    _blocked_task.push_back(task);
69
4.55M
}
70
71
76.4M
void Dependency::set_ready() {
72
76.9M
    if (_ready) {
73
76.9M
        return;
74
76.9M
    }
75
18.4E
    std::vector<std::weak_ptr<PipelineTask>> local_block_task {};
76
18.4E
    {
77
18.4E
        std::unique_lock<std::mutex> lc(_task_lock);
78
18.4E
        if (_ready) {
79
1.20k
            return;
80
1.20k
        }
81
18.4E
        _watcher.stop();
82
18.4E
        _ready = true;
83
18.4E
        local_block_task.swap(_blocked_task);
84
18.4E
    }
85
4.56M
    for (auto task : local_block_task) {
86
4.56M
        if (auto t = task.lock()) {
87
4.56M
            std::unique_lock<std::mutex> lc(_task_lock);
88
4.56M
            THROW_IF_ERROR(t->wake_up(this, lc));
89
4.56M
        }
90
4.56M
    }
91
18.4E
}
92
93
47.7M
Dependency* Dependency::is_blocked_by(std::shared_ptr<PipelineTask> task) {
94
47.7M
    std::unique_lock<std::mutex> lc(_task_lock);
95
47.7M
    auto ready = _ready.load();
96
47.7M
    if (!ready && task) {
97
4.56M
        _add_block_task(task);
98
4.56M
        start_watcher();
99
4.56M
        THROW_IF_ERROR(task->blocked(this, lc));
100
4.56M
    }
101
47.7M
    return ready ? nullptr : this;
102
47.7M
}
103
104
383k
std::string Dependency::debug_string(int indentation_level) {
105
383k
    fmt::memory_buffer debug_string_buffer;
106
383k
    fmt::format_to(debug_string_buffer, "{}{}: id={}, block task = {}, ready={}, _always_ready={}",
107
383k
                   std::string(indentation_level * 2, ' '), _name, _node_id, _blocked_task.size(),
108
383k
                   _ready, _always_ready);
109
383k
    return fmt::to_string(debug_string_buffer);
110
383k
}
111
112
308
std::string CountedFinishDependency::debug_string(int indentation_level) {
113
308
    fmt::memory_buffer debug_string_buffer;
114
308
    fmt::format_to(debug_string_buffer,
115
308
                   "{}{}: id={}, block_task={}, ready={}, _always_ready={}, count={}",
116
308
                   std::string(indentation_level * 2, ' '), _name, _node_id, _blocked_task.size(),
117
308
                   _ready, _always_ready, _counter);
118
308
    return fmt::to_string(debug_string_buffer);
119
308
}
120
121
1.91k
void RuntimeFilterTimer::call_timeout() {
122
1.91k
    _parent->set_ready();
123
1.91k
}
124
125
75.1k
void RuntimeFilterTimer::call_ready() {
126
75.1k
    _parent->set_ready();
127
75.1k
}
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
11.0M
bool RuntimeFilterTimer::should_be_check_timeout() {
133
11.0M
    if (!_parent->ready() && !_local_runtime_filter_dependencies.empty()) {
134
344k
        bool all_ready = true;
135
344k
        for (auto& dep : _local_runtime_filter_dependencies) {
136
344k
            if (!dep->ready()) {
137
344k
                all_ready = false;
138
344k
                break;
139
344k
            }
140
344k
        }
141
344k
        if (all_ready) {
142
1
            _local_runtime_filter_dependencies.clear();
143
1
            _registration_time = MonotonicMillis();
144
1
        }
145
344k
        return all_ready;
146
344k
    }
147
10.6M
    return true;
148
11.0M
}
149
150
8
void RuntimeFilterTimerQueue::start() {
151
325k
    while (!_stop) {
152
325k
        std::unique_lock<std::mutex> lk(cv_m);
153
154
327k
        while (_que.empty() && !_stop) {
155
3.58k
            cv.wait_for(lk, std::chrono::seconds(3), [this] { return !_que.empty() || _stop; });
156
1.79k
        }
157
325k
        if (_stop) {
158
3
            break;
159
3
        }
160
325k
        {
161
325k
            std::unique_lock<std::mutex> lc(_que_lock);
162
325k
            std::list<std::shared_ptr<RuntimeFilterTimer>> new_que;
163
11.0M
            for (auto& it : _que) {
164
11.0M
                if (it.use_count() == 1) {
165
                    // `use_count == 1` means this runtime filter has been released
166
11.0M
                } else if (it->should_be_check_timeout()) {
167
10.6M
                    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
10.6M
                        int64_t ms_since_registration = MonotonicMillis() - it->registration_time();
170
10.6M
                        if (ms_since_registration > it->wait_time_ms()) {
171
1.91k
                            it->call_timeout();
172
10.6M
                        } else {
173
10.6M
                            new_que.push_back(std::move(it));
174
10.6M
                        }
175
10.6M
                    }
176
10.6M
                } else {
177
344k
                    new_que.push_back(std::move(it));
178
344k
                }
179
11.0M
            }
180
325k
            new_que.swap(_que);
181
325k
        }
182
325k
        std::this_thread::sleep_for(std::chrono::milliseconds(interval));
183
325k
    }
184
8
    _shutdown = true;
185
8
}
186
187
361k
void LocalExchangeSharedState::sub_running_sink_operators() {
188
361k
    std::unique_lock<std::mutex> lc(le_lock);
189
361k
    if (exchanger->_running_sink_operators.fetch_sub(1) == 1) {
190
99.9k
        _set_always_ready();
191
99.9k
    }
192
361k
}
193
194
726k
void LocalExchangeSharedState::sub_running_source_operators() {
195
726k
    std::unique_lock<std::mutex> lc(le_lock);
196
726k
    if (exchanger->_running_source_operators.fetch_sub(1) == 1) {
197
99.9k
        _set_always_ready();
198
99.9k
        exchanger->finalize();
199
99.9k
    }
200
726k
}
201
202
99.8k
LocalExchangeSharedState::LocalExchangeSharedState(int num_instances) {
203
99.8k
    source_deps.resize(num_instances, nullptr);
204
99.8k
    mem_counters.resize(num_instances, nullptr);
205
99.8k
}
206
207
75
MutableColumns AggSharedState::_get_keys_hash_table() {
208
75
    return std::visit(
209
75
            Overload {[&](std::monostate& arg) {
210
0
                          throw doris::Exception(ErrorCode::INTERNAL_ERROR, "uninited hash table");
211
0
                          return MutableColumns();
212
0
                      },
213
75
                      [&](auto&& agg_method) -> MutableColumns {
214
75
                          MutableColumns key_columns;
215
220
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
145
                              key_columns.emplace_back(
217
145
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
145
                          }
219
75
                          auto& data = *agg_method.hash_table;
220
75
                          bool has_null_key = data.has_null_key_data();
221
75
                          const auto size = data.size() - has_null_key;
222
75
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
75
                          std::vector<KeyType> keys(size);
224
225
75
                          uint32_t num_rows = 0;
226
75
                          auto iter = aggregate_data_container->begin();
227
75
                          {
228
13.0k
                              while (iter != aggregate_data_container->end()) {
229
12.9k
                                  keys[num_rows] = iter.get_key<KeyType>();
230
12.9k
                                  ++iter;
231
12.9k
                                  ++num_rows;
232
12.9k
                              }
233
75
                          }
234
75
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
75
                          if (has_null_key) {
236
2
                              key_columns[0]->insert_data(nullptr, 0);
237
2
                          }
238
75
                          return key_columns;
239
75
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS5_vEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISE_EESaISH_EEOT_
Line
Count
Source
213
5
                      [&](auto&& agg_method) -> MutableColumns {
214
5
                          MutableColumns key_columns;
215
25
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
20
                              key_columns.emplace_back(
217
20
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
20
                          }
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
4.13k
                              while (iter != aggregate_data_container->end()) {
229
4.12k
                                  keys[num_rows] = iter.get_key<KeyType>();
230
4.12k
                                  ++iter;
231
4.12k
                                  ++num_rows;
232
4.12k
                              }
233
5
                          }
234
5
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
5
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
5
                          return key_columns;
239
5
                      }},
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_
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISD_EESaISG_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
10
                              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
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_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
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
30
                              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
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_26MethodSingleNullableColumnINS_15MethodOneNumberIhNS_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
Line
Count
Source
213
3
                      [&](auto&& agg_method) -> MutableColumns {
214
3
                          MutableColumns key_columns;
215
6
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
3
                              key_columns.emplace_back(
217
3
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
3
                          }
219
3
                          auto& data = *agg_method.hash_table;
220
3
                          bool has_null_key = data.has_null_key_data();
221
3
                          const auto size = data.size() - has_null_key;
222
3
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
3
                          std::vector<KeyType> keys(size);
224
225
3
                          uint32_t num_rows = 0;
226
3
                          auto iter = aggregate_data_container->begin();
227
3
                          {
228
13
                              while (iter != aggregate_data_container->end()) {
229
10
                                  keys[num_rows] = iter.get_key<KeyType>();
230
10
                                  ++iter;
231
10
                                  ++num_rows;
232
10
                              }
233
3
                          }
234
3
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
3
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
3
                          return key_columns;
239
3
                      }},
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
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
1.63k
                              while (iter != aggregate_data_container->end()) {
229
1.62k
                                  keys[num_rows] = iter.get_key<KeyType>();
230
1.62k
                                  ++iter;
231
1.62k
                                  ++num_rows;
232
1.62k
                              }
233
7
                          }
234
7
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
7
                          if (has_null_key) {
236
1
                              key_columns[0]->insert_data(nullptr, 0);
237
1
                          }
238
7
                          return key_columns;
239
7
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
Line
Count
Source
213
15
                      [&](auto&& agg_method) -> MutableColumns {
214
15
                          MutableColumns key_columns;
215
30
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
15
                              key_columns.emplace_back(
217
15
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
15
                          }
219
15
                          auto& data = *agg_method.hash_table;
220
15
                          bool has_null_key = data.has_null_key_data();
221
15
                          const auto size = data.size() - has_null_key;
222
15
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
15
                          std::vector<KeyType> keys(size);
224
225
15
                          uint32_t num_rows = 0;
226
15
                          auto iter = aggregate_data_container->begin();
227
15
                          {
228
4.91k
                              while (iter != aggregate_data_container->end()) {
229
4.89k
                                  keys[num_rows] = iter.get_key<KeyType>();
230
4.89k
                                  ++iter;
231
4.89k
                                  ++num_rows;
232
4.89k
                              }
233
15
                          }
234
15
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
15
                          if (has_null_key) {
236
1
                              key_columns[0]->insert_data(nullptr, 0);
237
1
                          }
238
15
                          return key_columns;
239
15
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS7_Pc9HashCRC32IS7_EEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISK_EESaISN_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
4
                              while (iter != aggregate_data_container->end()) {
229
3
                                  keys[num_rows] = iter.get_key<KeyType>();
230
3
                                  ++iter;
231
3
                                  ++num_rows;
232
3
                              }
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_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
30
                      [&](auto&& agg_method) -> MutableColumns {
214
30
                          MutableColumns key_columns;
215
115
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
85
                              key_columns.emplace_back(
217
85
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
85
                          }
219
30
                          auto& data = *agg_method.hash_table;
220
30
                          bool has_null_key = data.has_null_key_data();
221
30
                          const auto size = data.size() - has_null_key;
222
30
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
30
                          std::vector<KeyType> keys(size);
224
225
30
                          uint32_t num_rows = 0;
226
30
                          auto iter = aggregate_data_container->begin();
227
30
                          {
228
2.26k
                              while (iter != aggregate_data_container->end()) {
229
2.23k
                                  keys[num_rows] = iter.get_key<KeyType>();
230
2.23k
                                  ++iter;
231
2.23k
                                  ++num_rows;
232
2.23k
                              }
233
30
                          }
234
30
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
30
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
30
                          return key_columns;
239
30
                      }},
240
75
            agg_data->method_variant);
241
75
}
242
243
75
void AggSharedState::build_limit_heap(size_t hash_table_size) {
244
75
    limit_columns = _get_keys_hash_table();
245
13.1k
    for (size_t i = 0; i < hash_table_size; ++i) {
246
13.0k
        limit_heap.emplace(i, limit_columns, order_directions, null_directions);
247
13.0k
    }
248
12.9k
    while (hash_table_size > limit) {
249
12.9k
        limit_heap.pop();
250
12.9k
        hash_table_size--;
251
12.9k
    }
252
75
    limit_columns_min = limit_heap.top()._row_id;
253
75
}
254
255
bool AggSharedState::do_limit_filter(Block* block, size_t num_rows,
256
294
                                     const std::vector<int>* key_locs) {
257
294
    if (num_rows) {
258
294
        cmp_res.resize(num_rows);
259
294
        need_computes.resize(num_rows);
260
294
        memset(need_computes.data(), 0, need_computes.size());
261
294
        memset(cmp_res.data(), 0, cmp_res.size());
262
263
294
        const auto key_size = null_directions.size();
264
938
        for (int i = 0; i < key_size; i++) {
265
644
            block->get_by_position(key_locs ? key_locs->operator[](i) : i)
266
644
                    .column->compare_internal(limit_columns_min, *limit_columns[i],
267
644
                                              null_directions[i], order_directions[i], cmp_res,
268
644
                                              need_computes.data());
269
644
        }
270
271
294
        auto set_computes_arr = [](auto* __restrict res, auto* __restrict computes, size_t rows) {
272
76.9k
            for (size_t i = 0; i < rows; ++i) {
273
76.6k
                computes[i] = computes[i] == res[i];
274
76.6k
            }
275
294
        };
276
294
        set_computes_arr(cmp_res.data(), need_computes.data(), num_rows);
277
278
294
        return std::find(need_computes.begin(), need_computes.end(), 0) != need_computes.end();
279
294
    }
280
281
0
    return false;
282
294
}
283
284
3.34k
Status AggSharedState::reset_hash_table() {
285
3.34k
    return std::visit(
286
3.34k
            Overload {[&](std::monostate& arg) -> Status {
287
0
                          return Status::InternalError("Uninited hash table");
288
0
                      },
289
3.34k
                      [&](auto& agg_method) {
290
3.34k
                          auto& hash_table = *agg_method.hash_table;
291
3.34k
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
3.34k
                          agg_method.arena.clear();
294
3.34k
                          agg_method.inited_iterator = false;
295
296
1.05M
                          hash_table.for_each_mapped([&](auto& mapped) {
297
1.05M
                              if (mapped) {
298
1.05M
                                  _destroy_agg_status(mapped);
299
1.05M
                                  mapped = nullptr;
300
1.05M
                              }
301
1.05M
                          });
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS5_vEEEEEEDaRT_ENKUlSC_E_clIS6_EEDaSC_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEDaRT_ENKUlSB_E_clIS5_EEDaSB_
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
476
                          hash_table.for_each_mapped([&](auto& mapped) {
297
476
                              if (mapped) {
298
476
                                  _destroy_agg_status(mapped);
299
476
                                  mapped = nullptr;
300
476
                              }
301
476
                          });
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
766
                          hash_table.for_each_mapped([&](auto& mapped) {
297
766
                              if (mapped) {
298
766
                                  _destroy_agg_status(mapped);
299
766
                                  mapped = nullptr;
300
766
                              }
301
766
                          });
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.05M
                          hash_table.for_each_mapped([&](auto& mapped) {
297
1.05M
                              if (mapped) {
298
1.05M
                                  _destroy_agg_status(mapped);
299
1.05M
                                  mapped = nullptr;
300
1.05M
                              }
301
1.05M
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEDaRT_ENKUlSD_E_clIS5_EEDaSD_
Line
Count
Source
296
2.27k
                          hash_table.for_each_mapped([&](auto& mapped) {
297
2.27k
                              if (mapped) {
298
2.27k
                                  _destroy_agg_status(mapped);
299
2.27k
                                  mapped = nullptr;
300
2.27k
                              }
301
2.27k
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIhNS_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Line
Count
Source
296
628
                          hash_table.for_each_mapped([&](auto& mapped) {
297
628
                              if (mapped) {
298
628
                                  _destroy_agg_status(mapped);
299
628
                                  mapped = nullptr;
300
628
                              }
301
628
                          });
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
388
                          hash_table.for_each_mapped([&](auto& mapped) {
297
388
                              if (mapped) {
298
388
                                  _destroy_agg_status(mapped);
299
388
                                  mapped = nullptr;
300
388
                              }
301
388
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Line
Count
Source
296
270
                          hash_table.for_each_mapped([&](auto& mapped) {
297
270
                              if (mapped) {
298
270
                                  _destroy_agg_status(mapped);
299
270
                                  mapped = nullptr;
300
270
                              }
301
270
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEDaRT_ENKUlSH_E_clIS7_EEDaSH_
Line
Count
Source
296
1.24k
                          hash_table.for_each_mapped([&](auto& mapped) {
297
1.24k
                              if (mapped) {
298
1.24k
                                  _destroy_agg_status(mapped);
299
1.24k
                                  mapped = nullptr;
300
1.24k
                              }
301
1.24k
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEDaRT_ENKUlSH_E_clIS7_EEDaSH_
Line
Count
Source
296
1.33k
                          hash_table.for_each_mapped([&](auto& mapped) {
297
1.33k
                              if (mapped) {
298
1.33k
                                  _destroy_agg_status(mapped);
299
1.33k
                                  mapped = nullptr;
300
1.33k
                              }
301
1.33k
                          });
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
3.34k
                          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
3.34k
                          aggregate_data_container.reset(new AggregateDataContainer(
309
3.34k
                                  sizeof(typename HashTableType::key_type),
310
3.34k
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
3.34k
                                   align_aggregate_states) *
312
3.34k
                                          align_aggregate_states));
313
3.34k
                          agg_method.hash_table.reset(new HashTableType());
314
3.34k
                          return Status::OK();
315
3.34k
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS5_vEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEDaRT_
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
144
                      [&](auto& agg_method) {
290
144
                          auto& hash_table = *agg_method.hash_table;
291
144
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
144
                          agg_method.arena.clear();
294
144
                          agg_method.inited_iterator = false;
295
296
144
                          hash_table.for_each_mapped([&](auto& mapped) {
297
144
                              if (mapped) {
298
144
                                  _destroy_agg_status(mapped);
299
144
                                  mapped = nullptr;
300
144
                              }
301
144
                          });
302
303
144
                          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
144
                          aggregate_data_container.reset(new AggregateDataContainer(
309
144
                                  sizeof(typename HashTableType::key_type),
310
144
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
144
                                   align_aggregate_states) *
312
144
                                          align_aggregate_states));
313
144
                          agg_method.hash_table.reset(new HashTableType());
314
144
                          return Status::OK();
315
144
                      }},
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
220
                      [&](auto& agg_method) {
290
220
                          auto& hash_table = *agg_method.hash_table;
291
220
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
220
                          agg_method.arena.clear();
294
220
                          agg_method.inited_iterator = false;
295
296
220
                          hash_table.for_each_mapped([&](auto& mapped) {
297
220
                              if (mapped) {
298
220
                                  _destroy_agg_status(mapped);
299
220
                                  mapped = nullptr;
300
220
                              }
301
220
                          });
302
303
220
                          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
220
                          aggregate_data_container.reset(new AggregateDataContainer(
309
220
                                  sizeof(typename HashTableType::key_type),
310
220
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
220
                                   align_aggregate_states) *
312
220
                                          align_aggregate_states));
313
220
                          agg_method.hash_table.reset(new HashTableType());
314
220
                          return Status::OK();
315
220
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS6_Pc9HashCRC32IS6_EEEEEEDaRT_
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEDaRT_
Line
Count
Source
289
611
                      [&](auto& agg_method) {
290
611
                          auto& hash_table = *agg_method.hash_table;
291
611
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
611
                          agg_method.arena.clear();
294
611
                          agg_method.inited_iterator = false;
295
296
611
                          hash_table.for_each_mapped([&](auto& mapped) {
297
611
                              if (mapped) {
298
611
                                  _destroy_agg_status(mapped);
299
611
                                  mapped = nullptr;
300
611
                              }
301
611
                          });
302
303
611
                          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
611
                          aggregate_data_container.reset(new AggregateDataContainer(
309
611
                                  sizeof(typename HashTableType::key_type),
310
611
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
611
                                   align_aggregate_states) *
312
611
                                          align_aggregate_states));
313
611
                          agg_method.hash_table.reset(new HashTableType());
314
611
                          return Status::OK();
315
611
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEDaRT_
Line
Count
Source
289
754
                      [&](auto& agg_method) {
290
754
                          auto& hash_table = *agg_method.hash_table;
291
754
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
754
                          agg_method.arena.clear();
294
754
                          agg_method.inited_iterator = false;
295
296
754
                          hash_table.for_each_mapped([&](auto& mapped) {
297
754
                              if (mapped) {
298
754
                                  _destroy_agg_status(mapped);
299
754
                                  mapped = nullptr;
300
754
                              }
301
754
                          });
302
303
754
                          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
754
                          aggregate_data_container.reset(new AggregateDataContainer(
309
754
                                  sizeof(typename HashTableType::key_type),
310
754
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
754
                                   align_aggregate_states) *
312
754
                                          align_aggregate_states));
313
754
                          agg_method.hash_table.reset(new HashTableType());
314
754
                          return Status::OK();
315
754
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIhNS_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEDaRT_
Line
Count
Source
289
266
                      [&](auto& agg_method) {
290
266
                          auto& hash_table = *agg_method.hash_table;
291
266
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
266
                          agg_method.arena.clear();
294
266
                          agg_method.inited_iterator = false;
295
296
266
                          hash_table.for_each_mapped([&](auto& mapped) {
297
266
                              if (mapped) {
298
266
                                  _destroy_agg_status(mapped);
299
266
                                  mapped = nullptr;
300
266
                              }
301
266
                          });
302
303
266
                          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
266
                          aggregate_data_container.reset(new AggregateDataContainer(
309
266
                                  sizeof(typename HashTableType::key_type),
310
266
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
266
                                   align_aggregate_states) *
312
266
                                          align_aggregate_states));
313
266
                          agg_method.hash_table.reset(new HashTableType());
314
266
                          return Status::OK();
315
266
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberItNS_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEDaRT_
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEDaRT_
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
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEDaRT_
Line
Count
Source
289
79
                      [&](auto& agg_method) {
290
79
                          auto& hash_table = *agg_method.hash_table;
291
79
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
79
                          agg_method.arena.clear();
294
79
                          agg_method.inited_iterator = false;
295
296
79
                          hash_table.for_each_mapped([&](auto& mapped) {
297
79
                              if (mapped) {
298
79
                                  _destroy_agg_status(mapped);
299
79
                                  mapped = nullptr;
300
79
                              }
301
79
                          });
302
303
79
                          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
79
                          aggregate_data_container.reset(new AggregateDataContainer(
309
79
                                  sizeof(typename HashTableType::key_type),
310
79
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
79
                                   align_aggregate_states) *
312
79
                                          align_aggregate_states));
313
79
                          agg_method.hash_table.reset(new HashTableType());
314
79
                          return Status::OK();
315
79
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEDaRT_
Line
Count
Source
289
374
                      [&](auto& agg_method) {
290
374
                          auto& hash_table = *agg_method.hash_table;
291
374
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
374
                          agg_method.arena.clear();
294
374
                          agg_method.inited_iterator = false;
295
296
374
                          hash_table.for_each_mapped([&](auto& mapped) {
297
374
                              if (mapped) {
298
374
                                  _destroy_agg_status(mapped);
299
374
                                  mapped = nullptr;
300
374
                              }
301
374
                          });
302
303
374
                          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
374
                          aggregate_data_container.reset(new AggregateDataContainer(
309
374
                                  sizeof(typename HashTableType::key_type),
310
374
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
374
                                   align_aggregate_states) *
312
374
                                          align_aggregate_states));
313
374
                          agg_method.hash_table.reset(new HashTableType());
314
374
                          return Status::OK();
315
374
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEDaRT_
Line
Count
Source
289
459
                      [&](auto& agg_method) {
290
459
                          auto& hash_table = *agg_method.hash_table;
291
459
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
459
                          agg_method.arena.clear();
294
459
                          agg_method.inited_iterator = false;
295
296
459
                          hash_table.for_each_mapped([&](auto& mapped) {
297
459
                              if (mapped) {
298
459
                                  _destroy_agg_status(mapped);
299
459
                                  mapped = nullptr;
300
459
                              }
301
459
                          });
302
303
459
                          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
459
                          aggregate_data_container.reset(new AggregateDataContainer(
309
459
                                  sizeof(typename HashTableType::key_type),
310
459
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
459
                                   align_aggregate_states) *
312
459
                                          align_aggregate_states));
313
459
                          agg_method.hash_table.reset(new HashTableType());
314
459
                          return Status::OK();
315
459
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS7_Pc9HashCRC32IS7_EEEEEEEEEEDaRT_
Line
Count
Source
289
210
                      [&](auto& agg_method) {
290
210
                          auto& hash_table = *agg_method.hash_table;
291
210
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
210
                          agg_method.arena.clear();
294
210
                          agg_method.inited_iterator = false;
295
296
210
                          hash_table.for_each_mapped([&](auto& mapped) {
297
210
                              if (mapped) {
298
210
                                  _destroy_agg_status(mapped);
299
210
                                  mapped = nullptr;
300
210
                              }
301
210
                          });
302
303
210
                          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
210
                          aggregate_data_container.reset(new AggregateDataContainer(
309
210
                                  sizeof(typename HashTableType::key_type),
310
210
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
210
                                   align_aggregate_states) *
312
210
                                          align_aggregate_states));
313
210
                          agg_method.hash_table.reset(new HashTableType());
314
210
                          return Status::OK();
315
210
                      }},
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
3.34k
            agg_data->method_variant);
317
3.34k
}
318
319
362
void PartitionedAggSharedState::init_spill_params(size_t spill_partition_count) {
320
362
    partition_count = spill_partition_count;
321
362
    max_partition_index = partition_count - 1;
322
323
11.9k
    for (int i = 0; i < partition_count; ++i) {
324
11.5k
        spill_partitions.emplace_back(std::make_shared<AggSpillPartition>());
325
11.5k
    }
326
362
}
327
328
350
void PartitionedAggSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {
329
11.2k
    for (auto& partition : spill_partitions) {
330
11.2k
        if (partition->spilling_stream_) {
331
0
            partition->spilling_stream_->update_shared_profiles(source_profile);
332
0
        }
333
11.2k
        for (auto& stream : partition->spill_streams_) {
334
2.43k
            if (stream) {
335
2.43k
                stream->update_shared_profiles(source_profile);
336
2.43k
            }
337
2.43k
        }
338
11.2k
    }
339
350
}
340
341
Status AggSpillPartition::get_spill_stream(RuntimeState* state, int node_id,
342
4.99k
                                           RuntimeProfile* profile, SpillStreamSPtr& spill_stream) {
343
4.99k
    if (spilling_stream_) {
344
2.49k
        spill_stream = spilling_stream_;
345
2.49k
        return Status::OK();
346
2.49k
    }
347
2.50k
    RETURN_IF_ERROR(ExecEnv::GetInstance()->spill_stream_mgr()->register_spill_stream(
348
2.50k
            state, spilling_stream_, print_id(state->query_id()), "agg", node_id,
349
2.50k
            std::numeric_limits<int32_t>::max(), std::numeric_limits<size_t>::max(), profile));
350
2.50k
    spill_streams_.emplace_back(spilling_stream_);
351
2.50k
    spill_stream = spilling_stream_;
352
2.50k
    return Status::OK();
353
2.50k
}
354
7.91k
void AggSpillPartition::close() {
355
7.91k
    if (spilling_stream_) {
356
1
        spilling_stream_.reset();
357
1
    }
358
7.91k
    for (auto& stream : spill_streams_) {
359
5
        (void)ExecEnv::GetInstance()->spill_stream_mgr()->delete_spill_stream(stream);
360
5
    }
361
7.91k
    spill_streams_.clear();
362
7.91k
}
363
364
394
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
394
    bool false_close = false;
368
394
    if (!is_closed.compare_exchange_strong(false_close, true)) {
369
39
        return;
370
39
    }
371
394
    DCHECK(!false_close && is_closed);
372
7.91k
    for (auto partition : spill_partitions) {
373
7.91k
        partition->close();
374
7.91k
    }
375
355
    spill_partitions.clear();
376
355
}
377
378
21
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
21
}
385
386
23
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
23
    bool false_close = false;
390
23
    if (!is_closed.compare_exchange_strong(false_close, true)) {
391
1
        return;
392
1
    }
393
23
    DCHECK(!false_close && is_closed);
394
22
    for (auto& stream : sorted_streams) {
395
1
        (void)ExecEnv::GetInstance()->spill_stream_mgr()->delete_spill_stream(stream);
396
1
    }
397
22
    sorted_streams.clear();
398
22
}
399
400
MultiCastSharedState::MultiCastSharedState(ObjectPool* pool, int cast_sender_count, int node_id)
401
        : multi_cast_data_streamer(
402
2.19k
                  std::make_unique<MultiCastDataStreamer>(pool, cast_sender_count, node_id)) {}
403
404
0
void MultiCastSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {}
405
406
110k
int AggSharedState::get_slot_column_id(const AggFnEvaluator* evaluator) {
407
110k
    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
110k
    return ((VSlotRef*)ctxs[0]->root().get())->column_id();
412
110k
}
413
414
2.50M
void AggSharedState::_destroy_agg_status(AggregateDataPtr data) {
415
5.39M
    for (int i = 0; i < aggregate_evaluators.size(); ++i) {
416
2.88M
        aggregate_evaluators[i]->function()->destroy(data + offsets_of_aggregate_states[i]);
417
2.88M
    }
418
2.50M
}
419
420
99.9k
LocalExchangeSharedState::~LocalExchangeSharedState() = default;
421
422
11.7k
Status SetSharedState::update_build_not_ignore_null(const VExprContextSPtrs& ctxs) {
423
11.7k
    if (ctxs.size() > build_not_ignore_null.size()) {
424
0
        return Status::InternalError("build_not_ignore_null not initialized");
425
0
    }
426
427
98.3k
    for (int i = 0; i < ctxs.size(); ++i) {
428
86.5k
        build_not_ignore_null[i] = build_not_ignore_null[i] || ctxs[i]->root()->is_nullable();
429
86.5k
    }
430
431
11.7k
    return Status::OK();
432
11.7k
}
433
434
19.0k
size_t SetSharedState::get_hash_table_size() const {
435
19.0k
    size_t hash_table_size = 0;
436
19.0k
    std::visit(
437
19.0k
            [&](auto&& arg) {
438
19.0k
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
19.0k
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
19.0k
                    hash_table_size = arg.hash_table->size();
441
19.0k
                }
442
19.0k
            },
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.8k
            [&](auto&& arg) {
438
17.8k
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
17.8k
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
17.8k
                    hash_table_size = arg.hash_table->size();
441
17.8k
                }
442
17.8k
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_19MethodStringNoCacheI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS5_vEEEEEEDaOT_
Line
Count
Source
437
166
            [&](auto&& arg) {
438
166
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
166
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
166
                    hash_table_size = arg.hash_table->size();
441
166
                }
442
166
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_26MethodSingleNullableColumnINS_19MethodStringNoCacheINS_15DataWithNullKeyI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS7_vEEEEEEEEEEDaOT_
Line
Count
Source
437
79
            [&](auto&& arg) {
438
79
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
79
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
79
                    hash_table_size = arg.hash_table->size();
441
79
                }
442
79
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIhNS_15DataWithNullKeyI9PHHashMapIhNS_14RowRefWithFlagE9HashCRC32IhEEEEEEEEEEDaOT_
Line
Count
Source
437
54
            [&](auto&& arg) {
438
54
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
54
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
54
                    hash_table_size = arg.hash_table->size();
441
54
                }
442
54
            },
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
247
            [&](auto&& arg) {
438
247
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
247
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
247
                    hash_table_size = arg.hash_table->size();
441
247
                }
442
247
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImNS_14RowRefWithFlagE9HashCRC32ImEEEEEEEEEEDaOT_
Line
Count
Source
437
254
            [&](auto&& arg) {
438
254
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
254
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
254
                    hash_table_size = arg.hash_table->size();
441
254
                }
442
254
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS7_NS_14RowRefWithFlagE9HashCRC32IS7_EEEEEEEEEEDaOT_
Line
Count
Source
437
72
            [&](auto&& arg) {
438
72
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
72
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
72
                    hash_table_size = arg.hash_table->size();
441
72
                }
442
72
            },
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
27
            [&](auto&& arg) {
438
27
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
27
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
27
                    hash_table_size = arg.hash_table->size();
441
27
                }
442
27
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodKeysFixedI9PHHashMapINS_6UInt72ENS_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_6UInt96ENS_14RowRefWithFlagE9HashCRC32IS5_EEEEEEDaOT_
Line
Count
Source
437
24
            [&](auto&& arg) {
438
24
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
24
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
24
                    hash_table_size = arg.hash_table->size();
441
24
                }
442
24
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodKeysFixedI9PHHashMapINS_7UInt104ENS_14RowRefWithFlagE9HashCRC32IS5_EEEEEEDaOT_
Line
Count
Source
437
27
            [&](auto&& arg) {
438
27
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
27
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
27
                    hash_table_size = arg.hash_table->size();
441
27
                }
442
27
            },
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.0k
            hash_table_variants->method_variant);
444
19.0k
    return hash_table_size;
445
19.0k
}
446
447
4.92k
Status SetSharedState::hash_table_init() {
448
4.92k
    std::vector<DataTypePtr> data_types;
449
40.2k
    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
35.0k
            data_type = make_nullable(data_type);
454
35.0k
        }
455
35.2k
        data_types.emplace_back(std::move(data_type));
456
35.2k
    }
457
4.92k
    return init_hash_method<SetDataVariants>(hash_table_variants.get(), data_types, true);
458
4.92k
}
459
460
1.08k
void AggSharedState::refresh_top_limit(size_t row_id, const ColumnRawPtrs& key_columns) {
461
2.24k
    for (int j = 0; j < key_columns.size(); ++j) {
462
1.15k
        limit_columns[j]->insert_from(*key_columns[j], row_id);
463
1.15k
    }
464
1.08k
    limit_heap.emplace(limit_columns[0]->size() - 1, limit_columns, order_directions,
465
1.08k
                       null_directions);
466
467
1.08k
    limit_heap.pop();
468
1.08k
    limit_columns_min = limit_heap.top()._row_id;
469
1.08k
}
470
471
} // namespace doris