#ifndef HSEARCH_H
#define HSEARCH_H
typedef uint32 (*HashValueFunc) (const void *key, Size keysize);
typedef int (*HashCompareFunc) (const void *key1, const void *key2,
Size keysize);
typedef void *(*HashCopyFunc) (void *dest, const void *src, Size keysize);
typedef void *(*HashAllocFunc) (Size request);
typedef struct HASHELEMENT
{
struct HASHELEMENT *link;
uint32 hashvalue;
} HASHELEMENT;
typedef struct HASHHDR HASHHDR;
typedef struct HTAB HTAB;
typedef struct HASHCTL
{
long num_partitions;
long ssize;
long dsize;
long max_dsize;
Size keysize;
Size entrysize;
HashValueFunc hash;
HashCompareFunc match;
HashCopyFunc keycopy;
HashAllocFunc alloc;
MemoryContext hcxt;
HASHHDR *hctl;
} HASHCTL;
#define HASH_PARTITION 0x0001
#define HASH_SEGMENT 0x0002
#define HASH_DIRSIZE 0x0004
#define HASH_ELEM 0x0008
#define HASH_STRINGS 0x0010
#define HASH_BLOBS 0x0020
#define HASH_FUNCTION 0x0040
#define HASH_COMPARE 0x0080
#define HASH_KEYCOPY 0x0100
#define HASH_ALLOC 0x0200
#define HASH_CONTEXT 0x0400
#define HASH_SHARED_MEM 0x0800
#define HASH_ATTACH 0x1000
#define HASH_FIXED_SIZE 0x2000
#define NO_MAX_DSIZE (-1)
typedef enum
{
HASH_FIND,
HASH_ENTER,
HASH_REMOVE,
HASH_ENTER_NULL,
} HASHACTION;
typedef struct
{
HTAB *hashp;
uint32 curBucket;
HASHELEMENT *curEntry;
} HASH_SEQ_STATUS;
extern HTAB *hash_create(const char *tabname, long nelem,
const HASHCTL *info, int flags);
extern void hash_destroy(HTAB *hashp);
extern void hash_stats(const char *where, HTAB *hashp);
extern void *hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action,
bool *foundPtr);
extern uint32 get_hash_value(HTAB *hashp, const void *keyPtr);
extern void *hash_search_with_hash_value(HTAB *hashp, const void *keyPtr,
uint32 hashvalue, HASHACTION action,
bool *foundPtr);
extern bool hash_update_hash_key(HTAB *hashp, void *existingEntry,
const void *newKeyPtr);
extern long hash_get_num_entries(HTAB *hashp);
extern void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp);
extern void *hash_seq_search(HASH_SEQ_STATUS *status);
extern void hash_seq_term(HASH_SEQ_STATUS *status);
extern void hash_freeze(HTAB *hashp);
extern Size hash_estimate_size(long num_entries, Size entrysize);
extern long hash_select_dirsize(long num_entries);
extern Size hash_get_shared_size(HASHCTL *info, int flags);
extern void AtEOXact_HashTables(bool isCommit);
extern void AtEOSubXact_HashTables(bool isCommit, int nestDepth);
#endif