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

Function setop_fill_hash_table

src/backend/executor/nodeSetOp.c:338–419  ·  view source on GitHub ↗

* ExecSetOp for hashed case: phase 1, read input and build hash table */

Source from the content-addressed store, hash-verified

336 * ExecSetOp for hashed case: phase 1, read input and build hash table
337 */
338static void
339setop_fill_hash_table(SetOpState *setopstate)
340{
341 SetOp *node = (SetOp *) setopstate->ps.plan;
342 PlanState *outerPlan;
343 int firstFlag;
344 bool in_first_rel PG_USED_FOR_ASSERTS_ONLY;
345 ExprContext *econtext = setopstate->ps.ps_ExprContext;
346
347 /*
348 * get state info from node
349 */
350 outerPlan = outerPlanState(setopstate);
351 firstFlag = node->firstFlag;
352 /* verify planner didn't mess up */
353 Assert(firstFlag == 0 ||
354 (firstFlag == 1 &&
355 (node->cmd == SETOPCMD_INTERSECT ||
356 node->cmd == SETOPCMD_INTERSECT_ALL)));
357
358 /*
359 * Process each outer-plan tuple, and then fetch the next one, until we
360 * exhaust the outer plan.
361 */
362 in_first_rel = true;
363 for (;;)
364 {
365 TupleTableSlot *outerslot;
366 int flag;
367 TupleHashEntryData *entry;
368 bool isnew;
369
370 outerslot = ExecProcNode(outerPlan);
371 if (TupIsNull(outerslot))
372 break;
373
374 /* Identify whether it's left or right input */
375 flag = fetch_tuple_flag(setopstate, outerslot);
376
377 if (flag == firstFlag)
378 {
379 /* (still) in first input relation */
380 Assert(in_first_rel);
381
382 /* Find or build hashtable entry for this tuple's group */
383 entry = LookupTupleHashEntry(setopstate->hashtable, outerslot,
384 &isnew, NULL);
385
386 /* If new tuple group, initialize counts */
387 if (isnew)
388 {
389 entry->additional = (SetOpStatePerGroup)
390 MemoryContextAlloc(setopstate->hashtable->tablecxt,
391 sizeof(SetOpStatePerGroupData));
392 initialize_counts((SetOpStatePerGroup) entry->additional);
393 }
394
395 /* Advance the counts */

Callers 1

ExecSetOpFunction · 0.85

Calls 6

ExecProcNodeFunction · 0.85
fetch_tuple_flagFunction · 0.85
LookupTupleHashEntryFunction · 0.85
MemoryContextAllocFunction · 0.85
initialize_countsFunction · 0.85
advance_countsFunction · 0.85

Tested by

no test coverage detected