MySQL 8.0.39
Source Code Documentation
ha0ha.h File Reference

The hash table with external chains. More...

#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...
 

Functions

static const rec_tha_search_and_get_data (hash_table_t *table, uint64_t hash_value)
 Looks for an element in a hash table. More...
 
bool ha_search_and_update_if_found_func (hash_table_t *table, uint64_t hash_value, 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...
 
static bool ha_search_and_update_if_found (hash_table_t *table, uint64_t hash_value, 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 (size_t n, latch_id_t id, size_t n_sync_obj, uint32_t type)
 Creates 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...
 
bool ha_insert_for_hash_func (hash_table_t *table, uint64_t hash_value, buf_block_t *block, const rec_t *data)
 Inserts an entry into a hash table. More...
 
static void ha_insert_for_hash (hash_table_t *t, uint64_t f, buf_block_t *b, const rec_t *d)
 Inserts an entry into a hash table. More...
 
static bool ha_search_and_delete_if_found (hash_table_t *table, uint64_t hash_value, 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_a_node_to_page (hash_table_t *table, uint64_t hash_value, const page_t *page)
 Removes from the chain determined by hash value a single node whose data pointer points to the page given. More...
 
bool ha_validate (hash_table_t *table, uint64_t start_index, uint64_t 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...
 

Detailed Description

The hash table with external chains.

Created 8/18/1994 Heikki Tuuri

Function Documentation

◆ ha_clear()

void ha_clear ( hash_table_t table)

Empties a hash table and frees the memory heaps.

in, own: hash table

Parameters
tablein, own: hash table

◆ ha_insert_for_hash()

static void ha_insert_for_hash ( hash_table_t t,
uint64_t  f,
buf_block_t b,
const rec_t d 
)
inlinestatic

Inserts an entry into a hash table.

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

Parameters
[in]thash table
[in]fhashed value of data
[in]bbuffer block containing the data
[in]ddata, must not be NULL

◆ ha_insert_for_hash_func()

bool ha_insert_for_hash_func ( hash_table_t table,
uint64_t  hash_value,
buf_block_t block,
const rec_t data 
)

Inserts an entry into a hash table.

If an entry with the same hash 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.

Parameters
[in]tablehash table
[in]hash_valuehashed value of data; if a node with the same hash value already exists, it is updated to point to the same data, and no new node is created!
[in]blockbuffer block containing the data
[in]datadata, must not be NULL
Returns
true if succeeded, 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.

Parameters
[in]fileFile where to print
[in]tableHash table

◆ ha_remove_a_node_to_page()

void ha_remove_a_node_to_page ( hash_table_t table,
uint64_t  hash_value,
const page_t page 
)

Removes from the chain determined by hash value a single node whose data pointer points to the page given.

Note that the node deleted can have a different hash value.

Parameters
[in]tableHash table
[in]hash_valueHash value
[in]pageBuffer page

◆ ha_search_and_delete_if_found()

static bool ha_search_and_delete_if_found ( hash_table_t table,
uint64_t  hash_value,
const rec_t data 
)
inlinestatic

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]hash_valuehashed value of the searched data
[in]datapointer to the data
Returns
true if found

◆ ha_search_and_get_data()

static const rec_t * ha_search_and_get_data ( hash_table_t table,
uint64_t  hash_value 
)
inlinestatic

Looks for an element in a hash table.

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

◆ ha_search_and_update_if_found()

static bool ha_search_and_update_if_found ( hash_table_t table,
uint64_t  hash_value,
const rec_t data,
buf_block_t new_block,
const rec_t new_data 
)
inlinestatic

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
hash_valuein: hashed value of the searched data
datain: pointer to the data
new_blockin: block containing new_data
new_datain: new pointer to the data

◆ ha_search_and_update_if_found_func()

bool ha_search_and_update_if_found_func ( hash_table_t table,
uint64_t  hash_value,
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.

Parameters
[in,out]tablehash table
[in]hash_valuehashed value of the searched data
[in]datapointer to the data
[in]new_blockblock containing new data
[in]new_datanew pointer to the data
Returns
true if found

◆ ha_validate()

bool ha_validate ( hash_table_t table,
uint64_t  start_index,
uint64_t  end_index 
)

Validates a given range of the cells in hash table.

Parameters
[in]tableHash table
[in]start_indexStart index
[in]end_indexEnd index
Returns
true if ok

◆ ib_create()

hash_table_t * ib_create ( size_t  n,
latch_id_t  id,
size_t  n_sync_obj,
uint32_t  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.

Parameters
[in]nnumber of array cells
[in]idlatch ID
[in]n_sync_objNumber of sync objects protecting the hash table. Must be a power of 2, or 0.
[in]typetype of datastructure for which the memory heap is going to be used: MEM_HEAP_FOR_BTR_SEARCH or MEM_HEAP_FOR_PAGE_HASH
Returns
own: created table