Replace log2 by implementing Log2 in options_builder

Summary:
log2 function is only used in options_builder, and this function
is not available under certain platform such as android.
This patch implements Log2 by log(n) / log(2).

Test Plan:
make
This commit is contained in:
Yueh-Hsuan Chiang 2014-11-25 23:28:36 -08:00
parent 274ba62707
commit 9d5019327b

View file

@ -11,6 +11,10 @@ namespace rocksdb {
namespace {
double Log2(double n) {
return log(n) / log(2);
}
// For now, always use 1-0 as level bytes multiplier.
const int kBytesForLevelMultiplier = 10;
const size_t kBytesForOneMb = 1024 * 1024;
@ -28,7 +32,7 @@ CompactionStyle PickCompactionStyle(size_t write_buffer_size,
::log(target_db_size / write_buffer_size) / ::log(kBytesForLevelMultiplier)));
int expected_max_files_universal =
static_cast<int>(ceil(log2(target_db_size / write_buffer_size)));
static_cast<int>(ceil(Log2(target_db_size / write_buffer_size)));
const int kEstimatedLevel0FilesInLevelStyle = 2;
// Estimate write amplification: