| 177 | |
| 178 | |
| 179 | ConcurrentHashJoin::ConcurrentHashJoin( |
| 180 | std::shared_ptr<TableJoin> table_join_, |
| 181 | size_t slots_, |
| 182 | SharedHeader right_sample_block, |
| 183 | const StatsCollectingParams & stats_collecting_params_, |
| 184 | bool any_take_last_row_, |
| 185 | size_t external_join_threshold_) |
| 186 | : table_join(table_join_) |
| 187 | , slots(toPowerOfTwo(std::min<UInt32>(static_cast<UInt32>(slots_), 256))) |
| 188 | , any_take_last_row(any_take_last_row_) |
| 189 | , pool(std::make_unique<ThreadPool>( |
| 190 | CurrentMetrics::ConcurrentHashJoinPoolThreads, |
| 191 | CurrentMetrics::ConcurrentHashJoinPoolThreadsActive, |
| 192 | CurrentMetrics::ConcurrentHashJoinPoolThreadsScheduled, |
| 193 | /*max_threads_*/ slots, |
| 194 | /*max_free_threads_*/ 0, |
| 195 | /*queue_size_*/ slots)) |
| 196 | , stats_collecting_params(stats_collecting_params_) |
| 197 | , external_join_threshold(external_join_threshold_) |
| 198 | { |
| 199 | hash_joins.resize(slots); |
| 200 | |
| 201 | try |
| 202 | { |
| 203 | for (size_t i = 0; i < slots; ++i) |
| 204 | { |
| 205 | pool->scheduleOrThrow( |
| 206 | [&, i, thread_group = CurrentThread::getGroup()]() |
| 207 | { |
| 208 | ThreadGroupSwitcher switcher(thread_group, ThreadName::CONCURRENT_JOIN); |
| 209 | |
| 210 | /// reserve is not needed anyway - either we will use fixed-size hash map or shared two-level map (then reserve will be done in a special way below) |
| 211 | const size_t reserve_size = 0; |
| 212 | |
| 213 | auto inner_hash_join = std::make_shared<InternalHashJoin>(); |
| 214 | inner_hash_join->data = std::make_unique<HashJoin>( |
| 215 | table_join_, |
| 216 | right_sample_block, |
| 217 | any_take_last_row_, |
| 218 | reserve_size, |
| 219 | fmt::format("concurrent{}", i), |
| 220 | /*use_two_level_maps*/ true); |
| 221 | inner_hash_join->data->setMaxJoinedBlockRows(table_join->maxJoinedBlockRows()); |
| 222 | inner_hash_join->data->setMaxJoinedBlockBytes(table_join->maxJoinedBlockBytes()); |
| 223 | hash_joins[i] = std::move(inner_hash_join); |
| 224 | }); |
| 225 | } |
| 226 | pool->wait(); |
| 227 | } |
| 228 | catch (...) |
| 229 | { |
| 230 | tryLogCurrentException(__PRETTY_FUNCTION__); |
| 231 | pool->wait(); |
| 232 | throw; |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | ConcurrentHashJoin::~ConcurrentHashJoin() |
nothing calls this directly
no test coverage detected