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
main
Yuchi Chen 6 years ago committed by Facebook Github Bot
parent 47fd574829
commit 78a6e07c83
  1. 2
      monitoring/iostats_context_imp.h
  2. 3
      table/block_based_table_builder.cc
  3. 2
      table/block_based_table_reader.cc
  4. 2
      table/meta_blocks.cc

@ -55,6 +55,6 @@ extern __thread IOStatsContext iostats_context;
#define IOSTATS(metric) 0 #define IOSTATS(metric) 0
#define IOSTATS_TIMER_GUARD(metric) #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 #endif // ROCKSDB_SUPPORT_THREAD_LOCAL

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

@ -968,7 +968,7 @@ Status BlockBasedTable::TryReadPropertiesWithGlobalSeqno(
(*table_properties) (*table_properties)
->properties_offsets.find( ->properties_offsets.find(
ExternalSstFilePropertyNames::kGlobalSeqno); 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()) { if (seqno_pos_iter != (*table_properties)->properties_offsets.end()) {
uint64_t global_seqno_offset = seqno_pos_iter->second; uint64_t global_seqno_offset = seqno_pos_iter->second;
EncodeFixed64( EncodeFixed64(

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

Loading…
Cancel
Save