From 9d5019327bfd10e10cc0d0d27119d5c82e0fa98c Mon Sep 17 00:00:00 2001 From: Yueh-Hsuan Chiang Date: Tue, 25 Nov 2014 23:28:36 -0800 Subject: [PATCH] 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 --- util/options_builder.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/util/options_builder.cc b/util/options_builder.cc index a92a5e86e5..01774b6087 100644 --- a/util/options_builder.cc +++ b/util/options_builder.cc @@ -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(ceil(log2(target_db_size / write_buffer_size))); + static_cast(ceil(Log2(target_db_size / write_buffer_size))); const int kEstimatedLevel0FilesInLevelStyle = 2; // Estimate write amplification: