MySQL  8.0.19
Source Code Documentation
ha0ha.h File Reference
#include "univ.i"
#include "buf0types.h"
#include "hash0hash.h"
#include "page0types.h"
#include "rem0types.h"
#include "ha0ha.ic"

Go to the source code of this file.

Classes

struct  ha_node_t
 The hash table external chain node. More...
 

Macros

#define ha_search_and_update_if_found(table, fold, data, new_block, new_data)   ha_search_and_update_if_found_func(table, fold, data, new_block, new_data)
 Looks for an element when we know the pointer to the data and updates the pointer to data if found. More...
 
#define ha_insert_for_fold(t, f, b, d)
 Inserts an entry into a hash table. More...
 

Functions

const UNIV_INLINE rec_tha_search_and_get_data (hash_table_t *table, ulint fold)
 Looks for an element in a hash table. More...
 
ibool ha_search_and_update_if_found_func (hash_table_t *table, ulint fold, const rec_t *data, buf_block_t *new_block, const rec_t *new_data)
 Looks for an element when we know the pointer to the data and updates the pointer to data if found. More...
 
hash_table_tib_create (ulint n, latch_id_t id, ulint n_mutexes, ulint type)
 Creates a hash table with at least n array cells. More...
 
hash_table_tib_recreate (hash_table_t *table, ulint n)
 Recreate a hash table with at least n array cells. More...
 
void ha_clear (hash_table_t *table)
 Empties a hash table and frees the memory heaps. More...
 
ibool ha_insert_for_fold_func (hash_table_t *table, ulint fold, buf_block_t *block, const rec_t *data)
 Inserts an entry into a hash table. More...
 
UNIV_INLINE ibool ha_search_and_delete_if_found (hash_table_t *table, ulint fold, const rec_t *data)
 Looks for an element when we know the pointer to the data and deletes it from the hash table if found. More...
 
void ha_remove_all_nodes_to_page (hash_table_t *table, ulint fold, const page_t *page)
 Removes from the chain determined by fold all nodes whose data pointer points to the page given. More...
 
ibool ha_validate (hash_table_t *table, ulint start_index, ulint end_index)
 Validates a given range of the cells in hash table. More...
 
void ha_print_info (FILE *file, hash_table_t *table)
 Prints info of a hash table. More...
 
UNIV_INLINE void hash_assert_can_modify (hash_table_t *table, ulint fold)
 Assert that the synchronization object in a hash operation involving possible change in the hash table is held. More...
 
UNIV_INLINE void hash_assert_can_search (hash_table_t *table, ulint fold)
 Assert that the synchronization object in a hash search operation is held. More...
 

Detailed Description

The hash table with external chains

Created 8/18/1994 Heikki Tuuri

Macro Definition Documentation

◆ ha_insert_for_fold

#define ha_insert_for_fold (   t,
  f,
  b,
 
)
Value:
do { \
ha_insert_for_fold_func(t, f, b, d); \
} while (0)

Inserts an entry into a hash table.

If an entry with the same fold number is found, its node is updated to point to the new data, and no new node is inserted.

Returns
true if succeed, false if no more memory could be allocated
Parameters
tin: hash table
fin: folded value of data
bin: buffer block containing the data
din: data, must not be NULL

◆ ha_search_and_update_if_found

#define ha_search_and_update_if_found (   table,
  fold,
  data,
  new_block,
  new_data 
)    ha_search_and_update_if_found_func(table, fold, data, new_block, new_data)

Looks for an element when we know the pointer to the data and updates the pointer to data if found.

Parameters
tablein/out: hash table
foldin: folded value of the searched data
datain: pointer to the data
new_blockin: block containing new_data
new_datain: new pointer to the data

Function Documentation

◆ ha_clear()

void ha_clear ( hash_table_t table)

Empties a hash table and frees the memory heaps.

in, own: hash table

◆ ha_insert_for_fold_func()

ibool ha_insert_for_fold_func ( hash_table_t table,
ulint  fold,
buf_block_t block,
const rec_t data 
)

Inserts an entry into a hash table.

If an entry with the same fold number is found, its node is updated to point to the new data, and no new node is inserted.

Returns
true if succeed, false if no more memory could be allocated in: data, must not be NULL

If an entry with the same fold number is found, its node is updated to point to the new data, and no new node is inserted. If btr_search_enabled is set to FALSE, we will only allow updating existing nodes, but no new node is allowed to be added.

Returns
true if succeed, false if no more memory could be allocated

◆ ha_print_info()

void ha_print_info ( FILE *  file,
hash_table_t table 
)

Prints info of a hash table.

in: hash table

Parameters
filein: file where to print

◆ ha_remove_all_nodes_to_page()

void ha_remove_all_nodes_to_page ( hash_table_t table,
ulint  fold,
const page_t page 
)

Removes from the chain determined by fold all nodes whose data pointer points to the page given.

in: buffer page

Parameters
tablein: hash table
foldin: fold value

◆ ha_search_and_delete_if_found()

UNIV_INLINE ibool ha_search_and_delete_if_found ( hash_table_t table,
ulint  fold,
const rec_t data 
)

Looks for an element when we know the pointer to the data and deletes it from the hash table if found.

Parameters
[in]tablehash table
[in]foldfolded value of the searched data
[in]datapointer to the data
Returns
true if found

◆ ha_search_and_get_data()

const UNIV_INLINE rec_t* ha_search_and_get_data ( hash_table_t table,
ulint  fold 
)

Looks for an element in a hash table.

Parameters
[in]tablehash table
[in]foldfolded value of the searched data
Returns
pointer to the data of the first hash table node in chain having the fold number, NULL if not found

◆ ha_search_and_update_if_found_func()

ibool ha_search_and_update_if_found_func ( hash_table_t table,
ulint  fold,
const rec_t data,
buf_block_t new_block,
const rec_t new_data 
)

Looks for an element when we know the pointer to the data and updates the pointer to data if found.

Returns
true if found in: new pointer to the data

Looks for an element when we know the pointer to the data and updates the pointer to data if found.

Returns
true if found

◆ ha_validate()

ibool ha_validate ( hash_table_t table,
ulint  start_index,
ulint  end_index 
)

Validates a given range of the cells in hash table.

Returns
true if ok in: end index
true if ok

◆ hash_assert_can_modify()

UNIV_INLINE void hash_assert_can_modify ( hash_table_t table,
ulint  fold 
)

Assert that the synchronization object in a hash operation involving possible change in the hash table is held.

Note that in case of mutexes we assert that mutex is owned while in case of rw-locks we assert that it is held in exclusive mode.

Parameters
[in]tablehash table
[in]foldfold value

◆ hash_assert_can_search()

UNIV_INLINE void hash_assert_can_search ( hash_table_t table,
ulint  fold 
)

Assert that the synchronization object in a hash search operation is held.

Note that in case of mutexes we assert that mutex is owned while in case of rw-locks we assert that it is held either in x-mode or s-mode.

Parameters
[in]tablehash table
[in]foldfold value

◆ ib_create()

hash_table_t* ib_create ( ulint  n,
latch_id_t  id,
ulint  n_sync_obj,
ulint  type 
)

Creates a hash table with at least n array cells.

The actual number of cells is chosen to be a prime number slightly bigger than n.

Returns
own: created table in: type of datastructure for which the memory heap is going to be used e.g.: MEM_HEAP_FOR_BTR_SEARCH or MEM_HEAP_FOR_PAGE_HASH

The actual number of cells is chosen to be a prime number slightly bigger than n.

Returns
own: created table

◆ ib_recreate()

hash_table_t* ib_recreate ( hash_table_t table,
ulint  n 
)

Recreate a hash table with at least n array cells.

The actual number of cells is chosen to be a prime number slightly bigger than n. The new cells are all cleared. The heaps are recreated. The sync objects are reused.

Parameters
[in,out]tablehash table to be resuzed (to be freed later)
[in]nnumber of array cells
Returns
resized new table
MONITOR_ADAPTIVE_HASH_ROW_ADDED
@ MONITOR_ADAPTIVE_HASH_ROW_ADDED
Definition: srv0mon.h:424