MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / ConcurrentHashJoin

Method ConcurrentHashJoin

src/Interpreters/ConcurrentHashJoin.cpp:179–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177
178
179ConcurrentHashJoin::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
236ConcurrentHashJoin::~ConcurrentHashJoin()

Callers

nothing calls this directly

Calls 10

toPowerOfTwoFunction · 0.85
scheduleOrThrowMethod · 0.80
setMaxJoinedBlockRowsMethod · 0.80
maxJoinedBlockRowsMethod · 0.80
maxJoinedBlockBytesMethod · 0.80
formatFunction · 0.70
tryLogCurrentExceptionFunction · 0.50
resizeMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected