Coverage Report

Created: 2026-03-13 21:11

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
516k
                                                       const std::string& name) {
43
516k
    source_deps.push_back(std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY"));
44
516k
    source_deps.back()->set_shared_state(this);
45
516k
    return source_deps.back().get();
46
516k
}
47
48
void BasicSharedState::create_source_dependencies(int num_sources, int operator_id, int node_id,
49
98.8k
                                                  const std::string& name) {
50
98.8k
    source_deps.resize(num_sources, nullptr);
51
674k
    for (auto& source_dep : source_deps) {
52
674k
        source_dep = std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY");
53
674k
        source_dep->set_shared_state(this);
54
674k
    }
55
98.8k
}
56
57
Dependency* BasicSharedState::create_sink_dependency(int dest_id, int node_id,
58
1.02M
                                                     const std::string& name) {
59
1.02M
    sink_deps.push_back(std::make_shared<Dependency>(dest_id, node_id, name + "_DEPENDENCY", true));
60
1.02M
    sink_deps.back()->set_shared_state(this);
61
1.02M
    return sink_deps.back().get();
62
1.02M
}
63
64
4.37M
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.37M
    _blocked_task.push_back(task);
69
4.37M
}
70
71
91.4M
void Dependency::set_ready() {
72
92.1M
    if (_ready) {
73
92.1M
        return;
74
92.1M
    }
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.28k
            return;
80
1.28k
        }
81
18.4E
        _watcher.stop();
82
18.4E
        _ready = true;
83
18.4E
        local_block_task.swap(_blocked_task);
84
18.4E
    }
85
4.38M
    for (auto task : local_block_task) {
86
4.38M
        if (auto t = task.lock()) {
87
4.38M
            std::unique_lock<std::mutex> lc(_task_lock);
88
4.38M
            THROW_IF_ERROR(t->wake_up(this, lc));
89
4.38M
        }
90
4.38M
    }
91
18.4E
}
92
93
128M
Dependency* Dependency::is_blocked_by(std::shared_ptr<PipelineTask> task) {
94
128M
    std::unique_lock<std::mutex> lc(_task_lock);
95
128M
    auto ready = _ready.load();
96
128M
    if (!ready && task) {
97
4.38M
        _add_block_task(task);
98
4.38M
        start_watcher();
99
4.38M
        THROW_IF_ERROR(task->blocked(this, lc));
100
4.38M
    }
101
128M
    return ready ? nullptr : this;
102
128M
}
103
104
390k
std::string Dependency::debug_string(int indentation_level) {
105
390k
    fmt::memory_buffer debug_string_buffer;
106
390k
    fmt::format_to(debug_string_buffer, "{}{}: id={}, block task = {}, ready={}, _always_ready={}",
107
390k
                   std::string(indentation_level * 2, ' '), _name, _node_id, _blocked_task.size(),
108
390k
                   _ready, _always_ready);
109
390k
    return fmt::to_string(debug_string_buffer);
110
390k
}
111
112
444
std::string CountedFinishDependency::debug_string(int indentation_level) {
113
444
    fmt::memory_buffer debug_string_buffer;
114
444
    fmt::format_to(debug_string_buffer,
115
444
                   "{}{}: id={}, block_task={}, ready={}, _always_ready={}, count={}",
116
444
                   std::string(indentation_level * 2, ' '), _name, _node_id, _blocked_task.size(),
117
444
                   _ready, _always_ready, _counter);
118
444
    return fmt::to_string(debug_string_buffer);
119
444
}
120
121
2.19k
void RuntimeFilterTimer::call_timeout() {
122
2.19k
    _parent->set_ready();
123
2.19k
}
124
125
77.1k
void RuntimeFilterTimer::call_ready() {
126
77.1k
    _parent->set_ready();
127
77.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
8.92M
bool RuntimeFilterTimer::should_be_check_timeout() {
133
8.92M
    if (!_parent->ready() && !_local_runtime_filter_dependencies.empty()) {
134
291k
        bool all_ready = true;
135
292k
        for (auto& dep : _local_runtime_filter_dependencies) {
136
292k
            if (!dep->ready()) {
137
289k
                all_ready = false;
138
289k
                break;
139
289k
            }
140
292k
        }
141
291k
        if (all_ready) {
142
1.74k
            _local_runtime_filter_dependencies.clear();
143
1.74k
            _registration_time = MonotonicMillis();
144
1.74k
        }
145
291k
        return all_ready;
146
291k
    }
147
8.63M
    return true;
148
8.92M
}
149
150
8
void RuntimeFilterTimerQueue::start() {
151
362k
    while (!_stop) {
152
362k
        std::unique_lock<std::mutex> lk(cv_m);
153
154
364k
        while (_que.empty() && !_stop) {
155
3.35k
            cv.wait_for(lk, std::chrono::seconds(3), [this] { return !_que.empty() || _stop; });
156
1.67k
        }
157
362k
        if (_stop) {
158
3
            break;
159
3
        }
160
362k
        {
161
362k
            std::unique_lock<std::mutex> lc(_que_lock);
162
362k
            std::list<std::shared_ptr<RuntimeFilterTimer>> new_que;
163
8.92M
            for (auto& it : _que) {
164
8.92M
                if (it.use_count() == 1) {
165
                    // `use_count == 1` means this runtime filter has been released
166
8.92M
                } else if (it->should_be_check_timeout()) {
167
8.63M
                    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
8.55M
                        int64_t ms_since_registration = MonotonicMillis() - it->registration_time();
170
8.55M
                        if (ms_since_registration > it->wait_time_ms()) {
171
2.19k
                            it->call_timeout();
172
8.55M
                        } else {
173
8.55M
                            new_que.push_back(std::move(it));
174
8.55M
                        }
175
8.55M
                    }
176
8.63M
                } else {
177
289k
                    new_que.push_back(std::move(it));
178
289k
                }
179
8.92M
            }
180
362k
            new_que.swap(_que);
181
362k
        }
182
362k
        std::this_thread::sleep_for(std::chrono::milliseconds(interval));
183
362k
    }
184
8
    _shutdown = true;
185
8
}
186
187
314k
void LocalExchangeSharedState::sub_running_sink_operators() {
188
314k
    std::unique_lock<std::mutex> lc(le_lock);
189
314k
    if (exchanger->_running_sink_operators.fetch_sub(1) == 1) {
190
96.5k
        _set_always_ready();
191
96.5k
    }
192
314k
}
193
194
658k
void LocalExchangeSharedState::sub_running_source_operators() {
195
658k
    std::unique_lock<std::mutex> lc(le_lock);
196
658k
    if (exchanger->_running_source_operators.fetch_sub(1) == 1) {
197
96.5k
        _set_always_ready();
198
96.5k
        exchanger->finalize();
199
96.5k
    }
200
658k
}
201
202
96.4k
LocalExchangeSharedState::LocalExchangeSharedState(int num_instances) {
203
96.4k
    source_deps.resize(num_instances, nullptr);
204
96.4k
    mem_counters.resize(num_instances, nullptr);
205
96.4k
}
206
207
46
MutableColumns AggSharedState::_get_keys_hash_table() {
208
46
    return std::visit(
209
46
            Overload {[&](std::monostate& arg) {
210
0
                          throw doris::Exception(ErrorCode::INTERNAL_ERROR, "uninited hash table");
211
0
                          return MutableColumns();
212
0
                      },
213
46
                      [&](auto&& agg_method) -> MutableColumns {
214
46
                          MutableColumns key_columns;
215
120
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
74
                              key_columns.emplace_back(
217
74
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
74
                          }
219
46
                          auto& data = *agg_method.hash_table;
220
46
                          bool has_null_key = data.has_null_key_data();
221
46
                          const auto size = data.size() - has_null_key;
222
46
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
46
                          std::vector<KeyType> keys(size);
224
225
46
                          uint32_t num_rows = 0;
226
46
                          auto iter = aggregate_data_container->begin();
227
46
                          {
228
12.8k
                              while (iter != aggregate_data_container->end()) {
229
12.7k
                                  keys[num_rows] = iter.get_key<KeyType>();
230
12.7k
                                  ++iter;
231
12.7k
                                  ++num_rows;
232
12.7k
                              }
233
46
                          }
234
46
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
46
                          if (has_null_key) {
236
2
                              key_columns[0]->insert_data(nullptr, 0);
237
2
                          }
238
46
                          return key_columns;
239
46
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS5_vEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISE_EESaISH_EEOT_
Line
Count
Source
213
2
                      [&](auto&& agg_method) -> MutableColumns {
214
2
                          MutableColumns key_columns;
215
10
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
8
                              key_columns.emplace_back(
217
8
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
8
                          }
219
2
                          auto& data = *agg_method.hash_table;
220
2
                          bool has_null_key = data.has_null_key_data();
221
2
                          const auto size = data.size() - has_null_key;
222
2
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
2
                          std::vector<KeyType> keys(size);
224
225
2
                          uint32_t num_rows = 0;
226
2
                          auto iter = aggregate_data_container->begin();
227
2
                          {
228
2.52k
                              while (iter != aggregate_data_container->end()) {
229
2.52k
                                  keys[num_rows] = iter.get_key<KeyType>();
230
2.52k
                                  ++iter;
231
2.52k
                                  ++num_rows;
232
2.52k
                              }
233
2
                          }
234
2
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
2
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
2
                          return key_columns;
239
2
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISD_EESaISG_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISD_EESaISG_EEOT_
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEESt6vectorINS_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
6
                              while (iter != aggregate_data_container->end()) {
229
4
                                  keys[num_rows] = iter.get_key<KeyType>();
230
4
                                  ++iter;
231
4
                                  ++num_rows;
232
4
                              }
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_15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISD_EESaISG_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISE_EESaISH_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS6_Pc9HashCRC32IS6_EEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS6_Pc9HashCRC32IS6_EEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
Line
Count
Source
213
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
4
                              while (iter != aggregate_data_container->end()) {
229
2
                                  keys[num_rows] = iter.get_key<KeyType>();
230
2
                                  ++iter;
231
2
                                  ++num_rows;
232
2
                              }
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
                      }},
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
31
                              while (iter != aggregate_data_container->end()) {
229
25
                                  keys[num_rows] = iter.get_key<KeyType>();
230
25
                                  ++iter;
231
25
                                  ++num_rows;
232
25
                              }
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
2
                      [&](auto&& agg_method) -> MutableColumns {
214
2
                          MutableColumns key_columns;
215
4
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
2
                              key_columns.emplace_back(
217
2
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
2
                          }
219
2
                          auto& data = *agg_method.hash_table;
220
2
                          bool has_null_key = data.has_null_key_data();
221
2
                          const auto size = data.size() - has_null_key;
222
2
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
2
                          std::vector<KeyType> keys(size);
224
225
2
                          uint32_t num_rows = 0;
226
2
                          auto iter = aggregate_data_container->begin();
227
2
                          {
228
14
                              while (iter != aggregate_data_container->end()) {
229
12
                                  keys[num_rows] = iter.get_key<KeyType>();
230
12
                                  ++iter;
231
12
                                  ++num_rows;
232
12
                              }
233
2
                          }
234
2
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
2
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
2
                          return key_columns;
239
2
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberItNS_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
Line
Count
Source
213
5
                      [&](auto&& agg_method) -> MutableColumns {
214
5
                          MutableColumns key_columns;
215
10
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
5
                              key_columns.emplace_back(
217
5
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
5
                          }
219
5
                          auto& data = *agg_method.hash_table;
220
5
                          bool has_null_key = data.has_null_key_data();
221
5
                          const auto size = data.size() - has_null_key;
222
5
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
5
                          std::vector<KeyType> keys(size);
224
225
5
                          uint32_t num_rows = 0;
226
5
                          auto iter = aggregate_data_container->begin();
227
5
                          {
228
1.53k
                              while (iter != aggregate_data_container->end()) {
229
1.52k
                                  keys[num_rows] = iter.get_key<KeyType>();
230
1.52k
                                  ++iter;
231
1.52k
                                  ++num_rows;
232
1.52k
                              }
233
5
                          }
234
5
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
5
                          if (has_null_key) {
236
1
                              key_columns[0]->insert_data(nullptr, 0);
237
1
                          }
238
5
                          return key_columns;
239
5
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
Line
Count
Source
213
13
                      [&](auto&& agg_method) -> MutableColumns {
214
13
                          MutableColumns key_columns;
215
26
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
13
                              key_columns.emplace_back(
217
13
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
13
                          }
219
13
                          auto& data = *agg_method.hash_table;
220
13
                          bool has_null_key = data.has_null_key_data();
221
13
                          const auto size = data.size() - has_null_key;
222
13
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
13
                          std::vector<KeyType> keys(size);
224
225
13
                          uint32_t num_rows = 0;
226
13
                          auto iter = aggregate_data_container->begin();
227
13
                          {
228
6.54k
                              while (iter != aggregate_data_container->end()) {
229
6.53k
                                  keys[num_rows] = iter.get_key<KeyType>();
230
6.53k
                                  ++iter;
231
6.53k
                                  ++num_rows;
232
6.53k
                              }
233
13
                          }
234
13
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
13
                          if (has_null_key) {
236
1
                              key_columns[0]->insert_data(nullptr, 0);
237
1
                          }
238
13
                          return key_columns;
239
13
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS7_Pc9HashCRC32IS7_EEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISK_EESaISN_EEOT_
Line
Count
Source
213
2
                      [&](auto&& agg_method) -> MutableColumns {
214
2
                          MutableColumns key_columns;
215
4
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
2
                              key_columns.emplace_back(
217
2
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
2
                          }
219
2
                          auto& data = *agg_method.hash_table;
220
2
                          bool has_null_key = data.has_null_key_data();
221
2
                          const auto size = data.size() - has_null_key;
222
2
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
2
                          std::vector<KeyType> keys(size);
224
225
2
                          uint32_t num_rows = 0;
226
2
                          auto iter = aggregate_data_container->begin();
227
2
                          {
228
9
                              while (iter != aggregate_data_container->end()) {
229
7
                                  keys[num_rows] = iter.get_key<KeyType>();
230
7
                                  ++iter;
231
7
                                  ++num_rows;
232
7
                              }
233
2
                          }
234
2
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
2
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
2
                          return key_columns;
239
2
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm256EjEENS_15DataWithNullKeyI9PHHashMapIS7_Pc9HashCRC32IS7_EEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISK_EESaISN_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_19MethodStringNoCacheINS_15DataWithNullKeyINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISI_EESaISL_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISD_EESaISG_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodKeysFixedI9PHHashMapINS_6UInt72EPc9HashCRC32IS5_EEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISE_EESaISH_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodKeysFixedI9PHHashMapINS_6UInt96EPc9HashCRC32IS5_EEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISE_EESaISH_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodKeysFixedI9PHHashMapINS_7UInt104EPc9HashCRC32IS5_EEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISE_EESaISH_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS7_EEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodKeysFixedI9PHHashMapINS_7UInt136EPc9HashCRC32IS5_EEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISE_EESaISH_EEOT_
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS7_EEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
Line
Count
Source
213
12
                      [&](auto&& agg_method) -> MutableColumns {
214
12
                          MutableColumns key_columns;
215
46
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
34
                              key_columns.emplace_back(
217
34
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
34
                          }
219
12
                          auto& data = *agg_method.hash_table;
220
12
                          bool has_null_key = data.has_null_key_data();
221
12
                          const auto size = data.size() - has_null_key;
222
12
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
12
                          std::vector<KeyType> keys(size);
224
225
12
                          uint32_t num_rows = 0;
226
12
                          auto iter = aggregate_data_container->begin();
227
12
                          {
228
2.15k
                              while (iter != aggregate_data_container->end()) {
229
2.14k
                                  keys[num_rows] = iter.get_key<KeyType>();
230
2.14k
                                  ++iter;
231
2.14k
                                  ++num_rows;
232
2.14k
                              }
233
12
                          }
234
12
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
12
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
12
                          return key_columns;
239
12
                      }},
240
46
            agg_data->method_variant);
241
46
}
242
243
46
void AggSharedState::build_limit_heap(size_t hash_table_size) {
244
46
    limit_columns = _get_keys_hash_table();
245
12.7k
    for (size_t i = 0; i < hash_table_size; ++i) {
246
12.7k
        limit_heap.emplace(i, limit_columns, order_directions, null_directions);
247
12.7k
    }
248
12.6k
    while (hash_table_size > limit) {
249
12.5k
        limit_heap.pop();
250
12.5k
        hash_table_size--;
251
12.5k
    }
252
46
    limit_columns_min = limit_heap.top()._row_id;
253
46
}
254
255
bool AggSharedState::do_limit_filter(Block* block, size_t num_rows,
256
87
                                     const std::vector<int>* key_locs) {
257
87
    if (num_rows) {
258
87
        cmp_res.resize(num_rows);
259
87
        need_computes.resize(num_rows);
260
87
        memset(need_computes.data(), 0, need_computes.size());
261
87
        memset(cmp_res.data(), 0, cmp_res.size());
262
263
87
        const auto key_size = null_directions.size();
264
230
        for (int i = 0; i < key_size; i++) {
265
143
            block->get_by_position(key_locs ? key_locs->operator[](i) : i)
266
143
                    .column->compare_internal(limit_columns_min, *limit_columns[i],
267
143
                                              null_directions[i], order_directions[i], cmp_res,
268
143
                                              need_computes.data());
269
143
        }
270
271
87
        auto set_computes_arr = [](auto* __restrict res, auto* __restrict computes, size_t rows) {
272
23.8k
            for (size_t i = 0; i < rows; ++i) {
273
23.7k
                computes[i] = computes[i] == res[i];
274
23.7k
            }
275
87
        };
276
87
        set_computes_arr(cmp_res.data(), need_computes.data(), num_rows);
277
278
87
        return std::find(need_computes.begin(), need_computes.end(), 0) != need_computes.end();
279
87
    }
280
281
0
    return false;
282
87
}
283
284
5.82k
Status AggSharedState::reset_hash_table() {
285
5.82k
    return std::visit(
286
5.82k
            Overload {[&](std::monostate& arg) -> Status {
287
0
                          return Status::InternalError("Uninited hash table");
288
0
                      },
289
5.82k
                      [&](auto& agg_method) {
290
5.82k
                          auto& hash_table = *agg_method.hash_table;
291
5.82k
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
5.82k
                          agg_method.arena.clear();
294
5.82k
                          agg_method.inited_iterator = false;
295
296
1.39M
                          hash_table.for_each_mapped([&](auto& mapped) {
297
1.39M
                              if (mapped) {
298
1.39M
                                  _destroy_agg_status(mapped);
299
1.39M
                                  mapped = nullptr;
300
1.39M
                              }
301
1.39M
                          });
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS5_vEEEEEEDaRT_ENKUlSC_E_clIS6_EEDaSC_
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEDaRT_ENKUlSB_E_clIS5_EEDaSB_
Line
Count
Source
296
326
                          hash_table.for_each_mapped([&](auto& mapped) {
297
326
                              if (mapped) {
298
326
                                  _destroy_agg_status(mapped);
299
326
                                  mapped = nullptr;
300
326
                              }
301
326
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEDaRT_ENKUlSB_E_clIS5_EEDaSB_
Line
Count
Source
296
640
                          hash_table.for_each_mapped([&](auto& mapped) {
297
640
                              if (mapped) {
298
640
                                  _destroy_agg_status(mapped);
299
640
                                  mapped = nullptr;
300
640
                              }
301
640
                          });
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
504
                          hash_table.for_each_mapped([&](auto& mapped) {
297
504
                              if (mapped) {
298
504
                                  _destroy_agg_status(mapped);
299
504
                                  mapped = nullptr;
300
504
                              }
301
504
                          });
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
548
                          hash_table.for_each_mapped([&](auto& mapped) {
297
548
                              if (mapped) {
298
548
                                  _destroy_agg_status(mapped);
299
548
                                  mapped = nullptr;
300
548
                              }
301
548
                          });
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS6_Pc9HashCRC32IS6_EEEEEEDaRT_ENKUlSE_E_clIS8_EEDaSE_
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEDaRT_ENKUlSD_E_clIS5_EEDaSD_
Line
Count
Source
296
1.04M
                          hash_table.for_each_mapped([&](auto& mapped) {
297
1.04M
                              if (mapped) {
298
1.04M
                                  _destroy_agg_status(mapped);
299
1.04M
                                  mapped = nullptr;
300
1.04M
                              }
301
1.04M
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEDaRT_ENKUlSD_E_clIS5_EEDaSD_
Line
Count
Source
296
2.94k
                          hash_table.for_each_mapped([&](auto& mapped) {
297
2.94k
                              if (mapped) {
298
2.94k
                                  _destroy_agg_status(mapped);
299
2.94k
                                  mapped = nullptr;
300
2.94k
                              }
301
2.94k
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIhNS_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Line
Count
Source
296
230
                          hash_table.for_each_mapped([&](auto& mapped) {
297
230
                              if (mapped) {
298
230
                                  _destroy_agg_status(mapped);
299
230
                                  mapped = nullptr;
300
230
                              }
301
230
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberItNS_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Line
Count
Source
296
56
                          hash_table.for_each_mapped([&](auto& mapped) {
297
56
                              if (mapped) {
298
56
                                  _destroy_agg_status(mapped);
299
56
                                  mapped = nullptr;
300
56
                              }
301
56
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Line
Count
Source
296
86.2k
                          hash_table.for_each_mapped([&](auto& mapped) {
297
86.2k
                              if (mapped) {
298
86.2k
                                  _destroy_agg_status(mapped);
299
86.2k
                                  mapped = nullptr;
300
86.2k
                              }
301
86.2k
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Line
Count
Source
296
6.72k
                          hash_table.for_each_mapped([&](auto& mapped) {
297
6.72k
                              if (mapped) {
298
6.72k
                                  _destroy_agg_status(mapped);
299
6.72k
                                  mapped = nullptr;
300
6.72k
                              }
301
6.72k
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEDaRT_ENKUlSH_E_clIS7_EEDaSH_
Line
Count
Source
296
240k
                          hash_table.for_each_mapped([&](auto& mapped) {
297
240k
                              if (mapped) {
298
240k
                                  _destroy_agg_status(mapped);
299
240k
                                  mapped = nullptr;
300
240k
                              }
301
240k
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEDaRT_ENKUlSH_E_clIS7_EEDaSH_
Line
Count
Source
296
9.81k
                          hash_table.for_each_mapped([&](auto& mapped) {
297
9.81k
                              if (mapped) {
298
9.81k
                                  _destroy_agg_status(mapped);
299
9.81k
                                  mapped = nullptr;
300
9.81k
                              }
301
9.81k
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS7_Pc9HashCRC32IS7_EEEEEEEEEEDaRT_ENKUlSI_E_clISA_EEDaSI_
Line
Count
Source
296
200
                          hash_table.for_each_mapped([&](auto& mapped) {
297
200
                              if (mapped) {
298
200
                                  _destroy_agg_status(mapped);
299
200
                                  mapped = nullptr;
300
200
                              }
301
200
                          });
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
5.82k
                          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
5.82k
                          aggregate_data_container.reset(new AggregateDataContainer(
309
5.82k
                                  sizeof(typename HashTableType::key_type),
310
5.82k
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
5.82k
                                   align_aggregate_states) *
312
5.82k
                                          align_aggregate_states));
313
5.82k
                          agg_method.hash_table.reset(new HashTableType());
314
5.82k
                          return Status::OK();
315
5.82k
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS5_vEEEEEEDaRT_
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEDaRT_
Line
Count
Source
289
122
                      [&](auto& agg_method) {
290
122
                          auto& hash_table = *agg_method.hash_table;
291
122
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
122
                          agg_method.arena.clear();
294
122
                          agg_method.inited_iterator = false;
295
296
122
                          hash_table.for_each_mapped([&](auto& mapped) {
297
122
                              if (mapped) {
298
122
                                  _destroy_agg_status(mapped);
299
122
                                  mapped = nullptr;
300
122
                              }
301
122
                          });
302
303
122
                          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
122
                          aggregate_data_container.reset(new AggregateDataContainer(
309
122
                                  sizeof(typename HashTableType::key_type),
310
122
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
122
                                   align_aggregate_states) *
312
122
                                          align_aggregate_states));
313
122
                          agg_method.hash_table.reset(new HashTableType());
314
122
                          return Status::OK();
315
122
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEDaRT_
Line
Count
Source
289
158
                      [&](auto& agg_method) {
290
158
                          auto& hash_table = *agg_method.hash_table;
291
158
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
158
                          agg_method.arena.clear();
294
158
                          agg_method.inited_iterator = false;
295
296
158
                          hash_table.for_each_mapped([&](auto& mapped) {
297
158
                              if (mapped) {
298
158
                                  _destroy_agg_status(mapped);
299
158
                                  mapped = nullptr;
300
158
                              }
301
158
                          });
302
303
158
                          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
158
                          aggregate_data_container.reset(new AggregateDataContainer(
309
158
                                  sizeof(typename HashTableType::key_type),
310
158
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
158
                                   align_aggregate_states) *
312
158
                                          align_aggregate_states));
313
158
                          agg_method.hash_table.reset(new HashTableType());
314
158
                          return Status::OK();
315
158
                      }},
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
150
                      [&](auto& agg_method) {
290
150
                          auto& hash_table = *agg_method.hash_table;
291
150
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
150
                          agg_method.arena.clear();
294
150
                          agg_method.inited_iterator = false;
295
296
150
                          hash_table.for_each_mapped([&](auto& mapped) {
297
150
                              if (mapped) {
298
150
                                  _destroy_agg_status(mapped);
299
150
                                  mapped = nullptr;
300
150
                              }
301
150
                          });
302
303
150
                          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
150
                          aggregate_data_container.reset(new AggregateDataContainer(
309
150
                                  sizeof(typename HashTableType::key_type),
310
150
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
150
                                   align_aggregate_states) *
312
150
                                          align_aggregate_states));
313
150
                          agg_method.hash_table.reset(new HashTableType());
314
150
                          return Status::OK();
315
150
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS6_Pc9HashCRC32IS6_EEEEEEDaRT_
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEDaRT_
Line
Count
Source
289
385
                      [&](auto& agg_method) {
290
385
                          auto& hash_table = *agg_method.hash_table;
291
385
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
385
                          agg_method.arena.clear();
294
385
                          agg_method.inited_iterator = false;
295
296
385
                          hash_table.for_each_mapped([&](auto& mapped) {
297
385
                              if (mapped) {
298
385
                                  _destroy_agg_status(mapped);
299
385
                                  mapped = nullptr;
300
385
                              }
301
385
                          });
302
303
385
                          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
385
                          aggregate_data_container.reset(new AggregateDataContainer(
309
385
                                  sizeof(typename HashTableType::key_type),
310
385
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
385
                                   align_aggregate_states) *
312
385
                                          align_aggregate_states));
313
385
                          agg_method.hash_table.reset(new HashTableType());
314
385
                          return Status::OK();
315
385
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEDaRT_
Line
Count
Source
289
948
                      [&](auto& agg_method) {
290
948
                          auto& hash_table = *agg_method.hash_table;
291
948
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
948
                          agg_method.arena.clear();
294
948
                          agg_method.inited_iterator = false;
295
296
948
                          hash_table.for_each_mapped([&](auto& mapped) {
297
948
                              if (mapped) {
298
948
                                  _destroy_agg_status(mapped);
299
948
                                  mapped = nullptr;
300
948
                              }
301
948
                          });
302
303
948
                          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
948
                          aggregate_data_container.reset(new AggregateDataContainer(
309
948
                                  sizeof(typename HashTableType::key_type),
310
948
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
948
                                   align_aggregate_states) *
312
948
                                          align_aggregate_states));
313
948
                          agg_method.hash_table.reset(new HashTableType());
314
948
                          return Status::OK();
315
948
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIhNS_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEDaRT_
Line
Count
Source
289
102
                      [&](auto& agg_method) {
290
102
                          auto& hash_table = *agg_method.hash_table;
291
102
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
102
                          agg_method.arena.clear();
294
102
                          agg_method.inited_iterator = false;
295
296
102
                          hash_table.for_each_mapped([&](auto& mapped) {
297
102
                              if (mapped) {
298
102
                                  _destroy_agg_status(mapped);
299
102
                                  mapped = nullptr;
300
102
                              }
301
102
                          });
302
303
102
                          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
102
                          aggregate_data_container.reset(new AggregateDataContainer(
309
102
                                  sizeof(typename HashTableType::key_type),
310
102
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
102
                                   align_aggregate_states) *
312
102
                                          align_aggregate_states));
313
102
                          agg_method.hash_table.reset(new HashTableType());
314
102
                          return Status::OK();
315
102
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberItNS_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEDaRT_
Line
Count
Source
289
48
                      [&](auto& agg_method) {
290
48
                          auto& hash_table = *agg_method.hash_table;
291
48
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
48
                          agg_method.arena.clear();
294
48
                          agg_method.inited_iterator = false;
295
296
48
                          hash_table.for_each_mapped([&](auto& mapped) {
297
48
                              if (mapped) {
298
48
                                  _destroy_agg_status(mapped);
299
48
                                  mapped = nullptr;
300
48
                              }
301
48
                          });
302
303
48
                          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
48
                          aggregate_data_container.reset(new AggregateDataContainer(
309
48
                                  sizeof(typename HashTableType::key_type),
310
48
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
48
                                   align_aggregate_states) *
312
48
                                          align_aggregate_states));
313
48
                          agg_method.hash_table.reset(new HashTableType());
314
48
                          return Status::OK();
315
48
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEDaRT_
Line
Count
Source
289
590
                      [&](auto& agg_method) {
290
590
                          auto& hash_table = *agg_method.hash_table;
291
590
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
590
                          agg_method.arena.clear();
294
590
                          agg_method.inited_iterator = false;
295
296
590
                          hash_table.for_each_mapped([&](auto& mapped) {
297
590
                              if (mapped) {
298
590
                                  _destroy_agg_status(mapped);
299
590
                                  mapped = nullptr;
300
590
                              }
301
590
                          });
302
303
590
                          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
590
                          aggregate_data_container.reset(new AggregateDataContainer(
309
590
                                  sizeof(typename HashTableType::key_type),
310
590
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
590
                                   align_aggregate_states) *
312
590
                                          align_aggregate_states));
313
590
                          agg_method.hash_table.reset(new HashTableType());
314
590
                          return Status::OK();
315
590
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEDaRT_
Line
Count
Source
289
476
                      [&](auto& agg_method) {
290
476
                          auto& hash_table = *agg_method.hash_table;
291
476
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
476
                          agg_method.arena.clear();
294
476
                          agg_method.inited_iterator = false;
295
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
                          });
302
303
476
                          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
476
                          aggregate_data_container.reset(new AggregateDataContainer(
309
476
                                  sizeof(typename HashTableType::key_type),
310
476
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
476
                                   align_aggregate_states) *
312
476
                                          align_aggregate_states));
313
476
                          agg_method.hash_table.reset(new HashTableType());
314
476
                          return Status::OK();
315
476
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEDaRT_
Line
Count
Source
289
1.36k
                      [&](auto& agg_method) {
290
1.36k
                          auto& hash_table = *agg_method.hash_table;
291
1.36k
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
1.36k
                          agg_method.arena.clear();
294
1.36k
                          agg_method.inited_iterator = false;
295
296
1.36k
                          hash_table.for_each_mapped([&](auto& mapped) {
297
1.36k
                              if (mapped) {
298
1.36k
                                  _destroy_agg_status(mapped);
299
1.36k
                                  mapped = nullptr;
300
1.36k
                              }
301
1.36k
                          });
302
303
1.36k
                          if (hash_table.has_null_key_data()) {
304
0
                              _destroy_agg_status(
305
0
                                      hash_table.template get_null_key_data<AggregateDataPtr>());
306
0
                          }
307
308
1.36k
                          aggregate_data_container.reset(new AggregateDataContainer(
309
1.36k
                                  sizeof(typename HashTableType::key_type),
310
1.36k
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
1.36k
                                   align_aggregate_states) *
312
1.36k
                                          align_aggregate_states));
313
1.36k
                          agg_method.hash_table.reset(new HashTableType());
314
1.36k
                          return Status::OK();
315
1.36k
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEDaRT_
Line
Count
Source
289
1.28k
                      [&](auto& agg_method) {
290
1.28k
                          auto& hash_table = *agg_method.hash_table;
291
1.28k
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
1.28k
                          agg_method.arena.clear();
294
1.28k
                          agg_method.inited_iterator = false;
295
296
1.28k
                          hash_table.for_each_mapped([&](auto& mapped) {
297
1.28k
                              if (mapped) {
298
1.28k
                                  _destroy_agg_status(mapped);
299
1.28k
                                  mapped = nullptr;
300
1.28k
                              }
301
1.28k
                          });
302
303
1.28k
                          if (hash_table.has_null_key_data()) {
304
0
                              _destroy_agg_status(
305
0
                                      hash_table.template get_null_key_data<AggregateDataPtr>());
306
0
                          }
307
308
1.28k
                          aggregate_data_container.reset(new AggregateDataContainer(
309
1.28k
                                  sizeof(typename HashTableType::key_type),
310
1.28k
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
1.28k
                                   align_aggregate_states) *
312
1.28k
                                          align_aggregate_states));
313
1.28k
                          agg_method.hash_table.reset(new HashTableType());
314
1.28k
                          return Status::OK();
315
1.28k
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS7_Pc9HashCRC32IS7_EEEEEEEEEEDaRT_
Line
Count
Source
289
54
                      [&](auto& agg_method) {
290
54
                          auto& hash_table = *agg_method.hash_table;
291
54
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
54
                          agg_method.arena.clear();
294
54
                          agg_method.inited_iterator = false;
295
296
54
                          hash_table.for_each_mapped([&](auto& mapped) {
297
54
                              if (mapped) {
298
54
                                  _destroy_agg_status(mapped);
299
54
                                  mapped = nullptr;
300
54
                              }
301
54
                          });
302
303
54
                          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
54
                          aggregate_data_container.reset(new AggregateDataContainer(
309
54
                                  sizeof(typename HashTableType::key_type),
310
54
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
54
                                   align_aggregate_states) *
312
54
                                          align_aggregate_states));
313
54
                          agg_method.hash_table.reset(new HashTableType());
314
54
                          return Status::OK();
315
54
                      }},
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
5.82k
            agg_data->method_variant);
317
5.82k
}
318
319
931
void PartitionedAggSharedState::init_spill_params(size_t spill_partition_count) {
320
931
    partition_count = spill_partition_count;
321
931
    max_partition_index = partition_count - 1;
322
323
30.7k
    for (int i = 0; i < partition_count; ++i) {
324
29.7k
        spill_partitions.emplace_back(std::make_shared<AggSpillPartition>());
325
29.7k
    }
326
931
}
327
328
920
void PartitionedAggSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {
329
29.4k
    for (auto& partition : spill_partitions) {
330
29.4k
        if (partition->spilling_stream_) {
331
0
            partition->spilling_stream_->update_shared_profiles(source_profile);
332
0
        }
333
29.4k
        for (auto& stream : partition->spill_streams_) {
334
3.93k
            if (stream) {
335
3.93k
                stream->update_shared_profiles(source_profile);
336
3.93k
            }
337
3.93k
        }
338
29.4k
    }
339
920
}
340
341
Status AggSpillPartition::get_spill_stream(RuntimeState* state, int node_id,
342
17.9k
                                           RuntimeProfile* profile, SpillStreamSPtr& spill_stream) {
343
17.9k
    if (spilling_stream_) {
344
13.9k
        spill_stream = spilling_stream_;
345
13.9k
        return Status::OK();
346
13.9k
    }
347
3.98k
    RETURN_IF_ERROR(ExecEnv::GetInstance()->spill_stream_mgr()->register_spill_stream(
348
3.98k
            state, spilling_stream_, print_id(state->query_id()), "agg", node_id,
349
3.98k
            std::numeric_limits<int32_t>::max(), std::numeric_limits<size_t>::max(), profile));
350
3.98k
    spill_streams_.emplace_back(spilling_stream_);
351
3.98k
    spill_stream = spilling_stream_;
352
3.98k
    return Status::OK();
353
3.98k
}
354
21.8k
void AggSpillPartition::close() {
355
21.8k
    if (spilling_stream_) {
356
1
        spilling_stream_.reset();
357
1
    }
358
21.8k
    for (auto& stream : spill_streams_) {
359
5
        (void)ExecEnv::GetInstance()->spill_stream_mgr()->delete_spill_stream(stream);
360
5
    }
361
21.8k
    spill_streams_.clear();
362
21.8k
}
363
364
1.07k
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
1.07k
    bool false_close = false;
368
1.07k
    if (!is_closed.compare_exchange_strong(false_close, true)) {
369
146
        return;
370
146
    }
371
1.07k
    DCHECK(!false_close && is_closed);
372
21.8k
    for (auto partition : spill_partitions) {
373
21.8k
        partition->close();
374
21.8k
    }
375
925
    spill_partitions.clear();
376
925
}
377
378
17
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
17
}
385
386
19
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
19
    bool false_close = false;
390
19
    if (!is_closed.compare_exchange_strong(false_close, true)) {
391
1
        return;
392
1
    }
393
19
    DCHECK(!false_close && is_closed);
394
18
    for (auto& stream : sorted_streams) {
395
1
        (void)ExecEnv::GetInstance()->spill_stream_mgr()->delete_spill_stream(stream);
396
1
    }
397
18
    sorted_streams.clear();
398
18
}
399
400
MultiCastSharedState::MultiCastSharedState(ObjectPool* pool, int cast_sender_count, int node_id)
401
        : multi_cast_data_streamer(
402
4.34k
                  std::make_unique<MultiCastDataStreamer>(pool, cast_sender_count, node_id)) {}
403
404
0
void MultiCastSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {}
405
406
112k
int AggSharedState::get_slot_column_id(const AggFnEvaluator* evaluator) {
407
112k
    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
112k
    return ((VSlotRef*)ctxs[0]->root().get())->column_id();
412
112k
}
413
414
4.35M
void AggSharedState::_destroy_agg_status(AggregateDataPtr data) {
415
11.0M
    for (int i = 0; i < aggregate_evaluators.size(); ++i) {
416
6.66M
        aggregate_evaluators[i]->function()->destroy(data + offsets_of_aggregate_states[i]);
417
6.66M
    }
418
4.35M
}
419
420
96.5k
LocalExchangeSharedState::~LocalExchangeSharedState() = default;
421
422
12.4k
Status SetSharedState::update_build_not_ignore_null(const VExprContextSPtrs& ctxs) {
423
12.4k
    if (ctxs.size() > build_not_ignore_null.size()) {
424
0
        return Status::InternalError("build_not_ignore_null not initialized");
425
0
    }
426
427
100k
    for (int i = 0; i < ctxs.size(); ++i) {
428
88.4k
        build_not_ignore_null[i] = build_not_ignore_null[i] || ctxs[i]->root()->is_nullable();
429
88.4k
    }
430
431
12.4k
    return Status::OK();
432
12.4k
}
433
434
20.0k
size_t SetSharedState::get_hash_table_size() const {
435
20.0k
    size_t hash_table_size = 0;
436
20.0k
    std::visit(
437
20.0k
            [&](auto&& arg) {
438
20.0k
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
20.0k
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
20.0k
                    hash_table_size = arg.hash_table->size();
441
20.0k
                }
442
20.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
18.0k
            [&](auto&& arg) {
438
18.0k
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
18.0k
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
18.0k
                    hash_table_size = arg.hash_table->size();
441
18.0k
                }
442
18.0k
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_19MethodStringNoCacheI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS5_vEEEEEEDaOT_
Line
Count
Source
437
98
            [&](auto&& arg) {
438
98
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
98
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
98
                    hash_table_size = arg.hash_table->size();
441
98
                }
442
98
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_26MethodSingleNullableColumnINS_19MethodStringNoCacheINS_15DataWithNullKeyI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS7_vEEEEEEEEEEDaOT_
Line
Count
Source
437
506
            [&](auto&& arg) {
438
506
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
506
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
506
                    hash_table_size = arg.hash_table->size();
441
506
                }
442
506
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIhNS_15DataWithNullKeyI9PHHashMapIhNS_14RowRefWithFlagE9HashCRC32IhEEEEEEEEEEDaOT_
Line
Count
Source
437
48
            [&](auto&& arg) {
438
48
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
48
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
48
                    hash_table_size = arg.hash_table->size();
441
48
                }
442
48
            },
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
602
            [&](auto&& arg) {
438
602
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
602
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
602
                    hash_table_size = arg.hash_table->size();
441
602
                }
442
602
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImNS_14RowRefWithFlagE9HashCRC32ImEEEEEEEEEEDaOT_
Line
Count
Source
437
280
            [&](auto&& arg) {
438
280
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
280
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
280
                    hash_table_size = arg.hash_table->size();
441
280
                }
442
280
            },
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
96
            [&](auto&& arg) {
438
96
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
96
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
96
                    hash_table_size = arg.hash_table->size();
441
96
                }
442
96
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodKeysFixedI9PHHashMapINS_6UInt96ENS_14RowRefWithFlagE9HashCRC32IS5_EEEEEEDaOT_
Line
Count
Source
437
6
            [&](auto&& arg) {
438
6
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
6
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
6
                    hash_table_size = arg.hash_table->size();
441
6
                }
442
6
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodKeysFixedI9PHHashMapINS_7UInt104ENS_14RowRefWithFlagE9HashCRC32IS5_EEEEEEDaOT_
Line
Count
Source
437
18
            [&](auto&& arg) {
438
18
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
18
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
18
                    hash_table_size = arg.hash_table->size();
441
18
                }
442
18
            },
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
20.0k
            hash_table_variants->method_variant);
444
20.0k
    return hash_table_size;
445
20.0k
}
446
447
5.12k
Status SetSharedState::hash_table_init() {
448
5.12k
    std::vector<DataTypePtr> data_types;
449
40.7k
    for (size_t i = 0; i != child_exprs_lists[0].size(); ++i) {
450
35.6k
        auto& ctx = child_exprs_lists[0][i];
451
35.6k
        auto data_type = ctx->root()->data_type();
452
35.6k
        if (build_not_ignore_null[i]) {
453
35.4k
            data_type = make_nullable(data_type);
454
35.4k
        }
455
35.6k
        data_types.emplace_back(std::move(data_type));
456
35.6k
    }
457
5.12k
    return init_hash_method<SetDataVariants>(hash_table_variants.get(), data_types, true);
458
5.12k
}
459
460
21
void AggSharedState::refresh_top_limit(size_t row_id, const ColumnRawPtrs& key_columns) {
461
75
    for (int j = 0; j < key_columns.size(); ++j) {
462
54
        limit_columns[j]->insert_from(*key_columns[j], row_id);
463
54
    }
464
21
    limit_heap.emplace(limit_columns[0]->size() - 1, limit_columns, order_directions,
465
21
                       null_directions);
466
467
21
    limit_heap.pop();
468
21
    limit_columns_min = limit_heap.top()._row_id;
469
21
}
470
471
} // namespace doris