Fix compilation errors for 32bits/LITE/ios build. (#5220)

Summary:
When I build RocksDB for 32bits/LITE/iOS environment, some errors like the following.

`
table/block_based_table_reader.cc:971:44: error: implicit conversion loses integer precision: 'uint64_t'
      (aka 'unsigned long long') to 'size_t' (aka 'unsigned long') [-Werror,-Wshorten-64-to-32]
    size_t block_size = props_block_handle.size();
           ~~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~^~~~~~

./util/file_reader_writer.h:177:8: error: private field 'env_' is not used [-Werror,-Wunused-private-field]
  Env* env_;
       ^
`
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5220

Differential Revision: D15023481

Pulled By: siying

fbshipit-source-id: 1b5d121d3016f2b0a8a9a2cc1bd638479357f9f7
This commit is contained in:
Yuchi Chen 2019-04-22 15:59:16 -07:00 committed by Facebook Github Bot
parent 47fd574829
commit 78a6e07c83
4 changed files with 5 additions and 4 deletions

View File

@ -55,6 +55,6 @@ extern __thread IOStatsContext iostats_context;
#define IOSTATS(metric) 0
#define IOSTATS_TIMER_GUARD(metric)
#define IOSTATS_CPU_TIMER_GUARD(metric, env)
#define IOSTATS_CPU_TIMER_GUARD(metric, env) static_cast<void>(env)
#endif // ROCKSDB_SUPPORT_THREAD_LOCAL

View File

@ -1064,7 +1064,8 @@ void BlockBasedTableBuilder::EnterUnbuffered() {
if (!r->data_block_and_keys_buffers.empty()) {
while (compression_dict_samples.size() < kSampleBytes) {
size_t rand_idx =
generator.Uniform(r->data_block_and_keys_buffers.size());
static_cast<size_t>(
generator.Uniform(r->data_block_and_keys_buffers.size()));
size_t copy_len =
std::min(kSampleBytes - compression_dict_samples.size(),
r->data_block_and_keys_buffers[rand_idx].first.size());

View File

@ -968,7 +968,7 @@ Status BlockBasedTable::TryReadPropertiesWithGlobalSeqno(
(*table_properties)
->properties_offsets.find(
ExternalSstFilePropertyNames::kGlobalSeqno);
size_t block_size = props_block_handle.size();
size_t block_size = static_cast<size_t>(props_block_handle.size());
if (seqno_pos_iter != (*table_properties)->properties_offsets.end()) {
uint64_t global_seqno_offset = seqno_pos_iter->second;
EncodeFixed64(

View File

@ -339,7 +339,7 @@ Status ReadProperties(const Slice& handle_value, RandomAccessFileReader* file,
*ret_block_handle = handle;
}
if (verification_buf != nullptr) {
size_t len = handle.size() + kBlockTrailerSize;
size_t len = static_cast<size_t>(handle.size() + kBlockTrailerSize);
*verification_buf = rocksdb::AllocateBlock(len, memory_allocator);
if (verification_buf->get() != nullptr) {
memcpy(verification_buf->get(), block_contents.data.data(), len);