提交 7323e4c8 编写于 作者: O omegaga

Fix clang on macOS

Summary: Fix problem when casting `size_t` to `uint64_t`. Avoid usage of `size_t` when possible.

Test Plan: Pass related test on Travis CI.

Reviewers: sdong

Reviewed By: sdong

Subscribers: andrewkr, dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D61443
上级 ee027fc1
...@@ -62,14 +62,14 @@ size_t FixedLengthColBufDecoder::Init(const char* src) { ...@@ -62,14 +62,14 @@ size_t FixedLengthColBufDecoder::Init(const char* src) {
if (col_compression_type_ == kColDict || if (col_compression_type_ == kColDict ||
col_compression_type_ == kColRleDict) { col_compression_type_ == kColRleDict) {
const char* q; const char* q;
size_t dict_size; uint64_t dict_size;
// Bypass limit // Bypass limit
q = GetVarint64Ptr(src, src + 10, &dict_size); q = GetVarint64Ptr(src, src + 10, &dict_size);
assert(q != nullptr); assert(q != nullptr);
src = q; src = q;
uint64_t dict_key; uint64_t dict_key;
for (size_t i = 0; i < dict_size; ++i) { for (uint64_t i = 0; i < dict_size; ++i) {
// Bypass limit // Bypass limit
ReadVarint64(&src, &dict_key); ReadVarint64(&src, &dict_key);
...@@ -145,7 +145,7 @@ size_t FixedLengthColBufDecoder::Decode(const char* src, char** dest) { ...@@ -145,7 +145,7 @@ size_t FixedLengthColBufDecoder::Decode(const char* src, char** dest) {
last_val_ = tmp; last_val_ = tmp;
} else if (col_compression_type_ == kColRleDict || } else if (col_compression_type_ == kColRleDict ||
col_compression_type_ == kColDict) { col_compression_type_ == kColDict) {
size_t dict_val = read_val; uint64_t dict_val = read_val;
assert(dict_val < dict_vec_.size()); assert(dict_val < dict_vec_.size());
write_val = dict_vec_[dict_val]; write_val = dict_vec_[dict_val];
} }
...@@ -190,14 +190,14 @@ size_t VariableChunkColBufDecoder::Init(const char* src) { ...@@ -190,14 +190,14 @@ size_t VariableChunkColBufDecoder::Init(const char* src) {
const char* orig_src = src; const char* orig_src = src;
if (col_compression_type_ == kColDict) { if (col_compression_type_ == kColDict) {
const char* q; const char* q;
size_t dict_size; uint64_t dict_size;
// Bypass limit // Bypass limit
q = GetVarint64Ptr(src, src + 10, &dict_size); q = GetVarint64Ptr(src, src + 10, &dict_size);
assert(q != nullptr); assert(q != nullptr);
src = q; src = q;
uint64_t dict_key; uint64_t dict_key;
for (size_t i = 0; i < dict_size; ++i) { for (uint64_t i = 0; i < dict_size; ++i) {
// Bypass limit // Bypass limit
ReadVarint64(&src, &dict_key); ReadVarint64(&src, &dict_key);
dict_vec_.push_back(dict_key); dict_vec_.push_back(dict_key);
...@@ -219,7 +219,7 @@ size_t VariableChunkColBufDecoder::Decode(const char* src, char** dest) { ...@@ -219,7 +219,7 @@ size_t VariableChunkColBufDecoder::Decode(const char* src, char** dest) {
chunk_size = size % 8; chunk_size = size % 8;
} }
if (col_compression_type_ == kColDict) { if (col_compression_type_ == kColDict) {
size_t dict_val; uint64_t dict_val;
ReadVarint64(&src, &dict_val); ReadVarint64(&src, &dict_val);
assert(dict_val < dict_vec_.size()); assert(dict_val < dict_vec_.size());
chunk_buf = dict_vec_[dict_val]; chunk_buf = dict_vec_[dict_val];
......
...@@ -176,7 +176,7 @@ size_t VariableChunkColBufEncoder::Append(const char *buf) { ...@@ -176,7 +176,7 @@ size_t VariableChunkColBufEncoder::Append(const char *buf) {
int8_t chunk_size = 8 - (0xFF - mark); int8_t chunk_size = 8 - (0xFF - mark);
if (col_compression_type_ == kColDict) { if (col_compression_type_ == kColDict) {
auto iter = dictionary_.find(val); auto iter = dictionary_.find(val);
size_t dict_val; uint64_t dict_val;
if (iter == dictionary_.end()) { if (iter == dictionary_.end()) {
dict_val = dictionary_.size(); dict_val = dictionary_.size();
dictionary_.insert(std::make_pair(val, dict_val)); dictionary_.insert(std::make_pair(val, dict_val));
......
...@@ -3,12 +3,17 @@ ...@@ -3,12 +3,17 @@
// LICENSE file in the root directory of this source tree. An additional grant // LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory. // of patent rights can be found in the PATENTS file in the same directory.
// //
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
#include <cstdio> #include <cstdio>
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
#ifdef GFLAGS #ifdef GFLAGS
#include <gflags/gflags.h> #include <gflags/gflags.h>
#include <inttypes.h>
#include <vector> #include <vector>
#include "rocksdb/env.h" #include "rocksdb/env.h"
#include "rocksdb/options.h" #include "rocksdb/options.h"
...@@ -106,10 +111,10 @@ class ColumnAwareEncodingExp { ...@@ -106,10 +111,10 @@ class ColumnAwareEncodingExp {
if (encoded_out_file != nullptr) { if (encoded_out_file != nullptr) {
uint64_t size = 0; uint64_t size = 0;
env->GetFileSize(FLAGS_encoded_file, &size); env->GetFileSize(FLAGS_encoded_file, &size);
fprintf(stdout, "File size: %llu\n", size); fprintf(stdout, "File size: %" PRIu64 "\n", size);
} }
uint64_t encode_time = sw.ElapsedNanosSafe(false /* reset */); uint64_t encode_time = sw.ElapsedNanosSafe(false /* reset */);
fprintf(stdout, "Encode time:%llu\n", encode_time); fprintf(stdout, "Encode time: %" PRIu64 "\n", encode_time);
if (decode) { if (decode) {
unique_ptr<WritableFile> decoded_out_file; unique_ptr<WritableFile> decoded_out_file;
if (!FLAGS_decoded_file.empty()) { if (!FLAGS_decoded_file.empty()) {
...@@ -124,7 +129,7 @@ class ColumnAwareEncodingExp { ...@@ -124,7 +129,7 @@ class ColumnAwareEncodingExp {
&encoded_blocks); &encoded_blocks);
} }
uint64_t decode_time = sw.ElapsedNanosSafe(true /* reset */); uint64_t decode_time = sw.ElapsedNanosSafe(true /* reset */);
fprintf(stdout, "Decode time:%llu\n", decode_time); fprintf(stdout, "Decode time: %" PRIu64 "\n", decode_time);
} }
} else { } else {
fprintf(stdout, "Unsupported compression type: %s.\n", fprintf(stdout, "Unsupported compression type: %s.\n",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册