fix build warnnings on MSVC (#6309)

Summary:
Fix build warnings on MSVC. siying
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6309

Differential Revision: D19455012

Pulled By: ltamasi

fbshipit-source-id: 940739f2c92de60e47cc2bed8dd7f921459545a9
main
Burton Li 5 years ago committed by Facebook Github Bot
parent 90c71aa5d9
commit c9a5e48762
  1. 5
      db_stress_tool/db_stress_common.cc
  2. 4
      db_stress_tool/db_stress_test_base.cc
  3. 4
      util/filter_bench.cc

@ -62,7 +62,7 @@ void InitializeHotKeyGenerator(double alpha) {
int64_t GetOneHotKeyID(double rand_seed, int64_t max_key) { int64_t GetOneHotKeyID(double rand_seed, int64_t max_key) {
int64_t low = 1, mid, high = zipf_sum_size, zipf = 0; int64_t low = 1, mid, high = zipf_sum_size, zipf = 0;
while (low <= high) { while (low <= high) {
mid = std::floor((low + high) / 2); mid = (low + high) / 2;
if (sum_probs[mid] >= rand_seed && sum_probs[mid - 1] < rand_seed) { if (sum_probs[mid] >= rand_seed && sum_probs[mid - 1] < rand_seed) {
zipf = mid; zipf = mid;
break; break;
@ -72,8 +72,7 @@ int64_t GetOneHotKeyID(double rand_seed, int64_t max_key) {
low = mid + 1; low = mid + 1;
} }
} }
int64_t tmp_zipf_seed = static_cast<int64_t>( int64_t tmp_zipf_seed = zipf * max_key / zipf_sum_size;
std::floor(zipf * max_key / (static_cast<double>(zipf_sum_size))));
Random64 rand_local(tmp_zipf_seed); Random64 rand_local(tmp_zipf_seed);
return rand_local.Next() % max_key; return rand_local.Next() % max_key;
} }

@ -771,7 +771,7 @@ std::vector<std::string> StressTest::GetWhiteBoxKeys(ThreadState* thread,
k[i] = static_cast<char>(cur - 1); k[i] = static_cast<char>(cur - 1);
break; break;
} else if (i > 0) { } else if (i > 0) {
k[i] = 0xFF; k[i] = 0xFFu;
} }
} }
} else if (thread->rand.OneIn(2)) { } else if (thread->rand.OneIn(2)) {
@ -1550,7 +1550,7 @@ void StressTest::TestCompactRange(ThreadState* thread, int64_t rand_key,
cro.max_subcompactions = static_cast<uint32_t>(thread->rand.Next() % 4); cro.max_subcompactions = static_cast<uint32_t>(thread->rand.Next() % 4);
const Snapshot* pre_snapshot = nullptr; const Snapshot* pre_snapshot = nullptr;
uint32_t pre_hash; uint32_t pre_hash = 0;
if (thread->rand.OneIn(2)) { if (thread->rand.OneIn(2)) {
// Do some validation by declaring a snapshot and compare the data before // Do some validation by declaring a snapshot and compare the data before
// and after the compaction // and after the compaction

@ -330,8 +330,8 @@ void FilterBench::Go() {
if (FLAGS_use_plain_table_bloom) { if (FLAGS_use_plain_table_bloom) {
info.plain_table_bloom_.reset(new PlainTableBloomV1()); info.plain_table_bloom_.reset(new PlainTableBloomV1());
info.plain_table_bloom_->SetTotalBits( info.plain_table_bloom_->SetTotalBits(
&arena_, keys_to_add * FLAGS_bits_per_key, FLAGS_impl, &arena_, static_cast<uint32_t>(keys_to_add * FLAGS_bits_per_key),
0 /*huge_page*/, nullptr /*logger*/); FLAGS_impl, 0 /*huge_page*/, nullptr /*logger*/);
for (uint32_t i = 0; i < keys_to_add; ++i) { for (uint32_t i = 0; i < keys_to_add; ++i) {
uint32_t hash = GetSliceHash(kms_[0].Get(filter_id, i)); uint32_t hash = GetSliceHash(kms_[0].Get(filter_id, i));
info.plain_table_bloom_->AddHash(hash); info.plain_table_bloom_->AddHash(hash);

Loading…
Cancel
Save