* Find or create a hashtable entry for the tuple group containing the * given tuple. The tuple must be the same type as the hashtable entries. * * If isnew is NULL, we do not create new entries; we return NULL if no * match is found. * * If hash is not NULL, we set it to the calculated hash value. This allows * callers access to the hash value even if no entry is returned. * * If isnew i
| 314 | * been zeroed. |
| 315 | */ |
| 316 | TupleHashEntry |
| 317 | LookupTupleHashEntry(TupleHashTable hashtable, TupleTableSlot *slot, |
| 318 | bool *isnew, uint32 *hash) |
| 319 | { |
| 320 | TupleHashEntry entry; |
| 321 | MemoryContext oldContext; |
| 322 | uint32 local_hash; |
| 323 | |
| 324 | /* Need to run the hash functions in short-lived context */ |
| 325 | oldContext = MemoryContextSwitchTo(hashtable->tempcxt); |
| 326 | |
| 327 | /* set up data needed by hash and match functions */ |
| 328 | hashtable->inputslot = slot; |
| 329 | hashtable->in_hash_funcs = hashtable->tab_hash_funcs; |
| 330 | hashtable->cur_eq_func = hashtable->tab_eq_func; |
| 331 | |
| 332 | local_hash = TupleHashTableHash_internal(hashtable->hashtab, NULL); |
| 333 | entry = LookupTupleHashEntry_internal(hashtable, slot, isnew, local_hash); |
| 334 | |
| 335 | if (hash != NULL) |
| 336 | *hash = local_hash; |
| 337 | |
| 338 | Assert(entry == NULL || entry->hash == local_hash); |
| 339 | |
| 340 | MemoryContextSwitchTo(oldContext); |
| 341 | |
| 342 | return entry; |
| 343 | } |
| 344 | |
| 345 | /* |
| 346 | * Compute the hash value for a tuple |
no test coverage detected