aboutsummaryrefslogtreecommitdiff
path: root/src/backend/nodes/bitmapset.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2020-02-24 17:17:08 +0530
committerRobert Haas <rhaas@postgresql.org>2020-02-24 17:17:43 +0530
commit07b95c3d8334f737d4717c91967729f7721e785c (patch)
tree2abfb24ba5536bb20b0ceb9eae54eeb1b1b7bf91 /src/backend/nodes/bitmapset.c
parentbf883b211eae18662f2dfaede02f5d115bf0b805 (diff)
downloadpostgresql-07b95c3d8334f737d4717c91967729f7721e785c.tar.gz
postgresql-07b95c3d8334f737d4717c91967729f7721e785c.zip
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
Diffstat (limited to 'src/backend/nodes/bitmapset.c')
-rw-r--r--src/backend/nodes/bitmapset.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/backend/nodes/bitmapset.c b/src/backend/nodes/bitmapset.c
index 648cc1a7eb3..f711e6c6995 100644
--- a/src/backend/nodes/bitmapset.c
+++ b/src/backend/nodes/bitmapset.c
@@ -1167,3 +1167,26 @@ bms_hash_value(const Bitmapset *a)
return DatumGetUInt32(hash_any((const unsigned char *) a->words,
(lastword + 1) * sizeof(bitmapword)));
}
+
+/*
+ * bitmap_hash - hash function for keys that are (pointers to) Bitmapsets
+ *
+ * Note: don't forget to specify bitmap_match as the match function!
+ */
+uint32
+bitmap_hash(const void *key, Size keysize)
+{
+ Assert(keysize == sizeof(Bitmapset *));
+ return bms_hash_value(*((const Bitmapset *const *) key));
+}
+
+/*
+ * bitmap_match - match function to use with bitmap_hash
+ */
+int
+bitmap_match(const void *key1, const void *key2, Size keysize)
+{
+ Assert(keysize == sizeof(Bitmapset *));
+ return !bms_equal(*((const Bitmapset *const *) key1),
+ *((const Bitmapset *const *) key2));
+}