Drizzled Public API Documentation

ut0rnd.h File Reference

#include "univ.i"
#include "ut0byte.h"
#include "ut0rnd.ic"

Go to the source code of this file.

Defines

#define UT_END_OF_FIELD   257

Functions

UNIV_INLINE void ut_rnd_set_seed (ulint seed)
UNIV_INLINE ulint ut_rnd_gen_next_ulint (ulint rnd)
UNIV_INLINE ulint ut_rnd_gen_ulint (void)
UNIV_INLINE ulint ut_rnd_interval (ulint low, ulint high)
UNIV_INLINE ibool ut_rnd_gen_ibool (void)
UNIV_INLINE ulint ut_hash_ulint (ulint key, ulint table_size)
UNIV_INLINE ulint ut_fold_ulint_pair (ulint n1, ulint n2) __attribute__((const ))
UNIV_INLINE ulint ut_fold_ull (ib_uint64_t d) __attribute__((const ))
UNIV_INLINE ulint ut_fold_string (const char *str) __attribute__((pure))
UNIV_INLINE ulint ut_fold_binary (const byte *str, ulint len) __attribute__((pure))
UNIV_INTERN ulint ut_find_prime (ulint n) __attribute__((const ))

Detailed Description

Random numbers and hashing

Created 1/20/1994 Heikki Tuuri

Definition in file ut0rnd.h.


Define Documentation

#define UT_END_OF_FIELD   257

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

Definition at line 36 of file ut0rnd.h.


Function Documentation

UNIV_INTERN ulint ut_find_prime ( ulint  n) const

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
Parameters:
nin: positive number > 100

Referenced by hash_create().

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

Referenced by buf_calc_page_new_checksum(), buf_calc_page_old_checksum(), and ha_storage_put_memlim().

UNIV_INLINE ulint ut_fold_string ( const char *  str)

Folds a character string ending in the null character.

Returns:
folded value
Parameters:
strin: null-terminated string

Referenced by dict_table_add_to_cache(), dict_table_remove_from_cache(), dict_table_rename_in_cache(), fil_space_create(), and get_share().

UNIV_INLINE ulint ut_fold_ulint_pair ( ulint  n1,
ulint  n2 
) const

Folds a pair of ulints.

Returns:
folded value
Parameters:
n1in: ulint
n2in: ulint
UNIV_INLINE ulint ut_fold_ull ( ib_uint64_t  d) const

Folds a 64-bit integer.

Returns:
folded value
Parameters:
din: 64-bit integer

Referenced by dict_table_add_to_cache(), dict_table_change_id_in_cache(), and dict_table_remove_from_cache().

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.

Returns:
hash value in: hash table size
Parameters:
keyin: value to be hashed
UNIV_INLINE ibool ut_rnd_gen_ibool ( void  )

Generates a random iboolean value.

Returns:
the random value
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
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
UNIV_INLINE ulint ut_rnd_interval ( ulint  low,
ulint  high 
)

Generates a random integer from a given interval.

Returns:
the 'random' number in: high limit; can generate also this value
Parameters:
lowin: low limit; can generate also this value

Referenced by rw_lock_x_lock_func().

UNIV_INLINE void ut_rnd_set_seed ( ulint  seed)

This is used to set the random number seed. in: seed