MySQL 8.0.39
Source Code Documentation
|
The simple hash table utility. More...
#include <stddef.h>
#include "mem0mem.h"
#include "univ.i"
#include "ut0rnd.h"
#include "sync0rw.h"
#include "hash0hash.ic"
Go to the source code of this file.
Classes | |
struct | hash_cell_t |
class | hash_table_t |
Macros | |
#define | HASH_INSERT(TYPE, NAME, TABLE, HASH_VALUE, DATA) |
Inserts a struct to a hash table. More... | |
#define | HASH_ASSERT_VALID(DATA) |
#define | HASH_INVALIDATE(DATA, NAME) |
#define | HASH_DELETE(TYPE, NAME, TABLE, HASH_VALUE, DATA) |
Deletes a struct from a hash table. More... | |
#define | HASH_GET_NEXT(NAME, DATA) ((DATA)->NAME) |
Gets the next struct in a hash chain, NULL if none. More... | |
#define | HASH_SEARCH(NAME, TABLE, HASH_VALUE, TYPE, DATA, ASSERTION, TEST) |
Looks for a struct in a hash table. More... | |
#define | HASH_SEARCH_ALL(NAME, TABLE, TYPE, DATA, ASSERTION, TEST) |
Looks for an item in all hash cells. More... | |
#define | HASH_DELETE_AND_COMPACT(TYPE, NAME, TABLE, NODE) |
Deletes a struct which is stored in the heap of the hash table, and compacts the heap. More... | |
#define | HASH_MIGRATE(OLD_TABLE, NEW_TABLE, NODE_TYPE, PTR_NAME, HASH_FUNC) |
Move all hash table entries from OLD_TABLE to NEW_TABLE. More... | |
Typedefs | |
typedef void * | hash_node_t |
Enumerations | |
enum | hash_table_sync_t { HASH_TABLE_SYNC_NONE = 0 , HASH_TABLE_SYNC_RW_LOCK } |
Functions | |
void | hash_create_sync_obj (hash_table_t *table, latch_id_t id, size_t n_sync_obj) |
Creates a sync object array to protect a hash table. More... | |
static uint64_t | hash_calc_cell_id (uint64_t hash_value, hash_table_t *table) |
Calculates the cell index from a hashed value for a specified hash table. More... | |
static hash_cell_t * | hash_get_nth_cell (hash_table_t *table, size_t n) |
Gets the nth cell in a hash table. More... | |
static void *& | hash_get_first (hash_table_t *table, size_t cell_id) |
Gets the first struct in a hash chain, NULL if none. More... | |
static void | hash_table_clear (hash_table_t *table) |
Clears a hash table so that all the cells become empty. More... | |
static size_t | hash_get_n_cells (hash_table_t *table) |
Returns the number of cells in a hash table. More... | |
static uint64_t | hash_get_sync_obj_index (hash_table_t *table, uint64_t hash_value) |
Gets the sync object index for a hash value in a hash table. More... | |
static mem_heap_t * | hash_get_heap (hash_table_t *table) |
Gets the heap for a hash value in a hash table. More... | |
static rw_lock_t * | hash_get_nth_lock (hash_table_t *table, size_t i) |
Gets the nth rw_lock in a hash table. More... | |
static rw_lock_t * | hash_get_lock (hash_table_t *table, uint64_t hash_value) |
Gets the rw_lock for a hash value in a hash table. More... | |
static rw_lock_t * | hash_lock_s_confirm (rw_lock_t *hash_lock, hash_table_t *table, uint64_t hash_value) |
If not appropriate rw_lock for a hash value in a hash table, relock S-lock the another rw_lock until appropriate for a hash value. More... | |
static rw_lock_t * | hash_lock_x_confirm (rw_lock_t *hash_lock, hash_table_t *table, uint64_t hash_value) |
If not appropriate rw_lock for a hash value in a hash table, relock X-lock the another rw_lock until appropriate for a hash value. More... | |
bool | hash_lock_has_all_x (const hash_table_t *table) |
Verifies that the current thread holds X-latch on all shards. More... | |
void | hash_lock_x_all (hash_table_t *table) |
Reserves all the locks of a hash table, in an ascending order. More... | |
void | hash_unlock_x_all (hash_table_t *table) |
Releases all the locks of a hash table, in an ascending order. More... | |
void | hash_unlock_x_all_but (hash_table_t *table, rw_lock_t *keep_lock) |
Releases all but passed in lock of a hash table,. More... | |
The simple hash table utility.
Created 5/20/1997 Heikki Tuuri
#define HASH_ASSERT_VALID | ( | DATA | ) |
Deletes a struct from a hash table.
Deletes a struct which is stored in the heap of the hash table, and compacts the heap.
The hash value must be stored in the struct NODE in a field named 'hash_value'.
Gets the next struct in a hash chain, NULL if none.
Inserts a struct to a hash table.
#define HASH_INVALIDATE | ( | DATA, | |
NAME | |||
) |
#define HASH_MIGRATE | ( | OLD_TABLE, | |
NEW_TABLE, | |||
NODE_TYPE, | |||
PTR_NAME, | |||
HASH_FUNC | |||
) |
Move all hash table entries from OLD_TABLE to NEW_TABLE.
Looks for a struct in a hash table.
Looks for an item in all hash cells.
typedef void* hash_node_t |
enum hash_table_sync_t |
|
inlinestatic |
Calculates the cell index from a hashed value for a specified hash table.
[in] | hash_value | hashed value |
[in] | table | hash table |
void hash_create_sync_obj | ( | hash_table_t * | table, |
latch_id_t | id, | ||
size_t | n_sync_obj | ||
) |
Creates a sync object array to protect a hash table.
[in] | table | hash table |
[in] | id | latch ID |
[in] | n_sync_obj | number of sync objects, must be a power of 2 |
|
inlinestatic |
Gets the first struct in a hash chain, NULL if none.
|
inlinestatic |
Gets the heap for a hash value in a hash table.
[in] | table | hash table |
|
inlinestatic |
Gets the rw_lock for a hash value in a hash table.
[in] | table | hash table |
[in] | hash_value | hash value |
|
inlinestatic |
Returns the number of cells in a hash table.
|
inlinestatic |
Gets the nth cell in a hash table.
[in] | table | hash table |
[in] | n | cell index |
|
inlinestatic |
Gets the nth rw_lock in a hash table.
[in] | table | hash table |
[in] | i | index of the rw_lock |
|
inlinestatic |
Gets the sync object index for a hash value in a hash table.
[in] | table | hash table |
[in] | hash_value | hash value |
bool hash_lock_has_all_x | ( | const hash_table_t * | table | ) |
Verifies that the current thread holds X-latch on all shards.
Assumes type==HASH_TABLE_SYNC_RW_LOCK.
[in] | table | the table in question |
|
inlinestatic |
If not appropriate rw_lock for a hash value in a hash table, relock S-lock the another rw_lock until appropriate for a hash value.
[in] | hash_lock | latched rw_lock to be confirmed |
[in] | table | hash table |
[in] | hash_value | hash value |
void hash_lock_x_all | ( | hash_table_t * | table | ) |
Reserves all the locks of a hash table, in an ascending order.
in: hash table
table | in: hash table |
|
inlinestatic |
If not appropriate rw_lock for a hash value in a hash table, relock X-lock the another rw_lock until appropriate for a hash value.
[in] | hash_lock | latched rw_lock to be confirmed |
[in] | table | hash table |
[in] | hash_value | hash value |
|
inlinestatic |
Clears a hash table so that all the cells become empty.
in/out: hash table
void hash_unlock_x_all | ( | hash_table_t * | table | ) |
Releases all the locks of a hash table, in an ascending order.
in: hash table
table | in: hash table |
void hash_unlock_x_all_but | ( | hash_table_t * | table, |
rw_lock_t * | keep_lock | ||
) |
Releases all but passed in lock of a hash table,.
[in] | table | Hash table |
[in] | keep_lock | Lock to keep |
table | in: hash table |
keep_lock | in: lock to keep |