Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit11de6c9

Browse files
committed
Change signature of TupleHashTableHash().
Commit4eaea3d introduced TupleHashTableHash(), but the signaturedidn't match the other exposed functions. Separate it into internaland external versions. The external version hides the details behindan API more consistent with the other external functions, and theinternal version is still suitable for simplehash.
1 parent8fa8e01 commit11de6c9

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

‎src/backend/executor/execGrouping.c

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#include"utils/memutils.h"
2727

2828
staticintTupleHashTableMatch(structtuplehash_hash*tb,constMinimalTupletuple1,constMinimalTupletuple2);
29+
staticuint32TupleHashTableHash_internal(structtuplehash_hash*tb,
30+
constMinimalTupletuple);
2931
staticTupleHashEntryLookupTupleHashEntry_internal(
3032
TupleHashTablehashtable,TupleTableSlot*slot,bool*isnew,uint32hash);
3133

@@ -38,7 +40,7 @@ static TupleHashEntry LookupTupleHashEntry_internal(
3840
#defineSH_ELEMENT_TYPE TupleHashEntryData
3941
#defineSH_KEY_TYPE MinimalTuple
4042
#defineSH_KEY firstTuple
41-
#defineSH_HASH_KEY(tb,key)TupleHashTableHash(tb, key)
43+
#defineSH_HASH_KEY(tb,key)TupleHashTableHash_internal(tb, key)
4244
#defineSH_EQUAL(tb,a,b) TupleHashTableMatch(tb, a, b) == 0
4345
#defineSH_SCOPE extern
4446
#defineSH_STORE_HASH
@@ -313,14 +315,36 @@ LookupTupleHashEntry(TupleHashTable hashtable, TupleTableSlot *slot,
313315
hashtable->in_hash_funcs=hashtable->tab_hash_funcs;
314316
hashtable->cur_eq_func=hashtable->tab_eq_func;
315317

316-
hash=TupleHashTableHash(hashtable->hashtab,NULL);
318+
hash=TupleHashTableHash_internal(hashtable->hashtab,NULL);
317319
entry=LookupTupleHashEntry_internal(hashtable,slot,isnew,hash);
318320

319321
MemoryContextSwitchTo(oldContext);
320322

321323
returnentry;
322324
}
323325

326+
/*
327+
* Compute the hash value for a tuple
328+
*/
329+
uint32
330+
TupleHashTableHash(TupleHashTablehashtable,TupleTableSlot*slot)
331+
{
332+
MemoryContextoldContext;
333+
uint32hash;
334+
335+
hashtable->inputslot=slot;
336+
hashtable->in_hash_funcs=hashtable->tab_hash_funcs;
337+
338+
/* Need to run the hash functions in short-lived context */
339+
oldContext=MemoryContextSwitchTo(hashtable->tempcxt);
340+
341+
hash=TupleHashTableHash_internal(hashtable->hashtab,NULL);
342+
343+
MemoryContextSwitchTo(oldContext);
344+
345+
returnhash;
346+
}
347+
324348
/*
325349
* A variant of LookupTupleHashEntry for callers that have already computed
326350
* the hash value.
@@ -382,17 +406,16 @@ FindTupleHashEntry(TupleHashTable hashtable, TupleTableSlot *slot,
382406
}
383407

384408
/*
385-
* Compute the hash value for a tuple
386-
*
387409
* If tuple is NULL, use the input slot instead. This convention avoids the
388410
* need to materialize virtual input tuples unless they actually need to get
389411
* copied into the table.
390412
*
391413
* Also, the caller must select an appropriate memory context for running
392414
* the hash functions. (dynahash.c doesn't change CurrentMemoryContext.)
393415
*/
394-
uint32
395-
TupleHashTableHash(structtuplehash_hash*tb,constMinimalTupletuple)
416+
staticuint32
417+
TupleHashTableHash_internal(structtuplehash_hash*tb,
418+
constMinimalTupletuple)
396419
{
397420
TupleHashTablehashtable= (TupleHashTable)tb->private_data;
398421
intnumCols=hashtable->numCols;

‎src/include/executor/executor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ extern TupleHashTable BuildTupleHashTableExt(PlanState *parent,
140140
externTupleHashEntryLookupTupleHashEntry(TupleHashTablehashtable,
141141
TupleTableSlot*slot,
142142
bool*isnew);
143-
externuint32TupleHashTableHash(structtuplehash_hash*tb,
144-
constMinimalTupletuple);
143+
externuint32TupleHashTableHash(TupleHashTablehashtable,
144+
TupleTableSlot*slot);
145145
externTupleHashEntryLookupTupleHashEntryHash(TupleHashTablehashtable,
146146
TupleTableSlot*slot,
147147
bool*isnew,uint32hash);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp