Commit 242a28c3 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-6812: Remove the wrapper my_log2f()

parent 661289f4
...@@ -27,6 +27,7 @@ Completed by Sunny Bains and Marko Makela ...@@ -27,6 +27,7 @@ Completed by Sunny Bains and Marko Makela
#include <my_config.h> #include <my_config.h>
#include <log.h> #include <log.h>
#include <sql_class.h> #include <sql_class.h>
#include <math.h>
#include "row0merge.h" #include "row0merge.h"
#include "row0ext.h" #include "row0ext.h"
...@@ -42,15 +43,8 @@ Completed by Sunny Bains and Marko Makela ...@@ -42,15 +43,8 @@ Completed by Sunny Bains and Marko Makela
#include "row0import.h" #include "row0import.h"
#include "handler0alter.h" #include "handler0alter.h"
#include "ha_prototypes.h" #include "ha_prototypes.h"
#include "math.h" /* log() */
#include "fil0crypt.h" #include "fil0crypt.h"
float my_log2f(float n)
{
/* log(n) / log(2) is log2. */
return (float)(log((double)n) / log((double)2));
}
/* Ignore posix_fadvise() on those platforms where it does not exist */ /* Ignore posix_fadvise() on those platforms where it does not exist */
#if defined __WIN__ #if defined __WIN__
# define posix_fadvise(fd, offset, len, advice) /* nothing */ # define posix_fadvise(fd, offset, len, advice) /* nothing */
...@@ -2503,18 +2497,13 @@ row_merge_sort( ...@@ -2503,18 +2497,13 @@ row_merge_sort(
/* Record the number of merge runs we need to perform */ /* Record the number of merge runs we need to perform */
num_runs = file->offset; num_runs = file->offset;
/* Find the number N which 2^N is greater or equal than num_runs */
/* N is merge sort running count */
total_merge_sort_count = ceil(my_log2f(num_runs));
if(total_merge_sort_count <= 0) {
total_merge_sort_count=1;
}
/* If num_runs are less than 1, nothing to merge */ /* If num_runs are less than 1, nothing to merge */
if (num_runs <= 1) { if (num_runs <= 1) {
DBUG_RETURN(error); DBUG_RETURN(error);
} }
total_merge_sort_count = ceil(log2f(num_runs));
/* "run_offset" records each run's first offset number */ /* "run_offset" records each run's first offset number */
run_offset = (ulint*) mem_alloc(file->offset * sizeof(ulint)); run_offset = (ulint*) mem_alloc(file->offset * sizeof(ulint));
......
...@@ -27,6 +27,7 @@ Completed by Sunny Bains and Marko Makela ...@@ -27,6 +27,7 @@ Completed by Sunny Bains and Marko Makela
#include <my_config.h> #include <my_config.h>
#include <log.h> #include <log.h>
#include <sql_class.h> #include <sql_class.h>
#include <math.h>
#include "row0merge.h" #include "row0merge.h"
#include "row0ext.h" #include "row0ext.h"
...@@ -42,15 +43,8 @@ Completed by Sunny Bains and Marko Makela ...@@ -42,15 +43,8 @@ Completed by Sunny Bains and Marko Makela
#include "row0import.h" #include "row0import.h"
#include "handler0alter.h" #include "handler0alter.h"
#include "ha_prototypes.h" #include "ha_prototypes.h"
#include "math.h" /* log2() */
#include "fil0crypt.h" #include "fil0crypt.h"
float my_log2f(float n)
{
/* log(n) / log(2) is log2. */
return (float)(log((double)n) / log((double)2));
}
/* Ignore posix_fadvise() on those platforms where it does not exist */ /* Ignore posix_fadvise() on those platforms where it does not exist */
#if defined __WIN__ #if defined __WIN__
# define posix_fadvise(fd, offset, len, advice) /* nothing */ # define posix_fadvise(fd, offset, len, advice) /* nothing */
...@@ -2516,18 +2510,13 @@ row_merge_sort( ...@@ -2516,18 +2510,13 @@ row_merge_sort(
/* Record the number of merge runs we need to perform */ /* Record the number of merge runs we need to perform */
num_runs = file->offset; num_runs = file->offset;
/* Find the number N which 2^N is greater or equal than num_runs */
/* N is merge sort running count */
total_merge_sort_count = ceil(my_log2f(num_runs));
if(total_merge_sort_count <= 0) {
total_merge_sort_count=1;
}
/* If num_runs are less than 1, nothing to merge */ /* If num_runs are less than 1, nothing to merge */
if (num_runs <= 1) { if (num_runs <= 1) {
DBUG_RETURN(error); DBUG_RETURN(error);
} }
total_merge_sort_count = ceil(log2f(num_runs));
/* "run_offset" records each run's first offset number */ /* "run_offset" records each run's first offset number */
run_offset = (ulint*) mem_alloc(file->offset * sizeof(ulint)); run_offset = (ulint*) mem_alloc(file->offset * sizeof(ulint));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment