MySQL 8.0.40
Source Code Documentation
ha0ha.cc File Reference

The hash table with external chains. More...

#include "ha0ha.h"
#include <sys/types.h>
#include "buf0buf.h"
#include "btr0sea.h"
#include "page0page.h"

Macros

#define PRINT_USED_CELLS
 

Functions

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...
 
static void ha_btr_search_latch_x_locked (const hash_table_t *table)
 Verify if latch corresponding to the hash table is x-latched. 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...
 
void ha_delete_hash_node (hash_table_t *table, ha_node_t *del_node)
 Deletes a hash node. 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...
 
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/22/1994 Heikki Tuuri

Macro Definition Documentation

◆ PRINT_USED_CELLS

#define PRINT_USED_CELLS

Function Documentation

◆ ha_btr_search_latch_x_locked()

static void ha_btr_search_latch_x_locked ( const hash_table_t table)
static

Verify if latch corresponding to the hash table is x-latched.

Parameters
[in]tablehash table

◆ 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_delete_hash_node()

void ha_delete_hash_node ( hash_table_t table,
ha_node_t del_node 
)

Deletes a hash node.

in: node to be deleted

Parameters
tablein: hash table
del_nodein: node to be deleted

◆ 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_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