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

Function ExecHashJoinInitializeDSM

src/backend/executor/nodeHashjoin.c:2050–2113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2048}
2049
2050void
2051ExecHashJoinInitializeDSM(HashJoinState *state, ParallelContext *pcxt)
2052{
2053 int plan_node_id = state->js.ps.plan->plan_node_id;
2054 HashState *hashNode;
2055 ParallelHashJoinState *pstate;
2056 EState *estate = state->js.ps.state;
2057 /*
2058 * Disable shared hash table mode if we failed to create a real DSM
2059 * segment, because that means that we don't have a DSA area to work with.
2060 */
2061 if (pcxt->seg == NULL)
2062 return;
2063
2064 ExecSetExecProcNode(&state->js.ps, ExecParallelHashJoin);
2065
2066 /*
2067 * Set up the state needed to coordinate access to the shared hash
2068 * table(s), using the plan node ID as the toc key.
2069 */
2070 pstate = shm_toc_allocate(pcxt->toc, sizeof(ParallelHashJoinState));
2071 shm_toc_insert(pcxt->toc, plan_node_id, pstate);
2072
2073 /*
2074 * Set up the shared hash join state with no batches initially.
2075 * ExecHashTableCreate() will prepare at least one later and set nbatch
2076 * and space_allowed.
2077 */
2078 pstate->nbatch = 0;
2079 pstate->space_allowed = 0;
2080 pstate->batches = InvalidDsaPointer;
2081 pstate->old_batches = InvalidDsaPointer;
2082 pstate->nbuckets = 0;
2083 pstate->growth = PHJ_GROWTH_OK;
2084 pstate->chunk_work_queue = InvalidDsaPointer;
2085 pg_atomic_init_u32(&pstate->distributor, 0);
2086 if (estate->useMppParallelMode)
2087 pstate->nparticipants = pcxt->nworkers;
2088 else
2089 pstate->nparticipants = pcxt->nworkers + 1;
2090
2091 pstate->total_tuples = 0;
2092 LWLockInitialize(&pstate->lock,
2093 LWTRANCHE_PARALLEL_HASH_JOIN);
2094 BarrierInit(&pstate->build_barrier, 0);
2095 BarrierInit(&pstate->grow_batches_barrier, 0);
2096 BarrierInit(&pstate->grow_buckets_barrier, 0);
2097
2098 BarrierInit(&pstate->sync_barrier, pcxt->nworkers);
2099 BarrierInit(&pstate->batch0_barrier, pcxt->nworkers);
2100
2101 if (((HashJoin *)state->js.ps.plan)->outer_motionhazard)
2102 BarrierInit(&pstate->outer_motion_barrier, pcxt->nworkers);
2103
2104 pstate->phs_lasj_has_null = false;
2105
2106 /* Set up the space we'll use for shared temporary files. */
2107 SharedFileSetInit(&pstate->fileset, pcxt->seg);

Callers 2

Calls 7

ExecSetExecProcNodeFunction · 0.85
shm_toc_allocateFunction · 0.85
shm_toc_insertFunction · 0.85
pg_atomic_init_u32Function · 0.85
LWLockInitializeFunction · 0.85
BarrierInitFunction · 0.85
SharedFileSetInitFunction · 0.85

Tested by

no test coverage detected