25
26
#include "ut0rnd.h"
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 */
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 */
37
38
ut_ad(n < table->n_cells);
39
40
return(table->array + n);
42
/*****************************************************************
43
/*************************************************************//**
43
44
Clears a hash table so that all the cells become empty. */
48
hash_table_t* table) /* in/out: hash table */
49
hash_table_t* table) /*!< in/out: hash table */
50
51
memset(table->array, 0x0,
51
52
table->n_cells * sizeof(*table->array));
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 */
60
/* out: number of cells */
61
hash_table_t* table) /* in: table */
62
hash_table_t* table) /*!< in: table */
63
64
return(table->n_cells);
66
/******************************************************************
67
Calculates the hash value from a folded value. */
67
/**************************************************************//**
68
Calculates the hash value from a folded value.
69
@return hashed value */
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 */
76
77
return(ut_hash_ulint(fold, table->n_cells));
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 */
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 */
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));
94
/****************************************************************
95
Gets the nth heap in a hash table. */
96
/************************************************************//**
97
Gets the nth heap in a hash table.
98
101
hash_get_nth_heap(
99
102
/*==============*/
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 */
104
106
ut_ad(i < table->n_mutexes);
106
108
return(table->heaps[i]);
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.
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 */
127
129
return(hash_get_nth_heap(table, i));
130
/****************************************************************
131
Gets the nth mutex in a hash table. */
132
/************************************************************//**
133
Gets the nth mutex in a hash table.
134
137
hash_get_nth_mutex(
135
138
/*===============*/
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 */
140
142
ut_ad(i < table->n_mutexes);
142
144
return(table->mutexes + i);
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.
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 */