MySQL  8.0.19
Source Code Documentation
ut0rnd.h File Reference
#include "univ.i"
#include "ut0byte.h"
#include "ut0rnd.ic"

Go to the source code of this file.

Macros

#define UT_END_OF_FIELD   257
 The 'character code' for end of field or string (used in folding records. More...
 

Functions

UNIV_INLINE ulint ut_rnd_gen_next_ulint (ulint rnd)
 The following function generates a series of 'random' ulint integers. More...
 
UNIV_INLINE ulint ut_rnd_gen_ulint (void)
 The following function generates 'random' ulint integers which enumerate the value space (let there be N of them) of ulint integers in a pseudo-random fashion. More...
 
UNIV_INLINE ulint ut_rnd_interval (ulint low, ulint high)
 Generates a random integer from a given interval. More...
 
UNIV_INLINE ulint ut_hash_ulint (ulint key, ulint table_size)
 The following function generates a hash value for a ulint integer to a hash table of size table_size, which should be a prime or some random number to work reliably. More...
 
UNIV_INLINE ulint ut_fold_ull (ib_uint64_t d)
 Folds a 64-bit integer. More...
 
UNIV_INLINE ulint ut_fold_string (const char *str)
 Folds a character string ending in the null character. More...
 
ulint ut_find_prime (ulint n)
 Looks for a prime number slightly greater than the given argument. More...
 
UNIV_INLINE ulint ut_fold_ulint_pair (ulint n1, ulint n2)
 Folds a pair of ulints. More...
 
UNIV_INLINE ulint ut_fold_binary (const byte *str, ulint len)
 Folds a binary string. More...
 

Detailed Description

Random numbers and hashing

Created 1/20/1994 Heikki Tuuri

Macro Definition Documentation

◆ UT_END_OF_FIELD

#define UT_END_OF_FIELD   257

The 'character code' for end of field or string (used in folding records.

Function Documentation

◆ ut_find_prime()

ulint ut_find_prime ( ulint  n)

Looks for a prime number slightly greater than the given argument.

The prime is chosen so that it is not near any power of 2.

Returns
prime

◆ ut_fold_binary()

UNIV_INLINE ulint ut_fold_binary ( const byte str,
ulint  len 
)

Folds a binary string.

Returns
folded value
Parameters
strin: string of bytes
lenin: length

◆ ut_fold_string()

UNIV_INLINE ulint ut_fold_string ( const char *  str)

Folds a character string ending in the null character.

Returns
folded value

◆ ut_fold_ulint_pair()

UNIV_INLINE ulint ut_fold_ulint_pair ( ulint  n1,
ulint  n2 
)

Folds a pair of ulints.

Returns
folded value
Parameters
n1in: ulint
n2in: ulint

◆ ut_fold_ull()

UNIV_INLINE ulint ut_fold_ull ( ib_uint64_t  d)

Folds a 64-bit integer.

Returns
folded value
Parameters
din: 64-bit integer

◆ ut_hash_ulint()

UNIV_INLINE ulint ut_hash_ulint ( ulint  key,
ulint  table_size 
)

The following function generates a hash value for a ulint integer to a hash table of size table_size, which should be a prime or some random number to work reliably.

Parameters
[in]keyvalue to be hashed
[in]table_sizehash table size
Returns
hash value

◆ ut_rnd_gen_next_ulint()

UNIV_INLINE ulint ut_rnd_gen_next_ulint ( ulint  rnd)

The following function generates a series of 'random' ulint integers.

Returns
the next 'random' number in: the previous random number value

◆ ut_rnd_gen_ulint()

UNIV_INLINE ulint ut_rnd_gen_ulint ( void  )

The following function generates 'random' ulint integers which enumerate the value space (let there be N of them) of ulint integers in a pseudo-random fashion.

Note that the same integer is repeated always after N calls to the generator.

Returns
the 'random' number

◆ ut_rnd_interval()

UNIV_INLINE ulint ut_rnd_interval ( ulint  low,
ulint  high 
)

Generates a random integer from a given interval.

Parameters
[in]lowlow limit; can generate also this value
[in]highhigh limit; can generate also this value
Returns
the 'random' number