MySQL  8.0.19
Source Code Documentation
innodb_utility.h File Reference
#include "api0api.h"
#include "config.h"

Go to the source code of this file.

Classes

struct  hash_cell_struct
 
struct  hash_table_struct
 

Macros

#define UT_LIST_NODE_T(TYPE)
 
#define UT_LIST_BASE_NODE_T(TYPE)
 
#define UT_LIST_INIT(BASE)
 Some Macros to manipulate the list, extracted from "ut0lst.h". More...
 
#define UT_LIST_ADD_LAST(NAME, BASE, N)
 
#define UT_LIST_ADD_FIRST(NAME, BASE, N)
 
#define UT_LIST_REMOVE_CLEAR(NAME, N)
 
#define UT_LIST_REMOVE(NAME, BASE, N)
 Removes a node from a linked list. More...
 
#define UT_LIST_GET_NEXT(NAME, N)   (((N)->NAME).next)
 
#define UT_LIST_GET_LEN(BASE)   (BASE).count
 
#define UT_LIST_GET_FIRST(BASE)   (BASE).start
 
#define HASH_INSERT(TYPE, NAME, TABLE, FOLD, DATA)
 
#define HASH_GET_FIRST(TABLE, HASH_VAL)   (hash_get_nth_cell(TABLE, HASH_VAL)->node)
 Gets the first struct in a hash chain, NULL if none. More...
 
#define HASH_GET_NEXT(NAME, DATA)   ((DATA)->NAME)
 Gets the next struct in a hash chain, NULL if none. More...
 
#define HASH_SEARCH(NAME, TABLE, FOLD, TYPE, DATA, TEST)
 Looks for a struct in a hash table. More...
 
#define HASH_CLEANUP(TABLE, TYPE)
 Cleanup items in a hash table. More...
 

Typedefs

typedef struct hash_cell_struct hash_cell_t
 
typedef struct hash_table_struct hash_table_t
 

Functions

ib_ulint_t ut_fold_string (const char *str)
 Folds a character string ending in the null character. More...
 
hash_cell_thash_get_nth_cell (hash_table_t *table, ib_ulint_t n)
 Gets the nth cell in a hash table. More...
 
hash_table_thash_create (ib_ulint_t n)
 Creates a hash table with >= n array cells. More...
 
ib_ulint_t hash_calc_hash (ib_ulint_t fold, hash_table_t *table)
 Calculates the hash value from a folded value. More...
 

Detailed Description

Created 03/15/2011 Jimmy Yang (most macros and defines are adopted from utility files in the InnoDB. Namely ut/ut0lst.h, ut0rnd.h and hash0hash.h etc.)

Macro Definition Documentation

◆ HASH_CLEANUP

#define HASH_CLEANUP (   TABLE,
  TYPE 
)
Value:
do { \
ib_ulint_t i; \
TYPE data; \
for (i = 0; i < TABLE->n_cells; i++) { \
data = (TYPE)HASH_GET_FIRST(TABLE, i); \
while (data) { \
TYPE next_data; \
next_data = (TYPE)HASH_GET_NEXT(name_hash, data); \
innodb_config_free(data); \
free(data); \
data = next_data; \
} \
} \
free(TABLE->array); \
free(TABLE); \
} while (0)

Cleanup items in a hash table.

◆ HASH_GET_FIRST

#define HASH_GET_FIRST (   TABLE,
  HASH_VAL 
)    (hash_get_nth_cell(TABLE, HASH_VAL)->node)

Gets the first struct in a hash chain, NULL if none.

◆ HASH_GET_NEXT

#define HASH_GET_NEXT (   NAME,
  DATA 
)    ((DATA)->NAME)

Gets the next struct in a hash chain, NULL if none.

◆ HASH_INSERT

#define HASH_INSERT (   TYPE,
  NAME,
  TABLE,
  FOLD,
  DATA 
)
Value:
do { \
hash_cell_t *cell3333; \
TYPE *struct3333; \
\
(DATA)->NAME = NULL; \
\
if (cell3333->node == NULL) { \
cell3333->node = DATA; \
} else { \
struct3333 = (TYPE *)cell3333->node; \
\
while (struct3333->NAME != NULL) { \
struct3333 = (TYPE *)struct3333->NAME; \
} \
\
struct3333->NAME = DATA; \
} \
} while (0)

◆ HASH_SEARCH

#define HASH_SEARCH (   NAME,
  TABLE,
  FOLD,
  TYPE,
  DATA,
  TEST 
)
Value:
{ \
(DATA) = (TYPE)HASH_GET_FIRST(TABLE, hash_calc_hash(FOLD, TABLE)); \
while ((DATA) != NULL) { \
if (TEST) { \
break; \
} else { \
(DATA) = (TYPE)HASH_GET_NEXT(NAME, DATA); \
} \
} \
}

Looks for a struct in a hash table.

◆ UT_LIST_ADD_FIRST

#define UT_LIST_ADD_FIRST (   NAME,
  BASE,
 
)
Value:
{ \
((BASE).count)++; \
((N)->NAME).next = (BASE).start; \
((N)->NAME).prev = NULL; \
if (UNIV_LIKELY((BASE).start != NULL)) { \
(((BASE).start)->NAME).prev = (N); \
} \
(BASE).start = (N); \
if (UNIV_UNLIKELY((BASE).end == NULL)) { \
(BASE).end = (N); \
} \
}

◆ UT_LIST_ADD_LAST

#define UT_LIST_ADD_LAST (   NAME,
  BASE,
 
)
Value:
{ \
((BASE).count)++; \
((N)->NAME).prev = (BASE).end; \
((N)->NAME).next = NULL; \
if ((BASE).end != NULL) { \
(((BASE).end)->NAME).next = (N); \
} \
(BASE).end = (N); \
if ((BASE).start == NULL) { \
(BASE).start = (N); \
} \
}

◆ UT_LIST_BASE_NODE_T

#define UT_LIST_BASE_NODE_T (   TYPE)
Value:
struct { \
int count; /*!< count of nodes in list */ \
TYPE *start; /*!< pointer to list start, NULL if empty */ \
TYPE *end; /*!< pointer to list end, NULL if empty */ \
}

◆ UT_LIST_GET_FIRST

#define UT_LIST_GET_FIRST (   BASE)    (BASE).start

◆ UT_LIST_GET_LEN

#define UT_LIST_GET_LEN (   BASE)    (BASE).count

◆ UT_LIST_GET_NEXT

#define UT_LIST_GET_NEXT (   NAME,
 
)    (((N)->NAME).next)

◆ UT_LIST_INIT

#define UT_LIST_INIT (   BASE)
Value:
{ \
(BASE).count = 0; \
(BASE).start = NULL; \
(BASE).end = NULL; \
}

Some Macros to manipulate the list, extracted from "ut0lst.h".

◆ UT_LIST_NODE_T

#define UT_LIST_NODE_T (   TYPE)
Value:
struct { \
TYPE *prev; /*!< pointer to the previous node, \
NULL if start of list */ \
TYPE *next; /*!< pointer to next node, NULL if end of list */ \
}

◆ UT_LIST_REMOVE

#define UT_LIST_REMOVE (   NAME,
  BASE,
 
)
Value:
do { \
((BASE).count)--; \
if (((N)->NAME).next != NULL) { \
((((N)->NAME).next)->NAME).prev = ((N)->NAME).prev; \
} else { \
(BASE).end = ((N)->NAME).prev; \
} \
if (((N)->NAME).prev != NULL) { \
((((N)->NAME).prev)->NAME).next = ((N)->NAME).next; \
} else { \
(BASE).start = ((N)->NAME).next; \
} \
UT_LIST_REMOVE_CLEAR(NAME, N); \
} while (0)

Removes a node from a linked list.

◆ UT_LIST_REMOVE_CLEAR

#define UT_LIST_REMOVE_CLEAR (   NAME,
 
)
Value:
((N)->NAME.prev = (N)->NAME.next = \
reinterpret_cast<decltype((N)->NAME.next)>(-1))

Typedef Documentation

◆ hash_cell_t

typedef struct hash_cell_struct hash_cell_t

◆ hash_table_t

Function Documentation

◆ hash_calc_hash()

ib_ulint_t hash_calc_hash ( ib_ulint_t  fold,
hash_table_t table 
)

Calculates the hash value from a folded value.

Returns
hashed value in: hash table
hashed value

◆ hash_create()

hash_table_t* hash_create ( ib_ulint_t  n)

Creates a hash table with >= 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 array cells

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

Returns
own: created table

◆ hash_get_nth_cell()

hash_cell_t* hash_get_nth_cell ( hash_table_t table,
ib_ulint_t  n 
)

Gets the nth cell in a hash table.

Returns
pointer to cell in: cell index
pointer to cell

◆ ut_fold_string()

ib_ulint_t ut_fold_string ( const char *  str)

Folds a character string ending in the null character.

Extracted from ut0rnd.h and ut0rnd.ic.

Returns
folded value in: null-terminated string
folded value
NULL
#define NULL
Definition: types.h:55
free
#define free(A)
Definition: fts0ast.h:42
TABLE
Definition: table.h:1305
Counter::N
std::atomic< Type > N
Definition: ut0counter.h:230
HASH_GET_NEXT
#define HASH_GET_NEXT(NAME, DATA)
Gets the next struct in a hash chain, NULL if none.
Definition: innodb_utility.h:165
HASH_GET_FIRST
#define HASH_GET_FIRST(TABLE, HASH_VAL)
Gets the first struct in a hash chain, NULL if none.
Definition: innodb_utility.h:159
while
while(-- *argc > 0 &&*(pos= *(++*argv))=='-')
Definition: do_ctype.cc:83
if
if(!(yy_init))
Definition: lexyy.cc:1144
hash_get_nth_cell
hash_cell_t * hash_get_nth_cell(hash_table_t *table, ib_ulint_t n)
Gets the nth cell in a hash table.
Definition: innodb_utility.cc:188
rules_table_service::end
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:188
for
for(i=0;i< 3;i++)
Definition: do_ctype.cc:54
count
ssize_t count
Definition: memcached.c:386
start
static void start(PluginFuncEnv *env)
Definition: http_server_plugin.cc:572
hash_calc_hash
ib_ulint_t hash_calc_hash(ib_ulint_t fold, hash_table_t *table)
Calculates the hash value from a folded value.
Definition: innodb_utility.cc:177