Move bitmap_hash and bitmap_match to bitmapset.c.
authorRobert Haas <rhaas@postgresql.org>
Mon, 24 Feb 2020 11:47:08 +0000 (17:17 +0530)
committerRobert Haas <rhaas@postgresql.org>
Mon, 24 Feb 2020 11:47:43 +0000 (17:17 +0530)
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

src/backend/nodes/bitmapset.c
src/backend/utils/hash/hashfn.c
src/include/nodes/bitmapset.h
src/include/utils/hsearch.h

index 648cc1a7eb3fcbb152729f7080b2448bb0818b3c..f711e6c69953b64def86738197e627d2e8ad49b0 100644 (file)
@@ -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));
+}
index dc3cbac7ef7be2bed13077833a82933f3943e1e3..fa46c59d2546fb7072372ad7bd2b032844c938bb 100644 (file)
@@ -23,7 +23,6 @@
 #include "postgres.h"
 
 #include "fmgr.h"
-#include "nodes/bitmapset.h"
 #include "utils/hashutils.h"
 #include "utils/hsearch.h"
 
@@ -695,26 +694,3 @@ uint32_hash(const void *key, Size keysize)
        Assert(keysize == sizeof(uint32));
        return DatumGetUInt32(hash_uint32(*((const uint32 *) key)));
 }
-
-/*
- * 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));
-}
index b7b18a0b687c474b27049586c2accd3c64a47ef3..d113c271ee092bc83f3d36cf09c5ee2b3d83a3c5 100644 (file)
@@ -116,5 +116,7 @@ extern int  bms_prev_member(const Bitmapset *a, int prevbit);
 
 /* support for hashtables using Bitmapsets as keys: */
 extern uint32 bms_hash_value(const Bitmapset *a);
+extern uint32 bitmap_hash(const void *key, Size keysize);
+extern int     bitmap_match(const void *key1, const void *key2, Size keysize);
 
 #endif                                                 /* BITMAPSET_H */
index b0077b7827a49d0b66120483a167e0de43ae3c34..934c4a399e9d40ad0aac56e25017044a1e9a4bb7 100644 (file)
@@ -152,8 +152,6 @@ extern void AtEOSubXact_HashTables(bool isCommit, int nestDepth);
 extern uint32 string_hash(const void *key, Size keysize);
 extern uint32 tag_hash(const void *key, Size keysize);
 extern uint32 uint32_hash(const void *key, Size keysize);
-extern uint32 bitmap_hash(const void *key, Size keysize);
-extern int     bitmap_match(const void *key1, const void *key2, Size keysize);
 
 #define oid_hash uint32_hash   /* Remove me eventually */