00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #pragma once
00023
00024 #include <drizzled/dynamic_array.h>
00025
00026 namespace drizzled {
00027
00028 typedef struct charset_info_st CHARSET_INFO;
00029
00030
00031
00032
00033
00034 #define HASH_OVERHEAD (sizeof(char*)*2)
00035
00036
00037 #define HASH_UNIQUE 1
00038
00039 typedef unsigned char *(*hash_get_key)(const unsigned char *,size_t*,bool);
00040 typedef void (*hash_free_key)(void *);
00041
00042 struct HASH_LINK
00043 {
00044
00045 uint32_t next;
00046
00047 unsigned char *data;
00048 } ;
00049
00050 struct HASH
00051 {
00052
00053 typedef DYNAMIC_ARRAY array_t;
00054
00055 size_t key_offset,key_length;
00056 uint32_t blength;
00057 uint32_t records;
00058 uint32_t flags;
00059
00060 array_t array;
00061 hash_get_key get_key;
00062 hash_free_key free;
00063 const CHARSET_INFO *charset;
00064 };
00065
00066
00067 typedef uint32_t HASH_SEARCH_STATE;
00068
00069 bool
00070 _hash_init(HASH *hash,uint32_t growth_size, const CHARSET_INFO * const charset,
00071 uint32_t size, size_t key_offset, size_t key_length,
00072 hash_get_key get_key,
00073 hash_free_key free_element, uint32_t flags);
00074 #define hash_init(A,B,C,D,E,F,G,H) _hash_init(A,0,B,C,D,E,F,G,H)
00075 void hash_free(HASH *tree);
00076 unsigned char *hash_element(HASH *hash,uint32_t idx);
00077 unsigned char *hash_search(const HASH *info, const unsigned char *key,
00078 size_t length);
00079 unsigned char *hash_first(const HASH *info, const unsigned char *key,
00080 size_t length, HASH_SEARCH_STATE *state);
00081 unsigned char *hash_next(const HASH *info, const unsigned char *key,
00082 size_t length, HASH_SEARCH_STATE *state);
00083 bool my_hash_insert(HASH *info,const unsigned char *data);
00084 bool hash_delete(HASH *hash,unsigned char *record);
00085
00086 #define hash_inited(H) ((H)->array.buffer != 0)
00087
00088 }
00089