/root/doris/be/src/pipeline/dependency.cpp
Line | Count | Source (jump to first uncovered line) |
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 "dependency.h" |
19 | | |
20 | | #include <memory> |
21 | | #include <mutex> |
22 | | |
23 | | #include "common/logging.h" |
24 | | #include "pipeline/exec/multi_cast_data_streamer.h" |
25 | | #include "pipeline/pipeline_fragment_context.h" |
26 | | #include "pipeline/pipeline_task.h" |
27 | | #include "runtime/exec_env.h" |
28 | | #include "runtime/memory/mem_tracker.h" |
29 | | #include "runtime_filter/runtime_filter_consumer.h" |
30 | | #include "util/brpc_client_cache.h" |
31 | | #include "vec/exprs/vectorized_agg_fn.h" |
32 | | #include "vec/exprs/vslot_ref.h" |
33 | | #include "vec/spill/spill_stream_manager.h" |
34 | | #include "vec/utils/util.hpp" |
35 | | |
36 | | namespace doris::pipeline { |
37 | | #include "common/compile_check_begin.h" |
38 | | |
39 | | Dependency* BasicSharedState::create_source_dependency(int operator_id, int node_id, |
40 | 78.2k | const std::string& name) { |
41 | 78.2k | source_deps.push_back(std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY")); |
42 | 78.2k | source_deps.back()->set_shared_state(this); |
43 | 78.2k | return source_deps.back().get(); |
44 | 78.2k | } |
45 | | |
46 | | void BasicSharedState::create_source_dependencies(int num_sources, int operator_id, int node_id, |
47 | 7 | const std::string& name) { |
48 | 7 | source_deps.resize(num_sources, nullptr); |
49 | 32 | for (auto& source_dep : source_deps) { |
50 | 32 | source_dep = std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY"); |
51 | 32 | source_dep->set_shared_state(this); |
52 | 32 | } |
53 | 7 | } |
54 | | |
55 | | Dependency* BasicSharedState::create_sink_dependency(int dest_id, int node_id, |
56 | 78.2k | const std::string& name) { |
57 | 78.2k | sink_deps.push_back(std::make_shared<Dependency>(dest_id, node_id, name + "_DEPENDENCY", true)); |
58 | 78.2k | sink_deps.back()->set_shared_state(this); |
59 | 78.2k | return sink_deps.back().get(); |
60 | 78.2k | } |
61 | | |
62 | 25 | void Dependency::_add_block_task(std::shared_ptr<PipelineTask> task) { |
63 | 25 | DCHECK(_blocked_task.empty() || _blocked_task[_blocked_task.size() - 1].lock() == nullptr || |
64 | 0 | _blocked_task[_blocked_task.size() - 1].lock().get() != task.get()) |
65 | 0 | << "Duplicate task: " << task->debug_string(); |
66 | 25 | _blocked_task.push_back(task); |
67 | 25 | } |
68 | | |
69 | 132k | void Dependency::set_ready() { |
70 | 132k | if (_ready) { |
71 | 79.2k | return; |
72 | 79.2k | } |
73 | 53.6k | _watcher.stop(); |
74 | 53.6k | std::vector<std::weak_ptr<PipelineTask>> local_block_task {}; |
75 | 53.6k | { |
76 | 53.6k | std::unique_lock<std::mutex> lc(_task_lock); |
77 | 53.6k | if (_ready) { |
78 | 0 | return; |
79 | 0 | } |
80 | 53.6k | _ready = true; |
81 | 53.6k | local_block_task.swap(_blocked_task); |
82 | 53.6k | } |
83 | 25 | for (auto task : local_block_task) { |
84 | 25 | if (auto t = task.lock()) { |
85 | 25 | std::unique_lock<std::mutex> lc(_task_lock); |
86 | 25 | THROW_IF_ERROR(t->wake_up(this)); |
87 | 25 | } |
88 | 25 | } |
89 | 53.6k | } |
90 | | |
91 | 2.73M | Dependency* Dependency::is_blocked_by(std::shared_ptr<PipelineTask> task) { |
92 | 2.73M | std::unique_lock<std::mutex> lc(_task_lock); |
93 | 2.73M | auto ready = _ready.load(); |
94 | 2.73M | if (!ready && task) { |
95 | 25 | _add_block_task(task); |
96 | 25 | start_watcher(); |
97 | 25 | THROW_IF_ERROR(task->blocked(this)); |
98 | 25 | } |
99 | 2.73M | return ready ? nullptr : this; |
100 | 2.73M | } |
101 | | |
102 | 191k | std::string Dependency::debug_string(int indentation_level) { |
103 | 191k | fmt::memory_buffer debug_string_buffer; |
104 | 191k | fmt::format_to(debug_string_buffer, "{}{}: id={}, block task = {}, ready={}, _always_ready={}", |
105 | 191k | std::string(indentation_level * 2, ' '), _name, _node_id, _blocked_task.size(), |
106 | 191k | _ready, _always_ready); |
107 | 191k | return fmt::to_string(debug_string_buffer); |
108 | 191k | } |
109 | | |
110 | 0 | std::string CountedFinishDependency::debug_string(int indentation_level) { |
111 | 0 | fmt::memory_buffer debug_string_buffer; |
112 | 0 | fmt::format_to(debug_string_buffer, |
113 | 0 | "{}{}: id={}, block_task={}, ready={}, _always_ready={}, count={}", |
114 | 0 | std::string(indentation_level * 2, ' '), _name, _node_id, _blocked_task.size(), |
115 | 0 | _ready, _always_ready, _counter); |
116 | 0 | return fmt::to_string(debug_string_buffer); |
117 | 0 | } |
118 | | |
119 | 0 | void RuntimeFilterTimer::call_timeout() { |
120 | 0 | _parent->set_ready(); |
121 | 0 | } |
122 | | |
123 | 2 | void RuntimeFilterTimer::call_ready() { |
124 | 2 | _parent->set_ready(); |
125 | 2 | } |
126 | | |
127 | | // should check rf timeout in two case: |
128 | | // 1. the rf is ready just remove the wait queue |
129 | | // 2. if the rf have local dependency, the rf should start wait when all local dependency is ready |
130 | 2 | bool RuntimeFilterTimer::should_be_check_timeout() { |
131 | 2 | if (!_parent->ready() && !_local_runtime_filter_dependencies.empty()) { |
132 | 0 | bool all_ready = true; |
133 | 0 | for (auto& dep : _local_runtime_filter_dependencies) { |
134 | 0 | if (!dep->ready()) { |
135 | 0 | all_ready = false; |
136 | 0 | break; |
137 | 0 | } |
138 | 0 | } |
139 | 0 | if (all_ready) { |
140 | 0 | _local_runtime_filter_dependencies.clear(); |
141 | 0 | _registration_time = MonotonicMillis(); |
142 | 0 | } |
143 | 0 | return all_ready; |
144 | 0 | } |
145 | 2 | return true; |
146 | 2 | } |
147 | | |
148 | 1 | void RuntimeFilterTimerQueue::start() { |
149 | 4 | while (!_stop) { |
150 | 3 | std::unique_lock<std::mutex> lk(cv_m); |
151 | | |
152 | 1.33k | while (_que.empty() && !_stop) { |
153 | 2.66k | cv.wait_for(lk, std::chrono::seconds(3), [this] { return !_que.empty() || _stop; }); |
154 | 1.33k | } |
155 | 3 | if (_stop) { |
156 | 0 | break; |
157 | 0 | } |
158 | 3 | { |
159 | 3 | std::unique_lock<std::mutex> lc(_que_lock); |
160 | 3 | std::list<std::shared_ptr<pipeline::RuntimeFilterTimer>> new_que; |
161 | 4 | for (auto& it : _que) { |
162 | 4 | if (it.use_count() == 1) { |
163 | | // `use_count == 1` means this runtime filter has been released |
164 | 2 | } else if (it->should_be_check_timeout()) { |
165 | 2 | if (it->_parent->is_blocked_by()) { |
166 | | // This means runtime filter is not ready, so we call timeout or continue to poll this timer. |
167 | 2 | int64_t ms_since_registration = MonotonicMillis() - it->registration_time(); |
168 | 2 | if (ms_since_registration > it->wait_time_ms()) { |
169 | 0 | it->call_timeout(); |
170 | 2 | } else { |
171 | 2 | new_que.push_back(std::move(it)); |
172 | 2 | } |
173 | 2 | } |
174 | 2 | } else { |
175 | 0 | new_que.push_back(std::move(it)); |
176 | 0 | } |
177 | 4 | } |
178 | 3 | new_que.swap(_que); |
179 | 3 | } |
180 | 3 | std::this_thread::sleep_for(std::chrono::milliseconds(interval)); |
181 | 3 | } |
182 | 1 | _shutdown = true; |
183 | 1 | } |
184 | | |
185 | 20 | void LocalExchangeSharedState::sub_running_sink_operators() { |
186 | 20 | std::unique_lock<std::mutex> lc(le_lock); |
187 | 20 | if (exchanger->_running_sink_operators.fetch_sub(1) == 1) { |
188 | 5 | _set_always_ready(); |
189 | 5 | } |
190 | 20 | } |
191 | | |
192 | 20 | void LocalExchangeSharedState::sub_running_source_operators() { |
193 | 20 | std::unique_lock<std::mutex> lc(le_lock); |
194 | 20 | if (exchanger->_running_source_operators.fetch_sub(1) == 1) { |
195 | 5 | _set_always_ready(); |
196 | 5 | exchanger->finalize(); |
197 | 5 | } |
198 | 20 | } |
199 | | |
200 | 6 | LocalExchangeSharedState::LocalExchangeSharedState(int num_instances) { |
201 | 6 | source_deps.resize(num_instances, nullptr); |
202 | 6 | mem_counters.resize(num_instances, nullptr); |
203 | 6 | } |
204 | | |
205 | 4 | vectorized::MutableColumns AggSharedState::_get_keys_hash_table() { |
206 | 4 | return std::visit( |
207 | 4 | vectorized::Overload { |
208 | 4 | [&](std::monostate& arg) { |
209 | 0 | throw doris::Exception(ErrorCode::INTERNAL_ERROR, "uninited hash table"); |
210 | 0 | return vectorized::MutableColumns(); |
211 | 0 | }, |
212 | 4 | [&](auto&& agg_method) -> vectorized::MutableColumns { |
213 | 4 | vectorized::MutableColumns key_columns; |
214 | 8 | for (int i = 0; i < probe_expr_ctxs.size(); ++i) { |
215 | 4 | key_columns.emplace_back( |
216 | 4 | probe_expr_ctxs[i]->root()->data_type()->create_column()); |
217 | 4 | } |
218 | 4 | auto& data = *agg_method.hash_table; |
219 | 4 | bool has_null_key = data.has_null_key_data(); |
220 | 4 | const auto size = data.size() - has_null_key; |
221 | 4 | using KeyType = std::decay_t<decltype(agg_method.iterator->get_first())>; |
222 | 4 | std::vector<KeyType> keys(size); |
223 | | |
224 | 4 | size_t num_rows = 0; |
225 | 4 | auto iter = aggregate_data_container->begin(); |
226 | 4 | { |
227 | 27 | while (iter != aggregate_data_container->end()) { |
228 | 23 | keys[num_rows] = iter.get_key<KeyType>(); |
229 | 23 | ++iter; |
230 | 23 | ++num_rows; |
231 | 23 | } |
232 | 4 | } |
233 | 4 | agg_method.insert_keys_into_columns(keys, key_columns, num_rows); |
234 | 4 | if (has_null_key) { |
235 | 1 | key_columns[0]->insert_data(nullptr, 0); |
236 | 1 | } |
237 | 4 | return key_columns; |
238 | 4 | }}, Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS7_vEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISI_EESaISL_EEOT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISI_EESaISL_EEOT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_ dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_ Line | Count | Source | 212 | 2 | [&](auto&& agg_method) -> vectorized::MutableColumns { | 213 | 2 | vectorized::MutableColumns key_columns; | 214 | 4 | for (int i = 0; i < probe_expr_ctxs.size(); ++i) { | 215 | 2 | key_columns.emplace_back( | 216 | 2 | probe_expr_ctxs[i]->root()->data_type()->create_column()); | 217 | 2 | } | 218 | 2 | auto& data = *agg_method.hash_table; | 219 | 2 | bool has_null_key = data.has_null_key_data(); | 220 | 2 | const auto size = data.size() - has_null_key; | 221 | 2 | using KeyType = std::decay_t<decltype(agg_method.iterator->get_first())>; | 222 | 2 | std::vector<KeyType> keys(size); | 223 | | | 224 | 2 | size_t num_rows = 0; | 225 | 2 | auto iter = aggregate_data_container->begin(); | 226 | 2 | { | 227 | 14 | while (iter != aggregate_data_container->end()) { | 228 | 12 | keys[num_rows] = iter.get_key<KeyType>(); | 229 | 12 | ++iter; | 230 | 12 | ++num_rows; | 231 | 12 | } | 232 | 2 | } | 233 | 2 | agg_method.insert_keys_into_columns(keys, key_columns, num_rows); | 234 | 2 | if (has_null_key) { | 235 | 0 | key_columns[0]->insert_data(nullptr, 0); | 236 | 0 | } | 237 | 2 | return key_columns; | 238 | 2 | }}, |
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIhNS4_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberItNS4_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISL_EESaISO_EEOT_ dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISL_EESaISO_EEOT_ Line | Count | Source | 212 | 2 | [&](auto&& agg_method) -> vectorized::MutableColumns { | 213 | 2 | vectorized::MutableColumns key_columns; | 214 | 4 | for (int i = 0; i < probe_expr_ctxs.size(); ++i) { | 215 | 2 | key_columns.emplace_back( | 216 | 2 | probe_expr_ctxs[i]->root()->data_type()->create_column()); | 217 | 2 | } | 218 | 2 | auto& data = *agg_method.hash_table; | 219 | 2 | bool has_null_key = data.has_null_key_data(); | 220 | 2 | const auto size = data.size() - has_null_key; | 221 | 2 | using KeyType = std::decay_t<decltype(agg_method.iterator->get_first())>; | 222 | 2 | std::vector<KeyType> keys(size); | 223 | | | 224 | 2 | size_t num_rows = 0; | 225 | 2 | auto iter = aggregate_data_container->begin(); | 226 | 2 | { | 227 | 13 | while (iter != aggregate_data_container->end()) { | 228 | 11 | keys[num_rows] = iter.get_key<KeyType>(); | 229 | 11 | ++iter; | 230 | 11 | ++num_rows; | 231 | 11 | } | 232 | 2 | } | 233 | 2 | agg_method.insert_keys_into_columns(keys, key_columns, num_rows); | 234 | 2 | if (has_null_key) { | 235 | 1 | key_columns[0]->insert_data(nullptr, 0); | 236 | 1 | } | 237 | 2 | return key_columns; | 238 | 2 | }}, |
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISM_EESaISP_EEOT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm256EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISM_EESaISP_EEOT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_19MethodStringNoCacheINS4_15DataWithNullKeyINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorEEEEEEEEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISK_EESaISN_EEOT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImEEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS9_EEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISI_EESaISL_EEOT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS9_EEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISI_EESaISL_EEOT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136EPc9HashCRC32IS7_EEEEEESt6vectorINS_3COWINS4_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_ |
239 | 4 | agg_data->method_variant); |
240 | 4 | } |
241 | | |
242 | 4 | void AggSharedState::build_limit_heap(size_t hash_table_size) { |
243 | 4 | limit_columns = _get_keys_hash_table(); |
244 | 28 | for (size_t i = 0; i < hash_table_size; ++i) { |
245 | 24 | limit_heap.emplace(i, limit_columns, order_directions, null_directions); |
246 | 24 | } |
247 | 16 | while (hash_table_size > limit) { |
248 | 12 | limit_heap.pop(); |
249 | 12 | hash_table_size--; |
250 | 12 | } |
251 | 4 | limit_columns_min = limit_heap.top()._row_id; |
252 | 4 | } |
253 | | |
254 | | bool AggSharedState::do_limit_filter(vectorized::Block* block, size_t num_rows, |
255 | 8 | const std::vector<int>* key_locs) { |
256 | 8 | if (num_rows) { |
257 | 8 | cmp_res.resize(num_rows); |
258 | 8 | need_computes.resize(num_rows); |
259 | 8 | memset(need_computes.data(), 0, need_computes.size()); |
260 | 8 | memset(cmp_res.data(), 0, cmp_res.size()); |
261 | | |
262 | 8 | const auto key_size = null_directions.size(); |
263 | 16 | for (int i = 0; i < key_size; i++) { |
264 | 8 | block->get_by_position(key_locs ? key_locs->operator[](i) : i) |
265 | 8 | .column->compare_internal(limit_columns_min, *limit_columns[i], |
266 | 8 | null_directions[i], order_directions[i], cmp_res, |
267 | 8 | need_computes.data()); |
268 | 8 | } |
269 | | |
270 | 8 | auto set_computes_arr = [](auto* __restrict res, auto* __restrict computes, size_t rows) { |
271 | 58 | for (size_t i = 0; i < rows; ++i) { |
272 | 50 | computes[i] = computes[i] == res[i]; |
273 | 50 | } |
274 | 8 | }; |
275 | 8 | set_computes_arr(cmp_res.data(), need_computes.data(), num_rows); |
276 | | |
277 | 8 | return std::find(need_computes.begin(), need_computes.end(), 0) != need_computes.end(); |
278 | 8 | } |
279 | | |
280 | 0 | return false; |
281 | 8 | } |
282 | | |
283 | 15 | Status AggSharedState::reset_hash_table() { |
284 | 15 | return std::visit( |
285 | 15 | vectorized::Overload { |
286 | 15 | [&](std::monostate& arg) -> Status { |
287 | 0 | return Status::InternalError("Uninited hash table"); |
288 | 0 | }, |
289 | 15 | [&](auto& agg_method) { |
290 | 15 | auto& hash_table = *agg_method.hash_table; |
291 | 15 | using HashTableType = std::decay_t<decltype(hash_table)>; |
292 | | |
293 | 15 | agg_method.reset(); |
294 | | |
295 | 1.04M | hash_table.for_each_mapped([&](auto& mapped) { |
296 | 1.04M | if (mapped) { |
297 | 1.04M | static_cast<void>(_destroy_agg_status(mapped)); |
298 | 1.04M | mapped = nullptr; |
299 | 1.04M | } |
300 | 1.04M | }); Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS7_vEEEEEEDaRT_ENKUlSE_E_clIS8_EEDaSE_ Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEDaRT_ENKUlSD_E_clIS7_EEDaSD_ Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEDaRT_ENKUlSD_E_clIS7_EEDaSD_ Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEEDaRT_ENKUlSD_E_clIS7_EEDaSD_ Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEEDaRT_ENKUlSD_E_clIS7_EEDaSD_ Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorEEEEEEEEEDaRT_ENKUlSE_E_clIS7_EEDaSE_ Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEEDaRT_ENKUlSG_E_clISA_EEDaSG_ Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEEDaRT_ENKUlSG_E_clISA_EEDaSG_ dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_ Line | Count | Source | 295 | 1.04M | hash_table.for_each_mapped([&](auto& mapped) { | 296 | 1.04M | if (mapped) { | 297 | 1.04M | static_cast<void>(_destroy_agg_status(mapped)); | 298 | 1.04M | mapped = nullptr; | 299 | 1.04M | } | 300 | 1.04M | }); |
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_ Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIhNS4_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_ Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberItNS4_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_ Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_ Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEDaRT_ENKUlSH_E_clIS9_EEDaSH_ Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEDaRT_ENKUlSJ_E_clIS9_EEDaSJ_ Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEDaRT_ENKUlSJ_E_clIS9_EEDaSJ_ Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEEDaRT_ENKUlSK_E_clISC_EEDaSK_ Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm256EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEEDaRT_ENKUlSK_E_clISC_EEDaSK_ Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_19MethodStringNoCacheINS4_15DataWithNullKeyINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorEEEEEEEEEEEEEDaRT_ENKUlSI_E_clIS9_EEDaSI_ Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImEEEEEEDaRT_ENKUlSD_E_clIS7_EEDaSD_ Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS9_EEEEEEDaRT_ENKUlSG_E_clISA_EEDaSG_ Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS9_EEEEEEDaRT_ENKUlSG_E_clISA_EEDaSG_ Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136EPc9HashCRC32IS7_EEEEEEDaRT_ENKUlSE_E_clIS8_EEDaSE_ |
301 | | |
302 | 15 | if (hash_table.has_null_key_data()) { |
303 | 0 | auto st = _destroy_agg_status(hash_table.template get_null_key_data< |
304 | 0 | vectorized::AggregateDataPtr>()); |
305 | 0 | RETURN_IF_ERROR(st); |
306 | 0 | } |
307 | | |
308 | 15 | aggregate_data_container.reset(new AggregateDataContainer( |
309 | 15 | sizeof(typename HashTableType::key_type), |
310 | 15 | ((total_size_of_aggregate_states + align_aggregate_states - 1) / |
311 | 15 | align_aggregate_states) * |
312 | 15 | align_aggregate_states)); |
313 | 15 | agg_method.hash_table.reset(new HashTableType()); |
314 | 15 | agg_arena_pool.reset(new vectorized::Arena); |
315 | 15 | return Status::OK(); |
316 | 15 | }}, Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS7_vEEEEEEDaRT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEDaRT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEDaRT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEEDaRT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEEDaRT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorEEEEEEEEEDaRT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEEDaRT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEEDaRT_ dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEDaRT_ Line | Count | Source | 289 | 15 | [&](auto& agg_method) { | 290 | 15 | auto& hash_table = *agg_method.hash_table; | 291 | 15 | using HashTableType = std::decay_t<decltype(hash_table)>; | 292 | | | 293 | 15 | agg_method.reset(); | 294 | | | 295 | 15 | hash_table.for_each_mapped([&](auto& mapped) { | 296 | 15 | if (mapped) { | 297 | 15 | static_cast<void>(_destroy_agg_status(mapped)); | 298 | 15 | mapped = nullptr; | 299 | 15 | } | 300 | 15 | }); | 301 | | | 302 | 15 | if (hash_table.has_null_key_data()) { | 303 | 0 | auto st = _destroy_agg_status(hash_table.template get_null_key_data< | 304 | 0 | vectorized::AggregateDataPtr>()); | 305 | 0 | RETURN_IF_ERROR(st); | 306 | 0 | } | 307 | | | 308 | 15 | aggregate_data_container.reset(new AggregateDataContainer( | 309 | 15 | sizeof(typename HashTableType::key_type), | 310 | 15 | ((total_size_of_aggregate_states + align_aggregate_states - 1) / | 311 | 15 | align_aggregate_states) * | 312 | 15 | align_aggregate_states)); | 313 | 15 | agg_method.hash_table.reset(new HashTableType()); | 314 | 15 | agg_arena_pool.reset(new vectorized::Arena); | 315 | 15 | return Status::OK(); | 316 | 15 | }}, |
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEDaRT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIhNS4_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEDaRT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberItNS4_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEDaRT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEDaRT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEDaRT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEDaRT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEDaRT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEEDaRT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm256EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEEDaRT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized26MethodSingleNullableColumnINS4_19MethodStringNoCacheINS4_15DataWithNullKeyINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorEEEEEEEEEEEEEDaRT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImEEEEEEDaRT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS9_EEEEEEDaRT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS9_EEEEEEDaRT_ Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136EPc9HashCRC32IS7_EEEEEEDaRT_ |
317 | 15 | agg_data->method_variant); |
318 | 15 | } |
319 | | |
320 | 11 | void PartitionedAggSharedState::init_spill_params(size_t spill_partition_count) { |
321 | 11 | partition_count = spill_partition_count; |
322 | 11 | max_partition_index = partition_count - 1; |
323 | | |
324 | 363 | for (int i = 0; i < partition_count; ++i) { |
325 | 352 | spill_partitions.emplace_back(std::make_shared<AggSpillPartition>()); |
326 | 352 | } |
327 | 11 | } |
328 | | |
329 | 0 | void PartitionedAggSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) { |
330 | 0 | for (auto& partition : spill_partitions) { |
331 | 0 | if (partition->spilling_stream_) { |
332 | 0 | partition->spilling_stream_->update_shared_profiles(source_profile); |
333 | 0 | } |
334 | 0 | for (auto& stream : partition->spill_streams_) { |
335 | 0 | if (stream) { |
336 | 0 | stream->update_shared_profiles(source_profile); |
337 | 0 | } |
338 | 0 | } |
339 | 0 | } |
340 | 0 | } |
341 | | |
342 | | Status AggSpillPartition::get_spill_stream(RuntimeState* state, int node_id, |
343 | | RuntimeProfile* profile, |
344 | 65 | vectorized::SpillStreamSPtr& spill_stream) { |
345 | 65 | if (spilling_stream_) { |
346 | 16 | spill_stream = spilling_stream_; |
347 | 16 | return Status::OK(); |
348 | 16 | } |
349 | 49 | RETURN_IF_ERROR(ExecEnv::GetInstance()->spill_stream_mgr()->register_spill_stream( |
350 | 49 | state, spilling_stream_, print_id(state->query_id()), "agg", node_id, |
351 | 49 | std::numeric_limits<int32_t>::max(), std::numeric_limits<size_t>::max(), profile)); |
352 | 49 | spill_streams_.emplace_back(spilling_stream_); |
353 | 49 | spill_stream = spilling_stream_; |
354 | 49 | return Status::OK(); |
355 | 49 | } |
356 | 110 | void AggSpillPartition::close() { |
357 | 110 | if (spilling_stream_) { |
358 | 1 | spilling_stream_.reset(); |
359 | 1 | } |
360 | 110 | for (auto& stream : spill_streams_) { |
361 | 5 | (void)ExecEnv::GetInstance()->spill_stream_mgr()->delete_spill_stream(stream); |
362 | 5 | } |
363 | 110 | spill_streams_.clear(); |
364 | 110 | } |
365 | | |
366 | 7 | void PartitionedAggSharedState::close() { |
367 | | // need to use CAS instead of only `if (!is_closed)` statement, |
368 | | // to avoid concurrent entry of close() both pass the if statement |
369 | 7 | bool false_close = false; |
370 | 7 | if (!is_closed.compare_exchange_strong(false_close, true)) { |
371 | 2 | return; |
372 | 2 | } |
373 | 5 | DCHECK(!false_close && is_closed); |
374 | 110 | for (auto partition : spill_partitions) { |
375 | 110 | partition->close(); |
376 | 110 | } |
377 | 5 | spill_partitions.clear(); |
378 | 5 | } |
379 | | |
380 | 4 | void SpillSortSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) { |
381 | 12 | for (auto& stream : sorted_streams) { |
382 | 12 | if (stream) { |
383 | 12 | stream->update_shared_profiles(source_profile); |
384 | 12 | } |
385 | 12 | } |
386 | 4 | } |
387 | | |
388 | 7 | void SpillSortSharedState::close() { |
389 | | // need to use CAS instead of only `if (!is_closed)` statement, |
390 | | // to avoid concurrent entry of close() both pass the if statement |
391 | 7 | bool false_close = false; |
392 | 7 | if (!is_closed.compare_exchange_strong(false_close, true)) { |
393 | 2 | return; |
394 | 2 | } |
395 | 5 | DCHECK(!false_close && is_closed); |
396 | 5 | for (auto& stream : sorted_streams) { |
397 | 1 | (void)ExecEnv::GetInstance()->spill_stream_mgr()->delete_spill_stream(stream); |
398 | 1 | } |
399 | 5 | sorted_streams.clear(); |
400 | 5 | } |
401 | | |
402 | | MultiCastSharedState::MultiCastSharedState(ObjectPool* pool, int cast_sender_count, int node_id) |
403 | | : multi_cast_data_streamer(std::make_unique<pipeline::MultiCastDataStreamer>( |
404 | 3 | this, pool, cast_sender_count, node_id)) {} |
405 | | |
406 | 0 | void MultiCastSharedState::update_spill_stream_profiles(RuntimeProfile* source_profile) {} |
407 | | |
408 | 7 | int AggSharedState::get_slot_column_id(const vectorized::AggFnEvaluator* evaluator) { |
409 | 7 | auto ctxs = evaluator->input_exprs_ctxs(); |
410 | 7 | CHECK(ctxs.size() == 1 && ctxs[0]->root()->is_slot_ref()) |
411 | 0 | << "input_exprs_ctxs is invalid, input_exprs_ctx[0]=" |
412 | 0 | << ctxs[0]->root()->debug_string(); |
413 | 7 | return ((vectorized::VSlotRef*)ctxs[0]->root().get())->column_id(); |
414 | 7 | } |
415 | | |
416 | 1.04M | Status AggSharedState::_destroy_agg_status(vectorized::AggregateDataPtr data) { |
417 | 2.09M | for (int i = 0; i < aggregate_evaluators.size(); ++i) { |
418 | 1.04M | aggregate_evaluators[i]->function()->destroy(data + offsets_of_aggregate_states[i]); |
419 | 1.04M | } |
420 | 1.04M | return Status::OK(); |
421 | 1.04M | } |
422 | | |
423 | 6 | LocalExchangeSharedState::~LocalExchangeSharedState() = default; |
424 | | |
425 | 23 | Status SetSharedState::update_build_not_ignore_null(const vectorized::VExprContextSPtrs& ctxs) { |
426 | 23 | if (ctxs.size() > build_not_ignore_null.size()) { |
427 | 0 | return Status::InternalError("build_not_ignore_null not initialized"); |
428 | 0 | } |
429 | | |
430 | 60 | for (int i = 0; i < ctxs.size(); ++i) { |
431 | 37 | build_not_ignore_null[i] = build_not_ignore_null[i] || ctxs[i]->root()->is_nullable(); |
432 | 37 | } |
433 | | |
434 | 23 | return Status::OK(); |
435 | 23 | } |
436 | | |
437 | 13 | size_t SetSharedState::get_hash_table_size() const { |
438 | 13 | size_t hash_table_size = 0; |
439 | 13 | std::visit( |
440 | 13 | [&](auto&& arg) { |
441 | 13 | using HashTableCtxType = std::decay_t<decltype(arg)>; |
442 | 13 | if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) { |
443 | 13 | hash_table_size = arg.hash_table->size(); |
444 | 13 | } |
445 | 13 | }, Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRSt9monostateEEDaOT_ Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS7_vEEEEEEDaOT_ Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized19MethodStringNoCacheI9PHHashMapINS_9StringRefENS_14RowRefWithFlagE11DefaultHashIS7_vEEEEEEDaOT_ Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIhNS4_15DataWithNullKeyI9PHHashMapIhNS_14RowRefWithFlagE9HashCRC32IhEEEEEEEEEEDaOT_ Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberItNS4_15DataWithNullKeyI9PHHashMapItNS_14RowRefWithFlagE9HashCRC32ItEEEEEEEEEEDaOT_ Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjNS_14RowRefWithFlagE9HashCRC32IjEEEEEEEEEEDaOT_ dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImNS_14RowRefWithFlagE9HashCRC32ImEEEEEEEEEEDaOT_ Line | Count | Source | 440 | 2 | [&](auto&& arg) { | 441 | 2 | using HashTableCtxType = std::decay_t<decltype(arg)>; | 442 | 2 | if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) { | 443 | 2 | hash_table_size = arg.hash_table->size(); | 444 | 2 | } | 445 | 2 | }, |
Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_NS_14RowRefWithFlagE9HashCRC32IS9_EEEEEEEEEEDaOT_ Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm256EjEENS4_15DataWithNullKeyI9PHHashMapIS9_NS_14RowRefWithFlagE9HashCRC32IS9_EEEEEEEEEEDaOT_ Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodOneNumberIh9PHHashMapIhNS_14RowRefWithFlagE9HashCRC32IhEEEEEEDaOT_ Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodOneNumberIt9PHHashMapItNS_14RowRefWithFlagE9HashCRC32ItEEEEEEDaOT_ Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodOneNumberIj9PHHashMapIjNS_14RowRefWithFlagE9HashCRC32IjEEEEEEDaOT_ dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodOneNumberIm9PHHashMapImNS_14RowRefWithFlagE9HashCRC32ImEEEEEEDaOT_ Line | Count | Source | 440 | 8 | [&](auto&& arg) { | 441 | 8 | using HashTableCtxType = std::decay_t<decltype(arg)>; | 442 | 8 | if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) { | 443 | 8 | hash_table_size = arg.hash_table->size(); | 444 | 8 | } | 445 | 8 | }, |
Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS8_NS_14RowRefWithFlagE9HashCRC32IS8_EEEEEEDaOT_ Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS8_NS_14RowRefWithFlagE9HashCRC32IS8_EEEEEEDaOT_ Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodKeysFixedI9PHHashMapImNS_14RowRefWithFlagE9HashCRC32ImEEEEEEDaOT_ Unexecuted instantiation: dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEENS_14RowRefWithFlagE9HashCRC32IS9_EEEEEEDaOT_ dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEENS_14RowRefWithFlagE9HashCRC32IS9_EEEEEEDaOT_ Line | Count | Source | 440 | 2 | [&](auto&& arg) { | 441 | 2 | using HashTableCtxType = std::decay_t<decltype(arg)>; | 442 | 2 | if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) { | 443 | 2 | hash_table_size = arg.hash_table->size(); | 444 | 2 | } | 445 | 2 | }, |
dependency.cpp:_ZZNK5doris8pipeline14SetSharedState19get_hash_table_sizeEvENK3$_0clIRNS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136ENS_14RowRefWithFlagE9HashCRC32IS7_EEEEEEDaOT_ Line | Count | Source | 440 | 1 | [&](auto&& arg) { | 441 | 1 | using HashTableCtxType = std::decay_t<decltype(arg)>; | 442 | 1 | if constexpr (!std::is_same_v<HashTableCtxType, std::monostate>) { | 443 | 1 | hash_table_size = arg.hash_table->size(); | 444 | 1 | } | 445 | 1 | }, |
|
446 | 13 | hash_table_variants->method_variant); |
447 | 13 | return hash_table_size; |
448 | 13 | } |
449 | | |
450 | 10 | Status SetSharedState::hash_table_init() { |
451 | 10 | std::vector<vectorized::DataTypePtr> data_types; |
452 | 27 | for (size_t i = 0; i != child_exprs_lists[0].size(); ++i) { |
453 | 17 | auto& ctx = child_exprs_lists[0][i]; |
454 | 17 | auto data_type = ctx->root()->data_type(); |
455 | 17 | if (build_not_ignore_null[i]) { |
456 | 4 | data_type = vectorized::make_nullable(data_type); |
457 | 4 | } |
458 | 17 | data_types.emplace_back(std::move(data_type)); |
459 | 17 | } |
460 | 10 | return init_hash_method<SetDataVariants>(hash_table_variants.get(), data_types, true); |
461 | 10 | } |
462 | | |
463 | | void AggSharedState::refresh_top_limit(size_t row_id, |
464 | 4 | const vectorized::ColumnRawPtrs& key_columns) { |
465 | 8 | for (int j = 0; j < key_columns.size(); ++j) { |
466 | 4 | limit_columns[j]->insert_from(*key_columns[j], row_id); |
467 | 4 | } |
468 | 4 | limit_heap.emplace(limit_columns[0]->size() - 1, limit_columns, order_directions, |
469 | 4 | null_directions); |
470 | | |
471 | 4 | limit_heap.pop(); |
472 | 4 | limit_columns_min = limit_heap.top()._row_id; |
473 | 4 | } |
474 | | |
475 | 2 | Status MaterializationSharedState::merge_multi_response(vectorized::Block* block) { |
476 | 2 | std::map<int64_t, std::pair<vectorized::Block, int>> _block_maps; |
477 | 5 | for (int i = 0; i < block_order_results.size(); ++i) { |
478 | 6 | for (auto& [backend_id, rpc_struct] : rpc_struct_map) { |
479 | 6 | vectorized::Block partial_block; |
480 | 6 | RETURN_IF_ERROR( |
481 | 6 | partial_block.deserialize(rpc_struct.callback->response_->blocks(i).block())); |
482 | | |
483 | 6 | if (!partial_block.is_empty_column()) { |
484 | 6 | _block_maps[backend_id] = std::make_pair(std::move(partial_block), 0); |
485 | 6 | } |
486 | 6 | } |
487 | | |
488 | 12 | for (int j = 0; j < block_order_results[i].size(); ++j) { |
489 | 9 | auto backend_id = block_order_results[i][j]; |
490 | 9 | if (backend_id) { |
491 | 6 | auto& source_block_rows = _block_maps[backend_id]; |
492 | 6 | DCHECK(source_block_rows.second < source_block_rows.first.rows()); |
493 | 12 | for (int k = 0; k < response_blocks[i].columns(); ++k) { |
494 | 6 | response_blocks[i].get_column_by_position(k)->insert_from( |
495 | 6 | *source_block_rows.first.get_by_position(k).column, |
496 | 6 | source_block_rows.second); |
497 | 6 | } |
498 | 6 | source_block_rows.second++; |
499 | 6 | } else { |
500 | 6 | for (int k = 0; k < response_blocks[i].columns(); ++k) { |
501 | 3 | response_blocks[i].get_column_by_position(k)->insert_default(); |
502 | 3 | } |
503 | 3 | } |
504 | 9 | } |
505 | 3 | } |
506 | | |
507 | | // clear request/response |
508 | 4 | for (auto& [_, rpc_struct] : rpc_struct_map) { |
509 | 8 | for (int i = 0; i < rpc_struct.request.request_block_descs_size(); ++i) { |
510 | 4 | rpc_struct.request.mutable_request_block_descs(i)->clear_row_id(); |
511 | 4 | rpc_struct.request.mutable_request_block_descs(i)->clear_file_id(); |
512 | 4 | } |
513 | 4 | } |
514 | | |
515 | 8 | for (int i = 0, j = 0, rowid_to_block_loc = rowid_locs[j]; i < origin_block.columns(); i++) { |
516 | 6 | if (i != rowid_to_block_loc) { |
517 | 3 | block->insert(origin_block.get_by_position(i)); |
518 | 3 | } else { |
519 | 3 | auto response_block = response_blocks[j].to_block(); |
520 | 6 | for (int k = 0; k < response_block.columns(); k++) { |
521 | 3 | auto& data = response_block.get_by_position(k); |
522 | 3 | response_blocks[j].mutable_columns()[k] = data.column->clone_empty(); |
523 | 3 | block->insert(data); |
524 | 3 | } |
525 | 3 | if (++j < rowid_locs.size()) { |
526 | 1 | rowid_to_block_loc = rowid_locs[j]; |
527 | 1 | } |
528 | 3 | } |
529 | 6 | } |
530 | 2 | origin_block.clear(); |
531 | | |
532 | 2 | return Status::OK(); |
533 | 2 | } |
534 | | |
535 | | Dependency* MaterializationSharedState::create_source_dependency(int operator_id, int node_id, |
536 | 1 | const std::string& name) { |
537 | 1 | auto dep = |
538 | 1 | std::make_shared<CountedFinishDependency>(operator_id, node_id, name + "_DEPENDENCY"); |
539 | 1 | dep->set_shared_state(this); |
540 | | // just block source wait for add the counter in sink |
541 | 1 | dep->add(0); |
542 | | |
543 | 1 | source_deps.push_back(dep); |
544 | 1 | return source_deps.back().get(); |
545 | 1 | } |
546 | | |
547 | | Status MaterializationSharedState::create_muiltget_result(const vectorized::Columns& columns, |
548 | 1 | bool eos, bool gc_id_map) { |
549 | 1 | const auto rows = columns.empty() ? 0 : columns[0]->size(); |
550 | 1 | block_order_results.resize(columns.size()); |
551 | | |
552 | 2 | for (int i = 0; i < columns.size(); ++i) { |
553 | 1 | const uint8_t* null_map = nullptr; |
554 | 1 | const vectorized::ColumnString* column_rowid = nullptr; |
555 | 1 | auto& column = columns[i]; |
556 | | |
557 | 1 | if (auto column_ptr = check_and_get_column<vectorized::ColumnNullable>(*column)) { |
558 | 0 | null_map = column_ptr->get_null_map_data().data(); |
559 | 0 | column_rowid = assert_cast<const vectorized::ColumnString*>( |
560 | 0 | column_ptr->get_nested_column_ptr().get()); |
561 | 1 | } else { |
562 | 1 | column_rowid = assert_cast<const vectorized::ColumnString*>(column.get()); |
563 | 1 | } |
564 | | |
565 | 1 | auto& block_order = block_order_results[i]; |
566 | 1 | block_order.resize(rows); |
567 | | |
568 | 3 | for (int j = 0; j < rows; ++j) { |
569 | 2 | if (!null_map || !null_map[j]) { |
570 | 2 | DCHECK(column_rowid->get_data_at(j).size == sizeof(GlobalRowLoacationV2)); |
571 | 2 | GlobalRowLoacationV2 row_location = |
572 | 2 | *((GlobalRowLoacationV2*)column_rowid->get_data_at(j).data); |
573 | 2 | auto rpc_struct = rpc_struct_map.find(row_location.backend_id); |
574 | 2 | if (UNLIKELY(rpc_struct == rpc_struct_map.end())) { |
575 | 0 | return Status::InternalError( |
576 | 0 | "MaterializationSinkOperatorX failed to find rpc_struct, backend_id={}", |
577 | 0 | row_location.backend_id); |
578 | 0 | } |
579 | 2 | rpc_struct->second.request.mutable_request_block_descs(i)->add_row_id( |
580 | 2 | row_location.row_id); |
581 | 2 | rpc_struct->second.request.mutable_request_block_descs(i)->add_file_id( |
582 | 2 | row_location.file_id); |
583 | 2 | block_order[j] = row_location.backend_id; |
584 | 2 | } else { |
585 | 0 | block_order[j] = 0; |
586 | 0 | } |
587 | 2 | } |
588 | 1 | } |
589 | | |
590 | 1 | if (eos && gc_id_map) { |
591 | 2 | for (auto& [_, rpc_struct] : rpc_struct_map) { |
592 | 2 | rpc_struct.request.set_gc_id_map(true); |
593 | 2 | } |
594 | 1 | } |
595 | 1 | last_block = eos; |
596 | 1 | need_merge_block = rows > 0; |
597 | | |
598 | 1 | return Status::OK(); |
599 | 1 | } |
600 | | |
601 | | Status MaterializationSharedState::init_multi_requests( |
602 | 0 | const TMaterializationNode& materialization_node, RuntimeState* state) { |
603 | 0 | rpc_struct_inited = true; |
604 | 0 | PMultiGetRequestV2 multi_get_request; |
605 | | // Initialize the base struct of PMultiGetRequestV2 |
606 | 0 | multi_get_request.set_be_exec_version(state->be_exec_version()); |
607 | 0 | multi_get_request.set_wg_id(state->get_query_ctx()->workload_group()->id()); |
608 | 0 | auto query_id = multi_get_request.mutable_query_id(); |
609 | 0 | query_id->set_hi(state->query_id().hi); |
610 | 0 | query_id->set_lo(state->query_id().lo); |
611 | 0 | DCHECK_EQ(materialization_node.column_descs_lists.size(), |
612 | 0 | materialization_node.slot_locs_lists.size()); |
613 | |
|
614 | 0 | const auto& tuple_desc = |
615 | 0 | state->desc_tbl().get_tuple_descriptor(materialization_node.intermediate_tuple_id); |
616 | 0 | const auto& slots = tuple_desc->slots(); |
617 | 0 | response_blocks = |
618 | 0 | std::vector<vectorized::MutableBlock>(materialization_node.column_descs_lists.size()); |
619 | |
|
620 | 0 | for (int i = 0; i < materialization_node.column_descs_lists.size(); ++i) { |
621 | 0 | auto request_block_desc = multi_get_request.add_request_block_descs(); |
622 | 0 | request_block_desc->set_fetch_row_store(materialization_node.fetch_row_stores[i]); |
623 | | // Initialize the column_descs and slot_locs |
624 | 0 | auto& column_descs = materialization_node.column_descs_lists[i]; |
625 | 0 | for (auto& column_desc_item : column_descs) { |
626 | 0 | TabletColumn(column_desc_item).to_schema_pb(request_block_desc->add_column_descs()); |
627 | 0 | } |
628 | |
|
629 | 0 | auto& slot_locs = materialization_node.slot_locs_lists[i]; |
630 | 0 | tuple_desc->to_protobuf(request_block_desc->mutable_desc()); |
631 | |
|
632 | 0 | auto& column_idxs = materialization_node.column_idxs_lists[i]; |
633 | 0 | for (auto idx : column_idxs) { |
634 | 0 | request_block_desc->add_column_idxs(idx); |
635 | 0 | } |
636 | |
|
637 | 0 | std::vector<SlotDescriptor*> slots_res; |
638 | 0 | for (auto& slot_loc_item : slot_locs) { |
639 | 0 | slots[slot_loc_item]->to_protobuf(request_block_desc->add_slots()); |
640 | 0 | slots_res.emplace_back(slots[slot_loc_item]); |
641 | 0 | } |
642 | 0 | response_blocks[i] = vectorized::MutableBlock(vectorized::Block(slots_res, 10)); |
643 | 0 | } |
644 | | |
645 | | // Initialize the stubs and requests for each BE |
646 | 0 | for (const auto& node_info : materialization_node.nodes_info.nodes) { |
647 | 0 | auto client = ExecEnv::GetInstance()->brpc_internal_client_cache()->get_client( |
648 | 0 | node_info.host, node_info.async_internal_port); |
649 | 0 | if (!client) { |
650 | 0 | LOG(WARNING) << "Get rpc stub failed, host=" << node_info.host |
651 | 0 | << ", port=" << node_info.async_internal_port; |
652 | 0 | return Status::InternalError("RowIDFetcher failed to init rpc client, host={}, port={}", |
653 | 0 | node_info.host, node_info.async_internal_port); |
654 | 0 | } |
655 | 0 | rpc_struct_map.emplace(node_info.id, FetchRpcStruct {.stub = std::move(client), |
656 | 0 | .request = multi_get_request, |
657 | 0 | .callback = nullptr}); |
658 | 0 | } |
659 | | // add be_num ad count finish counter for source dependency |
660 | 0 | ((CountedFinishDependency*)source_deps.back().get())->add((int)rpc_struct_map.size()); |
661 | |
|
662 | 0 | return Status::OK(); |
663 | 0 | } |
664 | | |
665 | | } // namespace doris::pipeline |