MCPcopy Create free account
hub / github.com/apache/cloudberry / MultiExecParallelHash

Function MultiExecParallelHash

src/backend/executor/nodeHash.c:266–448  ·  view source on GitHub ↗

---------------------------------------------------------------- * MultiExecParallelHash * * parallel-aware version, building a shared hash table and * (if necessary) batch files using the combined effort of * a set of co-operating backends. * ---------------------------------------------------------------- */

Source from the content-addressed store, hash-verified

264 * ----------------------------------------------------------------
265 */
266static void
267MultiExecParallelHash(HashState *node)
268{
269 ParallelHashJoinState *pstate;
270 PlanState *outerNode;
271 List *hashkeys;
272 HashJoinTable hashtable;
273 TupleTableSlot *slot;
274 ExprContext *econtext;
275 uint32 hashvalue;
276 Barrier *build_barrier;
277 int i;
278
279 /*
280 * get state info from node
281 */
282 outerNode = outerPlanState(node);
283 hashtable = node->hashtable;
284
285 /*
286 * set expression context
287 */
288 hashkeys = node->hashkeys;
289 econtext = node->ps.ps_ExprContext;
290
291 /*
292 * Synchronize the parallel hash table build. At this stage we know that
293 * the shared hash table has been or is being set up by
294 * ExecHashTableCreate(), but we don't know if our peers have returned
295 * from there or are here in MultiExecParallelHash(), and if so how far
296 * through they are. To find out, we check the build_barrier phase then
297 * and jump to the right step in the build algorithm.
298 */
299 pstate = hashtable->parallel_state;
300 build_barrier = &pstate->build_barrier;
301 Assert(BarrierPhase(build_barrier) >= PHJ_BUILD_ALLOCATING);
302 switch (BarrierPhase(build_barrier))
303 {
304 case PHJ_BUILD_ALLOCATING:
305
306 /*
307 * Either I just allocated the initial hash table in
308 * ExecHashTableCreate(), or someone else is doing that. Either
309 * way, wait for everyone to arrive here so we can proceed.
310 */
311 BarrierArriveAndWait(build_barrier, WAIT_EVENT_HASH_BUILD_ALLOCATE);
312 /* Fall through. */
313
314 case PHJ_BUILD_HASHING_INNER:
315
316 /*
317 * It's time to begin hashing, or if we just arrived here then
318 * hashing is already underway, so join in that effort. While
319 * hashing we have to be prepared to help increase the number of
320 * batches or buckets at any time, and if we arrived here when
321 * that was already underway we'll have to help complete that work
322 * immediately so that it's safe to access batches and buckets
323 * below.

Callers 1

MultiExecHashFunction · 0.85

Calls 15

BarrierPhaseFunction · 0.85
BarrierArriveAndWaitFunction · 0.85
BarrierAttachFunction · 0.85
ExecSquelchNodeFunction · 0.85
ExecProcNodeFunction · 0.85
ExecHashGetHashValueFunction · 0.85
sts_end_writeFunction · 0.85

Tested by

no test coverage detected