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
00029
00030
00031
00032 #define HASH_OVERHEAD (sizeof(char*)*2)
00033
00034
00035 #define HASH_UNIQUE 1
00036
00037 typedef unsigned char *(*hash_get_key)(const unsigned char *,size_t*,bool);
00038 typedef void (*hash_free_key)(void *);
00039
00040 struct HASH_LINK
00041 {
00042
00043 uint32_t next;
00044
00045 unsigned char *data;
00046 } ;
00047
00048 struct charset_info_st;
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_st *charset;
00064 };
00065
00066
00067 typedef uint32_t HASH_SEARCH_STATE;
00068
00069 void
00070 _hash_init(HASH *hash,uint32_t growth_size, const charset_info_st* const,
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_search(const HASH *info, const unsigned char *key,
00077 size_t length);
00078 unsigned char *hash_first(const HASH *info, const unsigned char *key, size_t length, HASH_SEARCH_STATE *state);
00079 bool my_hash_insert(HASH *info,const unsigned char *data);
00080 bool hash_delete(HASH *hash,unsigned char *record);
00081
00082 }
00083