1
/* Copyright (C) 2000 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16
20
/* Dynamic hashing of record with different key-length */
22
#ifndef DRIZZLED_HASH_H
23
#define DRIZZLED_HASH_H
25
#include <mysys/my_sys.h>
50
59
#define hash_init(A,B,C,D,E,F,G,H) _hash_init(A,0,B,C,D,E,F,G,H CALLER_INFO)
51
60
#define hash_init2(A,B,C,D,E,F,G,H,I) _hash_init(A,B,C,D,E,F,G,H,I CALLER_INFO)
52
bool _hash_init(HASH *hash, uint32_t growth_size, const CHARSET_INFO * const charset,
53
uint32_t default_array_elements, size_t key_offset,
54
size_t key_length, hash_get_key get_key,
55
void (*free_element)(void*), uint32_t flags CALLER_INFO_PROTO);
61
bool _hash_init(HASH *hash, uint32_t growth_size,
62
const CHARSET_INFO * const charset,
63
uint32_t default_array_elements, size_t key_offset,
64
size_t key_length, hash_get_key get_key,
65
void (*free_element)(void*), uint32_t flags CALLER_INFO_PROTO);
56
66
void hash_free(HASH *tree);
57
67
void my_hash_reset(HASH *hash);
58
68
unsigned char *hash_element(HASH *hash,uint32_t idx);
59
unsigned char *hash_search(const HASH *info, const unsigned char *key, size_t length);
60
unsigned char *hash_first(const HASH *info, const unsigned char *key, size_t length,
61
HASH_SEARCH_STATE *state);
62
unsigned char *hash_next(const HASH *info, const unsigned char *key, size_t length,
63
HASH_SEARCH_STATE *state);
69
unsigned char *hash_search(const HASH *info, const unsigned char *key,
71
unsigned char *hash_first(const HASH *info, const unsigned char *key,
72
size_t length, HASH_SEARCH_STATE *state);
73
unsigned char *hash_next(const HASH *info, const unsigned char *key,
74
size_t length, HASH_SEARCH_STATE *state);
64
75
bool my_hash_insert(HASH *info,const unsigned char *data);
65
76
bool hash_delete(HASH *hash,unsigned char *record);
66
bool hash_update(HASH *hash,unsigned char *record,unsigned char *old_key,size_t old_key_length);
77
bool hash_update(HASH *hash,unsigned char *record, unsigned char *old_key,
78
size_t old_key_length);
67
79
void hash_replace(HASH *hash, HASH_SEARCH_STATE *state, unsigned char *new_row);
69
81
#define hash_clear(H) memset((H), 0, sizeof(*(H)))
70
82
#define hash_inited(H) ((H)->array.buffer != 0)
71
#define hash_init_opt(A,B,C,D,E,F,G,H) \
72
(!hash_inited(A) && _hash_init(A,0,B,C,D,E,F,G, H CALLER_INFO))
83
#define hash_init_opt(A,B,C,D,E,F,G,H) \
84
(!hash_inited(A) && _hash_init(A,0,B,C,D,E,F,G, H CALLER_INFO))