Header And Logo

PostgreSQL
| The world's most advanced open source database.

Functions

hashfn.c File Reference

#include "postgres.h"
#include "access/hash.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 oid_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 75 of file hashfn.c.

References Assert, and bms_hash_value().

{
    Assert(keysize == sizeof(Bitmapset *));
    return bms_hash_value(*((const Bitmapset *const *) key));
}

int bitmap_match ( const void *  key1,
const void *  key2,
Size  keysize 
)

Definition at line 85 of file hashfn.c.

References Assert, and bms_equal().

{
    Assert(keysize == sizeof(Bitmapset *));
    return !bms_equal(*((const Bitmapset *const *) key1),
                      *((const Bitmapset *const *) key2));
}

uint32 oid_hash ( const void *  key,
Size  keysize 
)

Definition at line 63 of file hashfn.c.

References Assert, DatumGetUInt32, and hash_uint32().

{
    Assert(keysize == sizeof(Oid));
    return DatumGetUInt32(hash_uint32((uint32) *((const Oid *) key)));
}

uint32 string_hash ( const void *  key,
Size  keysize 
)

Definition at line 33 of file hashfn.c.

References DatumGetUInt32, hash_any(), and Min.

Referenced by hash_create().

{
    /*
     * If the string exceeds keysize-1 bytes, we want to hash only that many,
     * because when it is copied into the hash table it will be truncated at
     * that length.
     */
    Size        s_len = strlen((const char *) key);

    s_len = Min(s_len, keysize - 1);
    return DatumGetUInt32(hash_any((const unsigned char *) key,
                                   (int) s_len));
}

uint32 tag_hash ( const void *  key,
Size  keysize 
)

Definition at line 51 of file hashfn.c.

References DatumGetUInt32, and hash_any().

{
    return DatumGetUInt32(hash_any((const unsigned char *) key,
                                   (int) keysize));
}