* 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
| 2085 | * hashkeys_null indicates all the hashkeys are null. |
| 2086 | */ |
| 2087 | bool |
| 2088 | ExecHashGetHashValue(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 |
no test coverage detected