~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/ha/hash0hash.c

  • Committer: Monty Taylor
  • Date: 2009-04-14 19:16:51 UTC
  • mto: (997.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 994.
  • Revision ID: mordred@inaugust.com-20090414191651-ltbww6hpqks8k7qk
Clarified instructions in README.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
*****************************************************************************/
18
18
 
19
 
/**************************************************//**
20
 
@file ha/hash0hash.c
 
19
/******************************************************
21
20
The simple hash table utility
22
21
 
23
22
Created 5/20/1997 Heikki Tuuri
30
29
 
31
30
#include "mem0mem.h"
32
31
 
33
 
#ifndef UNIV_HOTBACKUP
34
 
/************************************************************//**
 
32
/****************************************************************
35
33
Reserves the mutex for a fold value in a hash table. */
36
34
UNIV_INTERN
37
35
void
38
36
hash_mutex_enter(
39
37
/*=============*/
40
 
        hash_table_t*   table,  /*!< in: hash table */
41
 
        ulint           fold)   /*!< in: fold */
 
38
        hash_table_t*   table,  /* in: hash table */
 
39
        ulint           fold)   /* in: fold */
42
40
{
43
41
        mutex_enter(hash_get_mutex(table, fold));
44
42
}
45
43
 
46
 
/************************************************************//**
 
44
/****************************************************************
47
45
Releases the mutex for a fold value in a hash table. */
48
46
UNIV_INTERN
49
47
void
50
48
hash_mutex_exit(
51
49
/*============*/
52
 
        hash_table_t*   table,  /*!< in: hash table */
53
 
        ulint           fold)   /*!< in: fold */
 
50
        hash_table_t*   table,  /* in: hash table */
 
51
        ulint           fold)   /* in: fold */
54
52
{
55
53
        mutex_exit(hash_get_mutex(table, fold));
56
54
}
57
55
 
58
 
/************************************************************//**
 
56
/****************************************************************
59
57
Reserves all the mutexes of a hash table, in an ascending order. */
60
58
UNIV_INTERN
61
59
void
62
60
hash_mutex_enter_all(
63
61
/*=================*/
64
 
        hash_table_t*   table)  /*!< in: hash table */
 
62
        hash_table_t*   table)  /* in: hash table */
65
63
{
66
64
        ulint   i;
67
65
 
71
69
        }
72
70
}
73
71
 
74
 
/************************************************************//**
 
72
/****************************************************************
75
73
Releases all the mutexes of a hash table. */
76
74
UNIV_INTERN
77
75
void
78
76
hash_mutex_exit_all(
79
77
/*================*/
80
 
        hash_table_t*   table)  /*!< in: hash table */
 
78
        hash_table_t*   table)  /* in: hash table */
81
79
{
82
80
        ulint   i;
83
81
 
86
84
                mutex_exit(table->mutexes + i);
87
85
        }
88
86
}
89
 
#endif /* !UNIV_HOTBACKUP */
90
87
 
91
 
/*************************************************************//**
 
88
/*****************************************************************
92
89
Creates a hash table with >= n array cells. The actual number of cells is
93
 
chosen to be a prime number slightly bigger than n.
94
 
@return own: created table */
 
90
chosen to be a prime number slightly bigger than n. */
95
91
UNIV_INTERN
96
92
hash_table_t*
97
93
hash_create(
98
94
/*========*/
99
 
        ulint   n)      /*!< in: number of array cells */
 
95
                        /* out, own: created table */
 
96
        ulint   n)      /* in: number of array cells */
100
97
{
101
98
        hash_cell_t*    array;
102
99
        ulint           prime;
108
105
 
109
106
        array = ut_malloc(sizeof(hash_cell_t) * prime);
110
107
 
 
108
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
 
109
        table->adaptive = FALSE;
 
110
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
111
111
        table->array = array;
112
112
        table->n_cells = prime;
113
 
#ifndef UNIV_HOTBACKUP
114
 
# if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
115
 
        table->adaptive = FALSE;
116
 
# endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
117
113
        table->n_mutexes = 0;
118
114
        table->mutexes = NULL;
119
115
        table->heaps = NULL;
120
 
#endif /* !UNIV_HOTBACKUP */
121
116
        table->heap = NULL;
122
117
        table->magic_n = HASH_TABLE_MAGIC_N;
123
118
 
127
122
        return(table);
128
123
}
129
124
 
130
 
/*************************************************************//**
 
125
/*****************************************************************
131
126
Frees a hash table. */
132
127
UNIV_INTERN
133
128
void
134
129
hash_table_free(
135
130
/*============*/
136
 
        hash_table_t*   table)  /*!< in, own: hash table */
 
131
        hash_table_t*   table)  /* in, own: hash table */
137
132
{
138
 
#ifndef UNIV_HOTBACKUP
139
133
        ut_a(table->mutexes == NULL);
140
 
#endif /* !UNIV_HOTBACKUP */
141
134
 
142
135
        ut_free(table->array);
143
136
        mem_free(table);
144
137
}
145
138
 
146
 
#ifndef UNIV_HOTBACKUP
147
 
/*************************************************************//**
 
139
/*****************************************************************
148
140
Creates a mutex array to protect a hash table. */
149
141
UNIV_INTERN
150
142
void
151
143
hash_create_mutexes_func(
152
144
/*=====================*/
153
 
        hash_table_t*   table,          /*!< in: hash table */
 
145
        hash_table_t*   table,          /* in: hash table */
154
146
#ifdef UNIV_SYNC_DEBUG
155
 
        ulint           sync_level,     /*!< in: latching order level of the
 
147
        ulint           sync_level,     /* in: latching order level of the
156
148
                                        mutexes: used in the debug version */
157
149
#endif /* UNIV_SYNC_DEBUG */
158
 
        ulint           n_mutexes)      /*!< in: number of mutexes, must be a
 
150
        ulint           n_mutexes)      /* in: number of mutexes, must be a
159
151
                                        power of 2 */
160
152
{
161
153
        ulint   i;
171
163
 
172
164
        table->n_mutexes = n_mutexes;
173
165
}
174
 
#endif /* !UNIV_HOTBACKUP */