blob: 24255f31e6e0ac19a5416461e31f1c7338539447 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/*-------------------------------------------------------------------------
*
* hashfn.c
* Hash functions for use in dynahash.c hashtables
*
*
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/hash/hashfn.c,v 1.23 2005/04/14 20:32:43 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "access/hash.h"
#include "utils/hsearch.h"
/*
* string_hash: hash function for keys that are null-terminated strings.
*
* NOTE: this is the default hash function if none is specified.
*/
uint32
string_hash(const void *key, Size keysize)
{
return DatumGetUInt32(hash_any((const unsigned char *) key,
(int) strlen((const char *) key)));
}
/*
* tag_hash: hash function for fixed-size tag values
*/
uint32
tag_hash(const void *key, Size keysize)
{
return DatumGetUInt32(hash_any((const unsigned char *) key,
(int) keysize));
}
/*
* oid_hash: hash function for keys that are OIDs
*
* (tag_hash works for this case too, but is slower)
*/
uint32
oid_hash(const void *key, Size keysize)
{
Assert(keysize == sizeof(Oid));
/* We don't actually bother to do anything to the OID value ... */
return (uint32) *((const Oid *) key);
}
|