Coverage Report

Created: 2026-04-10 05:08

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/operator/multi_cast_data_streamer.h"
25
#include "exec/pipeline/pipeline_fragment_context.h"
26
#include "exec/pipeline/pipeline_task.h"
27
#include "exec/spill/spill_file_manager.h"
28
#include "exprs/vectorized_agg_fn.h"
29
#include "exprs/vslot_ref.h"
30
#include "runtime/exec_env.h"
31
32
namespace doris {
33
#include "common/compile_check_begin.h"
34
35
Dependency* BasicSharedState::create_source_dependency(int operator_id, int node_id,
36
426k
                                                       const std::string& name) {
37
426k
    source_deps.push_back(std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY"));
38
426k
    source_deps.back()->set_shared_state(this);
39
426k
    return source_deps.back().get();
40
426k
}
41
42
void BasicSharedState::create_source_dependencies(int num_sources, int operator_id, int node_id,
43
105k
                                                  const std::string& name) {
44
105k
    source_deps.resize(num_sources, nullptr);
45
742k
    for (auto& source_dep : source_deps) {
46
742k
        source_dep = std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY");
47
742k
        source_dep->set_shared_state(this);
48
742k
    }
49
105k
}
50
51
Dependency* BasicSharedState::create_sink_dependency(int dest_id, int node_id,
52
976k
                                                     const std::string& name) {
53
976k
    sink_deps.push_back(std::make_shared<Dependency>(dest_id, node_id, name + "_DEPENDENCY", true));
54
976k
    sink_deps.back()->set_shared_state(this);
55
976k
    return sink_deps.back().get();
56
976k
}
57
58
4.22M
void Dependency::_add_block_task(std::shared_ptr<PipelineTask> task) {
59
18.4E
    DCHECK(_blocked_task.empty() || _blocked_task[_blocked_task.size() - 1].lock() == nullptr ||
60
18.4E
           _blocked_task[_blocked_task.size() - 1].lock().get() != task.get())
61
18.4E
            << "Duplicate task: " << task->debug_string();
62
4.22M
    _blocked_task.push_back(task);
63
4.22M
}
64
65
43.5M
void Dependency::set_ready() {
66
43.5M
    if (_ready) {
67
41.8M
        return;
68
41.8M
    }
69
1.74M
    std::vector<std::weak_ptr<PipelineTask>> local_block_task {};
70
1.74M
    {
71
1.74M
        std::unique_lock<std::mutex> lc(_task_lock);
72
1.74M
        if (_ready) {
73
378
            return;
74
378
        }
75
1.74M
        _watcher.stop();
76
1.74M
        _ready = true;
77
1.74M
        local_block_task.swap(_blocked_task);
78
1.74M
    }
79
4.23M
    for (auto task : local_block_task) {
80
4.23M
        if (auto t = task.lock()) {
81
4.23M
            std::unique_lock<std::mutex> lc(_task_lock);
82
4.23M
            t->wake_up(this, lc);
83
4.23M
        }
84
4.23M
    }
85
1.74M
}
86
87
95.4M
Dependency* Dependency::is_blocked_by(std::shared_ptr<PipelineTask> task) {
88
95.4M
    std::unique_lock<std::mutex> lc(_task_lock);
89
95.4M
    auto ready = _ready.load();
90
95.4M
    if (!ready && task) {
91
4.23M
        _add_block_task(task);
92
4.23M
        start_watcher();
93
4.23M
        THROW_IF_ERROR(task->blocked(this, lc));
94
4.23M
    }
95
95.4M
    return ready ? nullptr : this;
96
95.4M
}
97
98
114k
std::string Dependency::debug_string(int indentation_level) {
99
114k
    fmt::memory_buffer debug_string_buffer;
100
114k
    fmt::format_to(debug_string_buffer, "{}{}: id={}, block task = {}, ready={}, _always_ready={}",
101
114k
                   std::string(indentation_level * 2, ' '), _name, _node_id, _blocked_task.size(),
102
114k
                   _ready, _always_ready);
103
114k
    return fmt::to_string(debug_string_buffer);
104
114k
}
105
106
255
std::string CountedFinishDependency::debug_string(int indentation_level) {
107
255
    fmt::memory_buffer debug_string_buffer;
108
255
    fmt::format_to(debug_string_buffer,
109
255
                   "{}{}: id={}, block_task={}, ready={}, _always_ready={}, count={}",
110
255
                   std::string(indentation_level * 2, ' '), _name, _node_id, _blocked_task.size(),
111
255
                   _ready, _always_ready, _counter);
112
255
    return fmt::to_string(debug_string_buffer);
113
255
}
114
115
446
void RuntimeFilterTimer::call_timeout() {
116
446
    _parent->set_ready();
117
446
}
118
119
40.6k
void RuntimeFilterTimer::call_ready() {
120
40.6k
    _parent->set_ready();
121
40.6k
}
122
123
// should check rf timeout in two case:
124
// 1. the rf is ready just remove the wait queue
125
// 2. if the rf have local dependency, the rf should start wait when all local dependency is ready
126
8.11M
bool RuntimeFilterTimer::should_be_check_timeout() {
127
8.11M
    if (!_parent->ready() && !_local_runtime_filter_dependencies.empty()) {
128
4.11k
        bool all_ready = true;
129
4.12k
        for (auto& dep : _local_runtime_filter_dependencies) {
130
4.12k
            if (!dep->ready()) {
131
4.08k
                all_ready = false;
132
4.08k
                break;
133
4.08k
            }
134
4.12k
        }
135
4.11k
        if (all_ready) {
136
30
            _local_runtime_filter_dependencies.clear();
137
30
            _registration_time = MonotonicMillis();
138
30
        }
139
4.11k
        return all_ready;
140
4.11k
    }
141
8.10M
    return true;
142
8.11M
}
143
144
8
void RuntimeFilterTimerQueue::start() {
145
273k
    while (!_stop) {
146
273k
        std::unique_lock<std::mutex> lk(cv_m);
147
148
275k
        while (_que.empty() && !_stop) {
149
4.53k
            cv.wait_for(lk, std::chrono::seconds(3), [this] { return !_que.empty() || _stop; });
150
2.26k
        }
151
273k
        if (_stop) {
152
3
            break;
153
3
        }
154
273k
        {
155
273k
            std::unique_lock<std::mutex> lc(_que_lock);
156
273k
            std::list<std::shared_ptr<RuntimeFilterTimer>> new_que;
157
8.11M
            for (auto& it : _que) {
158
8.11M
                if (it.use_count() == 1) {
159
                    // `use_count == 1` means this runtime filter has been released
160
8.11M
                } else if (it->should_be_check_timeout()) {
161
8.10M
                    if (it->force_wait_timeout() || it->_parent->is_blocked_by()) {
162
                        // This means runtime filter is not ready, so we call timeout or continue to poll this timer.
163
8.06M
                        int64_t ms_since_registration = MonotonicMillis() - it->registration_time();
164
8.06M
                        if (ms_since_registration > it->wait_time_ms()) {
165
446
                            it->call_timeout();
166
8.06M
                        } else {
167
8.06M
                            new_que.push_back(std::move(it));
168
8.06M
                        }
169
8.06M
                    }
170
8.10M
                } else {
171
4.08k
                    new_que.push_back(std::move(it));
172
4.08k
                }
173
8.11M
            }
174
273k
            new_que.swap(_que);
175
273k
        }
176
273k
        std::this_thread::sleep_for(std::chrono::milliseconds(interval));
177
273k
    }
178
8
    _shutdown = true;
179
8
}
180
181
336k
void LocalExchangeSharedState::sub_running_sink_operators() {
182
336k
    std::unique_lock<std::mutex> lc(le_lock);
183
336k
    if (exchanger->_running_sink_operators.fetch_sub(1) == 1) {
184
103k
        _set_always_ready();
185
103k
    }
186
336k
}
187
188
726k
void LocalExchangeSharedState::sub_running_source_operators() {
189
726k
    std::unique_lock<std::mutex> lc(le_lock);
190
726k
    if (exchanger->_running_source_operators.fetch_sub(1) == 1) {
191
103k
        _set_always_ready();
192
103k
        exchanger->finalize();
193
103k
    }
194
726k
}
195
196
103k
LocalExchangeSharedState::LocalExchangeSharedState(int num_instances) {
197
103k
    source_deps.resize(num_instances, nullptr);
198
103k
    mem_counters.resize(num_instances, nullptr);
199
103k
}
200
201
108
MutableColumns AggSharedState::_get_keys_hash_table() {
202
108
    return std::visit(
203
108
            Overload {[&](std::monostate& arg) {
204
0
                          throw doris::Exception(ErrorCode::INTERNAL_ERROR, "uninited hash table");
205
0
                          return MutableColumns();
206
0
                      },
207
108
                      [&](auto&& agg_method) -> MutableColumns {
208
108
                          MutableColumns key_columns;
209
356
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
210
248
                              key_columns.emplace_back(
211
248
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
212
248
                          }
213
108
                          auto& data = *agg_method.hash_table;
214
108
                          bool has_null_key = data.has_null_key_data();
215
108
                          const auto size = data.size() - has_null_key;
216
108
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
217
108
                          std::vector<KeyType> keys(size);
218
219
108
                          uint32_t num_rows = 0;
220
108
                          auto iter = aggregate_data_container->begin();
221
108
                          {
222
19.6k
                              while (iter != aggregate_data_container->end()) {
223
19.5k
                                  keys[num_rows] = iter.get_key<KeyType>();
224
19.5k
                                  ++iter;
225
19.5k
                                  ++num_rows;
226
19.5k
                              }
227
108
                          }
228
108
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
229
108
                          if (has_null_key) {
230
2
                              key_columns[0]->insert_data(nullptr, 0);
231
2
                          }
232
108
                          return key_columns;
233
108
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS5_vEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISE_EESaISH_EEOT_
Line
Count
Source
207
10
                      [&](auto&& agg_method) -> MutableColumns {
208
10
                          MutableColumns key_columns;
209
50
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
210
40
                              key_columns.emplace_back(
211
40
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
212
40
                          }
213
10
                          auto& data = *agg_method.hash_table;
214
10
                          bool has_null_key = data.has_null_key_data();
215
10
                          const auto size = data.size() - has_null_key;
216
10
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
217
10
                          std::vector<KeyType> keys(size);
218
219
10
                          uint32_t num_rows = 0;
220
10
                          auto iter = aggregate_data_container->begin();
221
10
                          {
222
7.45k
                              while (iter != aggregate_data_container->end()) {
223
7.44k
                                  keys[num_rows] = iter.get_key<KeyType>();
224
7.44k
                                  ++iter;
225
7.44k
                                  ++num_rows;
226
7.44k
                              }
227
10
                          }
228
10
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
229
10
                          if (has_null_key) {
230
0
                              key_columns[0]->insert_data(nullptr, 0);
231
0
                          }
232
10
                          return key_columns;
233
10
                      }},
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
207
1
                      [&](auto&& agg_method) -> MutableColumns {
208
1
                          MutableColumns key_columns;
209
2
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
210
1
                              key_columns.emplace_back(
211
1
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
212
1
                          }
213
1
                          auto& data = *agg_method.hash_table;
214
1
                          bool has_null_key = data.has_null_key_data();
215
1
                          const auto size = data.size() - has_null_key;
216
1
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
217
1
                          std::vector<KeyType> keys(size);
218
219
1
                          uint32_t num_rows = 0;
220
1
                          auto iter = aggregate_data_container->begin();
221
1
                          {
222
5
                              while (iter != aggregate_data_container->end()) {
223
4
                                  keys[num_rows] = iter.get_key<KeyType>();
224
4
                                  ++iter;
225
4
                                  ++num_rows;
226
4
                              }
227
1
                          }
228
1
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
229
1
                          if (has_null_key) {
230
0
                              key_columns[0]->insert_data(nullptr, 0);
231
0
                          }
232
1
                          return key_columns;
233
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_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
Line
Count
Source
207
4
                      [&](auto&& agg_method) -> MutableColumns {
208
4
                          MutableColumns key_columns;
209
8
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
210
4
                              key_columns.emplace_back(
211
4
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
212
4
                          }
213
4
                          auto& data = *agg_method.hash_table;
214
4
                          bool has_null_key = data.has_null_key_data();
215
4
                          const auto size = data.size() - has_null_key;
216
4
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
217
4
                          std::vector<KeyType> keys(size);
218
219
4
                          uint32_t num_rows = 0;
220
4
                          auto iter = aggregate_data_container->begin();
221
4
                          {
222
20
                              while (iter != aggregate_data_container->end()) {
223
16
                                  keys[num_rows] = iter.get_key<KeyType>();
224
16
                                  ++iter;
225
16
                                  ++num_rows;
226
16
                              }
227
4
                          }
228
4
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
229
4
                          if (has_null_key) {
230
0
                              key_columns[0]->insert_data(nullptr, 0);
231
0
                          }
232
4
                          return key_columns;
233
4
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIhNS_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
Line
Count
Source
207
3
                      [&](auto&& agg_method) -> MutableColumns {
208
3
                          MutableColumns key_columns;
209
6
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
210
3
                              key_columns.emplace_back(
211
3
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
212
3
                          }
213
3
                          auto& data = *agg_method.hash_table;
214
3
                          bool has_null_key = data.has_null_key_data();
215
3
                          const auto size = data.size() - has_null_key;
216
3
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
217
3
                          std::vector<KeyType> keys(size);
218
219
3
                          uint32_t num_rows = 0;
220
3
                          auto iter = aggregate_data_container->begin();
221
3
                          {
222
13
                              while (iter != aggregate_data_container->end()) {
223
10
                                  keys[num_rows] = iter.get_key<KeyType>();
224
10
                                  ++iter;
225
10
                                  ++num_rows;
226
10
                              }
227
3
                          }
228
3
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
229
3
                          if (has_null_key) {
230
0
                              key_columns[0]->insert_data(nullptr, 0);
231
0
                          }
232
3
                          return key_columns;
233
3
                      }},
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
207
5
                      [&](auto&& agg_method) -> MutableColumns {
208
5
                          MutableColumns key_columns;
209
10
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
210
5
                              key_columns.emplace_back(
211
5
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
212
5
                          }
213
5
                          auto& data = *agg_method.hash_table;
214
5
                          bool has_null_key = data.has_null_key_data();
215
5
                          const auto size = data.size() - has_null_key;
216
5
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
217
5
                          std::vector<KeyType> keys(size);
218
219
5
                          uint32_t num_rows = 0;
220
5
                          auto iter = aggregate_data_container->begin();
221
5
                          {
222
2.34k
                              while (iter != aggregate_data_container->end()) {
223
2.33k
                                  keys[num_rows] = iter.get_key<KeyType>();
224
2.33k
                                  ++iter;
225
2.33k
                                  ++num_rows;
226
2.33k
                              }
227
5
                          }
228
5
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
229
5
                          if (has_null_key) {
230
0
                              key_columns[0]->insert_data(nullptr, 0);
231
0
                          }
232
5
                          return key_columns;
233
5
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
Line
Count
Source
207
5
                      [&](auto&& agg_method) -> MutableColumns {
208
5
                          MutableColumns key_columns;
209
10
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
210
5
                              key_columns.emplace_back(
211
5
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
212
5
                          }
213
5
                          auto& data = *agg_method.hash_table;
214
5
                          bool has_null_key = data.has_null_key_data();
215
5
                          const auto size = data.size() - has_null_key;
216
5
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
217
5
                          std::vector<KeyType> keys(size);
218
219
5
                          uint32_t num_rows = 0;
220
5
                          auto iter = aggregate_data_container->begin();
221
5
                          {
222
2.35k
                              while (iter != aggregate_data_container->end()) {
223
2.34k
                                  keys[num_rows] = iter.get_key<KeyType>();
224
2.34k
                                  ++iter;
225
2.34k
                                  ++num_rows;
226
2.34k
                              }
227
5
                          }
228
5
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
229
5
                          if (has_null_key) {
230
0
                              key_columns[0]->insert_data(nullptr, 0);
231
0
                          }
232
5
                          return key_columns;
233
5
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
Line
Count
Source
207
7
                      [&](auto&& agg_method) -> MutableColumns {
208
7
                          MutableColumns key_columns;
209
14
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
210
7
                              key_columns.emplace_back(
211
7
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
212
7
                          }
213
7
                          auto& data = *agg_method.hash_table;
214
7
                          bool has_null_key = data.has_null_key_data();
215
7
                          const auto size = data.size() - has_null_key;
216
7
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
217
7
                          std::vector<KeyType> keys(size);
218
219
7
                          uint32_t num_rows = 0;
220
7
                          auto iter = aggregate_data_container->begin();
221
7
                          {
222
23
                              while (iter != aggregate_data_container->end()) {
223
16
                                  keys[num_rows] = iter.get_key<KeyType>();
224
16
                                  ++iter;
225
16
                                  ++num_rows;
226
16
                              }
227
7
                          }
228
7
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
229
7
                          if (has_null_key) {
230
1
                              key_columns[0]->insert_data(nullptr, 0);
231
1
                          }
232
7
                          return key_columns;
233
7
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
Line
Count
Source
207
12
                      [&](auto&& agg_method) -> MutableColumns {
208
12
                          MutableColumns key_columns;
209
24
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
210
12
                              key_columns.emplace_back(
211
12
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
212
12
                          }
213
12
                          auto& data = *agg_method.hash_table;
214
12
                          bool has_null_key = data.has_null_key_data();
215
12
                          const auto size = data.size() - has_null_key;
216
12
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
217
12
                          std::vector<KeyType> keys(size);
218
219
12
                          uint32_t num_rows = 0;
220
12
                          auto iter = aggregate_data_container->begin();
221
12
                          {
222
5.01k
                              while (iter != aggregate_data_container->end()) {
223
5.00k
                                  keys[num_rows] = iter.get_key<KeyType>();
224
5.00k
                                  ++iter;
225
5.00k
                                  ++num_rows;
226
5.00k
                              }
227
12
                          }
228
12
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
229
12
                          if (has_null_key) {
230
1
                              key_columns[0]->insert_data(nullptr, 0);
231
1
                          }
232
12
                          return key_columns;
233
12
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS7_Pc9HashCRC32IS7_EEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISK_EESaISN_EEOT_
Line
Count
Source
207
1
                      [&](auto&& agg_method) -> MutableColumns {
208
1
                          MutableColumns key_columns;
209
2
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
210
1
                              key_columns.emplace_back(
211
1
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
212
1
                          }
213
1
                          auto& data = *agg_method.hash_table;
214
1
                          bool has_null_key = data.has_null_key_data();
215
1
                          const auto size = data.size() - has_null_key;
216
1
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
217
1
                          std::vector<KeyType> keys(size);
218
219
1
                          uint32_t num_rows = 0;
220
1
                          auto iter = aggregate_data_container->begin();
221
1
                          {
222
4
                              while (iter != aggregate_data_container->end()) {
223
3
                                  keys[num_rows] = iter.get_key<KeyType>();
224
3
                                  ++iter;
225
3
                                  ++num_rows;
226
3
                              }
227
1
                          }
228
1
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
229
1
                          if (has_null_key) {
230
0
                              key_columns[0]->insert_data(nullptr, 0);
231
0
                          }
232
1
                          return key_columns;
233
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
207
60
                      [&](auto&& agg_method) -> MutableColumns {
208
60
                          MutableColumns key_columns;
209
230
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
210
170
                              key_columns.emplace_back(
211
170
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
212
170
                          }
213
60
                          auto& data = *agg_method.hash_table;
214
60
                          bool has_null_key = data.has_null_key_data();
215
60
                          const auto size = data.size() - has_null_key;
216
60
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
217
60
                          std::vector<KeyType> keys(size);
218
219
60
                          uint32_t num_rows = 0;
220
60
                          auto iter = aggregate_data_container->begin();
221
60
                          {
222
2.40k
                              while (iter != aggregate_data_container->end()) {
223
2.34k
                                  keys[num_rows] = iter.get_key<KeyType>();
224
2.34k
                                  ++iter;
225
2.34k
                                  ++num_rows;
226
2.34k
                              }
227
60
                          }
228
60
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
229
60
                          if (has_null_key) {
230
0
                              key_columns[0]->insert_data(nullptr, 0);
231
0
                          }
232
60
                          return key_columns;
233
60
                      }},
234
108
            agg_data->method_variant);
235
108
}
236
237
108
void AggSharedState::build_limit_heap(size_t hash_table_size) {
238
108
    limit_columns = _get_keys_hash_table();
239
20.2k
    for (size_t i = 0; i < hash_table_size; ++i) {
240
20.1k
        limit_heap.emplace(i, limit_columns, order_directions, null_directions);
241
20.1k
    }
242
19.9k
    while (hash_table_size > limit) {
243
19.8k
        limit_heap.pop();
244
19.8k
        hash_table_size--;
245
19.8k
    }
246
108
    limit_columns_min = limit_heap.top()._row_id;
247
108
}
248
249
bool AggSharedState::do_limit_filter(Block* block, size_t num_rows,
250
460
                                     const std::vector<int>* key_locs) {
251
460
    if (num_rows) {
252
460
        cmp_res.resize(num_rows);
253
460
        need_computes.resize(num_rows);
254
460
        memset(need_computes.data(), 0, need_computes.size());
255
460
        memset(cmp_res.data(), 0, cmp_res.size());
256
257
460
        const auto key_size = null_directions.size();
258
1.60k
        for (int i = 0; i < key_size; i++) {
259
1.14k
            block->get_by_position(key_locs ? key_locs->operator[](i) : i)
260
1.14k
                    .column->compare_internal(limit_columns_min, *limit_columns[i],
261
1.14k
                                              null_directions[i], order_directions[i], cmp_res,
262
1.14k
                                              need_computes.data());
263
1.14k
        }
264
265
460
        auto set_computes_arr = [](auto* __restrict res, auto* __restrict computes, size_t rows) {
266
488k
            for (size_t i = 0; i < rows; ++i) {
267
488k
                computes[i] = computes[i] == res[i];
268
488k
            }
269
460
        };
270
460
        set_computes_arr(cmp_res.data(), need_computes.data(), num_rows);
271
272
460
        return std::find(need_computes.begin(), need_computes.end(), 0) != need_computes.end();
273
460
    }
274
275
0
    return false;
276
460
}
277
278
54
Status AggSharedState::reset_hash_table() {
279
54
    return std::visit(
280
54
            Overload {
281
54
                    [&](std::monostate& arg) -> Status {
282
0
                        return Status::InternalError("Uninited hash table");
283
0
                    },
284
54
                    [&](auto& agg_method) {
285
54
                        auto& hash_table = *agg_method.hash_table;
286
54
                        using HashTableType = std::decay_t<decltype(hash_table)>;
287
288
54
                        agg_method.arena.clear();
289
54
                        agg_method.inited_iterator = false;
290
291
54
                        if (!use_simple_count) {
292
1.06M
                            hash_table.for_each_mapped([&](auto& mapped) {
293
1.06M
                                if (mapped) {
294
1.06M
                                    _destroy_agg_status(mapped);
295
1.06M
                                    mapped = nullptr;
296
1.06M
                                }
297
1.06M
                            });
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_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEDaRT_ENKUlSB_E_clIS5_EEDaSB_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEEDaRT_ENKUlSB_E_clIS5_EEDaSB_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEEDaRT_ENKUlSB_E_clIS5_EEDaSB_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEDaRT_ENKUlSC_E_clIS5_EEDaSC_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS6_Pc9HashCRC32IS6_EEEEEEDaRT_ENKUlSE_E_clIS8_EEDaSE_
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
292
1.06M
                            hash_table.for_each_mapped([&](auto& mapped) {
293
1.06M
                                if (mapped) {
294
1.06M
                                    _destroy_agg_status(mapped);
295
1.06M
                                    mapped = nullptr;
296
1.06M
                                }
297
1.06M
                            });
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEDaRT_ENKUlSD_E_clIS5_EEDaSD_
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_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEDaRT_ENKUlSH_E_clIS7_EEDaSH_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEDaRT_ENKUlSH_E_clIS7_EEDaSH_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS7_Pc9HashCRC32IS7_EEEEEEEEEEDaRT_ENKUlSI_E_clISA_EEDaSI_
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_
298
299
54
                            if (hash_table.has_null_key_data()) {
300
2
                                _destroy_agg_status(
301
2
                                        hash_table.template get_null_key_data<AggregateDataPtr>());
302
2
                            }
303
304
54
                            aggregate_data_container.reset(new AggregateDataContainer(
305
54
                                    sizeof(typename HashTableType::key_type),
306
54
                                    ((total_size_of_aggregate_states + align_aggregate_states - 1) /
307
54
                                     align_aggregate_states) *
308
54
                                            align_aggregate_states));
309
54
                        }
310
54
                        agg_method.hash_table.reset(new HashTableType());
311
54
                        return Status::OK();
312
54
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS5_vEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS6_Pc9HashCRC32IS6_EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS6_Pc9HashCRC32IS6_EEEEEEDaRT_
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEDaRT_
Line
Count
Source
284
52
                    [&](auto& agg_method) {
285
52
                        auto& hash_table = *agg_method.hash_table;
286
52
                        using HashTableType = std::decay_t<decltype(hash_table)>;
287
288
52
                        agg_method.arena.clear();
289
52
                        agg_method.inited_iterator = false;
290
291
52
                        if (!use_simple_count) {
292
52
                            hash_table.for_each_mapped([&](auto& mapped) {
293
52
                                if (mapped) {
294
52
                                    _destroy_agg_status(mapped);
295
52
                                    mapped = nullptr;
296
52
                                }
297
52
                            });
298
299
52
                            if (hash_table.has_null_key_data()) {
300
0
                                _destroy_agg_status(
301
0
                                        hash_table.template get_null_key_data<AggregateDataPtr>());
302
0
                            }
303
304
52
                            aggregate_data_container.reset(new AggregateDataContainer(
305
52
                                    sizeof(typename HashTableType::key_type),
306
52
                                    ((total_size_of_aggregate_states + align_aggregate_states - 1) /
307
52
                                     align_aggregate_states) *
308
52
                                            align_aggregate_states));
309
52
                        }
310
52
                        agg_method.hash_table.reset(new HashTableType());
311
52
                        return Status::OK();
312
52
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIhNS_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberItNS_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEDaRT_
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEDaRT_
Line
Count
Source
284
2
                    [&](auto& agg_method) {
285
2
                        auto& hash_table = *agg_method.hash_table;
286
2
                        using HashTableType = std::decay_t<decltype(hash_table)>;
287
288
2
                        agg_method.arena.clear();
289
2
                        agg_method.inited_iterator = false;
290
291
2
                        if (!use_simple_count) {
292
2
                            hash_table.for_each_mapped([&](auto& mapped) {
293
2
                                if (mapped) {
294
2
                                    _destroy_agg_status(mapped);
295
2
                                    mapped = nullptr;
296
2
                                }
297
2
                            });
298
299
2
                            if (hash_table.has_null_key_data()) {
300
2
                                _destroy_agg_status(
301
2
                                        hash_table.template get_null_key_data<AggregateDataPtr>());
302
2
                            }
303
304
2
                            aggregate_data_container.reset(new AggregateDataContainer(
305
2
                                    sizeof(typename HashTableType::key_type),
306
2
                                    ((total_size_of_aggregate_states + align_aggregate_states - 1) /
307
2
                                     align_aggregate_states) *
308
2
                                            align_aggregate_states));
309
2
                        }
310
2
                        agg_method.hash_table.reset(new HashTableType());
311
2
                        return Status::OK();
312
2
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS7_Pc9HashCRC32IS7_EEEEEEEEEEDaRT_
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_
313
54
            agg_data->method_variant);
314
54
}
315
316
276
void PartitionedAggSharedState::close() {
317
276
    for (auto& partition : _spill_partitions) {
318
32
        if (partition) {
319
4
            ExecEnv::GetInstance()->spill_file_mgr()->delete_spill_file(partition);
320
4
        }
321
32
    }
322
276
    _spill_partitions.clear();
323
276
}
324
325
43
void SpillSortSharedState::close() {
326
    // need to use CAS instead of only `if (!is_closed)` statement,
327
    // to avoid concurrent entry of close() both pass the if statement
328
43
    bool false_close = false;
329
43
    if (!is_closed.compare_exchange_strong(false_close, true)) {
330
16
        return;
331
16
    }
332
43
    DCHECK(!false_close && is_closed);
333
27
    sorted_spill_groups.clear();
334
27
}
335
336
MultiCastSharedState::MultiCastSharedState(ObjectPool* pool, int cast_sender_count, int node_id)
337
        : multi_cast_data_streamer(
338
1.96k
                  std::make_unique<MultiCastDataStreamer>(pool, cast_sender_count, node_id)) {}
339
340
87.2k
int AggSharedState::get_slot_column_id(const AggFnEvaluator* evaluator) {
341
87.2k
    auto ctxs = evaluator->input_exprs_ctxs();
342
18.4E
    CHECK(ctxs.size() == 1 && ctxs[0]->root()->is_slot_ref())
343
18.4E
            << "input_exprs_ctxs is invalid, input_exprs_ctx[0]="
344
18.4E
            << ctxs[0]->root()->debug_string();
345
87.2k
    return ((VSlotRef*)ctxs[0]->root().get())->column_id();
346
87.2k
}
347
348
2.25M
void AggSharedState::_destroy_agg_status(AggregateDataPtr data) {
349
4.72M
    for (int i = 0; i < aggregate_evaluators.size(); ++i) {
350
2.47M
        aggregate_evaluators[i]->function()->destroy(data + offsets_of_aggregate_states[i]);
351
2.47M
    }
352
2.25M
}
353
354
103k
LocalExchangeSharedState::~LocalExchangeSharedState() = default;
355
356
11.8k
Status SetSharedState::update_build_not_ignore_null(const VExprContextSPtrs& ctxs) {
357
11.8k
    if (ctxs.size() > build_not_ignore_null.size()) {
358
0
        return Status::InternalError("build_not_ignore_null not initialized");
359
0
    }
360
361
100k
    for (int i = 0; i < ctxs.size(); ++i) {
362
88.5k
        build_not_ignore_null[i] = build_not_ignore_null[i] || ctxs[i]->root()->is_nullable();
363
88.5k
    }
364
365
11.8k
    return Status::OK();
366
11.8k
}
367
368
18.8k
size_t SetSharedState::get_hash_table_size() const {
369
18.8k
    size_t hash_table_size = 0;
370
18.8k
    std::visit(
371
18.8k
            [&](auto&& arg) {
372
18.8k
                using HashTableCtxType = std::decay_t<decltype(arg)>;
373
18.8k
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
374
18.8k
                    hash_table_size = arg.hash_table->size();
375
18.8k
                }
376
18.8k
            },
Unexecuted instantiation: dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRSt9monostateEEDaOT_
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_16MethodSerializedI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS5_vEEEEEEDaOT_
Line
Count
Source
371
17.8k
            [&](auto&& arg) {
372
17.8k
                using HashTableCtxType = std::decay_t<decltype(arg)>;
373
17.8k
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
374
17.8k
                    hash_table_size = arg.hash_table->size();
375
17.8k
                }
376
17.8k
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_19MethodStringNoCacheI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS5_vEEEEEEDaOT_
Line
Count
Source
371
88
            [&](auto&& arg) {
372
88
                using HashTableCtxType = std::decay_t<decltype(arg)>;
373
88
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
374
88
                    hash_table_size = arg.hash_table->size();
375
88
                }
376
88
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_26MethodSingleNullableColumnINS_19MethodStringNoCacheINS_15DataWithNullKeyI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS7_vEEEEEEEEEEDaOT_
Line
Count
Source
371
236
            [&](auto&& arg) {
372
236
                using HashTableCtxType = std::decay_t<decltype(arg)>;
373
236
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
374
236
                    hash_table_size = arg.hash_table->size();
375
236
                }
376
236
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIhNS_15DataWithNullKeyI9PHHashMapIhNS_14RowRefWithFlagE9HashCRC32IhEEEEEEEEEEDaOT_
Line
Count
Source
371
33
            [&](auto&& arg) {
372
33
                using HashTableCtxType = std::decay_t<decltype(arg)>;
373
33
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
374
33
                    hash_table_size = arg.hash_table->size();
375
33
                }
376
33
            },
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
371
236
            [&](auto&& arg) {
372
236
                using HashTableCtxType = std::decay_t<decltype(arg)>;
373
236
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
374
236
                    hash_table_size = arg.hash_table->size();
375
236
                }
376
236
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImNS_14RowRefWithFlagE9HashCRC32ImEEEEEEEEEEDaOT_
Line
Count
Source
371
118
            [&](auto&& arg) {
372
118
                using HashTableCtxType = std::decay_t<decltype(arg)>;
373
118
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
374
118
                    hash_table_size = arg.hash_table->size();
375
118
                }
376
118
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS7_NS_14RowRefWithFlagE9HashCRC32IS7_EEEEEEEEEEDaOT_
Line
Count
Source
371
12
            [&](auto&& arg) {
372
12
                using HashTableCtxType = std::decay_t<decltype(arg)>;
373
12
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
374
12
                    hash_table_size = arg.hash_table->size();
375
12
                }
376
12
            },
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
371
29
            [&](auto&& arg) {
372
29
                using HashTableCtxType = std::decay_t<decltype(arg)>;
373
29
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
374
29
                    hash_table_size = arg.hash_table->size();
375
29
                }
376
29
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodOneNumberIm9PHHashMapImNS_14RowRefWithFlagE9HashCRC32ImEEEEEEDaOT_
Line
Count
Source
371
16
            [&](auto&& arg) {
372
16
                using HashTableCtxType = std::decay_t<decltype(arg)>;
373
16
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
374
16
                    hash_table_size = arg.hash_table->size();
375
16
                }
376
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
371
30
            [&](auto&& arg) {
372
30
                using HashTableCtxType = std::decay_t<decltype(arg)>;
373
30
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
374
30
                    hash_table_size = arg.hash_table->size();
375
30
                }
376
30
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodKeysFixedI9PHHashMapINS_6UInt72ENS_14RowRefWithFlagE9HashCRC32IS5_EEEEEEDaOT_
Line
Count
Source
371
39
            [&](auto&& arg) {
372
39
                using HashTableCtxType = std::decay_t<decltype(arg)>;
373
39
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
374
39
                    hash_table_size = arg.hash_table->size();
375
39
                }
376
39
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodKeysFixedI9PHHashMapINS_6UInt96ENS_14RowRefWithFlagE9HashCRC32IS5_EEEEEEDaOT_
Line
Count
Source
371
41
            [&](auto&& arg) {
372
41
                using HashTableCtxType = std::decay_t<decltype(arg)>;
373
41
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
374
41
                    hash_table_size = arg.hash_table->size();
375
41
                }
376
41
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodKeysFixedI9PHHashMapINS_7UInt104ENS_14RowRefWithFlagE9HashCRC32IS5_EEEEEEDaOT_
Line
Count
Source
371
54
            [&](auto&& arg) {
372
54
                using HashTableCtxType = std::decay_t<decltype(arg)>;
373
54
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
374
54
                    hash_table_size = arg.hash_table->size();
375
54
                }
376
54
            },
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
371
4
            [&](auto&& arg) {
372
4
                using HashTableCtxType = std::decay_t<decltype(arg)>;
373
4
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
374
4
                    hash_table_size = arg.hash_table->size();
375
4
                }
376
4
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodKeysFixedI9PHHashMapINS_7UInt136ENS_14RowRefWithFlagE9HashCRC32IS5_EEEEEEDaOT_
Line
Count
Source
371
74
            [&](auto&& arg) {
372
74
                using HashTableCtxType = std::decay_t<decltype(arg)>;
373
74
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
374
74
                    hash_table_size = arg.hash_table->size();
375
74
                }
376
74
            },
377
18.8k
            hash_table_variants->method_variant);
378
18.8k
    return hash_table_size;
379
18.8k
}
380
381
4.86k
Status SetSharedState::hash_table_init() {
382
4.86k
    std::vector<DataTypePtr> data_types;
383
40.6k
    for (size_t i = 0; i != child_exprs_lists[0].size(); ++i) {
384
35.7k
        auto& ctx = child_exprs_lists[0][i];
385
35.7k
        auto data_type = ctx->root()->data_type();
386
35.7k
        if (build_not_ignore_null[i]) {
387
35.5k
            data_type = make_nullable(data_type);
388
35.5k
        }
389
35.7k
        data_types.emplace_back(std::move(data_type));
390
35.7k
    }
391
4.86k
    return init_hash_method<SetDataVariants>(hash_table_variants.get(), data_types, true);
392
4.86k
}
393
394
52
void AggSharedState::refresh_top_limit(size_t row_id, const ColumnRawPtrs& key_columns) {
395
200
    for (int j = 0; j < key_columns.size(); ++j) {
396
148
        limit_columns[j]->insert_from(*key_columns[j], row_id);
397
148
    }
398
52
    limit_heap.emplace(limit_columns[0]->size() - 1, limit_columns, order_directions,
399
52
                       null_directions);
400
401
52
    limit_heap.pop();
402
52
    limit_columns_min = limit_heap.top()._row_id;
403
52
}
404
405
} // namespace doris