Fix from some C-style casting (#5524)

Summary:
Fix from some C-style casting in bloom.cc and ./tools/db_bench_tool.cc
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5524

Differential Revision: D16075626

Pulled By: elipoz

fbshipit-source-id: 352948885efb64a7ef865942c75c3c727a914207
main
Eli Pozniansky 5 years ago committed by Facebook Github Bot
parent 9f0bd56889
commit f872009237
  1. 29
      tools/db_bench_tool.cc
  2. 6
      util/bloom.cc

@ -2397,16 +2397,19 @@ class Benchmark {
return nullptr; return nullptr;
} }
if (FLAGS_use_clock_cache) { if (FLAGS_use_clock_cache) {
auto cache = NewClockCache((size_t)capacity, FLAGS_cache_numshardbits); auto cache =
NewClockCache(static_cast<size_t>(capacity), FLAGS_cache_numshardbits);
if (!cache) { if (!cache) {
fprintf(stderr, "Clock cache not supported."); fprintf(stderr, "Clock cache not supported.");
exit(1); exit(1);
} }
return cache; return cache;
} else { } else {
return NewLRUCache((size_t)capacity, FLAGS_cache_numshardbits, return NewLRUCache(
false /*strict_capacity_limit*/, static_cast<size_t>(capacity),
FLAGS_cache_high_pri_pool_ratio); FLAGS_cache_numshardbits,
false /*strict_capacity_limit*/,
FLAGS_cache_high_pri_pool_ratio);
} }
} }
@ -3604,9 +3607,12 @@ class Benchmark {
} }
if (FLAGS_max_bytes_for_level_multiplier_additional_v.size() > 0) { if (FLAGS_max_bytes_for_level_multiplier_additional_v.size() > 0) {
if (FLAGS_max_bytes_for_level_multiplier_additional_v.size() != if (FLAGS_max_bytes_for_level_multiplier_additional_v.size() !=
(unsigned int)FLAGS_num_levels) { static_cast<unsigned int>(FLAGS_num_levels)) {
fprintf(stderr, "Insufficient number of fanouts specified %d\n", fprintf(
(int)FLAGS_max_bytes_for_level_multiplier_additional_v.size()); stderr,
"Insufficient number of fanouts specified %d\n",
static_cast<int>(
FLAGS_max_bytes_for_level_multiplier_additional_v.size()));
exit(1); exit(1);
} }
options.max_bytes_for_level_multiplier_additional = options.max_bytes_for_level_multiplier_additional =
@ -4791,7 +4797,7 @@ class Benchmark {
if (FLAGS_multiread_stride) { if (FLAGS_multiread_stride) {
int64_t key = GetRandomKey(&thread->rand); int64_t key = GetRandomKey(&thread->rand);
if ((key + (entries_per_batch_ - 1) * FLAGS_multiread_stride) >= if ((key + (entries_per_batch_ - 1) * FLAGS_multiread_stride) >=
(int64_t)FLAGS_num) { static_cast<int64_t>(FLAGS_num)) {
key = FLAGS_num - entries_per_batch_ * FLAGS_multiread_stride; key = FLAGS_num - entries_per_batch_ * FLAGS_multiread_stride;
} }
for (int64_t i = 0; i < entries_per_batch_; ++i) { for (int64_t i = 0; i < entries_per_batch_; ++i) {
@ -5161,9 +5167,10 @@ class Benchmark {
FLAGS_num, &lower_bound); FLAGS_num, &lower_bound);
options.iterate_lower_bound = &lower_bound; options.iterate_lower_bound = &lower_bound;
} else { } else {
auto min_num =
std::min(FLAGS_num, seek_pos + FLAGS_max_scan_distance);
GenerateKeyFromInt( GenerateKeyFromInt(
(uint64_t)std::min(FLAGS_num, seek_pos + FLAGS_max_scan_distance), static_cast<uint64_t>(min_num), FLAGS_num, &upper_bound);
FLAGS_num, &upper_bound);
options.iterate_upper_bound = &upper_bound; options.iterate_upper_bound = &upper_bound;
} }
} }
@ -5331,7 +5338,7 @@ class Benchmark {
// Wait for the writes to be finished // Wait for the writes to be finished
if (!hint_printed) { if (!hint_printed) {
fprintf(stderr, "Reads are finished. Have %d more writes to do\n", fprintf(stderr, "Reads are finished. Have %d more writes to do\n",
(int)writes_ - written); static_cast<int>(writes_) - written);
hint_printed = true; hint_printed = true;
} }
} else { } else {

@ -104,7 +104,7 @@ int FullFilterBitsBuilder::CalculateNumEntry(const uint32_t space) {
assert(bits_per_key_); assert(bits_per_key_);
assert(space > 0); assert(space > 0);
uint32_t dont_care1, dont_care2; uint32_t dont_care1, dont_care2;
int high = (int) (space * 8 / bits_per_key_ + 1); int high = static_cast<int>(space * 8 / bits_per_key_ + 1);
int low = 1; int low = 1;
int n = high; int n = high;
for (; n >= low; n--) { for (; n >= low; n--) {
@ -120,7 +120,7 @@ int FullFilterBitsBuilder::CalculateNumEntry(const uint32_t space) {
inline void FullFilterBitsBuilder::AddHash(uint32_t h, char* data, inline void FullFilterBitsBuilder::AddHash(uint32_t h, char* data,
uint32_t num_lines, uint32_t total_bits) { uint32_t num_lines, uint32_t total_bits) {
#ifdef NDEBUG #ifdef NDEBUG
(void)total_bits; static_cast<void>(total_bits);
#endif #endif
assert(num_lines > 0 && total_bits > 0); assert(num_lines > 0 && total_bits > 0);
@ -340,7 +340,7 @@ class BloomFilterPolicy : public FilterPolicy {
dst->resize(init_size + bytes, 0); dst->resize(init_size + bytes, 0);
dst->push_back(static_cast<char>(num_probes_)); // Remember # of probes dst->push_back(static_cast<char>(num_probes_)); // Remember # of probes
char* array = &(*dst)[init_size]; char* array = &(*dst)[init_size];
for (size_t i = 0; i < (size_t)n; i++) { for (size_t i = 0; i < static_cast<size_t>(n); i++) {
// Use double-hashing to generate a sequence of hash values. // Use double-hashing to generate a sequence of hash values.
// See analysis in [Kirsch,Mitzenmacher 2006]. // See analysis in [Kirsch,Mitzenmacher 2006].
uint32_t h = hash_func_(keys[i]); uint32_t h = hash_func_(keys[i]);

Loading…
Cancel
Save