Skip to content

Commit 07b95c3

Browse files
committed
Move bitmap_hash and bitmap_match to bitmapset.c.
The closely-related function bms_hash_value is already defined in that file, and this change means that hashfn.c no longer needs to depend on nodes/bitmapset.h. That gets us closer to allowing use of the hash functions in hashfn.c in frontend code. Patch by me, reviewed by Suraj Kharage and Mark Dilger. Discussion: http://postgr.es/m/CA+TgmoaRiG4TXND8QuM6JXFRkM_1wL2ZNhzaUKsuec9-4yrkgw@mail.gmail.com
1 parent bf883b2 commit 07b95c3

File tree

4 files changed

+25
-26
lines changed

4 files changed

+25
-26
lines changed

src/backend/nodes/bitmapset.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,3 +1167,26 @@ bms_hash_value(const Bitmapset *a)
11671167
return DatumGetUInt32(hash_any((const unsigned char *) a->words,
11681168
(lastword + 1) * sizeof(bitmapword)));
11691169
}
1170+
1171+
/*
1172+
* bitmap_hash - hash function for keys that are (pointers to) Bitmapsets
1173+
*
1174+
* Note: don't forget to specify bitmap_match as the match function!
1175+
*/
1176+
uint32
1177+
bitmap_hash(const void *key, Size keysize)
1178+
{
1179+
Assert(keysize == sizeof(Bitmapset *));
1180+
return bms_hash_value(*((const Bitmapset *const *) key));
1181+
}
1182+
1183+
/*
1184+
* bitmap_match - match function to use with bitmap_hash
1185+
*/
1186+
int
1187+
bitmap_match(const void *key1, const void *key2, Size keysize)
1188+
{
1189+
Assert(keysize == sizeof(Bitmapset *));
1190+
return !bms_equal(*((const Bitmapset *const *) key1),
1191+
*((const Bitmapset *const *) key2));
1192+
}

src/backend/utils/hash/hashfn.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "postgres.h"
2424

2525
#include "fmgr.h"
26-
#include "nodes/bitmapset.h"
2726
#include "utils/hashutils.h"
2827
#include "utils/hsearch.h"
2928

@@ -695,26 +694,3 @@ uint32_hash(const void *key, Size keysize)
695694
Assert(keysize == sizeof(uint32));
696695
return DatumGetUInt32(hash_uint32(*((const uint32 *) key)));
697696
}
698-
699-
/*
700-
* bitmap_hash: hash function for keys that are (pointers to) Bitmapsets
701-
*
702-
* Note: don't forget to specify bitmap_match as the match function!
703-
*/
704-
uint32
705-
bitmap_hash(const void *key, Size keysize)
706-
{
707-
Assert(keysize == sizeof(Bitmapset *));
708-
return bms_hash_value(*((const Bitmapset *const *) key));
709-
}
710-
711-
/*
712-
* bitmap_match: match function to use with bitmap_hash
713-
*/
714-
int
715-
bitmap_match(const void *key1, const void *key2, Size keysize)
716-
{
717-
Assert(keysize == sizeof(Bitmapset *));
718-
return !bms_equal(*((const Bitmapset *const *) key1),
719-
*((const Bitmapset *const *) key2));
720-
}

src/include/nodes/bitmapset.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,7 @@ extern int bms_prev_member(const Bitmapset *a, int prevbit);
116116

117117
/* support for hashtables using Bitmapsets as keys: */
118118
extern uint32 bms_hash_value(const Bitmapset *a);
119+
extern uint32 bitmap_hash(const void *key, Size keysize);
120+
extern int bitmap_match(const void *key1, const void *key2, Size keysize);
119121

120122
#endif /* BITMAPSET_H */

src/include/utils/hsearch.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,6 @@ extern void AtEOSubXact_HashTables(bool isCommit, int nestDepth);
152152
extern uint32 string_hash(const void *key, Size keysize);
153153
extern uint32 tag_hash(const void *key, Size keysize);
154154
extern uint32 uint32_hash(const void *key, Size keysize);
155-
extern uint32 bitmap_hash(const void *key, Size keysize);
156-
extern int bitmap_match(const void *key1, const void *key2, Size keysize);
157155

158156
#define oid_hash uint32_hash /* Remove me eventually */
159157

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy