~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/ha0ha.h

  • Committer: Brian Aker
  • Date: 2008-11-04 15:39:09 UTC
  • mfrom: (575.1.2 devel)
  • Revision ID: brian@tangent.org-20081104153909-c72hn65udxs1ccal
Merge of Monty's work

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 
14
14
#include "hash0hash.h"
15
15
#include "page0types.h"
 
16
#include "buf0types.h"
16
17
 
17
18
/*****************************************************************
18
19
Looks for an element in a hash table. */
28
29
/*************************************************************
29
30
Looks for an element when we know the pointer to the data and updates
30
31
the pointer to data if found. */
31
 
 
 
32
UNIV_INTERN
32
33
void
33
 
ha_search_and_update_if_found(
34
 
/*==========================*/
 
34
ha_search_and_update_if_found_func(
 
35
/*===============================*/
35
36
        hash_table_t*   table,  /* in: hash table */
36
37
        ulint           fold,   /* in: folded value of the searched data */
37
38
        void*           data,   /* in: pointer to the data */
 
39
#ifdef UNIV_DEBUG
 
40
        buf_block_t*    new_block,/* in: block containing new_data */
 
41
#endif
38
42
        void*           new_data);/* in: new pointer to the data */
 
43
 
 
44
#ifdef UNIV_DEBUG
 
45
# define ha_search_and_update_if_found(table,fold,data,new_block,new_data) \
 
46
        ha_search_and_update_if_found_func(table,fold,data,new_block,new_data)
 
47
#else
 
48
# define ha_search_and_update_if_found(table,fold,data,new_block,new_data) \
 
49
        ha_search_and_update_if_found_func(table,fold,data,new_data)
 
50
#endif
39
51
/*****************************************************************
40
52
Creates a hash table with >= n array cells. The actual number of cells is
41
53
chosen to be a prime number slightly bigger than n. */
42
 
 
 
54
UNIV_INTERN
43
55
hash_table_t*
44
56
ha_create_func(
45
57
/*===========*/
46
58
                                /* out, own: created table */
47
 
        ibool   in_btr_search,  /* in: TRUE if the hash table is used in
48
 
                                the btr_search module */
49
59
        ulint   n,              /* in: number of array cells */
50
60
#ifdef UNIV_SYNC_DEBUG
51
61
        ulint   mutex_level,    /* in: level of the mutexes in the latching
54
64
        ulint   n_mutexes);     /* in: number of mutexes to protect the
55
65
                                hash table: must be a power of 2 */
56
66
#ifdef UNIV_SYNC_DEBUG
57
 
# define ha_create(b,n_c,n_m,level) ha_create_func(b,n_c,level,n_m)
 
67
# define ha_create(n_c,n_m,level) ha_create_func(n_c,level,n_m)
58
68
#else /* UNIV_SYNC_DEBUG */
59
 
# define ha_create(b,n_c,n_m,level) ha_create_func(b,n_c,n_m)
 
69
# define ha_create(n_c,n_m,level) ha_create_func(n_c,n_m)
60
70
#endif /* UNIV_SYNC_DEBUG */
 
71
 
 
72
/*****************************************************************
 
73
Empties a hash table and frees the memory heaps. */
 
74
UNIV_INTERN
 
75
void
 
76
ha_clear(
 
77
/*=====*/
 
78
        hash_table_t*   table); /* in, own: hash table */
 
79
 
61
80
/*****************************************************************
62
81
Inserts an entry into a hash table. If an entry with the same fold number
63
82
is found, its node is updated to point to the new data, and no new node
64
83
is inserted. */
65
 
 
 
84
UNIV_INTERN
66
85
ibool
67
 
ha_insert_for_fold(
68
 
/*===============*/
 
86
ha_insert_for_fold_func(
 
87
/*====================*/
69
88
                                /* out: TRUE if succeed, FALSE if no more
70
89
                                memory could be allocated */
71
90
        hash_table_t*   table,  /* in: hash table */
73
92
                                the same fold value already exists, it is
74
93
                                updated to point to the same data, and no new
75
94
                                node is created! */
 
95
#ifdef UNIV_DEBUG
 
96
        buf_block_t*    block,  /* in: buffer block containing the data */
 
97
#endif /* UNIV_DEBUG */
76
98
        void*           data);  /* in: data, must not be NULL */
 
99
 
 
100
#ifdef UNIV_DEBUG
 
101
# define ha_insert_for_fold(t,f,b,d) ha_insert_for_fold_func(t,f,b,d)
 
102
#else
 
103
# define ha_insert_for_fold(t,f,b,d) ha_insert_for_fold_func(t,f,d)
 
104
#endif
 
105
 
77
106
/*****************************************************************
78
107
Deletes an entry from a hash table. */
79
 
 
 
108
UNIV_INTERN
80
109
void
81
110
ha_delete(
82
111
/*======*/
98
127
/*********************************************************************
99
128
Removes from the chain determined by fold all nodes whose data pointer
100
129
points to the page given. */
101
 
 
 
130
UNIV_INTERN
102
131
void
103
132
ha_remove_all_nodes_to_page(
104
133
/*========================*/
105
134
        hash_table_t*   table,  /* in: hash table */
106
135
        ulint           fold,   /* in: fold value */
107
 
        page_t*         page);  /* in: buffer page */
 
136
        const page_t*   page);  /* in: buffer page */
108
137
/*****************************************************************
109
138
Validates a given range of the cells in hash table. */
110
 
 
 
139
UNIV_INTERN
111
140
ibool
112
141
ha_validate(
113
142
/*========*/
117
146
        ulint           end_index);     /* in: end index */
118
147
/*****************************************************************
119
148
Prints info of a hash table. */
120
 
 
 
149
UNIV_INTERN
121
150
void
122
151
ha_print_info(
123
152
/*==========*/
128
157
 
129
158
typedef struct ha_node_struct ha_node_t;
130
159
struct ha_node_struct {
131
 
        ha_node_t* next; /* next chain node or NULL if none */
132
 
        void*   data;   /* pointer to the data */
133
 
        ulint   fold;   /* fold value for the data */
 
160
        ha_node_t*      next;   /* next chain node or NULL if none */
 
161
#ifdef UNIV_DEBUG
 
162
        buf_block_t*    block;  /* buffer block containing the data, or NULL */
 
163
#endif /* UNIV_DEBUG */
 
164
        void*           data;   /* pointer to the data */
 
165
        ulint           fold;   /* fold value for the data */
134
166
};
135
167
 
136
168
#ifndef UNIV_NONINL