Coverage Report

Created: 2024-11-21 15:53

/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 "exprs/runtime_filter.h"
25
#include "pipeline/exec/multi_cast_data_streamer.h"
26
#include "pipeline/pipeline_fragment_context.h"
27
#include "pipeline/pipeline_task.h"
28
#include "runtime/exec_env.h"
29
#include "runtime/memory/mem_tracker.h"
30
#include "vec/exprs/vectorized_agg_fn.h"
31
#include "vec/exprs/vslot_ref.h"
32
#include "vec/spill/spill_stream_manager.h"
33
34
namespace doris::pipeline {
35
#include "common/compile_check_begin.h"
36
Dependency* BasicSharedState::create_source_dependency(int operator_id, int node_id,
37
0
                                                       const std::string& name) {
38
0
    source_deps.push_back(std::make_shared<Dependency>(operator_id, node_id, name + "_DEPENDENCY"));
39
0
    source_deps.back()->set_shared_state(this);
40
0
    return source_deps.back().get();
41
0
}
42
43
Dependency* BasicSharedState::create_sink_dependency(int dest_id, int node_id,
44
0
                                                     const std::string& name) {
45
0
    sink_deps.push_back(std::make_shared<Dependency>(dest_id, node_id, name + "_DEPENDENCY", true));
46
0
    sink_deps.back()->set_shared_state(this);
47
0
    return sink_deps.back().get();
48
0
}
49
50
0
void Dependency::_add_block_task(PipelineTask* task) {
51
0
    DCHECK(_blocked_task.empty() || _blocked_task[_blocked_task.size() - 1] != task)
52
0
            << "Duplicate task: " << task->debug_string();
53
0
    _blocked_task.push_back(task);
54
0
}
55
56
0
void Dependency::set_ready() {
57
0
    if (_ready) {
58
0
        return;
59
0
    }
60
0
    _watcher.stop();
61
0
    std::vector<PipelineTask*> local_block_task {};
62
0
    {
63
0
        std::unique_lock<std::mutex> lc(_task_lock);
64
0
        if (_ready) {
65
0
            return;
66
0
        }
67
0
        _ready = true;
68
0
        local_block_task.swap(_blocked_task);
69
0
    }
70
0
    for (auto* task : local_block_task) {
71
0
        task->wake_up();
72
0
    }
73
0
}
74
75
0
Dependency* Dependency::is_blocked_by(PipelineTask* task) {
76
0
    std::unique_lock<std::mutex> lc(_task_lock);
77
0
    auto ready = _ready.load();
78
0
    if (!ready && task) {
79
0
        _add_block_task(task);
80
0
    }
81
0
    return ready ? nullptr : this;
82
0
}
83
84
0
std::string Dependency::debug_string(int indentation_level) {
85
0
    fmt::memory_buffer debug_string_buffer;
86
0
    fmt::format_to(debug_string_buffer,
87
0
                   "{}this={}, {}: id={}, block task = {}, ready={}, _always_ready={}",
88
0
                   std::string(indentation_level * 2, ' '), (void*)this, _name, _node_id,
89
0
                   _blocked_task.size(), _ready, _always_ready);
90
0
    return fmt::to_string(debug_string_buffer);
91
0
}
92
93
0
std::string CountedFinishDependency::debug_string(int indentation_level) {
94
0
    fmt::memory_buffer debug_string_buffer;
95
0
    fmt::format_to(debug_string_buffer,
96
0
                   "{}{}: id={}, block_task={}, ready={}, _always_ready={}, count={}",
97
0
                   std::string(indentation_level * 2, ' '), _name, _node_id, _blocked_task.size(),
98
0
                   _ready, _always_ready, _counter);
99
0
    return fmt::to_string(debug_string_buffer);
100
0
}
101
102
0
std::string RuntimeFilterDependency::debug_string(int indentation_level) {
103
0
    fmt::memory_buffer debug_string_buffer;
104
0
    fmt::format_to(debug_string_buffer, "{}, runtime filter: {}",
105
0
                   Dependency::debug_string(indentation_level), _runtime_filter->formatted_state());
106
0
    return fmt::to_string(debug_string_buffer);
107
0
}
108
109
0
void RuntimeFilterTimer::call_timeout() {
110
0
    _parent->set_ready();
111
0
}
112
113
0
void RuntimeFilterTimer::call_ready() {
114
0
    _parent->set_ready();
115
0
}
116
117
// should check rf timeout in two case:
118
// 1. the rf is ready just remove the wait queue
119
// 2. if the rf have local dependency, the rf should start wait when all local dependency is ready
120
0
bool RuntimeFilterTimer::should_be_check_timeout() {
121
0
    if (!_parent->ready() && !_local_runtime_filter_dependencies.empty()) {
122
0
        bool all_ready = true;
123
0
        for (auto& dep : _local_runtime_filter_dependencies) {
124
0
            if (!dep->ready()) {
125
0
                all_ready = false;
126
0
                break;
127
0
            }
128
0
        }
129
0
        if (all_ready) {
130
0
            _local_runtime_filter_dependencies.clear();
131
0
            _registration_time = MonotonicMillis();
132
0
        }
133
0
        return all_ready;
134
0
    }
135
0
    return true;
136
0
}
137
138
0
void RuntimeFilterTimerQueue::start() {
139
0
    while (!_stop) {
140
0
        std::unique_lock<std::mutex> lk(cv_m);
141
142
0
        while (_que.empty() && !_stop) {
143
0
            cv.wait_for(lk, std::chrono::seconds(3), [this] { return !_que.empty() || _stop; });
144
0
        }
145
0
        if (_stop) {
146
0
            break;
147
0
        }
148
0
        {
149
0
            std::unique_lock<std::mutex> lc(_que_lock);
150
0
            std::list<std::shared_ptr<pipeline::RuntimeFilterTimer>> new_que;
151
0
            for (auto& it : _que) {
152
0
                if (it.use_count() == 1) {
153
                    // `use_count == 1` means this runtime filter has been released
154
0
                } else if (it->should_be_check_timeout()) {
155
0
                    if (it->_parent->is_blocked_by(nullptr)) {
156
                        // This means runtime filter is not ready, so we call timeout or continue to poll this timer.
157
0
                        int64_t ms_since_registration = MonotonicMillis() - it->registration_time();
158
0
                        if (ms_since_registration > it->wait_time_ms()) {
159
0
                            it->call_timeout();
160
0
                        } else {
161
0
                            new_que.push_back(std::move(it));
162
0
                        }
163
0
                    }
164
0
                } else {
165
0
                    new_que.push_back(std::move(it));
166
0
                }
167
0
            }
168
0
            new_que.swap(_que);
169
0
        }
170
0
        std::this_thread::sleep_for(std::chrono::milliseconds(interval));
171
0
    }
172
0
    _shutdown = true;
173
0
}
174
175
0
void LocalExchangeSharedState::sub_running_sink_operators() {
176
0
    std::unique_lock<std::mutex> lc(le_lock);
177
0
    if (exchanger->_running_sink_operators.fetch_sub(1) == 1) {
178
0
        _set_always_ready();
179
0
    }
180
0
}
181
182
void LocalExchangeSharedState::sub_running_source_operators(
183
0
        LocalExchangeSourceLocalState& local_state) {
184
0
    std::unique_lock<std::mutex> lc(le_lock);
185
0
    if (exchanger->_running_source_operators.fetch_sub(1) == 1) {
186
0
        _set_always_ready();
187
0
        exchanger->finalize(local_state);
188
0
    }
189
0
}
190
191
0
LocalExchangeSharedState::LocalExchangeSharedState(int num_instances) {
192
0
    source_deps.resize(num_instances, nullptr);
193
0
    mem_counters.resize(num_instances, nullptr);
194
0
}
195
196
0
vectorized::MutableColumns AggSharedState::_get_keys_hash_table() {
197
0
    return std::visit(
198
0
            vectorized::Overload {
199
0
                    [&](std::monostate& arg) {
200
0
                        throw doris::Exception(ErrorCode::INTERNAL_ERROR, "uninited hash table");
201
0
                        return vectorized::MutableColumns();
202
0
                    },
203
0
                    [&](auto&& agg_method) -> vectorized::MutableColumns {
204
0
                        vectorized::MutableColumns key_columns;
205
0
                        for (int i = 0; i < probe_expr_ctxs.size(); ++i) {
206
0
                            key_columns.emplace_back(
207
0
                                    probe_expr_ctxs[i]->root()->data_type()->create_column());
208
0
                        }
209
0
                        auto& data = *agg_method.hash_table;
210
0
                        bool has_null_key = data.has_null_key_data();
211
0
                        const auto size = data.size() - has_null_key;
212
0
                        using KeyType = std::decay_t<decltype(agg_method.iterator->get_first())>;
213
0
                        std::vector<KeyType> keys(size);
214
215
0
                        size_t num_rows = 0;
216
0
                        auto iter = aggregate_data_container->begin();
217
0
                        {
218
0
                            while (iter != aggregate_data_container->end()) {
219
0
                                keys[num_rows] = iter.get_key<KeyType>();
220
0
                                ++iter;
221
0
                                ++num_rows;
222
0
                            }
223
0
                        }
224
0
                        agg_method.insert_keys_into_columns(keys, key_columns, num_rows);
225
0
                        if (has_null_key) {
226
0
                            key_columns[0]->insert_data(nullptr, 0);
227
0
                        }
228
0
                        return key_columns;
229
0
                    }},
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized16MethodSerializedI9PHHashMapINS_9StringRefEPc11DefaultHashIS7_vEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIh9PHHashMapIhPc9HashCRC32IhEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIt9PHHashMapItPc9HashCRC32ItEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIj9PHHashMapIjPc9HashCRC32IjEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIm9PHHashMapImPc9HashCRC32ImEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized19MethodStringNoCacheINS_13StringHashMapIPc9AllocatorILb1ELb1ELb0E22DefaultMemoryAllocatorEEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISI_EESaISL_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISI_EESaISL_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodOneNumberIm9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISH_EESaISK_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIhNS4_15DataWithNullKeyI9PHHashMapIhPc9HashCRC32IhEEEEEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberItNS4_15DataWithNullKeyI9PHHashMapItPc9HashCRC32ItEEEEEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc9HashCRC32IjEEEEEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc9HashCRC32ImEEEEEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISJ_EESaISM_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIjNS4_15DataWithNullKeyI9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISL_EESaISO_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberImNS4_15DataWithNullKeyI9PHHashMapImPc14HashMixWrapperIm9HashCRC32ImEEEEEEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISL_EESaISO_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm128EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISM_EESaISP_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_15MethodOneNumberIN4wide7integerILm256EjEENS4_15DataWithNullKeyI9PHHashMapIS9_Pc9HashCRC32IS9_EEEEEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISM_EESaISP_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized26MethodSingleNullableColumnINS4_19MethodStringNoCacheINS4_15DataWithNullKeyINS_13StringHashMapIPc9AllocatorILb1ELb1ELb0E22DefaultMemoryAllocatorEEEEEEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISK_EESaISN_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapImPc9HashCRC32ImEEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISF_EESaISI_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm128EjEEPc9HashCRC32IS9_EEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISI_EESaISL_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapIN4wide7integerILm256EjEEPc9HashCRC32IS9_EEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISI_EESaISL_EEOT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState20_get_keys_hash_tableEvENK3$_1clIRNS_10vectorized15MethodKeysFixedI9PHHashMapINS4_7UInt136EPc9HashCRC32IS7_EEEEEESt6vectorIN3COWINS4_7IColumnEE11mutable_ptrISG_EESaISJ_EEOT_
230
0
            agg_data->method_variant);
231
0
}
232
233
0
void AggSharedState::build_limit_heap(size_t hash_table_size) {
234
0
    limit_columns = _get_keys_hash_table();
235
0
    for (size_t i = 0; i < hash_table_size; ++i) {
236
0
        limit_heap.emplace(i, limit_columns, order_directions, null_directions);
237
0
    }
238
0
    while (hash_table_size > limit) {
239
0
        limit_heap.pop();
240
0
        hash_table_size--;
241
0
    }
242
0
    limit_columns_min = limit_heap.top()._row_id;
243
0
}
244
245
bool AggSharedState::do_limit_filter(vectorized::Block* block, size_t num_rows,
246
0
                                     const std::vector<int>* key_locs) {
247
0
    if (num_rows) {
248
0
        cmp_res.resize(num_rows);
249
0
        need_computes.resize(num_rows);
250
0
        memset(need_computes.data(), 0, need_computes.size());
251
0
        memset(cmp_res.data(), 0, cmp_res.size());
252
253
0
        const auto key_size = null_directions.size();
254
0
        for (int i = 0; i < key_size; i++) {
255
0
            block->get_by_position(key_locs ? key_locs->operator[](i) : i)
256
0
                    .column->compare_internal(limit_columns_min, *limit_columns[i],
257
0
                                              null_directions[i], order_directions[i], cmp_res,
258
0
                                              need_computes.data());
259
0
        }
260
261
0
        auto set_computes_arr = [](auto* __restrict res, auto* __restrict computes, size_t rows) {
262
0
            for (size_t i = 0; i < rows; ++i) {
263
0
                computes[i] = computes[i] == res[i];
264
0
            }
265
0
        };
266
0
        set_computes_arr(cmp_res.data(), need_computes.data(), num_rows);
267
268
0
        return std::find(need_computes.begin(), need_computes.end(), 0) != need_computes.end();
269
0
    }
270
271
0
    return false;
272
0
}
273
274
0
Status AggSharedState::reset_hash_table() {
275
0
    return std::visit(
276
0
            vectorized::Overload {
277
0
                    [&](std::monostate& arg) -> Status {
278
0
                        return Status::InternalError("Uninited hash table");
279
0
                    },
280
0
                    [&](auto& agg_method) {
281
0
                        auto& hash_table = *agg_method.hash_table;
282
0
                        using HashTableType = std::decay_t<decltype(hash_table)>;
283
284
0
                        agg_method.reset();
285
286
0
                        hash_table.for_each_mapped([&](auto& mapped) {
287
0
                            if (mapped) {
288
0
                                static_cast<void>(_destroy_agg_status(mapped));
289
0
                                mapped = nullptr;
290
0
                            }
291
0
                        });
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_13StringHashMapIPc9AllocatorILb1ELb1ELb0E22DefaultMemoryAllocatorEEEEEEEDaRT_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_
Unexecuted instantiation: dependency.cpp:_ZZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEDaRT_ENKUlSF_E_clIS7_EEDaSF_
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_13StringHashMapIPc9AllocatorILb1ELb1ELb0E22DefaultMemoryAllocatorEEEEEEEEEEEDaRT_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_
292
293
0
                        if (hash_table.has_null_key_data()) {
294
0
                            auto st = _destroy_agg_status(hash_table.template get_null_key_data<
295
0
                                                          vectorized::AggregateDataPtr>());
296
0
                            RETURN_IF_ERROR(st);
297
0
                        }
298
299
0
                        aggregate_data_container.reset(new AggregateDataContainer(
300
0
                                sizeof(typename HashTableType::key_type),
301
0
                                ((total_size_of_aggregate_states + align_aggregate_states - 1) /
302
0
                                 align_aggregate_states) *
303
0
                                        align_aggregate_states));
304
0
                        agg_method.hash_table.reset(new HashTableType());
305
0
                        agg_arena_pool.reset(new vectorized::Arena);
306
0
                        return Status::OK();
307
0
                    }},
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_13StringHashMapIPc9AllocatorILb1ELb1ELb0E22DefaultMemoryAllocatorEEEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIN4wide7integerILm128EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIN4wide7integerILm256EjEE9PHHashMapIS8_Pc9HashCRC32IS8_EEEEEEDaRT_
Unexecuted instantiation: dependency.cpp:_ZZN5doris8pipeline14AggSharedState16reset_hash_tableEvENK3$_1clINS_10vectorized15MethodOneNumberIj9PHHashMapIjPc14HashMixWrapperIj9HashCRC32IjEEEEEEEDaRT_
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_13StringHashMapIPc9AllocatorILb1ELb1ELb0E22DefaultMemoryAllocatorEEEEEEEEEEEDaRT_
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_
308
0
            agg_data->method_variant);
309
0
}
310
311
0
void PartitionedAggSharedState::init_spill_params(size_t spill_partition_count_bits) {
312
0
    partition_count_bits = spill_partition_count_bits;
313
0
    partition_count = (1 << spill_partition_count_bits);
314
0
    max_partition_index = partition_count - 1;
315
316
0
    for (int i = 0; i < partition_count; ++i) {
317
0
        spill_partitions.emplace_back(std::make_shared<AggSpillPartition>());
318
0
    }
319
0
}
320
321
Status AggSpillPartition::get_spill_stream(RuntimeState* state, int node_id,
322
                                           RuntimeProfile* profile,
323
0
                                           vectorized::SpillStreamSPtr& spill_stream) {
324
0
    if (spilling_stream_) {
325
0
        spill_stream = spilling_stream_;
326
0
        return Status::OK();
327
0
    }
328
0
    RETURN_IF_ERROR(ExecEnv::GetInstance()->spill_stream_mgr()->register_spill_stream(
329
0
            state, spilling_stream_, print_id(state->query_id()), "agg", node_id,
330
0
            std::numeric_limits<int32_t>::max(), std::numeric_limits<size_t>::max(), profile));
331
0
    spill_streams_.emplace_back(spilling_stream_);
332
0
    spill_stream = spilling_stream_;
333
0
    return Status::OK();
334
0
}
335
0
void AggSpillPartition::close() {
336
0
    if (spilling_stream_) {
337
0
        spilling_stream_.reset();
338
0
    }
339
0
    for (auto& stream : spill_streams_) {
340
0
        (void)ExecEnv::GetInstance()->spill_stream_mgr()->delete_spill_stream(stream);
341
0
    }
342
0
    spill_streams_.clear();
343
0
}
344
345
0
void PartitionedAggSharedState::close() {
346
    // need to use CAS instead of only `if (!is_closed)` statement,
347
    // to avoid concurrent entry of close() both pass the if statement
348
0
    bool false_close = false;
349
0
    if (!is_closed.compare_exchange_strong(false_close, true)) {
350
0
        return;
351
0
    }
352
0
    DCHECK(!false_close && is_closed);
353
0
    for (auto partition : spill_partitions) {
354
0
        partition->close();
355
0
    }
356
0
    spill_partitions.clear();
357
0
}
358
359
0
void SpillSortSharedState::close() {
360
    // need to use CAS instead of only `if (!is_closed)` statement,
361
    // to avoid concurrent entry of close() both pass the if statement
362
0
    bool false_close = false;
363
0
    if (!is_closed.compare_exchange_strong(false_close, true)) {
364
0
        return;
365
0
    }
366
0
    DCHECK(!false_close && is_closed);
367
0
    for (auto& stream : sorted_streams) {
368
0
        (void)ExecEnv::GetInstance()->spill_stream_mgr()->delete_spill_stream(stream);
369
0
    }
370
0
    sorted_streams.clear();
371
0
}
372
373
MultiCastSharedState::MultiCastSharedState(const RowDescriptor& row_desc, ObjectPool* pool,
374
                                           int cast_sender_count)
375
        : multi_cast_data_streamer(std::make_unique<pipeline::MultiCastDataStreamer>(
376
0
                  row_desc, pool, cast_sender_count, true)) {}
377
378
0
int AggSharedState::get_slot_column_id(const vectorized::AggFnEvaluator* evaluator) {
379
0
    auto ctxs = evaluator->input_exprs_ctxs();
380
0
    CHECK(ctxs.size() == 1 && ctxs[0]->root()->is_slot_ref())
381
0
            << "input_exprs_ctxs is invalid, input_exprs_ctx[0]="
382
0
            << ctxs[0]->root()->debug_string();
383
0
    return ((vectorized::VSlotRef*)ctxs[0]->root().get())->column_id();
384
0
}
385
386
0
Status AggSharedState::_destroy_agg_status(vectorized::AggregateDataPtr data) {
387
0
    for (int i = 0; i < aggregate_evaluators.size(); ++i) {
388
0
        aggregate_evaluators[i]->function()->destroy(data + offsets_of_aggregate_states[i]);
389
0
    }
390
0
    return Status::OK();
391
0
}
392
393
0
LocalExchangeSharedState::~LocalExchangeSharedState() = default;
394
395
0
Status SetSharedState::update_build_not_ignore_null(const vectorized::VExprContextSPtrs& ctxs) {
396
0
    if (ctxs.size() > build_not_ignore_null.size()) {
397
0
        return Status::InternalError("build_not_ignore_null not initialized");
398
0
    }
399
400
0
    for (int i = 0; i < ctxs.size(); ++i) {
401
0
        build_not_ignore_null[i] = build_not_ignore_null[i] || ctxs[i]->root()->is_nullable();
402
0
    }
403
404
0
    return Status::OK();
405
0
}
406
407
0
Status SetSharedState::hash_table_init() {
408
0
    std::vector<vectorized::DataTypePtr> data_types;
409
0
    for (size_t i = 0; i != child_exprs_lists[0].size(); ++i) {
410
0
        auto& ctx = child_exprs_lists[0][i];
411
0
        auto data_type = ctx->root()->data_type();
412
0
        if (build_not_ignore_null[i]) {
413
0
            data_type = vectorized::make_nullable(data_type);
414
0
        }
415
0
        data_types.emplace_back(std::move(data_type));
416
0
    }
417
0
    return init_hash_method<SetDataVariants>(hash_table_variants.get(), data_types, true);
418
0
}
419
420
} // namespace doris::pipeline