~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/hash0hash.ic

  • Committer: lbieber
  • Date: 2010-10-01 13:06:31 UTC
  • mfrom: (1802.2.2 drizzle-bug-651948)
  • mto: This revision was merged to the branch mainline in revision 1805.
  • Revision ID: lbieber@orisndriz08-20101001130631-xubscnhmj7r5dn6g
Merge Andrew - Fix bug 651948 - Index lengths not retrieved using drizzledump

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (C) 1997, 2009, Innobase Oy. All Rights Reserved.
4
 
 
5
 
This program is free software; you can redistribute it and/or modify it under
6
 
the terms of the GNU General Public License as published by the Free Software
7
 
Foundation; version 2 of the License.
8
 
 
9
 
This program is distributed in the hope that it will be useful, but WITHOUT
10
 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
 
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
 
 
13
 
You should have received a copy of the GNU General Public License along with
14
 
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/**************************************************//**
20
 
@file include/hash0hash.ic
21
 
The simple hash table utility
22
 
 
23
 
Created 5/20/1997 Heikki Tuuri
24
 
*******************************************************/
25
 
 
26
 
#include "ut0rnd.h"
27
 
 
28
 
/************************************************************//**
29
 
Gets the nth cell in a hash table.
30
 
@return pointer to cell */
31
 
UNIV_INLINE
32
 
hash_cell_t*
33
 
hash_get_nth_cell(
34
 
/*==============*/
35
 
        hash_table_t*   table,  /*!< in: hash table */
36
 
        ulint           n)      /*!< in: cell index */
37
 
{
38
 
        ut_ad(table);
39
 
        ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
40
 
        ut_ad(n < table->n_cells);
41
 
 
42
 
        return(table->array + n);
43
 
}
44
 
 
45
 
/*************************************************************//**
46
 
Clears a hash table so that all the cells become empty. */
47
 
UNIV_INLINE
48
 
void
49
 
hash_table_clear(
50
 
/*=============*/
51
 
        hash_table_t*   table)  /*!< in/out: hash table */
52
 
{
53
 
        ut_ad(table);
54
 
        ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
55
 
        memset(table->array, 0x0,
56
 
               table->n_cells * sizeof(*table->array));
57
 
}
58
 
 
59
 
/*************************************************************//**
60
 
Returns the number of cells in a hash table.
61
 
@return number of cells */
62
 
UNIV_INLINE
63
 
ulint
64
 
hash_get_n_cells(
65
 
/*=============*/
66
 
        hash_table_t*   table)  /*!< in: table */
67
 
{
68
 
        ut_ad(table);
69
 
        ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
70
 
        return(table->n_cells);
71
 
}
72
 
 
73
 
/**************************************************************//**
74
 
Calculates the hash value from a folded value.
75
 
@return hashed value */
76
 
UNIV_INLINE
77
 
ulint
78
 
hash_calc_hash(
79
 
/*===========*/
80
 
        ulint           fold,   /*!< in: folded value */
81
 
        hash_table_t*   table)  /*!< in: hash table */
82
 
{
83
 
        ut_ad(table);
84
 
        ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
85
 
        return(ut_hash_ulint(fold, table->n_cells));
86
 
}
87
 
 
88
 
#ifndef UNIV_HOTBACKUP
89
 
/************************************************************//**
90
 
Gets the mutex index for a fold value in a hash table.
91
 
@return mutex number */
92
 
UNIV_INLINE
93
 
ulint
94
 
hash_get_mutex_no(
95
 
/*==============*/
96
 
        hash_table_t*   table,  /*!< in: hash table */
97
 
        ulint           fold)   /*!< in: fold */
98
 
{
99
 
        ut_ad(table);
100
 
        ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
101
 
        ut_ad(ut_is_2pow(table->n_mutexes));
102
 
        return(ut_2pow_remainder(hash_calc_hash(fold, table),
103
 
                                 table->n_mutexes));
104
 
}
105
 
 
106
 
/************************************************************//**
107
 
Gets the nth heap in a hash table.
108
 
@return mem heap */
109
 
UNIV_INLINE
110
 
mem_heap_t*
111
 
hash_get_nth_heap(
112
 
/*==============*/
113
 
        hash_table_t*   table,  /*!< in: hash table */
114
 
        ulint           i)      /*!< in: index of the heap */
115
 
{
116
 
        ut_ad(table);
117
 
        ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
118
 
        ut_ad(i < table->n_mutexes);
119
 
 
120
 
        return(table->heaps[i]);
121
 
}
122
 
 
123
 
/************************************************************//**
124
 
Gets the heap for a fold value in a hash table.
125
 
@return mem heap */
126
 
UNIV_INLINE
127
 
mem_heap_t*
128
 
hash_get_heap(
129
 
/*==========*/
130
 
        hash_table_t*   table,  /*!< in: hash table */
131
 
        ulint           fold)   /*!< in: fold */
132
 
{
133
 
        ulint   i;
134
 
 
135
 
        ut_ad(table);
136
 
        ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
137
 
 
138
 
        if (table->heap) {
139
 
                return(table->heap);
140
 
        }
141
 
 
142
 
        i = hash_get_mutex_no(table, fold);
143
 
 
144
 
        return(hash_get_nth_heap(table, i));
145
 
}
146
 
 
147
 
/************************************************************//**
148
 
Gets the nth mutex in a hash table.
149
 
@return mutex */
150
 
UNIV_INLINE
151
 
mutex_t*
152
 
hash_get_nth_mutex(
153
 
/*===============*/
154
 
        hash_table_t*   table,  /*!< in: hash table */
155
 
        ulint           i)      /*!< in: index of the mutex */
156
 
{
157
 
        ut_ad(table);
158
 
        ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
159
 
        ut_ad(i < table->n_mutexes);
160
 
 
161
 
        return(table->mutexes + i);
162
 
}
163
 
 
164
 
/************************************************************//**
165
 
Gets the mutex for a fold value in a hash table.
166
 
@return mutex */
167
 
UNIV_INLINE
168
 
mutex_t*
169
 
hash_get_mutex(
170
 
/*===========*/
171
 
        hash_table_t*   table,  /*!< in: hash table */
172
 
        ulint           fold)   /*!< in: fold */
173
 
{
174
 
        ulint   i;
175
 
 
176
 
        ut_ad(table);
177
 
        ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
178
 
 
179
 
        i = hash_get_mutex_no(table, fold);
180
 
 
181
 
        return(hash_get_nth_mutex(table, i));
182
 
}
183
 
#endif /* !UNIV_HOTBACKUP */