diff options
| author | Tom Lane | 2002-03-09 17:35:37 +0000 |
|---|---|---|
| committer | Tom Lane | 2002-03-09 17:35:37 +0000 |
| commit | c422b5ca6b0dd9b8a2d1d7b8b437e14f3ca79052 (patch) | |
| tree | fc242c201ff8748e98bfbb610b312205c44b769b /src/include | |
| parent | 1eb31d197d8eadc5340f0dfe7e2c7169e1005275 (diff) | |
Code review for improved-hashing patch. Fix some portability issues
(char != unsigned char, Datum != uint32); make use of new hash code in
dynahash hash tables and hash joins.
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/access/hash.h | 7 | ||||
| -rw-r--r-- | src/include/utils/hsearch.h | 23 |
2 files changed, 14 insertions, 16 deletions
diff --git a/src/include/access/hash.h b/src/include/access/hash.h index 42c0558b64e..c809a139a40 100644 --- a/src/include/access/hash.h +++ b/src/include/access/hash.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: hash.h,v 1.44 2002/03/06 20:49:45 momjian Exp $ + * $Id: hash.h,v 1.45 2002/03/09 17:35:37 tgl Exp $ * * NOTES * modeled after Margo Seltzer's hash implementation for unix. @@ -252,7 +252,8 @@ extern Datum hashbulkdelete(PG_FUNCTION_ARGS); * Datatype-specific hash functions in hashfunc.c. * * NOTE: some of these are also used by catcache operations, without - * any direct connection to hash indexes. + * any direct connection to hash indexes. Also, the common hash_any + * routine is also used by dynahash tables and hash joins. */ extern Datum hashchar(PG_FUNCTION_ARGS); extern Datum hashint2(PG_FUNCTION_ARGS); @@ -265,7 +266,7 @@ extern Datum hashoidvector(PG_FUNCTION_ARGS); extern Datum hashint2vector(PG_FUNCTION_ARGS); extern Datum hashname(PG_FUNCTION_ARGS); extern Datum hashvarlena(PG_FUNCTION_ARGS); -extern Datum hash_any(register const char *k, register int keylen); +extern Datum hash_any(register const unsigned char *k, register int keylen); /* private routines */ diff --git a/src/include/utils/hsearch.h b/src/include/utils/hsearch.h index 126bd71d915..11dcd900054 100644 --- a/src/include/utils/hsearch.h +++ b/src/include/utils/hsearch.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: hsearch.h,v 1.25 2001/11/05 17:46:36 momjian Exp $ + * $Id: hsearch.h,v 1.26 2002/03/09 17:35:37 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -35,9 +35,6 @@ #define DEF_DIRSIZE 256 #define DEF_FFACTOR 1 /* default fill factor */ -#define PRIME1 37 /* for the hash function */ -#define PRIME2 1048583 - /* * HASHELEMENT is the private part of a hashtable entry. The caller's data @@ -60,10 +57,10 @@ typedef struct HASHHDR { long dsize; /* Directory Size */ long ssize; /* Segment Size --- must be power of 2 */ - long sshift; /* Segment shift */ - long max_bucket; /* ID of Maximum bucket in use */ - long high_mask; /* Mask to modulo into entire table */ - long low_mask; /* Mask to modulo into lower half of table */ + int sshift; /* Segment shift = log2(ssize) */ + uint32 max_bucket; /* ID of Maximum bucket in use */ + uint32 high_mask; /* Mask to modulo into entire table */ + uint32 low_mask; /* Mask to modulo into lower half of table */ long ffactor; /* Fill factor */ long nentries; /* Number of entries in hash table */ long nsegs; /* Number of allocated segments */ @@ -86,7 +83,7 @@ typedef struct HTAB { HASHHDR *hctl; /* shared control information */ HASHSEGMENT *dir; /* directory of segment starts */ - long (*hash) (void *key, int keysize); /* Hash Function */ + uint32 (*hash) (void *key, int keysize); /* Hash Function */ void *(*alloc) (Size); /* memory allocator */ MemoryContext hcxt; /* memory context if default allocator * used */ @@ -101,7 +98,7 @@ typedef struct HASHCTL long ssize; /* Segment Size */ long dsize; /* (initial) Directory Size */ long ffactor; /* Fill factor */ - long (*hash) (void *key, int keysize); /* Hash Function */ + uint32 (*hash) (void *key, int keysize); /* Hash Function */ long keysize; /* hash key length in bytes */ long entrysize; /* total user element size in bytes */ long max_dsize; /* limit to dsize if directory size is @@ -143,7 +140,7 @@ typedef enum typedef struct { HTAB *hashp; - long curBucket; /* index of current bucket */ + uint32 curBucket; /* index of current bucket */ HASHELEMENT *curEntry; /* current entry in bucket */ } HASH_SEQ_STATUS; @@ -164,7 +161,7 @@ extern long hash_select_dirsize(long num_entries); /* * prototypes for functions in hashfn.c */ -extern long string_hash(void *key, int keysize); -extern long tag_hash(void *key, int keysize); +extern uint32 string_hash(void *key, int keysize); +extern uint32 tag_hash(void *key, int keysize); #endif /* HSEARCH_H */ |
