Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef HSEARCH_H
00015 #define HSEARCH_H
00016
00017
00018
00019
00020
00021 typedef uint32 (*HashValueFunc) (const void *key, Size keysize);
00022
00023
00024
00025
00026
00027
00028
00029 typedef int (*HashCompareFunc) (const void *key1, const void *key2,
00030 Size keysize);
00031
00032
00033
00034
00035
00036
00037 typedef void *(*HashCopyFunc) (void *dest, const void *src, Size keysize);
00038
00039
00040
00041
00042
00043
00044 typedef void *(*HashAllocFunc) (Size request);
00045
00046
00047
00048
00049
00050
00051 typedef struct HASHELEMENT
00052 {
00053 struct HASHELEMENT *link;
00054 uint32 hashvalue;
00055 } HASHELEMENT;
00056
00057
00058 typedef struct HASHHDR HASHHDR;
00059
00060
00061 typedef struct HTAB HTAB;
00062
00063
00064
00065 typedef struct HASHCTL
00066 {
00067 long num_partitions;
00068 long ssize;
00069 long dsize;
00070 long max_dsize;
00071 long ffactor;
00072 Size keysize;
00073 Size entrysize;
00074 HashValueFunc hash;
00075 HashCompareFunc match;
00076 HashCopyFunc keycopy;
00077 HashAllocFunc alloc;
00078 MemoryContext hcxt;
00079 HASHHDR *hctl;
00080 } HASHCTL;
00081
00082
00083 #define HASH_PARTITION 0x001
00084 #define HASH_SEGMENT 0x002
00085 #define HASH_DIRSIZE 0x004
00086 #define HASH_FFACTOR 0x008
00087 #define HASH_FUNCTION 0x010
00088 #define HASH_ELEM 0x020
00089 #define HASH_SHARED_MEM 0x040
00090 #define HASH_ATTACH 0x080
00091 #define HASH_ALLOC 0x100
00092 #define HASH_CONTEXT 0x200
00093 #define HASH_COMPARE 0x400
00094 #define HASH_KEYCOPY 0x800
00095 #define HASH_FIXED_SIZE 0x1000
00096
00097
00098
00099 #define NO_MAX_DSIZE (-1)
00100
00101
00102 typedef enum
00103 {
00104 HASH_FIND,
00105 HASH_ENTER,
00106 HASH_REMOVE,
00107 HASH_ENTER_NULL
00108 } HASHACTION;
00109
00110
00111 typedef struct
00112 {
00113 HTAB *hashp;
00114 uint32 curBucket;
00115 HASHELEMENT *curEntry;
00116 } HASH_SEQ_STATUS;
00117
00118
00119
00120
00121 extern HTAB *hash_create(const char *tabname, long nelem,
00122 HASHCTL *info, int flags);
00123 extern void hash_destroy(HTAB *hashp);
00124 extern void hash_stats(const char *where, HTAB *hashp);
00125 extern void *hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action,
00126 bool *foundPtr);
00127 extern uint32 get_hash_value(HTAB *hashp, const void *keyPtr);
00128 extern void *hash_search_with_hash_value(HTAB *hashp, const void *keyPtr,
00129 uint32 hashvalue, HASHACTION action,
00130 bool *foundPtr);
00131 extern bool hash_update_hash_key(HTAB *hashp, void *existingEntry,
00132 const void *newKeyPtr);
00133 extern long hash_get_num_entries(HTAB *hashp);
00134 extern void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp);
00135 extern void *hash_seq_search(HASH_SEQ_STATUS *status);
00136 extern void hash_seq_term(HASH_SEQ_STATUS *status);
00137 extern void hash_freeze(HTAB *hashp);
00138 extern Size hash_estimate_size(long num_entries, Size entrysize);
00139 extern long hash_select_dirsize(long num_entries);
00140 extern Size hash_get_shared_size(HASHCTL *info, int flags);
00141 extern void AtEOXact_HashTables(bool isCommit);
00142 extern void AtEOSubXact_HashTables(bool isCommit, int nestDepth);
00143
00144
00145
00146
00147 extern uint32 string_hash(const void *key, Size keysize);
00148 extern uint32 tag_hash(const void *key, Size keysize);
00149 extern uint32 oid_hash(const void *key, Size keysize);
00150 extern uint32 bitmap_hash(const void *key, Size keysize);
00151 extern int bitmap_match(const void *key1, const void *key2, Size keysize);
00152
00153 #endif