~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2009-08-12 06:25:19 UTC
  • mto: (1114.1.1 innodb-plugin-merge)
  • mto: This revision was merged to the branch mainline in revision 1183.
  • Revision ID: mordred@inaugust.com-20090812062519-cij02mrrunvnxblt
Tags: innodb-plugin-1.0.4
InnoDB Plugin 1.0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
*****************************************************************************/
18
18
 
19
 
/******************************************************
 
19
/**************************************************//**
 
20
@file include/hash0hash.ic
20
21
The simple hash table utility
21
22
 
22
23
Created 5/20/1997 Heikki Tuuri
24
25
 
25
26
#include "ut0rnd.h"
26
27
 
27
 
/****************************************************************
28
 
Gets the nth cell in a hash table. */
 
28
/************************************************************//**
 
29
Gets the nth cell in a hash table.
 
30
@return pointer to cell */
29
31
UNIV_INLINE
30
32
hash_cell_t*
31
33
hash_get_nth_cell(
32
34
/*==============*/
33
 
                                /* out: pointer to cell */
34
 
        hash_table_t*   table,  /* in: hash table */
35
 
        ulint           n)      /* in: cell index */
 
35
        hash_table_t*   table,  /*!< in: hash table */
 
36
        ulint           n)      /*!< in: cell index */
36
37
{
37
38
        ut_ad(n < table->n_cells);
38
39
 
39
40
        return(table->array + n);
40
41
}
41
42
 
42
 
/*****************************************************************
 
43
/*************************************************************//**
43
44
Clears a hash table so that all the cells become empty. */
44
45
UNIV_INLINE
45
46
void
46
47
hash_table_clear(
47
48
/*=============*/
48
 
        hash_table_t*   table)  /* in/out: hash table */
 
49
        hash_table_t*   table)  /*!< in/out: hash table */
49
50
{
50
51
        memset(table->array, 0x0,
51
52
               table->n_cells * sizeof(*table->array));
52
53
}
53
54
 
54
 
/*****************************************************************
55
 
Returns the number of cells in a hash table. */
 
55
/*************************************************************//**
 
56
Returns the number of cells in a hash table.
 
57
@return number of cells */
56
58
UNIV_INLINE
57
59
ulint
58
60
hash_get_n_cells(
59
61
/*=============*/
60
 
                                /* out: number of cells */
61
 
        hash_table_t*   table)  /* in: table */
 
62
        hash_table_t*   table)  /*!< in: table */
62
63
{
63
64
        return(table->n_cells);
64
65
}
65
66
 
66
 
/******************************************************************
67
 
Calculates the hash value from a folded value. */
 
67
/**************************************************************//**
 
68
Calculates the hash value from a folded value.
 
69
@return hashed value */
68
70
UNIV_INLINE
69
71
ulint
70
72
hash_calc_hash(
71
73
/*===========*/
72
 
                                /* out: hashed value */
73
 
        ulint           fold,   /* in: folded value */
74
 
        hash_table_t*   table)  /* in: hash table */
 
74
        ulint           fold,   /*!< in: folded value */
 
75
        hash_table_t*   table)  /*!< in: hash table */
75
76
{
76
77
        return(ut_hash_ulint(fold, table->n_cells));
77
78
}
78
79
 
79
 
/****************************************************************
80
 
Gets the mutex index for a fold value in a hash table. */
 
80
#ifndef UNIV_HOTBACKUP
 
81
/************************************************************//**
 
82
Gets the mutex index for a fold value in a hash table.
 
83
@return mutex number */
81
84
UNIV_INLINE
82
85
ulint
83
86
hash_get_mutex_no(
84
87
/*==============*/
85
 
                                /* out: mutex number */
86
 
        hash_table_t*   table,  /* in: hash table */
87
 
        ulint           fold)   /* in: fold */
 
88
        hash_table_t*   table,  /*!< in: hash table */
 
89
        ulint           fold)   /*!< in: fold */
88
90
{
89
91
        ut_ad(ut_is_2pow(table->n_mutexes));
90
92
        return(ut_2pow_remainder(hash_calc_hash(fold, table),
91
93
                                 table->n_mutexes));
92
94
}
93
95
 
94
 
/****************************************************************
95
 
Gets the nth heap in a hash table. */
 
96
/************************************************************//**
 
97
Gets the nth heap in a hash table.
 
98
@return mem heap */
96
99
UNIV_INLINE
97
100
mem_heap_t*
98
101
hash_get_nth_heap(
99
102
/*==============*/
100
 
                                /* out: mem heap */
101
 
        hash_table_t*   table,  /* in: hash table */
102
 
        ulint           i)      /* in: index of the heap */
 
103
        hash_table_t*   table,  /*!< in: hash table */
 
104
        ulint           i)      /*!< in: index of the heap */
103
105
{
104
106
        ut_ad(i < table->n_mutexes);
105
107
 
106
108
        return(table->heaps[i]);
107
109
}
108
110
 
109
 
/****************************************************************
110
 
Gets the heap for a fold value in a hash table. */
 
111
/************************************************************//**
 
112
Gets the heap for a fold value in a hash table.
 
113
@return mem heap */
111
114
UNIV_INLINE
112
115
mem_heap_t*
113
116
hash_get_heap(
114
117
/*==========*/
115
 
                                /* out: mem heap */
116
 
        hash_table_t*   table,  /* in: hash table */
117
 
        ulint           fold)   /* in: fold */
 
118
        hash_table_t*   table,  /*!< in: hash table */
 
119
        ulint           fold)   /*!< in: fold */
118
120
{
119
121
        ulint   i;
120
122
 
127
129
        return(hash_get_nth_heap(table, i));
128
130
}
129
131
 
130
 
/****************************************************************
131
 
Gets the nth mutex in a hash table. */
 
132
/************************************************************//**
 
133
Gets the nth mutex in a hash table.
 
134
@return mutex */
132
135
UNIV_INLINE
133
136
mutex_t*
134
137
hash_get_nth_mutex(
135
138
/*===============*/
136
 
                                /* out: mutex */
137
 
        hash_table_t*   table,  /* in: hash table */
138
 
        ulint           i)      /* in: index of the mutex */
 
139
        hash_table_t*   table,  /*!< in: hash table */
 
140
        ulint           i)      /*!< in: index of the mutex */
139
141
{
140
142
        ut_ad(i < table->n_mutexes);
141
143
 
142
144
        return(table->mutexes + i);
143
145
}
144
146
 
145
 
/****************************************************************
146
 
Gets the mutex for a fold value in a hash table. */
 
147
/************************************************************//**
 
148
Gets the mutex for a fold value in a hash table.
 
149
@return mutex */
147
150
UNIV_INLINE
148
151
mutex_t*
149
152
hash_get_mutex(
150
153
/*===========*/
151
 
                                /* out: mutex */
152
 
        hash_table_t*   table,  /* in: hash table */
153
 
        ulint           fold)   /* in: fold */
 
154
        hash_table_t*   table,  /*!< in: hash table */
 
155
        ulint           fold)   /*!< in: fold */
154
156
{
155
157
        ulint   i;
156
158
 
158
160
 
159
161
        return(hash_get_nth_mutex(table, i));
160
162
}
 
163
#endif /* !UNIV_HOTBACKUP */