Change signature of TupleHashTableHash().
Commit 4eaea3db introduced TupleHashTableHash(), but the signature didn't match the other exposed functions. Separate it into internal and external versions. The external version hides the details behind an API more consistent with the other external functions, and the internal version is still suitable for simplehash.
This commit is contained in:
parent
8fa8e01156
commit
11de6c903d
@ -26,6 +26,8 @@
|
|||||||
#include "utils/memutils.h"
|
#include "utils/memutils.h"
|
||||||
|
|
||||||
static int TupleHashTableMatch(struct tuplehash_hash *tb, const MinimalTuple tuple1, const MinimalTuple tuple2);
|
static int TupleHashTableMatch(struct tuplehash_hash *tb, const MinimalTuple tuple1, const MinimalTuple tuple2);
|
||||||
|
static uint32 TupleHashTableHash_internal(struct tuplehash_hash *tb,
|
||||||
|
const MinimalTuple tuple);
|
||||||
static TupleHashEntry LookupTupleHashEntry_internal(
|
static TupleHashEntry LookupTupleHashEntry_internal(
|
||||||
TupleHashTable hashtable, TupleTableSlot *slot, bool *isnew, uint32 hash);
|
TupleHashTable hashtable, TupleTableSlot *slot, bool *isnew, uint32 hash);
|
||||||
|
|
||||||
@ -38,7 +40,7 @@ static TupleHashEntry LookupTupleHashEntry_internal(
|
|||||||
#define SH_ELEMENT_TYPE TupleHashEntryData
|
#define SH_ELEMENT_TYPE TupleHashEntryData
|
||||||
#define SH_KEY_TYPE MinimalTuple
|
#define SH_KEY_TYPE MinimalTuple
|
||||||
#define SH_KEY firstTuple
|
#define SH_KEY firstTuple
|
||||||
#define SH_HASH_KEY(tb, key) TupleHashTableHash(tb, key)
|
#define SH_HASH_KEY(tb, key) TupleHashTableHash_internal(tb, key)
|
||||||
#define SH_EQUAL(tb, a, b) TupleHashTableMatch(tb, a, b) == 0
|
#define SH_EQUAL(tb, a, b) TupleHashTableMatch(tb, a, b) == 0
|
||||||
#define SH_SCOPE extern
|
#define SH_SCOPE extern
|
||||||
#define SH_STORE_HASH
|
#define SH_STORE_HASH
|
||||||
@ -313,7 +315,7 @@ LookupTupleHashEntry(TupleHashTable hashtable, TupleTableSlot *slot,
|
|||||||
hashtable->in_hash_funcs = hashtable->tab_hash_funcs;
|
hashtable->in_hash_funcs = hashtable->tab_hash_funcs;
|
||||||
hashtable->cur_eq_func = hashtable->tab_eq_func;
|
hashtable->cur_eq_func = hashtable->tab_eq_func;
|
||||||
|
|
||||||
hash = TupleHashTableHash(hashtable->hashtab, NULL);
|
hash = TupleHashTableHash_internal(hashtable->hashtab, NULL);
|
||||||
entry = LookupTupleHashEntry_internal(hashtable, slot, isnew, hash);
|
entry = LookupTupleHashEntry_internal(hashtable, slot, isnew, hash);
|
||||||
|
|
||||||
MemoryContextSwitchTo(oldContext);
|
MemoryContextSwitchTo(oldContext);
|
||||||
@ -321,6 +323,28 @@ LookupTupleHashEntry(TupleHashTable hashtable, TupleTableSlot *slot,
|
|||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compute the hash value for a tuple
|
||||||
|
*/
|
||||||
|
uint32
|
||||||
|
TupleHashTableHash(TupleHashTable hashtable, TupleTableSlot *slot)
|
||||||
|
{
|
||||||
|
MemoryContext oldContext;
|
||||||
|
uint32 hash;
|
||||||
|
|
||||||
|
hashtable->inputslot = slot;
|
||||||
|
hashtable->in_hash_funcs = hashtable->tab_hash_funcs;
|
||||||
|
|
||||||
|
/* Need to run the hash functions in short-lived context */
|
||||||
|
oldContext = MemoryContextSwitchTo(hashtable->tempcxt);
|
||||||
|
|
||||||
|
hash = TupleHashTableHash_internal(hashtable->hashtab, NULL);
|
||||||
|
|
||||||
|
MemoryContextSwitchTo(oldContext);
|
||||||
|
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A variant of LookupTupleHashEntry for callers that have already computed
|
* A variant of LookupTupleHashEntry for callers that have already computed
|
||||||
* the hash value.
|
* the hash value.
|
||||||
@ -382,8 +406,6 @@ FindTupleHashEntry(TupleHashTable hashtable, TupleTableSlot *slot,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Compute the hash value for a tuple
|
|
||||||
*
|
|
||||||
* If tuple is NULL, use the input slot instead. This convention avoids the
|
* If tuple is NULL, use the input slot instead. This convention avoids the
|
||||||
* need to materialize virtual input tuples unless they actually need to get
|
* need to materialize virtual input tuples unless they actually need to get
|
||||||
* copied into the table.
|
* copied into the table.
|
||||||
@ -391,8 +413,9 @@ FindTupleHashEntry(TupleHashTable hashtable, TupleTableSlot *slot,
|
|||||||
* Also, the caller must select an appropriate memory context for running
|
* Also, the caller must select an appropriate memory context for running
|
||||||
* the hash functions. (dynahash.c doesn't change CurrentMemoryContext.)
|
* the hash functions. (dynahash.c doesn't change CurrentMemoryContext.)
|
||||||
*/
|
*/
|
||||||
uint32
|
static uint32
|
||||||
TupleHashTableHash(struct tuplehash_hash *tb, const MinimalTuple tuple)
|
TupleHashTableHash_internal(struct tuplehash_hash *tb,
|
||||||
|
const MinimalTuple tuple)
|
||||||
{
|
{
|
||||||
TupleHashTable hashtable = (TupleHashTable) tb->private_data;
|
TupleHashTable hashtable = (TupleHashTable) tb->private_data;
|
||||||
int numCols = hashtable->numCols;
|
int numCols = hashtable->numCols;
|
||||||
|
@ -140,8 +140,8 @@ extern TupleHashTable BuildTupleHashTableExt(PlanState *parent,
|
|||||||
extern TupleHashEntry LookupTupleHashEntry(TupleHashTable hashtable,
|
extern TupleHashEntry LookupTupleHashEntry(TupleHashTable hashtable,
|
||||||
TupleTableSlot *slot,
|
TupleTableSlot *slot,
|
||||||
bool *isnew);
|
bool *isnew);
|
||||||
extern uint32 TupleHashTableHash(struct tuplehash_hash *tb,
|
extern uint32 TupleHashTableHash(TupleHashTable hashtable,
|
||||||
const MinimalTuple tuple);
|
TupleTableSlot *slot);
|
||||||
extern TupleHashEntry LookupTupleHashEntryHash(TupleHashTable hashtable,
|
extern TupleHashEntry LookupTupleHashEntryHash(TupleHashTable hashtable,
|
||||||
TupleTableSlot *slot,
|
TupleTableSlot *slot,
|
||||||
bool *isnew, uint32 hash);
|
bool *isnew, uint32 hash);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user