/root/doris/be/src/pipeline/dependency.h
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 | | #pragma once |
19 | | |
20 | | #ifdef __APPLE__ |
21 | | #include <netinet/in.h> |
22 | | #include <sys/_types/_u_int.h> |
23 | | #endif |
24 | | |
25 | | #include <concurrentqueue.h> |
26 | | #include <sqltypes.h> |
27 | | |
28 | | #include <atomic> |
29 | | #include <functional> |
30 | | #include <memory> |
31 | | #include <mutex> |
32 | | #include <thread> |
33 | | #include <utility> |
34 | | |
35 | | #include "common/config.h" |
36 | | #include "common/logging.h" |
37 | | #include "gen_cpp/internal_service.pb.h" |
38 | | #include "pipeline/common/agg_utils.h" |
39 | | #include "pipeline/common/join_utils.h" |
40 | | #include "pipeline/common/set_utils.h" |
41 | | #include "pipeline/exec/data_queue.h" |
42 | | #include "pipeline/exec/join/process_hash_table_probe.h" |
43 | | #include "util/brpc_closure.h" |
44 | | #include "util/stack_util.h" |
45 | | #include "vec/common/sort/partition_sorter.h" |
46 | | #include "vec/common/sort/sorter.h" |
47 | | #include "vec/core/block.h" |
48 | | #include "vec/core/types.h" |
49 | | #include "vec/spill/spill_stream.h" |
50 | | |
51 | | namespace doris::vectorized { |
52 | | class AggFnEvaluator; |
53 | | class VSlotRef; |
54 | | } // namespace doris::vectorized |
55 | | |
56 | | namespace doris::pipeline { |
57 | | #include "common/compile_check_begin.h" |
58 | | class Dependency; |
59 | | class PipelineTask; |
60 | | struct BasicSharedState; |
61 | | using DependencySPtr = std::shared_ptr<Dependency>; |
62 | | class LocalExchangeSourceLocalState; |
63 | | |
64 | | static constexpr auto SLOW_DEPENDENCY_THRESHOLD = 60 * 1000L * 1000L * 1000L; |
65 | | static constexpr auto TIME_UNIT_DEPENDENCY_LOG = 30 * 1000L * 1000L * 1000L; |
66 | | static_assert(TIME_UNIT_DEPENDENCY_LOG < SLOW_DEPENDENCY_THRESHOLD); |
67 | | |
68 | | struct BasicSharedState { |
69 | | ENABLE_FACTORY_CREATOR(BasicSharedState) |
70 | | |
71 | | template <class TARGET> |
72 | 2.49M | TARGET* cast() { |
73 | 18.4E | DCHECK(dynamic_cast<TARGET*>(this)) |
74 | 18.4E | << " Mismatch type! Current type is " << typeid(*this).name() |
75 | 18.4E | << " and expect type is" << typeid(TARGET).name(); |
76 | 2.49M | return reinterpret_cast<TARGET*>(this); |
77 | 2.49M | } _ZN5doris8pipeline16BasicSharedState4castINS0_19HashJoinSharedStateEEEPT_v Line | Count | Source | 72 | 320k | TARGET* cast() { | 73 | 18.4E | DCHECK(dynamic_cast<TARGET*>(this)) | 74 | 18.4E | << " Mismatch type! Current type is " << typeid(*this).name() | 75 | 18.4E | << " and expect type is" << typeid(TARGET).name(); | 76 | 320k | return reinterpret_cast<TARGET*>(this); | 77 | 320k | } |
_ZN5doris8pipeline16BasicSharedState4castINS0_30PartitionedHashJoinSharedStateEEEPT_v Line | Count | Source | 72 | 3 | TARGET* cast() { | 73 | 3 | DCHECK(dynamic_cast<TARGET*>(this)) | 74 | 0 | << " Mismatch type! Current type is " << typeid(*this).name() | 75 | 0 | << " and expect type is" << typeid(TARGET).name(); | 76 | 3 | return reinterpret_cast<TARGET*>(this); | 77 | 3 | } |
_ZN5doris8pipeline16BasicSharedState4castINS0_15SortSharedStateEEEPT_v Line | Count | Source | 72 | 389k | TARGET* cast() { | 73 | 18.4E | DCHECK(dynamic_cast<TARGET*>(this)) | 74 | 18.4E | << " Mismatch type! Current type is " << typeid(*this).name() | 75 | 18.4E | << " and expect type is" << typeid(TARGET).name(); | 76 | 389k | return reinterpret_cast<TARGET*>(this); | 77 | 389k | } |
_ZN5doris8pipeline16BasicSharedState4castINS0_20SpillSortSharedStateEEEPT_v Line | Count | Source | 72 | 35 | TARGET* cast() { | 73 | 35 | DCHECK(dynamic_cast<TARGET*>(this)) | 74 | 0 | << " Mismatch type! Current type is " << typeid(*this).name() | 75 | 0 | << " and expect type is" << typeid(TARGET).name(); | 76 | 35 | return reinterpret_cast<TARGET*>(this); | 77 | 35 | } |
_ZN5doris8pipeline16BasicSharedState4castINS0_25NestedLoopJoinSharedStateEEEPT_v Line | Count | Source | 72 | 15.3k | TARGET* cast() { | 73 | 18.4E | DCHECK(dynamic_cast<TARGET*>(this)) | 74 | 18.4E | << " Mismatch type! Current type is " << typeid(*this).name() | 75 | 18.4E | << " and expect type is" << typeid(TARGET).name(); | 76 | 15.3k | return reinterpret_cast<TARGET*>(this); | 77 | 15.3k | } |
_ZN5doris8pipeline16BasicSharedState4castINS0_19AnalyticSharedStateEEEPT_v Line | Count | Source | 72 | 17.2k | TARGET* cast() { | 73 | 18.4E | DCHECK(dynamic_cast<TARGET*>(this)) | 74 | 18.4E | << " Mismatch type! Current type is " << typeid(*this).name() | 75 | 18.4E | << " and expect type is" << typeid(TARGET).name(); | 76 | 17.2k | return reinterpret_cast<TARGET*>(this); | 77 | 17.2k | } |
_ZN5doris8pipeline16BasicSharedState4castINS0_14AggSharedStateEEEPT_v Line | Count | Source | 72 | 265k | TARGET* cast() { | 73 | 18.4E | DCHECK(dynamic_cast<TARGET*>(this)) | 74 | 18.4E | << " Mismatch type! Current type is " << typeid(*this).name() | 75 | 18.4E | << " and expect type is" << typeid(TARGET).name(); | 76 | 265k | return reinterpret_cast<TARGET*>(this); | 77 | 265k | } |
_ZN5doris8pipeline16BasicSharedState4castINS0_25PartitionedAggSharedStateEEEPT_v Line | Count | Source | 72 | 36 | TARGET* cast() { | 73 | 36 | DCHECK(dynamic_cast<TARGET*>(this)) | 74 | 0 | << " Mismatch type! Current type is " << typeid(*this).name() | 75 | 0 | << " and expect type is" << typeid(TARGET).name(); | 76 | 36 | return reinterpret_cast<TARGET*>(this); | 77 | 36 | } |
_ZN5doris8pipeline16BasicSharedState4castINS0_16UnionSharedStateEEEPT_v Line | Count | Source | 72 | 11.8k | TARGET* cast() { | 73 | 18.4E | DCHECK(dynamic_cast<TARGET*>(this)) | 74 | 18.4E | << " Mismatch type! Current type is " << typeid(*this).name() | 75 | 18.4E | << " and expect type is" << typeid(TARGET).name(); | 76 | 11.8k | return reinterpret_cast<TARGET*>(this); | 77 | 11.8k | } |
_ZN5doris8pipeline16BasicSharedState4castINS0_28PartitionSortNodeSharedStateEEEPT_v Line | Count | Source | 72 | 1.20k | TARGET* cast() { | 73 | 18.4E | DCHECK(dynamic_cast<TARGET*>(this)) | 74 | 18.4E | << " Mismatch type! Current type is " << typeid(*this).name() | 75 | 18.4E | << " and expect type is" << typeid(TARGET).name(); | 76 | 1.20k | return reinterpret_cast<TARGET*>(this); | 77 | 1.20k | } |
_ZN5doris8pipeline16BasicSharedState4castINS0_20MultiCastSharedStateEEEPT_v Line | Count | Source | 72 | 10.1k | TARGET* cast() { | 73 | 18.4E | DCHECK(dynamic_cast<TARGET*>(this)) | 74 | 18.4E | << " Mismatch type! Current type is " << typeid(*this).name() | 75 | 18.4E | << " and expect type is" << typeid(TARGET).name(); | 76 | 10.1k | return reinterpret_cast<TARGET*>(this); | 77 | 10.1k | } |
_ZN5doris8pipeline16BasicSharedState4castINS0_14SetSharedStateEEEPT_v Line | Count | Source | 72 | 16.1k | TARGET* cast() { | 73 | 18.4E | DCHECK(dynamic_cast<TARGET*>(this)) | 74 | 18.4E | << " Mismatch type! Current type is " << typeid(*this).name() | 75 | 18.4E | << " and expect type is" << typeid(TARGET).name(); | 76 | 16.1k | return reinterpret_cast<TARGET*>(this); | 77 | 16.1k | } |
_ZN5doris8pipeline16BasicSharedState4castINS0_24LocalExchangeSharedStateEEEPT_v Line | Count | Source | 72 | 1.02M | TARGET* cast() { | 73 | 18.4E | DCHECK(dynamic_cast<TARGET*>(this)) | 74 | 18.4E | << " Mismatch type! Current type is " << typeid(*this).name() | 75 | 18.4E | << " and expect type is" << typeid(TARGET).name(); | 76 | 1.02M | return reinterpret_cast<TARGET*>(this); | 77 | 1.02M | } |
_ZN5doris8pipeline16BasicSharedState4castIS1_EEPT_v Line | Count | Source | 72 | 420k | TARGET* cast() { | 73 | 18.4E | DCHECK(dynamic_cast<TARGET*>(this)) | 74 | 18.4E | << " Mismatch type! Current type is " << typeid(*this).name() | 75 | 18.4E | << " and expect type is" << typeid(TARGET).name(); | 76 | 420k | return reinterpret_cast<TARGET*>(this); | 77 | 420k | } |
_ZN5doris8pipeline16BasicSharedState4castINS0_20DataQueueSharedStateEEEPT_v Line | Count | Source | 72 | 736 | TARGET* cast() { | 73 | 18.4E | DCHECK(dynamic_cast<TARGET*>(this)) | 74 | 18.4E | << " Mismatch type! Current type is " << typeid(*this).name() | 75 | 18.4E | << " and expect type is" << typeid(TARGET).name(); | 76 | 736 | return reinterpret_cast<TARGET*>(this); | 77 | 736 | } |
_ZN5doris8pipeline16BasicSharedState4castINS0_17RecCTESharedStateEEEPT_v Line | Count | Source | 72 | 450 | TARGET* cast() { | 73 | 450 | DCHECK(dynamic_cast<TARGET*>(this)) | 74 | 0 | << " Mismatch type! Current type is " << typeid(*this).name() | 75 | 0 | << " and expect type is" << typeid(TARGET).name(); | 76 | 450 | return reinterpret_cast<TARGET*>(this); | 77 | 450 | } |
|
78 | | template <class TARGET> |
79 | | const TARGET* cast() const { |
80 | | DCHECK(dynamic_cast<const TARGET*>(this)) |
81 | | << " Mismatch type! Current type is " << typeid(*this).name() |
82 | | << " and expect type is" << typeid(TARGET).name(); |
83 | | return reinterpret_cast<const TARGET*>(this); |
84 | | } |
85 | | std::vector<DependencySPtr> source_deps; |
86 | | std::vector<DependencySPtr> sink_deps; |
87 | | int id = 0; |
88 | | std::set<int> related_op_ids; |
89 | | |
90 | 1.67M | virtual ~BasicSharedState() = default; |
91 | | |
92 | | void create_source_dependencies(int num_sources, int operator_id, int node_id, |
93 | | const std::string& name); |
94 | | Dependency* create_source_dependency(int operator_id, int node_id, const std::string& name); |
95 | | |
96 | | Dependency* create_sink_dependency(int dest_id, int node_id, const std::string& name); |
97 | 704k | std::vector<DependencySPtr> get_dep_by_channel_id(int channel_id) { |
98 | 704k | DCHECK_LT(channel_id, source_deps.size()); |
99 | 704k | return {source_deps[channel_id]}; |
100 | 704k | } |
101 | | }; |
102 | | |
103 | | class Dependency : public std::enable_shared_from_this<Dependency> { |
104 | | public: |
105 | | ENABLE_FACTORY_CREATOR(Dependency); |
106 | | Dependency(int id, int node_id, std::string name, bool ready = false) |
107 | 6.29M | : _id(id), _node_id(node_id), _name(std::move(name)), _ready(ready) {} |
108 | 6.33M | virtual ~Dependency() = default; |
109 | | |
110 | 0 | [[nodiscard]] int id() const { return _id; } |
111 | 7.46M | [[nodiscard]] virtual std::string name() const { return _name; } |
112 | 344k | BasicSharedState* shared_state() { return _shared_state; } |
113 | 2.33M | void set_shared_state(BasicSharedState* shared_state) { _shared_state = shared_state; } |
114 | | virtual std::string debug_string(int indentation_level = 0); |
115 | 908M | bool ready() const { return _ready; } |
116 | | |
117 | | // Start the watcher. We use it to count how long this dependency block the current pipeline task. |
118 | 4.56M | void start_watcher() { _watcher.start(); } |
119 | 9.03M | [[nodiscard]] int64_t watcher_elapse_time() { return _watcher.elapsed_time(); } |
120 | | |
121 | | // Which dependency current pipeline task is blocked by. `nullptr` if this dependency is ready. |
122 | | [[nodiscard]] Dependency* is_blocked_by(std::shared_ptr<PipelineTask> task = nullptr); |
123 | | // Notify downstream pipeline tasks this dependency is ready. |
124 | | void set_ready(); |
125 | 518k | void set_ready_to_read(int channel_id = 0) { |
126 | 518k | DCHECK_LT(channel_id, _shared_state->source_deps.size()) << debug_string(); |
127 | 518k | _shared_state->source_deps[channel_id]->set_ready(); |
128 | 518k | } |
129 | 1.08k | void set_ready_to_write() { |
130 | 1.08k | DCHECK_EQ(_shared_state->sink_deps.size(), 1) << debug_string(); |
131 | 1.08k | _shared_state->sink_deps.front()->set_ready(); |
132 | 1.08k | } |
133 | | |
134 | | // Notify downstream pipeline tasks this dependency is blocked. |
135 | 1.31M | void block() { |
136 | 1.31M | if (_always_ready) { |
137 | 231k | return; |
138 | 231k | } |
139 | 1.08M | std::unique_lock<std::mutex> lc(_always_ready_lock); |
140 | 1.08M | if (_always_ready) { |
141 | 3 | return; |
142 | 3 | } |
143 | 1.08M | _ready = false; |
144 | 1.08M | } |
145 | | |
146 | 3.92M | void set_always_ready() { |
147 | 3.92M | if (_always_ready) { |
148 | 1.84M | return; |
149 | 1.84M | } |
150 | 2.08M | std::unique_lock<std::mutex> lc(_always_ready_lock); |
151 | 2.08M | if (_always_ready) { |
152 | 0 | return; |
153 | 0 | } |
154 | 2.08M | _always_ready = true; |
155 | 2.08M | set_ready(); |
156 | 2.08M | } |
157 | | |
158 | | protected: |
159 | | void _add_block_task(std::shared_ptr<PipelineTask> task); |
160 | | |
161 | | const int _id; |
162 | | const int _node_id; |
163 | | const std::string _name; |
164 | | std::atomic<bool> _ready; |
165 | | |
166 | | BasicSharedState* _shared_state = nullptr; |
167 | | MonotonicStopWatch _watcher; |
168 | | |
169 | | std::mutex _task_lock; |
170 | | std::vector<std::weak_ptr<PipelineTask>> _blocked_task; |
171 | | |
172 | | // If `_always_ready` is true, `block()` will never block tasks. |
173 | | std::atomic<bool> _always_ready = false; |
174 | | std::mutex _always_ready_lock; |
175 | | }; |
176 | | |
177 | | struct FakeSharedState final : public BasicSharedState { |
178 | | ENABLE_FACTORY_CREATOR(FakeSharedState) |
179 | | }; |
180 | | |
181 | | class CountedFinishDependency final : public Dependency { |
182 | | public: |
183 | | using SharedState = FakeSharedState; |
184 | | CountedFinishDependency(int id, int node_id, std::string name) |
185 | 213k | : Dependency(id, node_id, std::move(name), true) {} |
186 | | |
187 | 20.5k | void add(uint32_t count = 1) { |
188 | 20.5k | std::unique_lock<std::mutex> l(_mtx); |
189 | 20.5k | if (!_counter) { |
190 | 20.5k | block(); |
191 | 20.5k | } |
192 | 20.5k | _counter += count; |
193 | 20.5k | } |
194 | | |
195 | 20.5k | void sub() { |
196 | 20.5k | std::unique_lock<std::mutex> l(_mtx); |
197 | 20.5k | _counter--; |
198 | 20.5k | if (!_counter) { |
199 | 20.5k | set_ready(); |
200 | 20.5k | } |
201 | 20.5k | } |
202 | | |
203 | | std::string debug_string(int indentation_level = 0) override; |
204 | | |
205 | | private: |
206 | | std::mutex _mtx; |
207 | | uint32_t _counter = 0; |
208 | | }; |
209 | | |
210 | | struct RuntimeFilterTimerQueue; |
211 | | class RuntimeFilterTimer { |
212 | | public: |
213 | | RuntimeFilterTimer(int64_t registration_time, int32_t wait_time_ms, |
214 | | std::shared_ptr<Dependency> parent, bool force_wait_timeout = false) |
215 | 74.2k | : _parent(std::move(parent)), |
216 | 74.2k | _registration_time(registration_time), |
217 | 74.2k | _wait_time_ms(wait_time_ms), |
218 | 74.2k | _force_wait_timeout(force_wait_timeout) {} |
219 | | |
220 | | // Called by runtime filter producer. |
221 | | void call_ready(); |
222 | | |
223 | | // Called by RuntimeFilterTimerQueue which is responsible for checking if this rf is timeout. |
224 | | void call_timeout(); |
225 | | |
226 | 8.55M | int64_t registration_time() const { return _registration_time; } |
227 | 8.55M | int32_t wait_time_ms() const { return _wait_time_ms; } |
228 | | |
229 | | void set_local_runtime_filter_dependencies( |
230 | 5.06k | const std::vector<std::shared_ptr<Dependency>>& deps) { |
231 | 5.06k | _local_runtime_filter_dependencies = deps; |
232 | 5.06k | } |
233 | | |
234 | | bool should_be_check_timeout(); |
235 | | |
236 | 8.63M | bool force_wait_timeout() { return _force_wait_timeout; } |
237 | | |
238 | | private: |
239 | | friend struct RuntimeFilterTimerQueue; |
240 | | std::shared_ptr<Dependency> _parent = nullptr; |
241 | | std::vector<std::shared_ptr<Dependency>> _local_runtime_filter_dependencies; |
242 | | std::mutex _lock; |
243 | | int64_t _registration_time; |
244 | | const int32_t _wait_time_ms; |
245 | | // true only for group_commit_scan_operator |
246 | | bool _force_wait_timeout; |
247 | | }; |
248 | | |
249 | | struct RuntimeFilterTimerQueue { |
250 | | constexpr static int64_t interval = 10; |
251 | 8 | void run() { _thread.detach(); } |
252 | | void start(); |
253 | | |
254 | 3 | void stop() { |
255 | 3 | _stop = true; |
256 | 3 | cv.notify_all(); |
257 | 3 | wait_for_shutdown(); |
258 | 3 | } |
259 | | |
260 | 3 | void wait_for_shutdown() const { |
261 | 6 | while (!_shutdown) { |
262 | 3 | std::this_thread::sleep_for(std::chrono::milliseconds(interval)); |
263 | 3 | } |
264 | 3 | } |
265 | | |
266 | 3 | ~RuntimeFilterTimerQueue() = default; |
267 | 8 | RuntimeFilterTimerQueue() { _thread = std::thread(&RuntimeFilterTimerQueue::start, this); } |
268 | 43.7k | void push_filter_timer(std::vector<std::shared_ptr<pipeline::RuntimeFilterTimer>>&& filter) { |
269 | 43.7k | std::unique_lock<std::mutex> lc(_que_lock); |
270 | 43.7k | _que.insert(_que.end(), filter.begin(), filter.end()); |
271 | 43.7k | cv.notify_all(); |
272 | 43.7k | } |
273 | | |
274 | | std::thread _thread; |
275 | | std::condition_variable cv; |
276 | | std::mutex cv_m; |
277 | | std::mutex _que_lock; |
278 | | std::atomic_bool _stop = false; |
279 | | std::atomic_bool _shutdown = false; |
280 | | std::list<std::shared_ptr<pipeline::RuntimeFilterTimer>> _que; |
281 | | }; |
282 | | |
283 | | struct AggSharedState : public BasicSharedState { |
284 | | ENABLE_FACTORY_CREATOR(AggSharedState) |
285 | | public: |
286 | 134k | AggSharedState() { agg_data = std::make_unique<AggregatedDataVariants>(); } |
287 | 133k | ~AggSharedState() override { |
288 | 133k | if (!probe_expr_ctxs.empty()) { |
289 | 64.9k | _close_with_serialized_key(); |
290 | 69.0k | } else { |
291 | 69.0k | _close_without_key(); |
292 | 69.0k | } |
293 | 133k | } |
294 | | |
295 | | Status reset_hash_table(); |
296 | | |
297 | | bool do_limit_filter(vectorized::Block* block, size_t num_rows, |
298 | | const std::vector<int>* key_locs = nullptr); |
299 | | void build_limit_heap(size_t hash_table_size); |
300 | | |
301 | | // We should call this function only at 1st phase. |
302 | | // 1st phase: is_merge=true, only have one SlotRef. |
303 | | // 2nd phase: is_merge=false, maybe have multiple exprs. |
304 | | static int get_slot_column_id(const vectorized::AggFnEvaluator* evaluator); |
305 | | |
306 | | AggregatedDataVariantsUPtr agg_data = nullptr; |
307 | | std::unique_ptr<AggregateDataContainer> aggregate_data_container; |
308 | | std::vector<vectorized::AggFnEvaluator*> aggregate_evaluators; |
309 | | // group by k1,k2 |
310 | | vectorized::VExprContextSPtrs probe_expr_ctxs; |
311 | | size_t input_num_rows = 0; |
312 | | std::vector<vectorized::AggregateDataPtr> values; |
313 | | /// The total size of the row from the aggregate functions. |
314 | | size_t total_size_of_aggregate_states = 0; |
315 | | size_t align_aggregate_states = 1; |
316 | | /// The offset to the n-th aggregate function in a row of aggregate functions. |
317 | | vectorized::Sizes offsets_of_aggregate_states; |
318 | | std::vector<size_t> make_nullable_keys; |
319 | | |
320 | | bool agg_data_created_without_key = false; |
321 | | bool enable_spill = false; |
322 | | bool reach_limit = false; |
323 | | |
324 | | bool use_simple_count = false; |
325 | | int64_t limit = -1; |
326 | | bool do_sort_limit = false; |
327 | | vectorized::MutableColumns limit_columns; |
328 | | int limit_columns_min = -1; |
329 | | vectorized::PaddedPODArray<uint8_t> need_computes; |
330 | | std::vector<uint8_t> cmp_res; |
331 | | std::vector<int> order_directions; |
332 | | std::vector<int> null_directions; |
333 | | |
334 | | struct HeapLimitCursor { |
335 | | HeapLimitCursor(int row_id, vectorized::MutableColumns& limit_columns, |
336 | | std::vector<int>& order_directions, std::vector<int>& null_directions) |
337 | 8.50k | : _row_id(row_id), |
338 | 8.50k | _limit_columns(limit_columns), |
339 | 8.50k | _order_directions(order_directions), |
340 | 8.50k | _null_directions(null_directions) {} |
341 | | |
342 | | HeapLimitCursor(const HeapLimitCursor& other) = default; |
343 | | |
344 | | HeapLimitCursor(HeapLimitCursor&& other) noexcept |
345 | 53.5k | : _row_id(other._row_id), |
346 | 53.5k | _limit_columns(other._limit_columns), |
347 | 53.5k | _order_directions(other._order_directions), |
348 | 53.5k | _null_directions(other._null_directions) {} |
349 | | |
350 | 0 | HeapLimitCursor& operator=(const HeapLimitCursor& other) noexcept { |
351 | 0 | _row_id = other._row_id; |
352 | 0 | return *this; |
353 | 0 | } |
354 | | |
355 | 91.3k | HeapLimitCursor& operator=(HeapLimitCursor&& other) noexcept { |
356 | 91.3k | _row_id = other._row_id; |
357 | 91.3k | return *this; |
358 | 91.3k | } |
359 | | |
360 | 82.8k | bool operator<(const HeapLimitCursor& rhs) const { |
361 | 124k | for (int i = 0; i < _limit_columns.size(); ++i) { |
362 | 124k | const auto& _limit_column = _limit_columns[i]; |
363 | 124k | auto res = _limit_column->compare_at(_row_id, rhs._row_id, *_limit_column, |
364 | 124k | _null_directions[i]) * |
365 | 124k | _order_directions[i]; |
366 | 124k | if (res < 0) { |
367 | 40.0k | return true; |
368 | 84.9k | } else if (res > 0) { |
369 | 43.2k | return false; |
370 | 43.2k | } |
371 | 124k | } |
372 | 18.4E | return false; |
373 | 82.8k | } |
374 | | |
375 | | int _row_id; |
376 | | vectorized::MutableColumns& _limit_columns; |
377 | | std::vector<int>& _order_directions; |
378 | | std::vector<int>& _null_directions; |
379 | | }; |
380 | | |
381 | | std::priority_queue<HeapLimitCursor> limit_heap; |
382 | | |
383 | | // Refresh the top limit heap with a new row |
384 | | void refresh_top_limit(size_t row_id, const vectorized::ColumnRawPtrs& key_columns); |
385 | | |
386 | | vectorized::Arena agg_arena_pool; |
387 | | vectorized::Arena agg_profile_arena; |
388 | | |
389 | | private: |
390 | | vectorized::MutableColumns _get_keys_hash_table(); |
391 | | |
392 | 64.8k | void _close_with_serialized_key() { |
393 | 64.8k | std::visit( |
394 | 64.8k | vectorized::Overload {[&](std::monostate& arg) -> void { |
395 | | // Do nothing |
396 | 0 | }, |
397 | 64.9k | [&](auto& agg_method) -> void { |
398 | 64.9k | if (use_simple_count) { |
399 | | // Inline count: mapped slots hold UInt64, |
400 | | // not real agg state pointers. Skip destroy. |
401 | 1.21k | return; |
402 | 1.21k | } |
403 | 63.7k | auto& data = *agg_method.hash_table; |
404 | 1.25M | data.for_each_mapped([&](auto& mapped) { |
405 | 1.25M | if (mapped) { |
406 | 1.25M | _destroy_agg_status(mapped); |
407 | 1.25M | mapped = nullptr; |
408 | 1.25M | } |
409 | 1.25M | }); _ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32ISB_EEEEEEvS3_ENKUlS3_E_clISC_EEDaS3_ Line | Count | Source | 404 | 5.92k | data.for_each_mapped([&](auto& mapped) { | 405 | 5.92k | if (mapped) { | 406 | 5.92k | _destroy_agg_status(mapped); | 407 | 5.92k | mapped = nullptr; | 408 | 5.92k | } | 409 | 5.92k | }); |
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapINS6_7UInt136EPc9HashCRC32IS9_EEEEEEvS3_ENKUlS3_E_clISA_EEDaS3_ Line | Count | Source | 404 | 1.74k | data.for_each_mapped([&](auto& mapped) { | 405 | 1.74k | if (mapped) { | 406 | 1.74k | _destroy_agg_status(mapped); | 407 | 1.74k | mapped = nullptr; | 408 | 1.74k | } | 409 | 1.74k | }); |
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32ISB_EEEEEEvS3_ENKUlS3_E_clISC_EEDaS3_ Line | Count | Source | 404 | 1.13k | data.for_each_mapped([&](auto& mapped) { | 405 | 1.13k | if (mapped) { | 406 | 1.13k | _destroy_agg_status(mapped); | 407 | 1.13k | mapped = nullptr; | 408 | 1.13k | } | 409 | 1.13k | }); |
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapINS6_7UInt104EPc9HashCRC32IS9_EEEEEEvS3_ENKUlS3_E_clISA_EEDaS3_ Line | Count | Source | 404 | 693 | data.for_each_mapped([&](auto& mapped) { | 405 | 693 | if (mapped) { | 406 | 693 | _destroy_agg_status(mapped); | 407 | 693 | mapped = nullptr; | 408 | 693 | } | 409 | 693 | }); |
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapINS6_6UInt96EPc9HashCRC32IS9_EEEEEEvS3_ENKUlS3_E_clISA_EEDaS3_ Line | Count | Source | 404 | 7.62k | data.for_each_mapped([&](auto& mapped) { | 405 | 7.62k | if (mapped) { | 406 | 7.62k | _destroy_agg_status(mapped); | 407 | 7.62k | mapped = nullptr; | 408 | 7.62k | } | 409 | 7.62k | }); |
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapINS6_6UInt72EPc9HashCRC32IS9_EEEEEEvS3_ENKUlS3_E_clISA_EEDaS3_ Line | Count | Source | 404 | 856 | data.for_each_mapped([&](auto& mapped) { | 405 | 856 | if (mapped) { | 406 | 856 | _destroy_agg_status(mapped); | 407 | 856 | mapped = nullptr; | 408 | 856 | } | 409 | 856 | }); |
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImEEEEEEvS3_ENKUlS3_E_clIS9_EEDaS3_ Line | Count | Source | 404 | 145k | data.for_each_mapped([&](auto& mapped) { | 405 | 145k | if (mapped) { | 406 | 145k | _destroy_agg_status(mapped); | 407 | 145k | mapped = nullptr; | 408 | 145k | } | 409 | 145k | }); |
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_19MethodStringNoCacheINS6_15DataWithNullKeyINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEEEEEvS3_ENKUlS3_E_clISB_EEDaS3_ Line | Count | Source | 404 | 4.07k | data.for_each_mapped([&](auto& mapped) { | 405 | 4.07k | if (mapped) { | 406 | 4.07k | _destroy_agg_status(mapped); | 407 | 4.07k | mapped = nullptr; | 408 | 4.07k | } | 409 | 4.07k | }); |
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIN4wide7integerILm256EjEENS6_15DataWithNullKeyI9PHHashMapISB_Pc9HashCRC32ISB_EEEEEEEEEEvS3_ENKUlS3_E_clISE_EEDaS3_ Line | Count | Source | 404 | 9 | data.for_each_mapped([&](auto& mapped) { | 405 | 9 | if (mapped) { | 406 | 9 | _destroy_agg_status(mapped); | 407 | 9 | mapped = nullptr; | 408 | 9 | } | 409 | 9 | }); |
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIN4wide7integerILm128EjEENS6_15DataWithNullKeyI9PHHashMapISB_Pc9HashCRC32ISB_EEEEEEEEEEvS3_ENKUlS3_E_clISE_EEDaS3_ Line | Count | Source | 404 | 99 | data.for_each_mapped([&](auto& mapped) { | 405 | 99 | if (mapped) { | 406 | 99 | _destroy_agg_status(mapped); | 407 | 99 | mapped = nullptr; | 408 | 99 | } | 409 | 99 | }); |
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberImNS6_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEvS3_ENKUlS3_E_clISB_EEDaS3_ Line | Count | Source | 404 | 40.5k | data.for_each_mapped([&](auto& mapped) { | 405 | 40.6k | if (mapped) { | 406 | 40.6k | _destroy_agg_status(mapped); | 407 | 40.6k | mapped = nullptr; | 408 | 40.6k | } | 409 | 40.5k | }); |
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIjNS6_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEvS3_ENKUlS3_E_clISB_EEDaS3_ Line | Count | Source | 404 | 66.0k | data.for_each_mapped([&](auto& mapped) { | 405 | 66.0k | if (mapped) { | 406 | 66.0k | _destroy_agg_status(mapped); | 407 | 66.0k | mapped = nullptr; | 408 | 66.0k | } | 409 | 66.0k | }); |
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberImNS6_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEvS3_ENKUlS3_E_clISB_EEDaS3_ Line | Count | Source | 404 | 38.5k | data.for_each_mapped([&](auto& mapped) { | 405 | 38.5k | if (mapped) { | 406 | 38.5k | _destroy_agg_status(mapped); | 407 | 38.5k | mapped = nullptr; | 408 | 38.5k | } | 409 | 38.5k | }); |
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIjNS6_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEvS3_ENKUlS3_E_clISB_EEDaS3_ Line | Count | Source | 404 | 35.3k | data.for_each_mapped([&](auto& mapped) { | 405 | 35.3k | if (mapped) { | 406 | 35.3k | _destroy_agg_status(mapped); | 407 | 35.3k | mapped = nullptr; | 408 | 35.3k | } | 409 | 35.3k | }); |
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberItNS6_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEvS3_ENKUlS3_E_clISB_EEDaS3_ Line | Count | Source | 404 | 333 | data.for_each_mapped([&](auto& mapped) { | 405 | 333 | if (mapped) { | 406 | 333 | _destroy_agg_status(mapped); | 407 | 333 | mapped = nullptr; | 408 | 333 | } | 409 | 333 | }); |
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIhNS6_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEvS3_ENKUlS3_E_clISB_EEDaS3_ Line | Count | Source | 404 | 1.78k | data.for_each_mapped([&](auto& mapped) { | 405 | 1.78k | if (mapped) { | 406 | 1.78k | _destroy_agg_status(mapped); | 407 | 1.78k | mapped = nullptr; | 408 | 1.78k | } | 409 | 1.78k | }); |
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEvS3_ENKUlS3_E_clIS9_EEDaS3_ Line | Count | Source | 404 | 20.6k | data.for_each_mapped([&](auto& mapped) { | 405 | 20.6k | if (mapped) { | 406 | 20.6k | _destroy_agg_status(mapped); | 407 | 20.6k | mapped = nullptr; | 408 | 20.6k | } | 409 | 20.6k | }); |
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEvS3_ENKUlS3_E_clIS9_EEDaS3_ Line | Count | Source | 404 | 821k | data.for_each_mapped([&](auto& mapped) { | 405 | 822k | if (mapped) { | 406 | 822k | _destroy_agg_status(mapped); | 407 | 822k | mapped = nullptr; | 408 | 822k | } | 409 | 821k | }); |
Unexecuted instantiation: _ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapISA_Pc9HashCRC32ISA_EEEEEEvS3_ENKUlS3_E_clISC_EEDaS3_ _ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapISA_Pc9HashCRC32ISA_EEEEEEvS3_ENKUlS3_E_clISC_EEDaS3_ Line | Count | Source | 404 | 31 | data.for_each_mapped([&](auto& mapped) { | 405 | 31 | if (mapped) { | 406 | 31 | _destroy_agg_status(mapped); | 407 | 31 | mapped = nullptr; | 408 | 31 | } | 409 | 31 | }); |
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEvS3_ENKUlS3_E_clIS9_EEDaS3_ Line | Count | Source | 404 | 2.01k | data.for_each_mapped([&](auto& mapped) { | 405 | 2.01k | if (mapped) { | 406 | 2.01k | _destroy_agg_status(mapped); | 407 | 2.01k | mapped = nullptr; | 408 | 2.01k | } | 409 | 2.01k | }); |
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEEvS3_ENKUlS3_E_clIS9_EEDaS3_ Line | Count | Source | 404 | 752 | data.for_each_mapped([&](auto& mapped) { | 405 | 752 | if (mapped) { | 406 | 752 | _destroy_agg_status(mapped); | 407 | 752 | mapped = nullptr; | 408 | 752 | } | 409 | 752 | }); |
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEEvS3_ENKUlS3_E_clIS9_EEDaS3_ Line | Count | Source | 404 | 142 | data.for_each_mapped([&](auto& mapped) { | 405 | 142 | if (mapped) { | 406 | 142 | _destroy_agg_status(mapped); | 407 | 142 | mapped = nullptr; | 408 | 142 | } | 409 | 142 | }); |
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEvS3_ENKUlS3_E_clIS9_EEDaS3_ Line | Count | Source | 404 | 13 | data.for_each_mapped([&](auto& mapped) { | 405 | 13 | if (mapped) { | 406 | 13 | _destroy_agg_status(mapped); | 407 | 13 | mapped = nullptr; | 408 | 13 | } | 409 | 13 | }); |
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEvS3_ENKUlS3_E_clIS9_EEDaS3_ Line | Count | Source | 404 | 251 | data.for_each_mapped([&](auto& mapped) { | 405 | 251 | if (mapped) { | 406 | 251 | _destroy_agg_status(mapped); | 407 | 251 | mapped = nullptr; | 408 | 251 | } | 409 | 251 | }); |
_ZZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS9_vEEEEEEvS3_ENKUlS3_E_clISA_EEDaS3_ Line | Count | Source | 404 | 56.9k | data.for_each_mapped([&](auto& mapped) { | 405 | 56.9k | if (mapped) { | 406 | 56.9k | _destroy_agg_status(mapped); | 407 | 56.9k | mapped = nullptr; | 408 | 56.9k | } | 409 | 56.9k | }); |
|
410 | 63.7k | if (data.has_null_key_data()) { |
411 | 1.10k | _destroy_agg_status(data.template get_null_key_data< |
412 | 1.10k | vectorized::AggregateDataPtr>()); |
413 | 1.10k | } |
414 | 63.7k | }}, _ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32ISB_EEEEEEvS3_ Line | Count | Source | 397 | 7.64k | [&](auto& agg_method) -> void { | 398 | 7.64k | if (use_simple_count) { | 399 | | // Inline count: mapped slots hold UInt64, | 400 | | // not real agg state pointers. Skip destroy. | 401 | 14 | return; | 402 | 14 | } | 403 | 7.63k | auto& data = *agg_method.hash_table; | 404 | 7.63k | data.for_each_mapped([&](auto& mapped) { | 405 | 7.63k | if (mapped) { | 406 | 7.63k | _destroy_agg_status(mapped); | 407 | 7.63k | mapped = nullptr; | 408 | 7.63k | } | 409 | 7.63k | }); | 410 | 7.63k | if (data.has_null_key_data()) { | 411 | 0 | _destroy_agg_status(data.template get_null_key_data< | 412 | 0 | vectorized::AggregateDataPtr>()); | 413 | 0 | } | 414 | 7.63k | }}, |
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapINS6_7UInt136EPc9HashCRC32IS9_EEEEEEvS3_ Line | Count | Source | 397 | 1.78k | [&](auto& agg_method) -> void { | 398 | 1.78k | if (use_simple_count) { | 399 | | // Inline count: mapped slots hold UInt64, | 400 | | // not real agg state pointers. Skip destroy. | 401 | 96 | return; | 402 | 96 | } | 403 | 1.68k | auto& data = *agg_method.hash_table; | 404 | 1.68k | data.for_each_mapped([&](auto& mapped) { | 405 | 1.68k | if (mapped) { | 406 | 1.68k | _destroy_agg_status(mapped); | 407 | 1.68k | mapped = nullptr; | 408 | 1.68k | } | 409 | 1.68k | }); | 410 | 1.68k | if (data.has_null_key_data()) { | 411 | 0 | _destroy_agg_status(data.template get_null_key_data< | 412 | 0 | vectorized::AggregateDataPtr>()); | 413 | 0 | } | 414 | 1.68k | }}, |
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32ISB_EEEEEEvS3_ Line | Count | Source | 397 | 101 | [&](auto& agg_method) -> void { | 398 | 101 | if (use_simple_count) { | 399 | | // Inline count: mapped slots hold UInt64, | 400 | | // not real agg state pointers. Skip destroy. | 401 | 40 | return; | 402 | 40 | } | 403 | 61 | auto& data = *agg_method.hash_table; | 404 | 61 | data.for_each_mapped([&](auto& mapped) { | 405 | 61 | if (mapped) { | 406 | 61 | _destroy_agg_status(mapped); | 407 | 61 | mapped = nullptr; | 408 | 61 | } | 409 | 61 | }); | 410 | 61 | if (data.has_null_key_data()) { | 411 | 0 | _destroy_agg_status(data.template get_null_key_data< | 412 | 0 | vectorized::AggregateDataPtr>()); | 413 | 0 | } | 414 | 61 | }}, |
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapINS6_7UInt104EPc9HashCRC32IS9_EEEEEEvS3_ Line | Count | Source | 397 | 600 | [&](auto& agg_method) -> void { | 398 | 600 | if (use_simple_count) { | 399 | | // Inline count: mapped slots hold UInt64, | 400 | | // not real agg state pointers. Skip destroy. | 401 | 3 | return; | 402 | 3 | } | 403 | 597 | auto& data = *agg_method.hash_table; | 404 | 597 | data.for_each_mapped([&](auto& mapped) { | 405 | 597 | if (mapped) { | 406 | 597 | _destroy_agg_status(mapped); | 407 | 597 | mapped = nullptr; | 408 | 597 | } | 409 | 597 | }); | 410 | 597 | if (data.has_null_key_data()) { | 411 | 0 | _destroy_agg_status(data.template get_null_key_data< | 412 | 0 | vectorized::AggregateDataPtr>()); | 413 | 0 | } | 414 | 597 | }}, |
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapINS6_6UInt96EPc9HashCRC32IS9_EEEEEEvS3_ Line | Count | Source | 397 | 2.04k | [&](auto& agg_method) -> void { | 398 | 2.04k | if (use_simple_count) { | 399 | | // Inline count: mapped slots hold UInt64, | 400 | | // not real agg state pointers. Skip destroy. | 401 | 16 | return; | 402 | 16 | } | 403 | 2.03k | auto& data = *agg_method.hash_table; | 404 | 2.03k | data.for_each_mapped([&](auto& mapped) { | 405 | 2.03k | if (mapped) { | 406 | 2.03k | _destroy_agg_status(mapped); | 407 | 2.03k | mapped = nullptr; | 408 | 2.03k | } | 409 | 2.03k | }); | 410 | 2.03k | if (data.has_null_key_data()) { | 411 | 0 | _destroy_agg_status(data.template get_null_key_data< | 412 | 0 | vectorized::AggregateDataPtr>()); | 413 | 0 | } | 414 | 2.03k | }}, |
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapINS6_6UInt72EPc9HashCRC32IS9_EEEEEEvS3_ Line | Count | Source | 397 | 807 | [&](auto& agg_method) -> void { | 398 | 807 | if (use_simple_count) { | 399 | | // Inline count: mapped slots hold UInt64, | 400 | | // not real agg state pointers. Skip destroy. | 401 | 0 | return; | 402 | 0 | } | 403 | 807 | auto& data = *agg_method.hash_table; | 404 | 807 | data.for_each_mapped([&](auto& mapped) { | 405 | 807 | if (mapped) { | 406 | 807 | _destroy_agg_status(mapped); | 407 | 807 | mapped = nullptr; | 408 | 807 | } | 409 | 807 | }); | 410 | 807 | if (data.has_null_key_data()) { | 411 | 0 | _destroy_agg_status(data.template get_null_key_data< | 412 | 0 | vectorized::AggregateDataPtr>()); | 413 | 0 | } | 414 | 807 | }}, |
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImEEEEEEvS3_ Line | Count | Source | 397 | 835 | [&](auto& agg_method) -> void { | 398 | 835 | if (use_simple_count) { | 399 | | // Inline count: mapped slots hold UInt64, | 400 | | // not real agg state pointers. Skip destroy. | 401 | 110 | return; | 402 | 110 | } | 403 | 725 | auto& data = *agg_method.hash_table; | 404 | 725 | data.for_each_mapped([&](auto& mapped) { | 405 | 725 | if (mapped) { | 406 | 725 | _destroy_agg_status(mapped); | 407 | 725 | mapped = nullptr; | 408 | 725 | } | 409 | 725 | }); | 410 | 725 | if (data.has_null_key_data()) { | 411 | 0 | _destroy_agg_status(data.template get_null_key_data< | 412 | 0 | vectorized::AggregateDataPtr>()); | 413 | 0 | } | 414 | 725 | }}, |
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_19MethodStringNoCacheINS6_15DataWithNullKeyINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEEEEEvS3_ Line | Count | Source | 397 | 3.69k | [&](auto& agg_method) -> void { | 398 | 3.69k | if (use_simple_count) { | 399 | | // Inline count: mapped slots hold UInt64, | 400 | | // not real agg state pointers. Skip destroy. | 401 | 0 | return; | 402 | 0 | } | 403 | 3.69k | auto& data = *agg_method.hash_table; | 404 | 3.69k | data.for_each_mapped([&](auto& mapped) { | 405 | 3.69k | if (mapped) { | 406 | 3.69k | _destroy_agg_status(mapped); | 407 | 3.69k | mapped = nullptr; | 408 | 3.69k | } | 409 | 3.69k | }); | 410 | 3.69k | if (data.has_null_key_data()) { | 411 | 200 | _destroy_agg_status(data.template get_null_key_data< | 412 | 200 | vectorized::AggregateDataPtr>()); | 413 | 200 | } | 414 | 3.69k | }}, |
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIN4wide7integerILm256EjEENS6_15DataWithNullKeyI9PHHashMapISB_Pc9HashCRC32ISB_EEEEEEEEEEvS3_ Line | Count | Source | 397 | 10 | [&](auto& agg_method) -> void { | 398 | 10 | if (use_simple_count) { | 399 | | // Inline count: mapped slots hold UInt64, | 400 | | // not real agg state pointers. Skip destroy. | 401 | 0 | return; | 402 | 0 | } | 403 | 10 | auto& data = *agg_method.hash_table; | 404 | 10 | data.for_each_mapped([&](auto& mapped) { | 405 | 10 | if (mapped) { | 406 | 10 | _destroy_agg_status(mapped); | 407 | 10 | mapped = nullptr; | 408 | 10 | } | 409 | 10 | }); | 410 | 10 | if (data.has_null_key_data()) { | 411 | 0 | _destroy_agg_status(data.template get_null_key_data< | 412 | 0 | vectorized::AggregateDataPtr>()); | 413 | 0 | } | 414 | 10 | }}, |
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIN4wide7integerILm128EjEENS6_15DataWithNullKeyI9PHHashMapISB_Pc9HashCRC32ISB_EEEEEEEEEEvS3_ Line | Count | Source | 397 | 317 | [&](auto& agg_method) -> void { | 398 | 317 | if (use_simple_count) { | 399 | | // Inline count: mapped slots hold UInt64, | 400 | | // not real agg state pointers. Skip destroy. | 401 | 0 | return; | 402 | 0 | } | 403 | 317 | auto& data = *agg_method.hash_table; | 404 | 317 | data.for_each_mapped([&](auto& mapped) { | 405 | 317 | if (mapped) { | 406 | 317 | _destroy_agg_status(mapped); | 407 | 317 | mapped = nullptr; | 408 | 317 | } | 409 | 317 | }); | 410 | 317 | if (data.has_null_key_data()) { | 411 | 6 | _destroy_agg_status(data.template get_null_key_data< | 412 | 6 | vectorized::AggregateDataPtr>()); | 413 | 6 | } | 414 | 317 | }}, |
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberImNS6_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEEvS3_ Line | Count | Source | 397 | 5.89k | [&](auto& agg_method) -> void { | 398 | 5.89k | if (use_simple_count) { | 399 | | // Inline count: mapped slots hold UInt64, | 400 | | // not real agg state pointers. Skip destroy. | 401 | 0 | return; | 402 | 0 | } | 403 | 5.89k | auto& data = *agg_method.hash_table; | 404 | 5.89k | data.for_each_mapped([&](auto& mapped) { | 405 | 5.89k | if (mapped) { | 406 | 5.89k | _destroy_agg_status(mapped); | 407 | 5.89k | mapped = nullptr; | 408 | 5.89k | } | 409 | 5.89k | }); | 410 | 5.89k | if (data.has_null_key_data()) { | 411 | 105 | _destroy_agg_status(data.template get_null_key_data< | 412 | 105 | vectorized::AggregateDataPtr>()); | 413 | 105 | } | 414 | 5.89k | }}, |
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIjNS6_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEEvS3_ Line | Count | Source | 397 | 10.4k | [&](auto& agg_method) -> void { | 398 | 10.4k | if (use_simple_count) { | 399 | | // Inline count: mapped slots hold UInt64, | 400 | | // not real agg state pointers. Skip destroy. | 401 | 0 | return; | 402 | 0 | } | 403 | 10.4k | auto& data = *agg_method.hash_table; | 404 | 10.4k | data.for_each_mapped([&](auto& mapped) { | 405 | 10.4k | if (mapped) { | 406 | 10.4k | _destroy_agg_status(mapped); | 407 | 10.4k | mapped = nullptr; | 408 | 10.4k | } | 409 | 10.4k | }); | 410 | 10.4k | if (data.has_null_key_data()) { | 411 | 360 | _destroy_agg_status(data.template get_null_key_data< | 412 | 360 | vectorized::AggregateDataPtr>()); | 413 | 360 | } | 414 | 10.4k | }}, |
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberImNS6_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEEvS3_ Line | Count | Source | 397 | 466 | [&](auto& agg_method) -> void { | 398 | 466 | if (use_simple_count) { | 399 | | // Inline count: mapped slots hold UInt64, | 400 | | // not real agg state pointers. Skip destroy. | 401 | 0 | return; | 402 | 0 | } | 403 | 466 | auto& data = *agg_method.hash_table; | 404 | 466 | data.for_each_mapped([&](auto& mapped) { | 405 | 466 | if (mapped) { | 406 | 466 | _destroy_agg_status(mapped); | 407 | 466 | mapped = nullptr; | 408 | 466 | } | 409 | 466 | }); | 410 | 466 | if (data.has_null_key_data()) { | 411 | 36 | _destroy_agg_status(data.template get_null_key_data< | 412 | 36 | vectorized::AggregateDataPtr>()); | 413 | 36 | } | 414 | 466 | }}, |
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIjNS6_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEEvS3_ Line | Count | Source | 397 | 979 | [&](auto& agg_method) -> void { | 398 | 979 | if (use_simple_count) { | 399 | | // Inline count: mapped slots hold UInt64, | 400 | | // not real agg state pointers. Skip destroy. | 401 | 0 | return; | 402 | 0 | } | 403 | 979 | auto& data = *agg_method.hash_table; | 404 | 979 | data.for_each_mapped([&](auto& mapped) { | 405 | 979 | if (mapped) { | 406 | 979 | _destroy_agg_status(mapped); | 407 | 979 | mapped = nullptr; | 408 | 979 | } | 409 | 979 | }); | 410 | 979 | if (data.has_null_key_data()) { | 411 | 22 | _destroy_agg_status(data.template get_null_key_data< | 412 | 22 | vectorized::AggregateDataPtr>()); | 413 | 22 | } | 414 | 979 | }}, |
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberItNS6_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEEvS3_ Line | Count | Source | 397 | 436 | [&](auto& agg_method) -> void { | 398 | 436 | if (use_simple_count) { | 399 | | // Inline count: mapped slots hold UInt64, | 400 | | // not real agg state pointers. Skip destroy. | 401 | 0 | return; | 402 | 0 | } | 403 | 436 | auto& data = *agg_method.hash_table; | 404 | 436 | data.for_each_mapped([&](auto& mapped) { | 405 | 436 | if (mapped) { | 406 | 436 | _destroy_agg_status(mapped); | 407 | 436 | mapped = nullptr; | 408 | 436 | } | 409 | 436 | }); | 410 | 436 | if (data.has_null_key_data()) { | 411 | 19 | _destroy_agg_status(data.template get_null_key_data< | 412 | 19 | vectorized::AggregateDataPtr>()); | 413 | 19 | } | 414 | 436 | }}, |
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized26MethodSingleNullableColumnINS6_15MethodOneNumberIhNS6_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEEvS3_ Line | Count | Source | 397 | 5.94k | [&](auto& agg_method) -> void { | 398 | 5.94k | if (use_simple_count) { | 399 | | // Inline count: mapped slots hold UInt64, | 400 | | // not real agg state pointers. Skip destroy. | 401 | 0 | return; | 402 | 0 | } | 403 | 5.94k | auto& data = *agg_method.hash_table; | 404 | 5.94k | data.for_each_mapped([&](auto& mapped) { | 405 | 5.94k | if (mapped) { | 406 | 5.94k | _destroy_agg_status(mapped); | 407 | 5.94k | mapped = nullptr; | 408 | 5.94k | } | 409 | 5.94k | }); | 410 | 5.94k | if (data.has_null_key_data()) { | 411 | 358 | _destroy_agg_status(data.template get_null_key_data< | 412 | 358 | vectorized::AggregateDataPtr>()); | 413 | 358 | } | 414 | 5.94k | }}, |
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEvS3_ Line | Count | Source | 397 | 1.32k | [&](auto& agg_method) -> void { | 398 | 1.32k | if (use_simple_count) { | 399 | | // Inline count: mapped slots hold UInt64, | 400 | | // not real agg state pointers. Skip destroy. | 401 | 784 | return; | 402 | 784 | } | 403 | 536 | auto& data = *agg_method.hash_table; | 404 | 536 | data.for_each_mapped([&](auto& mapped) { | 405 | 536 | if (mapped) { | 406 | 536 | _destroy_agg_status(mapped); | 407 | 536 | mapped = nullptr; | 408 | 536 | } | 409 | 536 | }); | 410 | 536 | if (data.has_null_key_data()) { | 411 | 0 | _destroy_agg_status(data.template get_null_key_data< | 412 | 0 | vectorized::AggregateDataPtr>()); | 413 | 0 | } | 414 | 536 | }}, |
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEvS3_ Line | Count | Source | 397 | 5.07k | [&](auto& agg_method) -> void { | 398 | 5.07k | if (use_simple_count) { | 399 | | // Inline count: mapped slots hold UInt64, | 400 | | // not real agg state pointers. Skip destroy. | 401 | 69 | return; | 402 | 69 | } | 403 | 5.00k | auto& data = *agg_method.hash_table; | 404 | 5.00k | data.for_each_mapped([&](auto& mapped) { | 405 | 5.00k | if (mapped) { | 406 | 5.00k | _destroy_agg_status(mapped); | 407 | 5.00k | mapped = nullptr; | 408 | 5.00k | } | 409 | 5.00k | }); | 410 | 5.00k | if (data.has_null_key_data()) { | 411 | 0 | _destroy_agg_status(data.template get_null_key_data< | 412 | 0 | vectorized::AggregateDataPtr>()); | 413 | 0 | } | 414 | 5.00k | }}, |
Unexecuted instantiation: _ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapISA_Pc9HashCRC32ISA_EEEEEEvS3_ _ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapISA_Pc9HashCRC32ISA_EEEEEEvS3_ Line | Count | Source | 397 | 95 | [&](auto& agg_method) -> void { | 398 | 95 | if (use_simple_count) { | 399 | | // Inline count: mapped slots hold UInt64, | 400 | | // not real agg state pointers. Skip destroy. | 401 | 0 | return; | 402 | 0 | } | 403 | 95 | auto& data = *agg_method.hash_table; | 404 | 95 | data.for_each_mapped([&](auto& mapped) { | 405 | 95 | if (mapped) { | 406 | 95 | _destroy_agg_status(mapped); | 407 | 95 | mapped = nullptr; | 408 | 95 | } | 409 | 95 | }); | 410 | 95 | if (data.has_null_key_data()) { | 411 | 0 | _destroy_agg_status(data.template get_null_key_data< | 412 | 0 | vectorized::AggregateDataPtr>()); | 413 | 0 | } | 414 | 95 | }}, |
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized19MethodStringNoCacheINS_13StringHashMapIPcNS_9AllocatorILb1ELb1ELb0ENS_22DefaultMemoryAllocatorELb1EEEEEEEEEvS3_ Line | Count | Source | 397 | 836 | [&](auto& agg_method) -> void { | 398 | 836 | if (use_simple_count) { | 399 | | // Inline count: mapped slots hold UInt64, | 400 | | // not real agg state pointers. Skip destroy. | 401 | 0 | return; | 402 | 0 | } | 403 | 836 | auto& data = *agg_method.hash_table; | 404 | 836 | data.for_each_mapped([&](auto& mapped) { | 405 | 836 | if (mapped) { | 406 | 836 | _destroy_agg_status(mapped); | 407 | 836 | mapped = nullptr; | 408 | 836 | } | 409 | 836 | }); | 410 | 836 | if (data.has_null_key_data()) { | 411 | 0 | _destroy_agg_status(data.template get_null_key_data< | 412 | 0 | vectorized::AggregateDataPtr>()); | 413 | 0 | } | 414 | 836 | }}, |
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEEvS3_ Line | Count | Source | 397 | 119 | [&](auto& agg_method) -> void { | 398 | 119 | if (use_simple_count) { | 399 | | // Inline count: mapped slots hold UInt64, | 400 | | // not real agg state pointers. Skip destroy. | 401 | 0 | return; | 402 | 0 | } | 403 | 119 | auto& data = *agg_method.hash_table; | 404 | 119 | data.for_each_mapped([&](auto& mapped) { | 405 | 119 | if (mapped) { | 406 | 119 | _destroy_agg_status(mapped); | 407 | 119 | mapped = nullptr; | 408 | 119 | } | 409 | 119 | }); | 410 | 119 | if (data.has_null_key_data()) { | 411 | 0 | _destroy_agg_status(data.template get_null_key_data< | 412 | 0 | vectorized::AggregateDataPtr>()); | 413 | 0 | } | 414 | 119 | }}, |
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEEvS3_ Line | Count | Source | 397 | 196 | [&](auto& agg_method) -> void { | 398 | 196 | if (use_simple_count) { | 399 | | // Inline count: mapped slots hold UInt64, | 400 | | // not real agg state pointers. Skip destroy. | 401 | 0 | return; | 402 | 0 | } | 403 | 196 | auto& data = *agg_method.hash_table; | 404 | 196 | data.for_each_mapped([&](auto& mapped) { | 405 | 196 | if (mapped) { | 406 | 196 | _destroy_agg_status(mapped); | 407 | 196 | mapped = nullptr; | 408 | 196 | } | 409 | 196 | }); | 410 | 196 | if (data.has_null_key_data()) { | 411 | 0 | _destroy_agg_status(data.template get_null_key_data< | 412 | 0 | vectorized::AggregateDataPtr>()); | 413 | 0 | } | 414 | 196 | }}, |
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEEvS3_ Line | Count | Source | 397 | 60 | [&](auto& agg_method) -> void { | 398 | 60 | if (use_simple_count) { | 399 | | // Inline count: mapped slots hold UInt64, | 400 | | // not real agg state pointers. Skip destroy. | 401 | 0 | return; | 402 | 0 | } | 403 | 60 | auto& data = *agg_method.hash_table; | 404 | 60 | data.for_each_mapped([&](auto& mapped) { | 405 | 60 | if (mapped) { | 406 | 60 | _destroy_agg_status(mapped); | 407 | 60 | mapped = nullptr; | 408 | 60 | } | 409 | 60 | }); | 410 | 60 | if (data.has_null_key_data()) { | 411 | 0 | _destroy_agg_status(data.template get_null_key_data< | 412 | 0 | vectorized::AggregateDataPtr>()); | 413 | 0 | } | 414 | 60 | }}, |
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEEvS3_ Line | Count | Source | 397 | 1.92k | [&](auto& agg_method) -> void { | 398 | 1.92k | if (use_simple_count) { | 399 | | // Inline count: mapped slots hold UInt64, | 400 | | // not real agg state pointers. Skip destroy. | 401 | 6 | return; | 402 | 6 | } | 403 | 1.92k | auto& data = *agg_method.hash_table; | 404 | 1.92k | data.for_each_mapped([&](auto& mapped) { | 405 | 1.92k | if (mapped) { | 406 | 1.92k | _destroy_agg_status(mapped); | 407 | 1.92k | mapped = nullptr; | 408 | 1.92k | } | 409 | 1.92k | }); | 410 | 1.92k | if (data.has_null_key_data()) { | 411 | 0 | _destroy_agg_status(data.template get_null_key_data< | 412 | 0 | vectorized::AggregateDataPtr>()); | 413 | 0 | } | 414 | 1.92k | }}, |
_ZZN5doris8pipeline14AggSharedState26_close_with_serialized_keyEvENKUlRT_E_clINS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS9_vEEEEEEvS3_ Line | Count | Source | 397 | 13.3k | [&](auto& agg_method) -> void { | 398 | 13.3k | if (use_simple_count) { | 399 | | // Inline count: mapped slots hold UInt64, | 400 | | // not real agg state pointers. Skip destroy. | 401 | 74 | return; | 402 | 74 | } | 403 | 13.2k | auto& data = *agg_method.hash_table; | 404 | 13.2k | data.for_each_mapped([&](auto& mapped) { | 405 | 13.2k | if (mapped) { | 406 | 13.2k | _destroy_agg_status(mapped); | 407 | 13.2k | mapped = nullptr; | 408 | 13.2k | } | 409 | 13.2k | }); | 410 | 13.2k | if (data.has_null_key_data()) { | 411 | 0 | _destroy_agg_status(data.template get_null_key_data< | 412 | 0 | vectorized::AggregateDataPtr>()); | 413 | 0 | } | 414 | 13.2k | }}, |
|
415 | 64.8k | agg_data->method_variant); |
416 | 64.8k | } |
417 | | |
418 | 69.0k | void _close_without_key() { |
419 | | //because prepare maybe failed, and couldn't create agg data. |
420 | | //but finally call close to destory agg data, if agg data has bitmapValue |
421 | | //will be core dump, it's not initialized |
422 | 69.2k | if (agg_data_created_without_key) { |
423 | 69.2k | _destroy_agg_status(agg_data->without_key); |
424 | 69.2k | agg_data_created_without_key = false; |
425 | 69.2k | } |
426 | 69.0k | } |
427 | | void _destroy_agg_status(vectorized::AggregateDataPtr data); |
428 | | }; |
429 | | |
430 | | struct BasicSpillSharedState { |
431 | 3.01k | virtual ~BasicSpillSharedState() = default; |
432 | | |
433 | | // These two counters are shared to spill source operators as the initial value |
434 | | // of 'SpillWriteFileCurrentBytes' and 'SpillWriteFileCurrentCount'. |
435 | | // Total bytes of spill data written to disk file(after serialized) |
436 | | RuntimeProfile::Counter* _spill_write_file_total_size = nullptr; |
437 | | RuntimeProfile::Counter* _spill_file_total_count = nullptr; |
438 | | |
439 | 2.97k | void setup_shared_profile(RuntimeProfile* sink_profile) { |
440 | 2.97k | _spill_file_total_count = |
441 | 2.97k | ADD_COUNTER_WITH_LEVEL(sink_profile, "SpillWriteFileTotalCount", TUnit::UNIT, 1); |
442 | 2.97k | _spill_write_file_total_size = |
443 | 2.97k | ADD_COUNTER_WITH_LEVEL(sink_profile, "SpillWriteFileBytes", TUnit::BYTES, 1); |
444 | 2.97k | } |
445 | | |
446 | | virtual void update_spill_stream_profiles(RuntimeProfile* source_profile) = 0; |
447 | | }; |
448 | | |
449 | | struct AggSpillPartition; |
450 | | struct PartitionedAggSharedState : public BasicSharedState, |
451 | | public BasicSpillSharedState, |
452 | | public std::enable_shared_from_this<PartitionedAggSharedState> { |
453 | | ENABLE_FACTORY_CREATOR(PartitionedAggSharedState) |
454 | | |
455 | 22 | PartitionedAggSharedState() = default; |
456 | 22 | ~PartitionedAggSharedState() override = default; |
457 | | |
458 | | void update_spill_stream_profiles(RuntimeProfile* source_profile) override; |
459 | | |
460 | | void init_spill_params(size_t spill_partition_count); |
461 | | |
462 | | void close(); |
463 | | |
464 | | AggSharedState* in_mem_shared_state = nullptr; |
465 | | std::shared_ptr<BasicSharedState> in_mem_shared_state_sptr; |
466 | | |
467 | | size_t partition_count; |
468 | | size_t max_partition_index; |
469 | | bool is_spilled = false; |
470 | | std::atomic_bool is_closed = false; |
471 | | std::deque<std::shared_ptr<AggSpillPartition>> spill_partitions; |
472 | | |
473 | 1.04M | size_t get_partition_index(size_t hash_value) const { return hash_value % partition_count; } |
474 | | }; |
475 | | |
476 | | struct AggSpillPartition { |
477 | | static constexpr int64_t AGG_SPILL_FILE_SIZE = 1024 * 1024 * 1024; // 1G |
478 | | |
479 | 669 | AggSpillPartition() = default; |
480 | | |
481 | | void close(); |
482 | | |
483 | | Status get_spill_stream(RuntimeState* state, int node_id, RuntimeProfile* profile, |
484 | | vectorized::SpillStreamSPtr& spilling_stream); |
485 | | |
486 | 64 | Status flush_if_full() { |
487 | 64 | DCHECK(spilling_stream_); |
488 | 64 | Status status; |
489 | | // avoid small spill files |
490 | 64 | if (spilling_stream_->get_written_bytes() >= AGG_SPILL_FILE_SIZE) { |
491 | 0 | status = spilling_stream_->spill_eof(); |
492 | 0 | spilling_stream_.reset(); |
493 | 0 | } |
494 | 64 | return status; |
495 | 64 | } |
496 | | |
497 | 352 | Status finish_current_spilling(bool eos = false) { |
498 | 352 | if (spilling_stream_) { |
499 | 100 | if (eos || spilling_stream_->get_written_bytes() >= AGG_SPILL_FILE_SIZE) { |
500 | 48 | auto status = spilling_stream_->spill_eof(); |
501 | 48 | spilling_stream_.reset(); |
502 | 48 | return status; |
503 | 48 | } |
504 | 100 | } |
505 | 304 | return Status::OK(); |
506 | 352 | } |
507 | | |
508 | | std::deque<vectorized::SpillStreamSPtr> spill_streams_; |
509 | | vectorized::SpillStreamSPtr spilling_stream_; |
510 | | }; |
511 | | using AggSpillPartitionSPtr = std::shared_ptr<AggSpillPartition>; |
512 | | struct SortSharedState : public BasicSharedState { |
513 | | ENABLE_FACTORY_CREATOR(SortSharedState) |
514 | | public: |
515 | | std::shared_ptr<vectorized::Sorter> sorter; |
516 | | }; |
517 | | |
518 | | struct SpillSortSharedState : public BasicSharedState, |
519 | | public BasicSpillSharedState, |
520 | | public std::enable_shared_from_this<SpillSortSharedState> { |
521 | | ENABLE_FACTORY_CREATOR(SpillSortSharedState) |
522 | | |
523 | 21 | SpillSortSharedState() = default; |
524 | 21 | ~SpillSortSharedState() override = default; |
525 | | |
526 | 427 | void update_spill_block_batch_row_count(RuntimeState* state, const vectorized::Block* block) { |
527 | 427 | auto rows = block->rows(); |
528 | 427 | if (rows > 0 && 0 == avg_row_bytes) { |
529 | 12 | avg_row_bytes = std::max((std::size_t)1, block->bytes() / rows); |
530 | 12 | spill_block_batch_row_count = |
531 | 12 | (state->spill_sort_batch_bytes() + avg_row_bytes - 1) / avg_row_bytes; |
532 | 12 | LOG(INFO) << "spill sort block batch row count: " << spill_block_batch_row_count; |
533 | 12 | } |
534 | 427 | } |
535 | | |
536 | | void update_spill_stream_profiles(RuntimeProfile* source_profile) override; |
537 | | |
538 | | void close(); |
539 | | |
540 | | SortSharedState* in_mem_shared_state = nullptr; |
541 | | bool enable_spill = false; |
542 | | bool is_spilled = false; |
543 | | int64_t limit = -1; |
544 | | int64_t offset = 0; |
545 | | std::atomic_bool is_closed = false; |
546 | | std::shared_ptr<BasicSharedState> in_mem_shared_state_sptr; |
547 | | |
548 | | std::deque<vectorized::SpillStreamSPtr> sorted_streams; |
549 | | size_t avg_row_bytes = 0; |
550 | | size_t spill_block_batch_row_count; |
551 | | }; |
552 | | |
553 | | struct UnionSharedState : public BasicSharedState { |
554 | | ENABLE_FACTORY_CREATOR(UnionSharedState) |
555 | | |
556 | | public: |
557 | 3.82k | UnionSharedState(int child_count = 1) : data_queue(child_count), _child_count(child_count) {}; |
558 | 0 | int child_count() const { return _child_count; } |
559 | | DataQueue data_queue; |
560 | | const int _child_count; |
561 | | }; |
562 | | |
563 | | struct DataQueueSharedState : public BasicSharedState { |
564 | | ENABLE_FACTORY_CREATOR(DataQueueSharedState) |
565 | | public: |
566 | | DataQueue data_queue; |
567 | | }; |
568 | | |
569 | | class MultiCastDataStreamer; |
570 | | |
571 | | struct MultiCastSharedState : public BasicSharedState, |
572 | | public BasicSpillSharedState, |
573 | | public std::enable_shared_from_this<MultiCastSharedState> { |
574 | | MultiCastSharedState(ObjectPool* pool, int cast_sender_count, int node_id); |
575 | | std::unique_ptr<pipeline::MultiCastDataStreamer> multi_cast_data_streamer; |
576 | | |
577 | | void update_spill_stream_profiles(RuntimeProfile* source_profile) override; |
578 | | }; |
579 | | |
580 | | struct AnalyticSharedState : public BasicSharedState { |
581 | | ENABLE_FACTORY_CREATOR(AnalyticSharedState) |
582 | | |
583 | | public: |
584 | 8.76k | AnalyticSharedState() = default; |
585 | | std::queue<vectorized::Block> blocks_buffer; |
586 | | std::mutex buffer_mutex; |
587 | | bool sink_eos = false; |
588 | | std::mutex sink_eos_lock; |
589 | | vectorized::Arena agg_arena_pool; |
590 | | }; |
591 | | |
592 | | struct JoinSharedState : public BasicSharedState { |
593 | | // For some join case, we can apply a short circuit strategy |
594 | | // 1. _has_null_in_build_side = true |
595 | | // 2. build side rows is empty, Join op is: inner join/right outer join/left semi/right semi/right anti |
596 | | bool _has_null_in_build_side = false; |
597 | | bool short_circuit_for_probe = false; |
598 | | // for some join, when build side rows is empty, we could return directly by add some additional null data in probe table. |
599 | | bool empty_right_table_need_probe_dispose = false; |
600 | | JoinOpVariants join_op_variants; |
601 | | }; |
602 | | |
603 | | struct HashJoinSharedState : public JoinSharedState { |
604 | | ENABLE_FACTORY_CREATOR(HashJoinSharedState) |
605 | 174k | HashJoinSharedState() { |
606 | 174k | hash_table_variant_vector.push_back(std::make_shared<JoinDataVariants>()); |
607 | 174k | } |
608 | 2.06k | HashJoinSharedState(int num_instances) { |
609 | 2.06k | source_deps.resize(num_instances, nullptr); |
610 | 2.06k | hash_table_variant_vector.resize(num_instances, nullptr); |
611 | 12.8k | for (int i = 0; i < num_instances; i++) { |
612 | 10.7k | hash_table_variant_vector[i] = std::make_shared<JoinDataVariants>(); |
613 | 10.7k | } |
614 | 2.06k | } |
615 | | std::shared_ptr<vectorized::Arena> arena = std::make_shared<vectorized::Arena>(); |
616 | | |
617 | | const std::vector<TupleDescriptor*> build_side_child_desc; |
618 | | size_t build_exprs_size = 0; |
619 | | std::shared_ptr<vectorized::Block> build_block; |
620 | | std::shared_ptr<std::vector<uint32_t>> build_indexes_null; |
621 | | |
622 | | // Used by shared hash table |
623 | | // For probe operator, hash table in _hash_table_variants is read-only if visited flags is not |
624 | | // used. (visited flags will be used only in right / full outer join). |
625 | | // |
626 | | // For broadcast join, although hash table is read-only, some states in `_hash_table_variants` |
627 | | // are still could be written. For example, serialized keys will be written in a continuous |
628 | | // memory in `_hash_table_variants`. So before execution, we should use a local _hash_table_variants |
629 | | // which has a shared hash table in it. |
630 | | std::vector<std::shared_ptr<JoinDataVariants>> hash_table_variant_vector; |
631 | | |
632 | | // whether left semi join could directly return |
633 | | // if runtime filters contains local in filter, we can make sure all input rows are matched |
634 | | // local filter will always be applied, and in filter could guarantee precise filtering |
635 | | // ATTN: we should disable always_true logic for in filter when we set this flag |
636 | | bool left_semi_direct_return = false; |
637 | | }; |
638 | | |
639 | | struct PartitionedHashJoinSharedState |
640 | | : public HashJoinSharedState, |
641 | | public BasicSpillSharedState, |
642 | | public std::enable_shared_from_this<PartitionedHashJoinSharedState> { |
643 | | ENABLE_FACTORY_CREATOR(PartitionedHashJoinSharedState) |
644 | | |
645 | 0 | void update_spill_stream_profiles(RuntimeProfile* source_profile) override { |
646 | 0 | for (auto& stream : spilled_streams) { |
647 | 0 | if (stream) { |
648 | 0 | stream->update_shared_profiles(source_profile); |
649 | 0 | } |
650 | 0 | } |
651 | 0 | } |
652 | | |
653 | | std::unique_ptr<RuntimeState> inner_runtime_state; |
654 | | std::shared_ptr<HashJoinSharedState> inner_shared_state; |
655 | | std::vector<std::unique_ptr<vectorized::MutableBlock>> partitioned_build_blocks; |
656 | | std::vector<vectorized::SpillStreamSPtr> spilled_streams; |
657 | | bool is_spilled = false; |
658 | | }; |
659 | | |
660 | | struct NestedLoopJoinSharedState : public JoinSharedState { |
661 | | ENABLE_FACTORY_CREATOR(NestedLoopJoinSharedState) |
662 | | // if true, probe child has no more rows to process |
663 | | bool probe_side_eos = false; |
664 | | // Visited flags for each row in build side. |
665 | | vectorized::MutableColumns build_side_visited_flags; |
666 | | // List of build blocks, constructed in prepare() |
667 | | vectorized::Blocks build_blocks; |
668 | | }; |
669 | | |
670 | | struct PartitionSortNodeSharedState : public BasicSharedState { |
671 | | ENABLE_FACTORY_CREATOR(PartitionSortNodeSharedState) |
672 | | public: |
673 | | std::queue<vectorized::Block> blocks_buffer; |
674 | | std::mutex buffer_mutex; |
675 | | std::vector<std::unique_ptr<vectorized::PartitionSorter>> partition_sorts; |
676 | | bool sink_eos = false; |
677 | | std::mutex sink_eos_lock; |
678 | | std::mutex prepared_finish_lock; |
679 | | }; |
680 | | |
681 | | struct SetSharedState : public BasicSharedState { |
682 | | ENABLE_FACTORY_CREATOR(SetSharedState) |
683 | | public: |
684 | | /// default init |
685 | | vectorized::Block build_block; // build to source |
686 | | //record element size in hashtable |
687 | | int64_t valid_element_in_hash_tbl = 0; |
688 | | //first: idx mapped to column types |
689 | | //second: column_id, could point to origin column or cast column |
690 | | std::unordered_map<int, int> build_col_idx; |
691 | | |
692 | | //// shared static states (shared, decided in prepare/open...) |
693 | | |
694 | | /// init in setup_local_state |
695 | | std::unique_ptr<SetDataVariants> hash_table_variants = |
696 | | std::make_unique<SetDataVariants>(); // the real data HERE. |
697 | | std::vector<bool> build_not_ignore_null; |
698 | | |
699 | | // The SET operator's child might have different nullable attributes. |
700 | | // If a calculation involves both nullable and non-nullable columns, the final output should be a nullable column |
701 | | Status update_build_not_ignore_null(const vectorized::VExprContextSPtrs& ctxs); |
702 | | |
703 | | size_t get_hash_table_size() const; |
704 | | /// init in both upstream side. |
705 | | //The i-th result expr list refers to the i-th child. |
706 | | std::vector<vectorized::VExprContextSPtrs> child_exprs_lists; |
707 | | |
708 | | /// init in build side |
709 | | size_t child_quantity; |
710 | | vectorized::VExprContextSPtrs build_child_exprs; |
711 | | std::vector<Dependency*> probe_finished_children_dependency; |
712 | | |
713 | | /// init in probe side |
714 | | std::vector<vectorized::VExprContextSPtrs> probe_child_exprs_lists; |
715 | | |
716 | | std::atomic<bool> ready_for_read = false; |
717 | | |
718 | | vectorized::Arena arena; |
719 | | |
720 | | /// called in setup_local_state |
721 | | Status hash_table_init(); |
722 | | }; |
723 | | |
724 | | enum class ExchangeType : uint8_t { |
725 | | NOOP = 0, |
726 | | // Shuffle data by Crc32CHashPartitioner |
727 | | HASH_SHUFFLE = 1, |
728 | | // Round-robin passthrough data blocks. |
729 | | PASSTHROUGH = 2, |
730 | | // Shuffle data by Crc32HashPartitioner<ShuffleChannelIds> (e.g. same as storage engine). |
731 | | BUCKET_HASH_SHUFFLE = 3, |
732 | | // Passthrough data blocks to all channels. |
733 | | BROADCAST = 4, |
734 | | // Passthrough data to channels evenly in an adaptive way. |
735 | | ADAPTIVE_PASSTHROUGH = 5, |
736 | | // Send all data to the first channel. |
737 | | PASS_TO_ONE = 6, |
738 | | }; |
739 | | |
740 | 228k | inline std::string get_exchange_type_name(ExchangeType idx) { |
741 | 228k | switch (idx) { |
742 | 14 | case ExchangeType::NOOP: |
743 | 14 | return "NOOP"; |
744 | 46.2k | case ExchangeType::HASH_SHUFFLE: |
745 | 46.2k | return "HASH_SHUFFLE"; |
746 | 175k | case ExchangeType::PASSTHROUGH: |
747 | 175k | return "PASSTHROUGH"; |
748 | 998 | case ExchangeType::BUCKET_HASH_SHUFFLE: |
749 | 998 | return "BUCKET_HASH_SHUFFLE"; |
750 | 854 | case ExchangeType::BROADCAST: |
751 | 854 | return "BROADCAST"; |
752 | 1.70k | case ExchangeType::ADAPTIVE_PASSTHROUGH: |
753 | 1.70k | return "ADAPTIVE_PASSTHROUGH"; |
754 | 3.83k | case ExchangeType::PASS_TO_ONE: |
755 | 3.83k | return "PASS_TO_ONE"; |
756 | 228k | } |
757 | 0 | throw Exception(Status::FatalError("__builtin_unreachable")); |
758 | 228k | } |
759 | | |
760 | | struct DataDistribution { |
761 | 2.08M | DataDistribution(ExchangeType type) : distribution_type(type) {} |
762 | | DataDistribution(ExchangeType type, const std::vector<TExpr>& partition_exprs_) |
763 | 254k | : distribution_type(type), partition_exprs(partition_exprs_) {} |
764 | 238k | DataDistribution(const DataDistribution& other) = default; |
765 | 673k | bool need_local_exchange() const { return distribution_type != ExchangeType::NOOP; } |
766 | 612k | DataDistribution& operator=(const DataDistribution& other) = default; |
767 | | ExchangeType distribution_type; |
768 | | std::vector<TExpr> partition_exprs; |
769 | | }; |
770 | | |
771 | | class ExchangerBase; |
772 | | |
773 | | struct LocalExchangeSharedState : public BasicSharedState { |
774 | | public: |
775 | | ENABLE_FACTORY_CREATOR(LocalExchangeSharedState); |
776 | | LocalExchangeSharedState(int num_instances); |
777 | | ~LocalExchangeSharedState() override; |
778 | | std::unique_ptr<ExchangerBase> exchanger {}; |
779 | | std::vector<RuntimeProfile::Counter*> mem_counters; |
780 | | std::atomic<int64_t> mem_usage = 0; |
781 | | std::atomic<size_t> _buffer_mem_limit = config::local_exchange_buffer_mem_limit; |
782 | | // We need to make sure to add mem_usage first and then enqueue, otherwise sub mem_usage may cause negative mem_usage during concurrent dequeue. |
783 | | std::mutex le_lock; |
784 | | void sub_running_sink_operators(); |
785 | | void sub_running_source_operators(); |
786 | 228k | void _set_always_ready() { |
787 | 1.41M | for (auto& dep : source_deps) { |
788 | 1.41M | DCHECK(dep); |
789 | 1.41M | dep->set_always_ready(); |
790 | 1.41M | } |
791 | 229k | for (auto& dep : sink_deps) { |
792 | 229k | DCHECK(dep); |
793 | 229k | dep->set_always_ready(); |
794 | 229k | } |
795 | 228k | } |
796 | | |
797 | 329k | Dependency* get_sink_dep_by_channel_id(int channel_id) { return nullptr; } |
798 | | |
799 | 230k | void set_ready_to_read(int channel_id) { |
800 | 230k | auto& dep = source_deps[channel_id]; |
801 | 18.4E | DCHECK(dep) << channel_id; |
802 | 230k | dep->set_ready(); |
803 | 230k | } |
804 | | |
805 | 230k | void add_mem_usage(int channel_id, size_t delta) { mem_counters[channel_id]->update(delta); } |
806 | | |
807 | 230k | void sub_mem_usage(int channel_id, size_t delta) { |
808 | 230k | mem_counters[channel_id]->update(-(int64_t)delta); |
809 | 230k | } |
810 | | |
811 | 183k | void add_total_mem_usage(size_t delta) { |
812 | 183k | if (cast_set<int64_t>(mem_usage.fetch_add(delta) + delta) > _buffer_mem_limit) { |
813 | 19 | sink_deps.front()->block(); |
814 | 19 | } |
815 | 183k | } |
816 | | |
817 | 183k | void sub_total_mem_usage(size_t delta) { |
818 | 183k | auto prev_usage = mem_usage.fetch_sub(delta); |
819 | 183k | DCHECK_GE(prev_usage - delta, 0) << "prev_usage: " << prev_usage << " delta: " << delta; |
820 | 183k | if (cast_set<int64_t>(prev_usage - delta) <= _buffer_mem_limit) { |
821 | 183k | sink_deps.front()->set_ready(); |
822 | 183k | } |
823 | 183k | } |
824 | | |
825 | 136 | void set_low_memory_mode(RuntimeState* state) { |
826 | 136 | _buffer_mem_limit = std::min<int64_t>(config::local_exchange_buffer_mem_limit, |
827 | 136 | state->low_memory_mode_buffer_limit()); |
828 | 136 | } |
829 | | }; |
830 | | |
831 | | #include "common/compile_check_end.h" |
832 | | } // namespace doris::pipeline |