Coverage Report

Created: 2026-03-15 15:38

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
527k
                                                       const std::string& name) {
43
527k
    source_deps.push_back(std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY"));
44
527k
    source_deps.back()->set_shared_state(this);
45
527k
    return source_deps.back().get();
46
527k
}
47
48
void BasicSharedState::create_source_dependencies(int num_sources, int operator_id, int node_id,
49
112k
                                                  const std::string& name) {
50
112k
    source_deps.resize(num_sources, nullptr);
51
704k
    for (auto& source_dep : source_deps) {
52
704k
        source_dep = std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY");
53
704k
        source_dep->set_shared_state(this);
54
704k
    }
55
112k
}
56
57
Dependency* BasicSharedState::create_sink_dependency(int dest_id, int node_id,
58
1.06M
                                                     const std::string& name) {
59
1.06M
    sink_deps.push_back(std::make_shared<Dependency>(dest_id, node_id, name + "_DEPENDENCY", true));
60
1.06M
    sink_deps.back()->set_shared_state(this);
61
1.06M
    return sink_deps.back().get();
62
1.06M
}
63
64
4.50M
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.50M
    _blocked_task.push_back(task);
69
4.50M
}
70
71
38.8M
void Dependency::set_ready() {
72
38.8M
    if (_ready) {
73
35.8M
        return;
74
35.8M
    }
75
3.04M
    std::vector<std::weak_ptr<PipelineTask>> local_block_task {};
76
3.04M
    {
77
3.04M
        std::unique_lock<std::mutex> lc(_task_lock);
78
3.04M
        if (_ready) {
79
1
            return;
80
1
        }
81
3.04M
        _watcher.stop();
82
3.04M
        _ready = true;
83
3.04M
        local_block_task.swap(_blocked_task);
84
3.04M
    }
85
4.51M
    for (auto task : local_block_task) {
86
4.51M
        if (auto t = task.lock()) {
87
4.51M
            std::unique_lock<std::mutex> lc(_task_lock);
88
4.51M
            THROW_IF_ERROR(t->wake_up(this, lc));
89
4.51M
        }
90
4.51M
    }
91
3.04M
}
92
93
49.9M
Dependency* Dependency::is_blocked_by(std::shared_ptr<PipelineTask> task) {
94
49.9M
    std::unique_lock<std::mutex> lc(_task_lock);
95
49.9M
    auto ready = _ready.load();
96
49.9M
    if (!ready && task) {
97
4.51M
        _add_block_task(task);
98
4.51M
        start_watcher();
99
4.51M
        THROW_IF_ERROR(task->blocked(this, lc));
100
4.51M
    }
101
49.9M
    return ready ? nullptr : this;
102
49.9M
}
103
104
399k
std::string Dependency::debug_string(int indentation_level) {
105
399k
    fmt::memory_buffer debug_string_buffer;
106
399k
    fmt::format_to(debug_string_buffer, "{}{}: id={}, block task = {}, ready={}, _always_ready={}",
107
399k
                   std::string(indentation_level * 2, ' '), _name, _node_id, _blocked_task.size(),
108
399k
                   _ready, _always_ready);
109
399k
    return fmt::to_string(debug_string_buffer);
110
399k
}
111
112
3.45k
std::string CountedFinishDependency::debug_string(int indentation_level) {
113
3.45k
    fmt::memory_buffer debug_string_buffer;
114
3.45k
    fmt::format_to(debug_string_buffer,
115
3.45k
                   "{}{}: id={}, block_task={}, ready={}, _always_ready={}, count={}",
116
3.45k
                   std::string(indentation_level * 2, ' '), _name, _node_id, _blocked_task.size(),
117
3.45k
                   _ready, _always_ready, _counter);
118
3.45k
    return fmt::to_string(debug_string_buffer);
119
3.45k
}
120
121
3.67k
void RuntimeFilterTimer::call_timeout() {
122
3.67k
    _parent->set_ready();
123
3.67k
}
124
125
73.3k
void RuntimeFilterTimer::call_ready() {
126
73.3k
    _parent->set_ready();
127
73.3k
}
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
13.2M
bool RuntimeFilterTimer::should_be_check_timeout() {
133
13.2M
    if (!_parent->ready() && !_local_runtime_filter_dependencies.empty()) {
134
516k
        bool all_ready = true;
135
518k
        for (auto& dep : _local_runtime_filter_dependencies) {
136
518k
            if (!dep->ready()) {
137
514k
                all_ready = false;
138
514k
                break;
139
514k
            }
140
518k
        }
141
516k
        if (all_ready) {
142
1.76k
            _local_runtime_filter_dependencies.clear();
143
1.76k
            _registration_time = MonotonicMillis();
144
1.76k
        }
145
516k
        return all_ready;
146
516k
    }
147
12.7M
    return true;
148
13.2M
}
149
150
8
void RuntimeFilterTimerQueue::start() {
151
356k
    while (!_stop) {
152
356k
        std::unique_lock<std::mutex> lk(cv_m);
153
154
357k
        while (_que.empty() && !_stop) {
155
3.53k
            cv.wait_for(lk, std::chrono::seconds(3), [this] { return !_que.empty() || _stop; });
156
1.77k
        }
157
356k
        if (_stop) {
158
3
            break;
159
3
        }
160
356k
        {
161
356k
            std::unique_lock<std::mutex> lc(_que_lock);
162
356k
            std::list<std::shared_ptr<RuntimeFilterTimer>> new_que;
163
13.2M
            for (auto& it : _que) {
164
13.2M
                if (it.use_count() == 1) {
165
                    // `use_count == 1` means this runtime filter has been released
166
13.2M
                } else if (it->should_be_check_timeout()) {
167
12.7M
                    if (it->force_wait_timeout() || it->_parent->is_blocked_by()) {
168
                        // This means runtime filter is not ready, so we call timeout or continue to poll this timer.
169
12.6M
                        int64_t ms_since_registration = MonotonicMillis() - it->registration_time();
170
12.6M
                        if (ms_since_registration > it->wait_time_ms()) {
171
3.67k
                            it->call_timeout();
172
12.6M
                        } else {
173
12.6M
                            new_que.push_back(std::move(it));
174
12.6M
                        }
175
12.6M
                    }
176
12.7M
                } else {
177
514k
                    new_que.push_back(std::move(it));
178
514k
                }
179
13.2M
            }
180
356k
            new_que.swap(_que);
181
356k
        }
182
356k
        std::this_thread::sleep_for(std::chrono::milliseconds(interval));
183
356k
    }
184
8
    _shutdown = true;
185
8
}
186
187
332k
void LocalExchangeSharedState::sub_running_sink_operators() {
188
332k
    std::unique_lock<std::mutex> lc(le_lock);
189
332k
    if (exchanger->_running_sink_operators.fetch_sub(1) == 1) {
190
110k
        _set_always_ready();
191
110k
    }
192
332k
}
193
194
690k
void LocalExchangeSharedState::sub_running_source_operators() {
195
690k
    std::unique_lock<std::mutex> lc(le_lock);
196
690k
    if (exchanger->_running_source_operators.fetch_sub(1) == 1) {
197
110k
        _set_always_ready();
198
110k
        exchanger->finalize();
199
110k
    }
200
690k
}
201
202
109k
LocalExchangeSharedState::LocalExchangeSharedState(int num_instances) {
203
109k
    source_deps.resize(num_instances, nullptr);
204
109k
    mem_counters.resize(num_instances, nullptr);
205
109k
}
206
207
153
MutableColumns AggSharedState::_get_keys_hash_table() {
208
153
    return std::visit(
209
153
            Overload {[&](std::monostate& arg) {
210
0
                          throw doris::Exception(ErrorCode::INTERNAL_ERROR, "uninited hash table");
211
0
                          return MutableColumns();
212
0
                      },
213
153
                      [&](auto&& agg_method) -> MutableColumns {
214
153
                          MutableColumns key_columns;
215
500
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
347
                              key_columns.emplace_back(
217
347
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
347
                          }
219
153
                          auto& data = *agg_method.hash_table;
220
153
                          bool has_null_key = data.has_null_key_data();
221
153
                          const auto size = data.size() - has_null_key;
222
153
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
153
                          std::vector<KeyType> keys(size);
224
225
153
                          uint32_t num_rows = 0;
226
153
                          auto iter = aggregate_data_container->begin();
227
153
                          {
228
16.2k
                              while (iter != aggregate_data_container->end()) {
229
16.0k
                                  keys[num_rows] = iter.get_key<KeyType>();
230
16.0k
                                  ++iter;
231
16.0k
                                  ++num_rows;
232
16.0k
                              }
233
153
                          }
234
153
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
153
                          if (has_null_key) {
236
2
                              key_columns[0]->insert_data(nullptr, 0);
237
2
                          }
238
153
                          return key_columns;
239
153
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS5_vEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISE_EESaISH_EEOT_
Line
Count
Source
213
14
                      [&](auto&& agg_method) -> MutableColumns {
214
14
                          MutableColumns key_columns;
215
70
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
56
                              key_columns.emplace_back(
217
56
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
56
                          }
219
14
                          auto& data = *agg_method.hash_table;
220
14
                          bool has_null_key = data.has_null_key_data();
221
14
                          const auto size = data.size() - has_null_key;
222
14
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
14
                          std::vector<KeyType> keys(size);
224
225
14
                          uint32_t num_rows = 0;
226
14
                          auto iter = aggregate_data_container->begin();
227
14
                          {
228
4.58k
                              while (iter != aggregate_data_container->end()) {
229
4.56k
                                  keys[num_rows] = iter.get_key<KeyType>();
230
4.56k
                                  ++iter;
231
4.56k
                                  ++num_rows;
232
4.56k
                              }
233
14
                          }
234
14
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
14
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
14
                          return key_columns;
239
14
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISD_EESaISG_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISD_EESaISG_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISD_EESaISG_EEOT_
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISD_EESaISG_EEOT_
Line
Count
Source
213
1
                      [&](auto&& agg_method) -> MutableColumns {
214
1
                          MutableColumns key_columns;
215
2
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
1
                              key_columns.emplace_back(
217
1
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
1
                          }
219
1
                          auto& data = *agg_method.hash_table;
220
1
                          bool has_null_key = data.has_null_key_data();
221
1
                          const auto size = data.size() - has_null_key;
222
1
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
1
                          std::vector<KeyType> keys(size);
224
225
1
                          uint32_t num_rows = 0;
226
1
                          auto iter = aggregate_data_container->begin();
227
1
                          {
228
5
                              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
1
                          }
234
1
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
1
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
1
                          return key_columns;
239
1
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISE_EESaISH_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS6_Pc9HashCRC32IS6_EEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS6_Pc9HashCRC32IS6_EEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
Line
Count
Source
213
10
                      [&](auto&& agg_method) -> MutableColumns {
214
10
                          MutableColumns key_columns;
215
20
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
10
                              key_columns.emplace_back(
217
10
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
10
                          }
219
10
                          auto& data = *agg_method.hash_table;
220
10
                          bool has_null_key = data.has_null_key_data();
221
10
                          const auto size = data.size() - has_null_key;
222
10
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
10
                          std::vector<KeyType> keys(size);
224
225
10
                          uint32_t num_rows = 0;
226
10
                          auto iter = aggregate_data_container->begin();
227
10
                          {
228
20
                              while (iter != aggregate_data_container->end()) {
229
10
                                  keys[num_rows] = iter.get_key<KeyType>();
230
10
                                  ++iter;
231
10
                                  ++num_rows;
232
10
                              }
233
10
                          }
234
10
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
10
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
10
                          return key_columns;
239
10
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
Line
Count
Source
213
8
                      [&](auto&& agg_method) -> MutableColumns {
214
8
                          MutableColumns key_columns;
215
16
                          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
8
                          auto& data = *agg_method.hash_table;
220
8
                          bool has_null_key = data.has_null_key_data();
221
8
                          const auto size = data.size() - has_null_key;
222
8
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
8
                          std::vector<KeyType> keys(size);
224
225
8
                          uint32_t num_rows = 0;
226
8
                          auto iter = aggregate_data_container->begin();
227
8
                          {
228
33
                              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
8
                          }
234
8
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
8
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
8
                          return key_columns;
239
8
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIhNS_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
Line
Count
Source
213
1
                      [&](auto&& agg_method) -> MutableColumns {
214
1
                          MutableColumns key_columns;
215
2
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
1
                              key_columns.emplace_back(
217
1
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
1
                          }
219
1
                          auto& data = *agg_method.hash_table;
220
1
                          bool has_null_key = data.has_null_key_data();
221
1
                          const auto size = data.size() - has_null_key;
222
1
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
1
                          std::vector<KeyType> keys(size);
224
225
1
                          uint32_t num_rows = 0;
226
1
                          auto iter = aggregate_data_container->begin();
227
1
                          {
228
4
                              while (iter != aggregate_data_container->end()) {
229
3
                                  keys[num_rows] = iter.get_key<KeyType>();
230
3
                                  ++iter;
231
3
                                  ++num_rows;
232
3
                              }
233
1
                          }
234
1
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
1
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
1
                          return key_columns;
239
1
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberItNS_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
Line
Count
Source
213
7
                      [&](auto&& agg_method) -> MutableColumns {
214
7
                          MutableColumns key_columns;
215
14
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
7
                              key_columns.emplace_back(
217
7
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
7
                          }
219
7
                          auto& data = *agg_method.hash_table;
220
7
                          bool has_null_key = data.has_null_key_data();
221
7
                          const auto size = data.size() - has_null_key;
222
7
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
7
                          std::vector<KeyType> keys(size);
224
225
7
                          uint32_t num_rows = 0;
226
7
                          auto iter = aggregate_data_container->begin();
227
7
                          {
228
2.03k
                              while (iter != aggregate_data_container->end()) {
229
2.03k
                                  keys[num_rows] = iter.get_key<KeyType>();
230
2.03k
                                  ++iter;
231
2.03k
                                  ++num_rows;
232
2.03k
                              }
233
7
                          }
234
7
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
7
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
7
                          return key_columns;
239
7
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
Line
Count
Source
213
7
                      [&](auto&& agg_method) -> MutableColumns {
214
7
                          MutableColumns key_columns;
215
14
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
7
                              key_columns.emplace_back(
217
7
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
7
                          }
219
7
                          auto& data = *agg_method.hash_table;
220
7
                          bool has_null_key = data.has_null_key_data();
221
7
                          const auto size = data.size() - has_null_key;
222
7
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
7
                          std::vector<KeyType> keys(size);
224
225
7
                          uint32_t num_rows = 0;
226
7
                          auto iter = aggregate_data_container->begin();
227
7
                          {
228
2.03k
                              while (iter != aggregate_data_container->end()) {
229
2.03k
                                  keys[num_rows] = iter.get_key<KeyType>();
230
2.03k
                                  ++iter;
231
2.03k
                                  ++num_rows;
232
2.03k
                              }
233
7
                          }
234
7
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
7
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
7
                          return key_columns;
239
7
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
Line
Count
Source
213
9
                      [&](auto&& agg_method) -> MutableColumns {
214
9
                          MutableColumns key_columns;
215
18
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
9
                              key_columns.emplace_back(
217
9
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
9
                          }
219
9
                          auto& data = *agg_method.hash_table;
220
9
                          bool has_null_key = data.has_null_key_data();
221
9
                          const auto size = data.size() - has_null_key;
222
9
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
9
                          std::vector<KeyType> keys(size);
224
225
9
                          uint32_t num_rows = 0;
226
9
                          auto iter = aggregate_data_container->begin();
227
9
                          {
228
31
                              while (iter != aggregate_data_container->end()) {
229
22
                                  keys[num_rows] = iter.get_key<KeyType>();
230
22
                                  ++iter;
231
22
                                  ++num_rows;
232
22
                              }
233
9
                          }
234
9
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
9
                          if (has_null_key) {
236
1
                              key_columns[0]->insert_data(nullptr, 0);
237
1
                          }
238
9
                          return key_columns;
239
9
                      }},
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
Line
Count
Source
213
14
                      [&](auto&& agg_method) -> MutableColumns {
214
14
                          MutableColumns key_columns;
215
28
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
14
                              key_columns.emplace_back(
217
14
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
14
                          }
219
14
                          auto& data = *agg_method.hash_table;
220
14
                          bool has_null_key = data.has_null_key_data();
221
14
                          const auto size = data.size() - has_null_key;
222
14
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
14
                          std::vector<KeyType> keys(size);
224
225
14
                          uint32_t num_rows = 0;
226
14
                          auto iter = aggregate_data_container->begin();
227
14
                          {
228
5.01k
                              while (iter != aggregate_data_container->end()) {
229
5.00k
                                  keys[num_rows] = iter.get_key<KeyType>();
230
5.00k
                                  ++iter;
231
5.00k
                                  ++num_rows;
232
5.00k
                              }
233
14
                          }
234
14
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
14
                          if (has_null_key) {
236
1
                              key_columns[0]->insert_data(nullptr, 0);
237
1
                          }
238
14
                          return key_columns;
239
14
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS7_Pc9HashCRC32IS7_EEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISK_EESaISN_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm256EjEENS_15DataWithNullKeyI9PHHashMapIS7_Pc9HashCRC32IS7_EEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISK_EESaISN_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_26MethodSingleNullableColumnINS_19MethodStringNoCacheINS_15DataWithNullKeyINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISI_EESaISL_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImEEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISD_EESaISG_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodKeysFixedI9PHHashMapINS_6UInt72EPc9HashCRC32IS5_EEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISE_EESaISH_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodKeysFixedI9PHHashMapINS_6UInt96EPc9HashCRC32IS5_EEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISE_EESaISH_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodKeysFixedI9PHHashMapINS_7UInt104EPc9HashCRC32IS5_EEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISE_EESaISH_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS7_EEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodKeysFixedI9PHHashMapINS_7UInt136EPc9HashCRC32IS5_EEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISE_EESaISH_EEOT_
dependency.cpp:_ZZN5doris14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS7_EEEEEESt6vectorINS_3COWINS_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
Line
Count
Source
213
82
                      [&](auto&& agg_method) -> MutableColumns {
214
82
                          MutableColumns key_columns;
215
316
                          for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
216
234
                              key_columns.emplace_back(
217
234
                                      probe_expr_ctxs[i]->root()->data_type()->create_column());
218
234
                          }
219
82
                          auto& data = *agg_method.hash_table;
220
82
                          bool has_null_key = data.has_null_key_data();
221
82
                          const auto size = data.size() - has_null_key;
222
82
                          using KeyType = std::decay_t<decltype(agg_method)>::Key;
223
82
                          std::vector<KeyType> keys(size);
224
225
82
                          uint32_t num_rows = 0;
226
82
                          auto iter = aggregate_data_container->begin();
227
82
                          {
228
2.44k
                              while (iter != aggregate_data_container->end()) {
229
2.36k
                                  keys[num_rows] = iter.get_key<KeyType>();
230
2.36k
                                  ++iter;
231
2.36k
                                  ++num_rows;
232
2.36k
                              }
233
82
                          }
234
82
                          agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
235
82
                          if (has_null_key) {
236
0
                              key_columns[0]->insert_data(nullptr, 0);
237
0
                          }
238
82
                          return key_columns;
239
82
                      }},
240
153
            agg_data->method_variant);
241
153
}
242
243
153
void AggSharedState::build_limit_heap(size_t hash_table_size) {
244
153
    limit_columns = _get_keys_hash_table();
245
15.9k
    for (size_t i = 0; i < hash_table_size; ++i) {
246
15.8k
        limit_heap.emplace(i, limit_columns, order_directions, null_directions);
247
15.8k
    }
248
15.6k
    while (hash_table_size > limit) {
249
15.4k
        limit_heap.pop();
250
15.4k
        hash_table_size--;
251
15.4k
    }
252
153
    limit_columns_min = limit_heap.top()._row_id;
253
153
}
254
255
bool AggSharedState::do_limit_filter(Block* block, size_t num_rows,
256
645
                                     const std::vector<int>* key_locs) {
257
645
    if (num_rows) {
258
645
        cmp_res.resize(num_rows);
259
645
        need_computes.resize(num_rows);
260
645
        memset(need_computes.data(), 0, need_computes.size());
261
645
        memset(cmp_res.data(), 0, cmp_res.size());
262
263
645
        const auto key_size = null_directions.size();
264
2.24k
        for (int i = 0; i < key_size; i++) {
265
1.60k
            block->get_by_position(key_locs ? key_locs->operator[](i) : i)
266
1.60k
                    .column->compare_internal(limit_columns_min, *limit_columns[i],
267
1.60k
                                              null_directions[i], order_directions[i], cmp_res,
268
1.60k
                                              need_computes.data());
269
1.60k
        }
270
271
645
        auto set_computes_arr = [](auto* __restrict res, auto* __restrict computes, size_t rows) {
272
503k
            for (size_t i = 0; i < rows; ++i) {
273
503k
                computes[i] = computes[i] == res[i];
274
503k
            }
275
644
        };
276
645
        set_computes_arr(cmp_res.data(), need_computes.data(), num_rows);
277
278
645
        return std::find(need_computes.begin(), need_computes.end(), 0) != need_computes.end();
279
645
    }
280
281
0
    return false;
282
645
}
283
284
3.14k
Status AggSharedState::reset_hash_table() {
285
3.14k
    return std::visit(
286
3.14k
            Overload {[&](std::monostate& arg) -> Status {
287
0
                          return Status::InternalError("Uninited hash table");
288
0
                      },
289
3.14k
                      [&](auto& agg_method) {
290
3.14k
                          auto& hash_table = *agg_method.hash_table;
291
3.14k
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
3.14k
                          agg_method.arena.clear();
294
3.14k
                          agg_method.inited_iterator = false;
295
296
1.05M
                          hash_table.for_each_mapped([&](auto& mapped) {
297
1.05M
                              if (mapped) {
298
1.05M
                                  _destroy_agg_status(mapped);
299
1.05M
                                  mapped = nullptr;
300
1.05M
                              }
301
1.05M
                          });
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS5_vEEEEEEDaRT_ENKUlSC_E_clIS6_EEDaSC_
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEDaRT_ENKUlSB_E_clIS5_EEDaSB_
Line
Count
Source
296
238
                          hash_table.for_each_mapped([&](auto& mapped) {
297
238
                              if (mapped) {
298
238
                                  _destroy_agg_status(mapped);
299
238
                                  mapped = nullptr;
300
238
                              }
301
238
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEDaRT_ENKUlSB_E_clIS5_EEDaSB_
Line
Count
Source
296
660
                          hash_table.for_each_mapped([&](auto& mapped) {
297
660
                              if (mapped) {
298
660
                                  _destroy_agg_status(mapped);
299
660
                                  mapped = nullptr;
300
660
                              }
301
660
                          });
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_
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS6_Pc9HashCRC32IS6_EEEEEEDaRT_ENKUlSE_E_clIS8_EEDaSE_
Line
Count
Source
296
266
                          hash_table.for_each_mapped([&](auto& mapped) {
297
266
                              if (mapped) {
298
266
                                  _destroy_agg_status(mapped);
299
266
                                  mapped = nullptr;
300
266
                              }
301
266
                          });
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
1.08k
                          hash_table.for_each_mapped([&](auto& mapped) {
297
1.08k
                              if (mapped) {
298
1.08k
                                  _destroy_agg_status(mapped);
299
1.08k
                                  mapped = nullptr;
300
1.08k
                              }
301
1.08k
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIhNS_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Line
Count
Source
296
52
                          hash_table.for_each_mapped([&](auto& mapped) {
297
52
                              if (mapped) {
298
52
                                  _destroy_agg_status(mapped);
299
52
                                  mapped = nullptr;
300
52
                              }
301
52
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberItNS_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEDaRT_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_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Line
Count
Source
296
1.95k
                          hash_table.for_each_mapped([&](auto& mapped) {
297
1.95k
                              if (mapped) {
298
1.95k
                                  _destroy_agg_status(mapped);
299
1.95k
                                  mapped = nullptr;
300
1.95k
                              }
301
1.95k
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
Line
Count
Source
296
1.18k
                          hash_table.for_each_mapped([&](auto& mapped) {
297
1.18k
                              if (mapped) {
298
1.18k
                                  _destroy_agg_status(mapped);
299
1.18k
                                  mapped = nullptr;
300
1.18k
                              }
301
1.18k
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEDaRT_ENKUlSH_E_clIS7_EEDaSH_
Line
Count
Source
296
2.35k
                          hash_table.for_each_mapped([&](auto& mapped) {
297
2.35k
                              if (mapped) {
298
2.35k
                                  _destroy_agg_status(mapped);
299
2.35k
                                  mapped = nullptr;
300
2.35k
                              }
301
2.35k
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEDaRT_ENKUlSH_E_clIS7_EEDaSH_
Line
Count
Source
296
1.16k
                          hash_table.for_each_mapped([&](auto& mapped) {
297
1.16k
                              if (mapped) {
298
1.16k
                                  _destroy_agg_status(mapped);
299
1.16k
                                  mapped = nullptr;
300
1.16k
                              }
301
1.16k
                          });
dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS7_Pc9HashCRC32IS7_EEEEEEEEEEDaRT_ENKUlSI_E_clISA_EEDaSI_
Line
Count
Source
296
168
                          hash_table.for_each_mapped([&](auto& mapped) {
297
168
                              if (mapped) {
298
168
                                  _destroy_agg_status(mapped);
299
168
                                  mapped = nullptr;
300
168
                              }
301
168
                          });
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm256EjEENS_15DataWithNullKeyI9PHHashMapIS7_Pc9HashCRC32IS7_EEEEEEEEEEDaRT_ENKUlSI_E_clISA_EEDaSI_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_19MethodStringNoCacheINS_15DataWithNullKeyINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEEEEEDaRT_ENKUlSG_E_clIS7_EEDaSG_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImEEEEEEDaRT_ENKUlSB_E_clIS5_EEDaSB_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapINS_6UInt72EPc9HashCRC32IS5_EEEEEEDaRT_ENKUlSC_E_clIS6_EEDaSC_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapINS_6UInt96EPc9HashCRC32IS5_EEEEEEDaRT_ENKUlSC_E_clIS6_EEDaSC_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapINS_7UInt104EPc9HashCRC32IS5_EEEEEEDaRT_ENKUlSC_E_clIS6_EEDaSC_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS7_EEEEEEDaRT_ENKUlSE_E_clIS8_EEDaSE_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapINS_7UInt136EPc9HashCRC32IS5_EEEEEEDaRT_ENKUlSC_E_clIS6_EEDaSC_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS7_EEEEEEDaRT_ENKUlSE_E_clIS8_EEDaSE_
302
303
3.14k
                          if (hash_table.has_null_key_data()) {
304
0
                              _destroy_agg_status(
305
0
                                      hash_table.template get_null_key_data<AggregateDataPtr>());
306
0
                          }
307
308
3.14k
                          aggregate_data_container.reset(new AggregateDataContainer(
309
3.14k
                                  sizeof(typename HashTableType::key_type),
310
3.14k
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
3.14k
                                   align_aggregate_states) *
312
3.14k
                                          align_aggregate_states));
313
3.14k
                          agg_method.hash_table.reset(new HashTableType());
314
3.14k
                          return Status::OK();
315
3.14k
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS5_vEEEEEEDaRT_
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEDaRT_
Line
Count
Source
289
66
                      [&](auto& agg_method) {
290
66
                          auto& hash_table = *agg_method.hash_table;
291
66
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
66
                          agg_method.arena.clear();
294
66
                          agg_method.inited_iterator = false;
295
296
66
                          hash_table.for_each_mapped([&](auto& mapped) {
297
66
                              if (mapped) {
298
66
                                  _destroy_agg_status(mapped);
299
66
                                  mapped = nullptr;
300
66
                              }
301
66
                          });
302
303
66
                          if (hash_table.has_null_key_data()) {
304
0
                              _destroy_agg_status(
305
0
                                      hash_table.template get_null_key_data<AggregateDataPtr>());
306
0
                          }
307
308
66
                          aggregate_data_container.reset(new AggregateDataContainer(
309
66
                                  sizeof(typename HashTableType::key_type),
310
66
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
66
                                   align_aggregate_states) *
312
66
                                          align_aggregate_states));
313
66
                          agg_method.hash_table.reset(new HashTableType());
314
66
                          return Status::OK();
315
66
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEDaRT_
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_15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEEDaRT_
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
72
                      [&](auto& agg_method) {
290
72
                          auto& hash_table = *agg_method.hash_table;
291
72
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
72
                          agg_method.arena.clear();
294
72
                          agg_method.inited_iterator = false;
295
296
72
                          hash_table.for_each_mapped([&](auto& mapped) {
297
72
                              if (mapped) {
298
72
                                  _destroy_agg_status(mapped);
299
72
                                  mapped = nullptr;
300
72
                              }
301
72
                          });
302
303
72
                          if (hash_table.has_null_key_data()) {
304
0
                              _destroy_agg_status(
305
0
                                      hash_table.template get_null_key_data<AggregateDataPtr>());
306
0
                          }
307
308
72
                          aggregate_data_container.reset(new AggregateDataContainer(
309
72
                                  sizeof(typename HashTableType::key_type),
310
72
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
72
                                   align_aggregate_states) *
312
72
                                          align_aggregate_states));
313
72
                          agg_method.hash_table.reset(new HashTableType());
314
72
                          return Status::OK();
315
72
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS6_Pc9HashCRC32IS6_EEEEEEDaRT_
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEDaRT_
Line
Count
Source
289
91
                      [&](auto& agg_method) {
290
91
                          auto& hash_table = *agg_method.hash_table;
291
91
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
91
                          agg_method.arena.clear();
294
91
                          agg_method.inited_iterator = false;
295
296
91
                          hash_table.for_each_mapped([&](auto& mapped) {
297
91
                              if (mapped) {
298
91
                                  _destroy_agg_status(mapped);
299
91
                                  mapped = nullptr;
300
91
                              }
301
91
                          });
302
303
91
                          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
91
                          aggregate_data_container.reset(new AggregateDataContainer(
309
91
                                  sizeof(typename HashTableType::key_type),
310
91
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
91
                                   align_aggregate_states) *
312
91
                                          align_aggregate_states));
313
91
                          agg_method.hash_table.reset(new HashTableType());
314
91
                          return Status::OK();
315
91
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEDaRT_
Line
Count
Source
289
318
                      [&](auto& agg_method) {
290
318
                          auto& hash_table = *agg_method.hash_table;
291
318
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
318
                          agg_method.arena.clear();
294
318
                          agg_method.inited_iterator = false;
295
296
318
                          hash_table.for_each_mapped([&](auto& mapped) {
297
318
                              if (mapped) {
298
318
                                  _destroy_agg_status(mapped);
299
318
                                  mapped = nullptr;
300
318
                              }
301
318
                          });
302
303
318
                          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
318
                          aggregate_data_container.reset(new AggregateDataContainer(
309
318
                                  sizeof(typename HashTableType::key_type),
310
318
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
318
                                   align_aggregate_states) *
312
318
                                          align_aggregate_states));
313
318
                          agg_method.hash_table.reset(new HashTableType());
314
318
                          return Status::OK();
315
318
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIhNS_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEDaRT_
Line
Count
Source
289
36
                      [&](auto& agg_method) {
290
36
                          auto& hash_table = *agg_method.hash_table;
291
36
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
36
                          agg_method.arena.clear();
294
36
                          agg_method.inited_iterator = false;
295
296
36
                          hash_table.for_each_mapped([&](auto& mapped) {
297
36
                              if (mapped) {
298
36
                                  _destroy_agg_status(mapped);
299
36
                                  mapped = nullptr;
300
36
                              }
301
36
                          });
302
303
36
                          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
36
                          aggregate_data_container.reset(new AggregateDataContainer(
309
36
                                  sizeof(typename HashTableType::key_type),
310
36
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
36
                                   align_aggregate_states) *
312
36
                                          align_aggregate_states));
313
36
                          agg_method.hash_table.reset(new HashTableType());
314
36
                          return Status::OK();
315
36
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberItNS_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEDaRT_
Line
Count
Source
289
56
                      [&](auto& agg_method) {
290
56
                          auto& hash_table = *agg_method.hash_table;
291
56
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
56
                          agg_method.arena.clear();
294
56
                          agg_method.inited_iterator = false;
295
296
56
                          hash_table.for_each_mapped([&](auto& mapped) {
297
56
                              if (mapped) {
298
56
                                  _destroy_agg_status(mapped);
299
56
                                  mapped = nullptr;
300
56
                              }
301
56
                          });
302
303
56
                          if (hash_table.has_null_key_data()) {
304
0
                              _destroy_agg_status(
305
0
                                      hash_table.template get_null_key_data<AggregateDataPtr>());
306
0
                          }
307
308
56
                          aggregate_data_container.reset(new AggregateDataContainer(
309
56
                                  sizeof(typename HashTableType::key_type),
310
56
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
56
                                   align_aggregate_states) *
312
56
                                          align_aggregate_states));
313
56
                          agg_method.hash_table.reset(new HashTableType());
314
56
                          return Status::OK();
315
56
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEDaRT_
Line
Count
Source
289
505
                      [&](auto& agg_method) {
290
505
                          auto& hash_table = *agg_method.hash_table;
291
505
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
505
                          agg_method.arena.clear();
294
505
                          agg_method.inited_iterator = false;
295
296
505
                          hash_table.for_each_mapped([&](auto& mapped) {
297
505
                              if (mapped) {
298
505
                                  _destroy_agg_status(mapped);
299
505
                                  mapped = nullptr;
300
505
                              }
301
505
                          });
302
303
505
                          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
505
                          aggregate_data_container.reset(new AggregateDataContainer(
309
505
                                  sizeof(typename HashTableType::key_type),
310
505
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
505
                                   align_aggregate_states) *
312
505
                                          align_aggregate_states));
313
505
                          agg_method.hash_table.reset(new HashTableType());
314
505
                          return Status::OK();
315
505
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEDaRT_
Line
Count
Source
289
344
                      [&](auto& agg_method) {
290
344
                          auto& hash_table = *agg_method.hash_table;
291
344
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
344
                          agg_method.arena.clear();
294
344
                          agg_method.inited_iterator = false;
295
296
344
                          hash_table.for_each_mapped([&](auto& mapped) {
297
344
                              if (mapped) {
298
344
                                  _destroy_agg_status(mapped);
299
344
                                  mapped = nullptr;
300
344
                              }
301
344
                          });
302
303
344
                          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
344
                          aggregate_data_container.reset(new AggregateDataContainer(
309
344
                                  sizeof(typename HashTableType::key_type),
310
344
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
344
                                   align_aggregate_states) *
312
344
                                          align_aggregate_states));
313
344
                          agg_method.hash_table.reset(new HashTableType());
314
344
                          return Status::OK();
315
344
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIjNS_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEDaRT_
Line
Count
Source
289
874
                      [&](auto& agg_method) {
290
874
                          auto& hash_table = *agg_method.hash_table;
291
874
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
874
                          agg_method.arena.clear();
294
874
                          agg_method.inited_iterator = false;
295
296
874
                          hash_table.for_each_mapped([&](auto& mapped) {
297
874
                              if (mapped) {
298
874
                                  _destroy_agg_status(mapped);
299
874
                                  mapped = nullptr;
300
874
                              }
301
874
                          });
302
303
874
                          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
874
                          aggregate_data_container.reset(new AggregateDataContainer(
309
874
                                  sizeof(typename HashTableType::key_type),
310
874
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
874
                                   align_aggregate_states) *
312
874
                                          align_aggregate_states));
313
874
                          agg_method.hash_table.reset(new HashTableType());
314
874
                          return Status::OK();
315
874
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEDaRT_
Line
Count
Source
289
586
                      [&](auto& agg_method) {
290
586
                          auto& hash_table = *agg_method.hash_table;
291
586
                          using HashTableType = std::decay_t<decltype(hash_table)>;
292
293
586
                          agg_method.arena.clear();
294
586
                          agg_method.inited_iterator = false;
295
296
586
                          hash_table.for_each_mapped([&](auto& mapped) {
297
586
                              if (mapped) {
298
586
                                  _destroy_agg_status(mapped);
299
586
                                  mapped = nullptr;
300
586
                              }
301
586
                          });
302
303
586
                          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
586
                          aggregate_data_container.reset(new AggregateDataContainer(
309
586
                                  sizeof(typename HashTableType::key_type),
310
586
                                  ((total_size_of_aggregate_states + align_aggregate_states - 1) /
311
586
                                   align_aggregate_states) *
312
586
                                          align_aggregate_states));
313
586
                          agg_method.hash_table.reset(new HashTableType());
314
586
                          return Status::OK();
315
586
                      }},
dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS7_Pc9HashCRC32IS7_EEEEEEEEEEDaRT_
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
                      }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm256EjEENS_15DataWithNullKeyI9PHHashMapIS7_Pc9HashCRC32IS7_EEEEEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_26MethodSingleNullableColumnINS_19MethodStringNoCacheINS_15DataWithNullKeyINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapINS_6UInt72EPc9HashCRC32IS5_EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapINS_6UInt96EPc9HashCRC32IS5_EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapINS_7UInt104EPc9HashCRC32IS5_EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS7_EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapINS_7UInt136EPc9HashCRC32IS5_EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris14AggSharedState16reset_hash_tableEvENK3$_1clINS_15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS7_EEEEEEDaRT_
316
3.14k
            agg_data->method_variant);
317
3.14k
}
318
319
305
void PartitionedAggSharedState::init_spill_params(size_t spill_partition_count) {
320
305
    partition_count = spill_partition_count;
321
305
    max_partition_index = partition_count - 1;
322
323
10.0k
    for (int i = 0; i < partition_count; ++i) {
324
9.76k
        spill_partitions.emplace_back(std::make_shared<AggSpillPartition>());
325
9.76k
    }
326
305
}
327
328
293
void PartitionedAggSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {
329
9.37k
    for (auto& partition : spill_partitions) {
330
9.37k
        if (partition->spilling_stream_) {
331
0
            partition->spilling_stream_->update_shared_profiles(source_profile);
332
0
        }
333
9.37k
        for (auto& stream : partition->spill_streams_) {
334
2.07k
            if (stream) {
335
2.07k
                stream->update_shared_profiles(source_profile);
336
2.07k
            }
337
2.07k
        }
338
9.37k
    }
339
293
}
340
341
Status AggSpillPartition::get_spill_stream(RuntimeState* state, int node_id,
342
4.61k
                                           RuntimeProfile* profile, SpillStreamSPtr& spill_stream) {
343
4.61k
    if (spilling_stream_) {
344
2.46k
        spill_stream = spilling_stream_;
345
2.46k
        return Status::OK();
346
2.46k
    }
347
2.14k
    RETURN_IF_ERROR(ExecEnv::GetInstance()->spill_stream_mgr()->register_spill_stream(
348
2.14k
            state, spilling_stream_, print_id(state->query_id()), "agg", node_id,
349
2.14k
            std::numeric_limits<int32_t>::max(), std::numeric_limits<size_t>::max(), profile));
350
2.14k
    spill_streams_.emplace_back(spilling_stream_);
351
2.14k
    spill_stream = spilling_stream_;
352
2.14k
    return Status::OK();
353
2.14k
}
354
6.70k
void AggSpillPartition::close() {
355
6.70k
    if (spilling_stream_) {
356
1
        spilling_stream_.reset();
357
1
    }
358
6.70k
    for (auto& stream : spill_streams_) {
359
5
        (void)ExecEnv::GetInstance()->spill_stream_mgr()->delete_spill_stream(stream);
360
5
    }
361
6.70k
    spill_streams_.clear();
362
6.70k
}
363
364
330
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
330
    bool false_close = false;
368
330
    if (!is_closed.compare_exchange_strong(false_close, true)) {
369
33
        return;
370
33
    }
371
330
    DCHECK(!false_close && is_closed);
372
6.70k
    for (auto partition : spill_partitions) {
373
6.70k
        partition->close();
374
6.70k
    }
375
297
    spill_partitions.clear();
376
297
}
377
378
19
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
19
}
385
386
21
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
21
    bool false_close = false;
390
21
    if (!is_closed.compare_exchange_strong(false_close, true)) {
391
1
        return;
392
1
    }
393
21
    DCHECK(!false_close && is_closed);
394
20
    for (auto& stream : sorted_streams) {
395
1
        (void)ExecEnv::GetInstance()->spill_stream_mgr()->delete_spill_stream(stream);
396
1
    }
397
20
    sorted_streams.clear();
398
20
}
399
400
MultiCastSharedState::MultiCastSharedState(ObjectPool* pool, int cast_sender_count, int node_id)
401
        : multi_cast_data_streamer(
402
4.02k
                  std::make_unique<MultiCastDataStreamer>(pool, cast_sender_count, node_id)) {}
403
404
0
void MultiCastSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {}
405
406
106k
int AggSharedState::get_slot_column_id(const AggFnEvaluator* evaluator) {
407
106k
    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
106k
    return ((VSlotRef*)ctxs[0]->root().get())->column_id();
412
106k
}
413
414
2.49M
void AggSharedState::_destroy_agg_status(AggregateDataPtr data) {
415
5.26M
    for (int i = 0; i < aggregate_evaluators.size(); ++i) {
416
2.76M
        aggregate_evaluators[i]->function()->destroy(data + offsets_of_aggregate_states[i]);
417
2.76M
    }
418
2.49M
}
419
420
110k
LocalExchangeSharedState::~LocalExchangeSharedState() = default;
421
422
11.8k
Status SetSharedState::update_build_not_ignore_null(const VExprContextSPtrs& ctxs) {
423
11.8k
    if (ctxs.size() > build_not_ignore_null.size()) {
424
0
        return Status::InternalError("build_not_ignore_null not initialized");
425
0
    }
426
427
99.7k
    for (int i = 0; i < ctxs.size(); ++i) {
428
87.9k
        build_not_ignore_null[i] = build_not_ignore_null[i] || ctxs[i]->root()->is_nullable();
429
87.9k
    }
430
431
11.8k
    return Status::OK();
432
11.8k
}
433
434
19.1k
size_t SetSharedState::get_hash_table_size() const {
435
19.1k
    size_t hash_table_size = 0;
436
19.1k
    std::visit(
437
19.1k
            [&](auto&& arg) {
438
19.1k
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
19.1k
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
19.1k
                    hash_table_size = arg.hash_table->size();
441
19.1k
                }
442
19.1k
            },
Unexecuted instantiation: dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRSt9monostateEEDaOT_
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_16MethodSerializedI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS5_vEEEEEEDaOT_
Line
Count
Source
437
17.8k
            [&](auto&& arg) {
438
17.8k
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
17.8k
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
17.8k
                    hash_table_size = arg.hash_table->size();
441
17.8k
                }
442
17.8k
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_19MethodStringNoCacheI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS5_vEEEEEEDaOT_
Line
Count
Source
437
155
            [&](auto&& arg) {
438
155
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
155
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
155
                    hash_table_size = arg.hash_table->size();
441
155
                }
442
155
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_26MethodSingleNullableColumnINS_19MethodStringNoCacheINS_15DataWithNullKeyI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS7_vEEEEEEEEEEDaOT_
Line
Count
Source
437
153
            [&](auto&& arg) {
438
153
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
153
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
153
                    hash_table_size = arg.hash_table->size();
441
153
                }
442
153
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIhNS_15DataWithNullKeyI9PHHashMapIhNS_14RowRefWithFlagE9HashCRC32IhEEEEEEEEEEDaOT_
Line
Count
Source
437
81
            [&](auto&& arg) {
438
81
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
81
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
81
                    hash_table_size = arg.hash_table->size();
441
81
                }
442
81
            },
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
382
            [&](auto&& arg) {
438
382
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
382
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
382
                    hash_table_size = arg.hash_table->size();
441
382
                }
442
382
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberImNS_15DataWithNullKeyI9PHHashMapImNS_14RowRefWithFlagE9HashCRC32ImEEEEEEEEEEDaOT_
Line
Count
Source
437
100
            [&](auto&& arg) {
438
100
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
100
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
100
                    hash_table_size = arg.hash_table->size();
441
100
                }
442
100
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_26MethodSingleNullableColumnINS_15MethodOneNumberIN4wide7integerILm128EjEENS_15DataWithNullKeyI9PHHashMapIS7_NS_14RowRefWithFlagE9HashCRC32IS7_EEEEEEEEEEDaOT_
Line
Count
Source
437
24
            [&](auto&& arg) {
438
24
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
24
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
24
                    hash_table_size = arg.hash_table->size();
441
24
                }
442
24
            },
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
45
            [&](auto&& arg) {
438
45
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
45
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
45
                    hash_table_size = arg.hash_table->size();
441
45
                }
442
45
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodKeysFixedI9PHHashMapINS_6UInt96ENS_14RowRefWithFlagE9HashCRC32IS5_EEEEEEDaOT_
Line
Count
Source
437
30
            [&](auto&& arg) {
438
30
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
30
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
30
                    hash_table_size = arg.hash_table->size();
441
30
                }
442
30
            },
dependency.cpp:_ZZNK5doris14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_15MethodKeysFixedI9PHHashMapINS_7UInt104ENS_14RowRefWithFlagE9HashCRC32IS5_EEEEEEDaOT_
Line
Count
Source
437
144
            [&](auto&& arg) {
438
144
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
144
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
144
                    hash_table_size = arg.hash_table->size();
441
144
                }
442
144
            },
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
74
            [&](auto&& arg) {
438
74
                using HashTableCtxType = std::decay_t<decltype(arg)>;
439
74
                if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) {
440
74
                    hash_table_size = arg.hash_table->size();
441
74
                }
442
74
            },
443
19.1k
            hash_table_variants->method_variant);
444
19.1k
    return hash_table_size;
445
19.1k
}
446
447
4.90k
Status SetSharedState::hash_table_init() {
448
4.90k
    std::vector<DataTypePtr> data_types;
449
40.6k
    for (size_t i = 0; i != child_exprs_lists[0].size(); ++i) {
450
35.7k
        auto& ctx = child_exprs_lists[0][i];
451
35.7k
        auto data_type = ctx->root()->data_type();
452
35.7k
        if (build_not_ignore_null[i]) {
453
35.5k
            data_type = make_nullable(data_type);
454
35.5k
        }
455
35.7k
        data_types.emplace_back(std::move(data_type));
456
35.7k
    }
457
4.90k
    return init_hash_method<SetDataVariants>(hash_table_variants.get(), data_types, true);
458
4.90k
}
459
460
133
void AggSharedState::refresh_top_limit(size_t row_id, const ColumnRawPtrs& key_columns) {
461
542
    for (int j = 0; j < key_columns.size(); ++j) {
462
409
        limit_columns[j]->insert_from(*key_columns[j], row_id);
463
409
    }
464
133
    limit_heap.emplace(limit_columns[0]->size() - 1, limit_columns, order_directions,
465
133
                       null_directions);
466
467
133
    limit_heap.pop();
468
133
    limit_columns_min = limit_heap.top()._row_id;
469
133
}
470
471
} // namespace doris