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

Function ExecHashGetHashValue

src/backend/executor/nodeHash.c:2087–2192  ·  view source on GitHub ↗

* ExecHashGetHashValue * Compute the hash value for a tuple * * The tuple to be tested must be in econtext->ecxt_outertuple (thus Vars in * the hashkeys expressions need to have OUTER_VAR as varno). If outer_tuple * is false (meaning it's the HashJoin's inner node, Hash), econtext, * hashkeys, and slot need to be from Hash, with hashkeys/slot referencing and * being suitable for tuples fro

Source from the content-addressed store, hash-verified

2085 * hashkeys_null indicates all the hashkeys are null.
2086 */
2087bool
2088ExecHashGetHashValue(HashState *hashState, HashJoinTable hashtable,
2089 ExprContext *econtext,
2090 List *hashkeys,
2091 bool outer_tuple,
2092 bool keep_nulls,
2093 uint32 *hashvalue,
2094 bool *hashkeys_null)
2095{
2096 uint32 hashkey = 0;
2097 FmgrInfo *hashfunctions;
2098 List *keyvalues = NIL;
2099 ListCell *hk;
2100 int i = 0;
2101 MemoryContext oldContext;
2102 bool result = true;
2103 bool build_runtime_filter;
2104
2105 Assert(hashkeys_null);
2106
2107 (*hashkeys_null) = true;
2108
2109 /*
2110 * We reset the eval context each time to reclaim any memory leaked in the
2111 * hashkey expressions.
2112 */
2113 ResetExprContext(econtext);
2114
2115 oldContext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
2116
2117 if (outer_tuple)
2118 hashfunctions = hashtable->outer_hashfunctions;
2119 else
2120 hashfunctions = hashtable->inner_hashfunctions;
2121
2122 build_runtime_filter = !outer_tuple && hashState->rfstate != NULL &&
2123 !hashState->rfstate->build_suspend;
2124
2125 foreach(hk, hashkeys)
2126 {
2127 ExprState *keyexpr = (ExprState *) lfirst(hk);
2128 Datum keyval;
2129 uint32 hkey = 0;
2130 bool isNull = false;
2131
2132 /* rotate hashkey left 1 bit at each step */
2133 hashkey = (hashkey << 1) | ((hashkey & 0x80000000) ? 1 : 0);
2134
2135 /*
2136 * Get the join attribute value of the tuple
2137 */
2138 keyval = ExecEvalExpr(keyexpr, econtext, &isNull);
2139
2140 if (!isNull)
2141 {
2142 *hashkeys_null = false;
2143 }
2144

Callers 5

MultiExecPrivateHashFunction · 0.85
MultiExecParallelHashFunction · 0.85

Calls 8

MemoryContextSwitchToFunction · 0.85
ExecEvalExprFunction · 0.85
DatumGetUInt32Function · 0.85
FunctionCall1CollFunction · 0.85
lappendFunction · 0.85
RFAddTupleValuesFunction · 0.85
foreachFunction · 0.50
pallocFunction · 0.50

Tested by

no test coverage detected