diff options
Diffstat (limited to 'storage/innobase/page/page0cur.cc')
-rw-r--r-- | storage/innobase/page/page0cur.cc | 50 |
1 files changed, 7 insertions, 43 deletions
diff --git a/storage/innobase/page/page0cur.cc b/storage/innobase/page/page0cur.cc index b4ec3e6dcdf..a5a8c6c3d1e 100644 --- a/storage/innobase/page/page0cur.cc +++ b/storage/innobase/page/page0cur.cc @@ -35,38 +35,6 @@ Created 10/4/1994 Heikki Tuuri #include <algorithm> -/*******************************************************************//** -This is a linear congruential generator PRNG. Returns a pseudo random -number between 0 and 2^64-1 inclusive. The formula and the constants -being used are: -X[n+1] = (a * X[n] + c) mod m -where: -X[0] = my_interval_timer() -a = 1103515245 (3^5 * 5 * 7 * 129749) -c = 12345 (3 * 5 * 823) -m = 18446744073709551616 (2^64) - -@return number between 0 and 2^64-1 */ -static -ib_uint64_t -page_cur_lcg_prng(void) -/*===================*/ -{ -#define LCG_a 1103515245 -#define LCG_c 12345 - static uint64_t lcg_current; - - if (!lcg_current) { - lcg_current = my_interval_timer(); - } - - /* no need to "% 2^64" explicitly because lcg_current is - 64 bit and this will be done anyway */ - lcg_current = LCG_a * lcg_current + LCG_c; - - return(lcg_current); -} - #ifdef BTR_CUR_HASH_ADAPT # ifdef UNIV_SEARCH_PERF_STAT static ulint page_cur_short_succ; @@ -814,8 +782,7 @@ page_cur_open_on_rnd_user_rec( buf_block_t* block, /*!< in: page */ page_cur_t* cursor) /*!< out: page cursor */ { - ulint rnd; - ulint n_recs = page_get_n_recs(buf_block_get_frame(block)); + const ulint n_recs = page_get_n_recs(block->frame); page_cur_set_before_first(block, cursor); @@ -824,11 +791,9 @@ page_cur_open_on_rnd_user_rec( return; } - rnd = (ulint) (page_cur_lcg_prng() % n_recs); - - do { - page_cur_move_to_next(cursor); - } while (rnd--); + cursor->rec = page_rec_get_nth(block->frame, + static_cast<ulint> + (ut_rnd_gen() % n_recs) + 1); } /** Write a redo log record of inserting a record into an index page. @@ -2426,18 +2391,17 @@ page_cur_delete_rec( #ifdef UNIV_COMPILE_TEST_FUNCS /*******************************************************************//** -Print the first n numbers, generated by page_cur_lcg_prng() to make sure +Print the first n numbers, generated by ut_rnd_gen() to make sure (visually) that it works properly. */ void -test_page_cur_lcg_prng( -/*===================*/ +test_ut_rnd_gen( int n) /*!< in: print first n numbers */ { int i; unsigned long long rnd; for (i = 0; i < n; i++) { - rnd = page_cur_lcg_prng(); + rnd = ut_rnd_gen(); printf("%llu\t%%2=%llu %%3=%llu %%5=%llu %%7=%llu %%11=%llu\n", rnd, rnd % 2, |