Drizzled Public API Documentation

ha0ha.h File Reference
#include "univ.i"
#include "hash0hash.h"
#include "page0types.h"
#include "buf0types.h"

Go to the source code of this file.

Classes

struct  ha_node_struct

Macros

#define ha0ha_h
#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_data)
#define ha_create(n_c, n_m, level)   ha_create_func(n_c,n_m)
#define ha_insert_for_fold(t, f, b, d)   ha_insert_for_fold_func(t,f,d)
#define ASSERT_HASH_MUTEX_OWN(table, fold)   ut_ad(!(table)->mutexes || mutex_own(hash_get_mutex(table, fold)))

Typedefs

typedef struct ha_node_struct ha_node_t

Functions

UNIV_INLINE void * ha_search_and_get_data (hash_table_t *table, ulint fold)
UNIV_INTERN void ha_search_and_update_if_found_func (hash_table_t *table, ulint fold, void *data, void *new_data)
UNIV_INTERN hash_table_tha_create_func (ulint n, ulint n_mutexes)
UNIV_INTERN void ha_clear (hash_table_t *table)
UNIV_INTERN ibool ha_insert_for_fold_func (hash_table_t *table, ulint fold, void *data)
UNIV_INLINE ibool ha_search_and_delete_if_found (hash_table_t *table, ulint fold, void *data)
UNIV_INTERN void ha_remove_all_nodes_to_page (hash_table_t *table, ulint fold, const page_t *page)
UNIV_INTERN void ha_print_info (FILE *file, hash_table_t *table)

Detailed Description

The hash table with external chains

Created 8/18/1994 Heikki Tuuri

Definition in file ha0ha.h.

Macro Definition Documentation

#define ASSERT_HASH_MUTEX_OWN (   table,
  fold 
)    ut_ad(!(table)->mutexes || mutex_own(hash_get_mutex(table, fold)))
Assert that the current thread is holding the mutex protecting a

hash bucket corresponding to a fold value.

Parameters
tablein: hash table
foldin: fold value

Definition at line 230 of file ha0ha.h.

Referenced by ha_insert_for_fold_func(), ha_remove_all_nodes_to_page(), and ha_search_and_update_if_found_func().

#define ha_create (   n_c,
  n_m,
  level 
)    ha_create_func(n_c,n_m)
Creates a hash table.
Returns
own: created table
Parameters
n_cin: number of array cells. The actual number of cells is chosen to be a slightly bigger prime number.
levelin: level of the mutexes in the latching order
n_min: number of mutexes to protect the hash table; must be a power of 2, or 0

Definition at line 114 of file ha0ha.h.

Referenced by btr_search_sys_create().

#define ha_insert_for_fold (   t,
  f,
  b,
 
)    ha_insert_for_fold_func(t,f,d)

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
bignored: buffer block containing the data
din: data, must not be NULL

Definition at line 165 of file ha0ha.h.

Referenced by btr_search_update_hash_on_insert().

#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_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_blockignored: block containing new_data
new_datain: new pointer to the data

Definition at line 79 of file ha0ha.h.

Referenced by btr_search_update_hash_node_on_insert().

Typedef Documentation

typedef struct ha_node_struct ha_node_t

The hash table external chain node

Definition at line 213 of file ha0ha.h.

Function Documentation

UNIV_INTERN void ha_clear ( hash_table_t table)

Empties a hash table and frees the memory heaps. in, own: hash table

Empties a hash table and frees the memory heaps.

Parameters
tablein, own: hash table

Definition at line 95 of file ha0ha.cc.

References btr_search_latch, hash_get_n_cells(), hash_get_nth_cell(), hash_table_struct::heaps, mem_heap_free, hash_cell_struct::node, and ut_ad.

UNIV_INTERN hash_table_t* ha_create_func ( ulint  n,
ulint  n_mutexes 
)

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: number of mutexes to protect the hash table: must be a power of 2, or 0

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
Parameters
nin: number of array cells
n_mutexesin: number of mutexes to protect the hash table: must be a power of 2, or 0

Definition at line 43 of file ha0ha.cc.

References hash_table_struct::heaps, mem_heap_create_in_btr_search, ut_a, ut_ad, ut_is_2pow, and ut_min().

UNIV_INTERN ibool ha_insert_for_fold_func ( hash_table_t table,
ulint  fold,
void *  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

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. 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
Parameters
tablein: hash table
foldin: folded value of data; if a node with the same fold value already exists, it is updated to point to the same data, and no new node is created!
datain: data, must not be NULL

Definition at line 133 of file ha0ha.cc.

References ASSERT_HASH_MUTEX_OWN, ha_node_struct::data, ha_node_struct::fold, buf_block_struct::frame, hash_calc_hash(), hash_get_heap(), hash_get_nth_cell(), mem_heap_alloc(), ha_node_struct::next, hash_cell_struct::node, page_align(), ut_a, and ut_ad.

UNIV_INTERN void ha_print_info ( FILE *  file,
hash_table_t table 
)

Prints info of a hash table. in: hash table

Prints info of a hash table.

Parameters
filein: file where to print
tablein: hash table

Definition at line 410 of file ha0ha.cc.

References hash_get_n_cells(), hash_get_nth_cell(), hash_table_struct::heaps, hash_cell_struct::node, ut_ad, and UT_LIST_GET_LEN.

UNIV_INTERN 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

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

Parameters
tablein: hash table
foldin: fold value
pagein: buffer page

Definition at line 314 of file ha0ha.cc.

References ASSERT_HASH_MUTEX_OWN, page_align(), ut_a, and ut_ad.

UNIV_INLINE ibool ha_search_and_delete_if_found ( hash_table_t table,
ulint  fold,
void *  data 
)

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

Returns
TRUE if found in: pointer to the data
Parameters
tablein: hash table
foldin: folded value of the searched data

Referenced by btr_search_update_hash_on_delete().

UNIV_INLINE void* ha_search_and_get_data ( hash_table_t table,
ulint  fold 
)

Looks for an element in a hash table.

Returns
pointer to the data of the first hash table node in chain having the fold number, NULL if not found in: folded value of the searched data
Parameters
tablein: hash table

Referenced by btr_search_guess_on_hash().

UNIV_INTERN void ha_search_and_update_if_found_func ( hash_table_t table,
ulint  fold,
void *  data,
void *  new_data 
)

Looks for an element when we know the pointer to the data and updates the pointer to data 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.

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

Definition at line 271 of file ha0ha.cc.

References ASSERT_HASH_MUTEX_OWN, ha_node_struct::data, page_align(), ut_a, and ut_ad.