PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
hashfn.c File Reference
#include "postgres.h"
#include "access/hash.h"
#include "utils/hsearch.h"
Include dependency graph for hashfn.c:

Go to the source code of this file.

Functions

uint32 string_hash (const void *key, Size keysize)
 
uint32 tag_hash (const void *key, Size keysize)
 
uint32 uint32_hash (const void *key, Size keysize)
 
uint32 bitmap_hash (const void *key, Size keysize)
 
int bitmap_match (const void *key1, const void *key2, Size keysize)
 

Function Documentation

uint32 bitmap_hash ( const void *  key,
Size  keysize 
)

Definition at line 76 of file hashfn.c.

References Assert, and bms_hash_value().

Referenced by build_join_rel_hash().

77 {
78  Assert(keysize == sizeof(Bitmapset *));
79  return bms_hash_value(*((const Bitmapset *const *) key));
80 }
uint32 bms_hash_value(const Bitmapset *a)
Definition: bitmapset.c:984
#define Assert(condition)
Definition: c.h:676
int bitmap_match ( const void *  key1,
const void *  key2,
Size  keysize 
)

Definition at line 86 of file hashfn.c.

References Assert, and bms_equal().

Referenced by build_join_rel_hash().

87 {
88  Assert(keysize == sizeof(Bitmapset *));
89  return !bms_equal(*((const Bitmapset *const *) key1),
90  *((const Bitmapset *const *) key2));
91 }
#define Assert(condition)
Definition: c.h:676
bool bms_equal(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:131
uint32 string_hash ( const void *  key,
Size  keysize 
)

Definition at line 34 of file hashfn.c.

References DatumGetUInt32, hash_any(), and Min.

Referenced by hash_create().

35 {
36  /*
37  * If the string exceeds keysize-1 bytes, we want to hash only that many,
38  * because when it is copied into the hash table it will be truncated at
39  * that length.
40  */
41  Size s_len = strlen((const char *) key);
42 
43  s_len = Min(s_len, keysize - 1);
44  return DatumGetUInt32(hash_any((const unsigned char *) key,
45  (int) s_len));
46 }
#define DatumGetUInt32(X)
Definition: postgres.h:492
#define Min(x, y)
Definition: c.h:807
Datum hash_any(register const unsigned char *k, register int keylen)
Definition: hashfunc.c:307
size_t Size
Definition: c.h:356
uint32 tag_hash ( const void *  key,
Size  keysize 
)

Definition at line 52 of file hashfn.c.

References DatumGetUInt32, and hash_any().

Referenced by hash_create().

53 {
54  return DatumGetUInt32(hash_any((const unsigned char *) key,
55  (int) keysize));
56 }
#define DatumGetUInt32(X)
Definition: postgres.h:492
Datum hash_any(register const unsigned char *k, register int keylen)
Definition: hashfunc.c:307
uint32 uint32_hash ( const void *  key,
Size  keysize 
)

Definition at line 64 of file hashfn.c.

References Assert, DatumGetUInt32, and hash_uint32().

Referenced by hash_create().

65 {
66  Assert(keysize == sizeof(uint32));
67  return DatumGetUInt32(hash_uint32(*((const uint32 *) key)));
68 }
#define DatumGetUInt32(X)
Definition: postgres.h:492
unsigned int uint32
Definition: c.h:268
Datum hash_uint32(uint32 k)
Definition: hashfunc.c:512
#define Assert(condition)
Definition: c.h:676