MySQL 8.4.3
Source Code Documentation
|
#include "my_config.h"
#include <stddef.h>
#include <sys/types.h>
#include <atomic>
#include "my_inttypes.h"
#include "my_macros.h"
#include "mysql/psi/mysql_statement.h"
#include "mysql/service_mysql_alloc.h"
#include "sql_string.h"
Go to the source code of this file.
Classes | |
struct | LF_DYNARRAY |
struct | LF_PINBOX |
struct | LF_PINS |
struct | LF_ALLOCATOR |
struct | LF_HASH |
Macros | |
#define | LF_DYNARRAY_LEVEL_LENGTH 256 |
#define | LF_DYNARRAY_LEVELS 4 |
#define | LF_PINBOX_PINS 4 |
#define | LF_PURGATORY_SIZE 10 |
#define | LF_REQUIRE_PINS(N) |
#define | lf_alloc_init(A, B, C) lf_alloc_init2(A, B, C, NULL, NULL) |
#define | LF_HASH_UNIQUE 1 |
#define | MY_LF_ERRPTR ((void *)(intptr)1) |
#define | lf_hash_init(A, B, C, D, E, F, G) lf_hash_init2(A, B, C, D, E, F, G, NULL, NULL, NULL, NULL) |
Typedefs | |
typedef int(* | lf_dynarray_func) (void *, void *) |
typedef void | lf_pinbox_free_func(void *, void *, void *) |
typedef void | lf_allocator_func(uchar *) |
typedef uint | lf_hash_func(const LF_HASH *, const uchar *, size_t) |
typedef int | lf_cmp_func(const uchar *key1, size_t key1_length, const uchar *key2, size_t key2_length) |
typedef void | lf_hash_init_func(uchar *dst, const uchar *src) |
typedef const uchar *(* | hash_get_key_function) (const uchar *arg, size_t *length) |
Callback for extracting key and key length from user data in a LF_HASH. More... | |
typedef int | lf_hash_match_func(const uchar *el, void *arg) |
Functions | |
void | lf_dynarray_init (LF_DYNARRAY *array, uint element_size) |
void | lf_dynarray_destroy (LF_DYNARRAY *array) |
void * | lf_dynarray_value (LF_DYNARRAY *array, uint idx) |
void * | lf_dynarray_lvalue (LF_DYNARRAY *array, uint idx) |
int | lf_dynarray_iterate (LF_DYNARRAY *array, lf_dynarray_func func, void *arg) |
static void | lf_pin (LF_PINS *pins, int pin, void *addr) |
static void | lf_unpin (LF_PINS *pins, int pin) |
void | lf_pinbox_init (LF_PINBOX *pinbox, uint free_ptr_offset, lf_pinbox_free_func *free_func, void *free_func_arg) |
void | lf_pinbox_destroy (LF_PINBOX *pinbox) |
LF_PINS * | lf_pinbox_get_pins (LF_PINBOX *pinbox) |
void | lf_pinbox_put_pins (LF_PINS *pins) |
void | lf_pinbox_free (LF_PINS *pins, void *addr) |
void | lf_alloc_init2 (LF_ALLOCATOR *allocator, uint size, uint free_ptr_offset, lf_allocator_func *ctor, lf_allocator_func *dtor) |
Initialize lock-free allocator. More... | |
void | lf_alloc_destroy (LF_ALLOCATOR *allocator) |
uint | lf_alloc_pool_count (LF_ALLOCATOR *allocator) |
static void | lf_alloc_direct_free (LF_ALLOCATOR *allocator, void *addr) |
void * | lf_alloc_new (LF_PINS *pins) |
void | lf_hash_init2 (LF_HASH *hash, uint element_size, uint flags, uint key_offset, uint key_length, hash_get_key_function get_key, CHARSET_INFO *charset, lf_hash_func *hash_function, lf_allocator_func *ctor, lf_allocator_func *dtor, lf_hash_init_func *init) |
void | lf_hash_init3 (LF_HASH *hash, uint element_size, uint flags, hash_get_key_function get_key, lf_hash_func *hash_function, lf_cmp_func *cmp_function, lf_allocator_func *ctor, lf_allocator_func *dtor, lf_hash_init_func *init) |
void | lf_hash_destroy (LF_HASH *hash) |
int | lf_hash_insert (LF_HASH *hash, LF_PINS *pins, const void *data) |
void * | lf_hash_search (LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen) |
Find hash element corresponding to the key. More... | |
int | lf_hash_delete (LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen) |
static LF_PINS * | lf_hash_get_pins (LF_HASH *hash) |
static void | lf_hash_put_pins (LF_PINS *pins) |
static void | lf_hash_search_unpin (LF_PINS *pins) |
void * | lf_hash_random_match (LF_HASH *hash, LF_PINS *pins, lf_hash_match_func *match, uint rand_val, void *match_arg) |
Find random hash element which satisfies condition specified by match function. More... | |
Variables | |
MYSQL_PLUGIN_IMPORT const int | LF_HASH_OVERHEAD |
#define lf_alloc_init | ( | A, | |
B, | |||
C | |||
) | lf_alloc_init2(A, B, C, NULL, NULL) |
#define LF_DYNARRAY_LEVEL_LENGTH 256 |
#define LF_DYNARRAY_LEVELS 4 |
#define lf_hash_init | ( | A, | |
B, | |||
C, | |||
D, | |||
E, | |||
F, | |||
G | |||
) | lf_hash_init2(A, B, C, D, E, F, G, NULL, NULL, NULL, NULL) |
#define LF_HASH_UNIQUE 1 |
#define LF_PINBOX_PINS 4 |
#define LF_PURGATORY_SIZE 10 |
#define LF_REQUIRE_PINS | ( | N | ) |
#define MY_LF_ERRPTR ((void *)(intptr)1) |
Callback for extracting key and key length from user data in a LF_HASH.
arg | Pointer to user data. | |
[out] | length | Store key length here. |
typedef void lf_allocator_func(uchar *) |
typedef int lf_cmp_func(const uchar *key1, size_t key1_length, const uchar *key2, size_t key2_length) |
typedef int(* lf_dynarray_func) (void *, void *) |
typedef int lf_hash_match_func(const uchar *el, void *arg) |
typedef void lf_pinbox_free_func(void *, void *, void *) |
void lf_alloc_destroy | ( | LF_ALLOCATOR * | allocator | ) |
|
inlinestatic |
void lf_alloc_init2 | ( | LF_ALLOCATOR * | allocator, |
uint | size, | ||
uint | free_ptr_offset, | ||
lf_allocator_func * | ctor, | ||
lf_allocator_func * | dtor | ||
) |
Initialize lock-free allocator.
allocator | Allocator structure to initialize. |
size | A size of an object to allocate. |
free_ptr_offset | An offset inside the object to a sizeof(void *) memory that is guaranteed to be unused after the object is put in the purgatory. Unused by ANY thread, not only the purgatory owner. This memory will be used to link waiting-to-be-freed objects in a purgatory list. |
ctor | Function to be called after object was malloc()'ed. |
dtor | Function to be called before object is free()'d. |
void * lf_alloc_new | ( | LF_PINS * | pins | ) |
uint lf_alloc_pool_count | ( | LF_ALLOCATOR * | allocator | ) |
void lf_dynarray_destroy | ( | LF_DYNARRAY * | array | ) |
void lf_dynarray_init | ( | LF_DYNARRAY * | array, |
uint | element_size | ||
) |
int lf_dynarray_iterate | ( | LF_DYNARRAY * | array, |
lf_dynarray_func | func, | ||
void * | arg | ||
) |
void * lf_dynarray_lvalue | ( | LF_DYNARRAY * | array, |
uint | idx | ||
) |
void * lf_dynarray_value | ( | LF_DYNARRAY * | array, |
uint | idx | ||
) |
void lf_hash_destroy | ( | LF_HASH * | hash | ) |
void lf_hash_init2 | ( | LF_HASH * | hash, |
uint | element_size, | ||
uint | flags, | ||
uint | key_offset, | ||
uint | key_length, | ||
hash_get_key_function | get_key, | ||
CHARSET_INFO * | charset, | ||
lf_hash_func * | hash_function, | ||
lf_allocator_func * | ctor, | ||
lf_allocator_func * | dtor, | ||
lf_hash_init_func * | init | ||
) |
void lf_hash_init3 | ( | LF_HASH * | hash, |
uint | element_size, | ||
uint | flags, | ||
hash_get_key_function | get_key, | ||
lf_hash_func * | hash_function, | ||
lf_cmp_func * | cmp_function, | ||
lf_allocator_func * | ctor, | ||
lf_allocator_func * | dtor, | ||
lf_hash_init_func * | init | ||
) |
|
inlinestatic |
void * lf_hash_random_match | ( | LF_HASH * | hash, |
LF_PINS * | pins, | ||
lf_hash_match_func * | match, | ||
uint | rand_val, | ||
void * | match_arg | ||
) |
Find random hash element which satisfies condition specified by match function.
hash | Hash to search element in. |
pins | Pins for calling thread to be used during search and for pinning its result. |
match | Pointer to match function. This function takes pointer to object stored in hash as parameter and returns 0 if object doesn't satisfy its condition (and non-0 value if it does). |
rand_val | Random value to be used for selecting hash bucket from which search in sort-ordered list needs to be started. |
match_arg | Argument passed to match function. |
A | pointer to a random element matching condition. |
NULL | - if nothing is found |
MY_LF_ERRPTR | - OOM. |
Find hash element corresponding to the key.
hash | The hash to search element in. |
pins | Pins for the calling thread which were earlier obtained from this hash using lf_hash_get_pins(). |
key | Key |
keylen | Key length |
A | pointer to an element with the given key (if a hash is not unique and there're many elements with this key - the "first" matching element). |
NULL | - if nothing is found |
MY_LF_ERRPTR | - if OOM |
|
inlinestatic |
|
inlinestatic |
void lf_pinbox_destroy | ( | LF_PINBOX * | pinbox | ) |
void lf_pinbox_free | ( | LF_PINS * | pins, |
void * | addr | ||
) |
void lf_pinbox_init | ( | LF_PINBOX * | pinbox, |
uint | free_ptr_offset, | ||
lf_pinbox_free_func * | free_func, | ||
void * | free_func_arg | ||
) |
void lf_pinbox_put_pins | ( | LF_PINS * | pins | ) |
|
inlinestatic |
|
extern |