mariadb/innobase/include/ha0ha.h

148 lines
4.7 KiB
C
Raw Normal View History

/******************************************************
The hash table with external chains
(c) 1994-1997 Innobase Oy
Created 8/18/1994 Heikki Tuuri
*******************************************************/
#ifndef ha0ha_h
#define ha0ha_h
#include "univ.i"
#include "hash0hash.h"
#include "page0types.h"
/*****************************************************************
Looks for an element in a hash table. */
UNIV_INLINE
void*
ha_search_and_get_data(
/*===================*/
/* out: pointer to the data of the first hash
table node in chain having the fold number,
NULL if not found */
hash_table_t* table, /* in: hash table */
ulint fold); /* in: folded value of the searched data */
/*************************************************************
Looks for an element when we know the pointer to the data and updates
the pointer to data if found. */
UNIV_INLINE
void
ha_search_and_update_if_found(
/*==========================*/
hash_table_t* table, /* in: hash table */
ulint fold, /* in: folded value of the searched data */
void* data, /* in: pointer to the data */
void* new_data);/* in: new pointer to the data */
/*****************************************************************
Creates a hash table with >= n array cells. The actual number of cells is
chosen to be a prime number slightly bigger than n. */
hash_table_t*
ha_create(
/*======*/
/* out, own: created table */
ibool in_btr_search, /* in: TRUE if the hash table is used in
the btr_search module */
ulint n, /* in: number of array cells */
ulint n_mutexes, /* in: number of mutexes to protect the
hash table: must be a power of 2 */
ulint mutex_level); /* in: level of the mutexes in the latching
order: this is used in the debug version */
/*****************************************************************
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. */
ibool
ha_insert_for_fold(
/*===============*/
/* out: TRUE if succeed, FALSE if no more
memory could be allocated */
hash_table_t* table, /* in: hash table */
ulint fold, /* in: 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! */
void* data); /* in: data, must not be NULL */
/*****************************************************************
Reserves the necessary hash table mutex and inserts an entry into the hash
table. */
UNIV_INLINE
ibool
ha_insert_for_fold_mutex(
/*=====================*/
/* out: TRUE if succeed, FALSE if no more
memory could be allocated */
hash_table_t* table, /* in: hash table */
ulint fold, /* in: 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! */
void* data); /* in: data, must not be NULL */
/*****************************************************************
Deletes an entry from a hash table. */
void
ha_delete(
/*======*/
hash_table_t* table, /* in: hash table */
ulint fold, /* in: folded value of data */
void* data); /* in: data, must not be NULL and must exist
in the hash table */
/*************************************************************
Looks for an element when we know the pointer to the data and deletes
it from the hash table if found. */
UNIV_INLINE
ibool
ha_search_and_delete_if_found(
/*==========================*/
/* out: TRUE if found */
hash_table_t* table, /* in: hash table */
ulint fold, /* in: folded value of the searched data */
void* data); /* in: pointer to the data */
/*********************************************************************
Removes from the chain determined by fold all nodes whose data pointer
points to the page given. */
void
ha_remove_all_nodes_to_page(
/*========================*/
hash_table_t* table, /* in: hash table */
ulint fold, /* in: fold value */
page_t* page); /* in: buffer page */
/*****************************************************************
Validates a hash table. */
ibool
ha_validate(
/*========*/
/* out: TRUE if ok */
hash_table_t* table); /* in: hash table */
/*****************************************************************
Prints info of a hash table. */
void
ha_print_info(
/*==========*/
Many files: Merge InnoDB-3.23.52b innobase/btr/btr0btr.c: Merge InnoDB-3.23.52b innobase/btr/btr0cur.c: Merge InnoDB-3.23.52b innobase/btr/btr0sea.c: Merge InnoDB-3.23.52b innobase/buf/buf0buf.c: Merge InnoDB-3.23.52b innobase/ha/ha0ha.c: Merge InnoDB-3.23.52b innobase/ibuf/ibuf0ibuf.c: Merge InnoDB-3.23.52b innobase/include/btr0cur.h: Merge InnoDB-3.23.52b innobase/include/buf0buf.h: Merge InnoDB-3.23.52b innobase/include/ha0ha.h: Merge InnoDB-3.23.52b innobase/include/ibuf0ibuf.h: Merge InnoDB-3.23.52b innobase/include/lock0lock.h: Merge InnoDB-3.23.52b innobase/include/log0log.h: Merge InnoDB-3.23.52b innobase/include/os0file.h: Merge InnoDB-3.23.52b innobase/include/rem0rec.ic: Merge InnoDB-3.23.52b innobase/include/srv0srv.h: Merge InnoDB-3.23.52b innobase/include/sync0arr.h: Merge InnoDB-3.23.52b innobase/include/sync0sync.h: Merge InnoDB-3.23.52b innobase/include/trx0trx.h: Merge InnoDB-3.23.52b innobase/lock/lock0lock.c: Merge InnoDB-3.23.52b innobase/log/log0log.c: Merge InnoDB-3.23.52b innobase/os/os0file.c: Merge InnoDB-3.23.52b innobase/row/row0mysql.c: Merge InnoDB-3.23.52b innobase/row/row0umod.c: Merge InnoDB-3.23.52b innobase/row/row0upd.c: Merge InnoDB-3.23.52b innobase/srv/srv0srv.c: Merge InnoDB-3.23.52b innobase/srv/srv0start.c: Merge InnoDB-3.23.52b innobase/sync/sync0arr.c: Merge InnoDB-3.23.52b innobase/sync/sync0sync.c: Merge InnoDB-3.23.52b innobase/trx/trx0trx.c: Merge InnoDB-3.23.52b sql/ha_innobase.h: Merge InnoDB-3.23.52b sql/ha_innobase.cc: Merge InnoDB-3.23.52b sql/sql_lex.h: Merge InnoDB-3.23.52b sql/mysqld.cc: Merge InnoDB-3.23.52b sql/sql_parse.cc: Merge InnoDB-3.23.52b sql/sql_yacc.yy: Merge InnoDB-3.23.52b
2002-07-08 18:34:49 +02:00
char* buf, /* in/out: buffer where to print */
char* buf_end,/* in: buffer end */
hash_table_t* table); /* in: hash table */
/* The hash table external chain node */
typedef struct ha_node_struct ha_node_t;
struct ha_node_struct {
ha_node_t* next; /* next chain node or NULL if none */
void* data; /* pointer to the data */
ulint fold; /* fold value for the data */
};
#ifndef UNIV_NONINL
#include "ha0ha.ic"
#endif
#endif