提交 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) {
if (col_compression_type_ == kColDict ||
col_compression_type_ == kColRleDict) {
const char* q;
size_t dict_size;
uint64_t dict_size;
// Bypass limit
q = GetVarint64Ptr(src, src + 10, &dict_size);
assert(q != nullptr);
src = q;
uint64_t dict_key;
for (size_t i = 0; i < dict_size; ++i) {
for (uint64_t i = 0; i < dict_size; ++i) {
// Bypass limit
ReadVarint64(&src, &dict_key);
......@@ -145,7 +145,7 @@ size_t FixedLengthColBufDecoder::Decode(const char* src, char** dest) {
last_val_ = tmp;
} else if (col_compression_type_ == kColRleDict ||
col_compression_type_ == kColDict) {
size_t dict_val = read_val;
uint64_t dict_val = read_val;
assert(dict_val < dict_vec_.size());
write_val = dict_vec_[dict_val];
}
......@@ -190,14 +190,14 @@ size_t VariableChunkColBufDecoder::Init(const char* src) {
const char* orig_src = src;
if (col_compression_type_ == kColDict) {
const char* q;
size_t dict_size;
uint64_t dict_size;
// Bypass limit
q = GetVarint64Ptr(src, src + 10, &dict_size);
assert(q != nullptr);
src = q;
uint64_t dict_key;
for (size_t i = 0; i < dict_size; ++i) {
for (uint64_t i = 0; i < dict_size; ++i) {
// Bypass limit
ReadVarint64(&src, &dict_key);
dict_vec_.push_back(dict_key);
......@@ -219,7 +219,7 @@ size_t VariableChunkColBufDecoder::Decode(const char* src, char** dest) {
chunk_size = size % 8;
}
if (col_compression_type_ == kColDict) {
size_t dict_val;
uint64_t dict_val;
ReadVarint64(&src, &dict_val);
assert(dict_val < dict_vec_.size());
chunk_buf = dict_vec_[dict_val];
......
......@@ -176,7 +176,7 @@ size_t VariableChunkColBufEncoder::Append(const char *buf) {
int8_t chunk_size = 8 - (0xFF - mark);
if (col_compression_type_ == kColDict) {
auto iter = dictionary_.find(val);
size_t dict_val;
uint64_t dict_val;
if (iter == dictionary_.end()) {
dict_val = dictionary_.size();
dictionary_.insert(std::make_pair(val, dict_val));
......
......@@ -3,12 +3,17 @@
// 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.
//
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
#include <cstdio>
#ifndef ROCKSDB_LITE
#ifdef GFLAGS
#include <gflags/gflags.h>
#include <inttypes.h>
#include <vector>
#include "rocksdb/env.h"
#include "rocksdb/options.h"
......@@ -106,10 +111,10 @@ class ColumnAwareEncodingExp {
if (encoded_out_file != nullptr) {
uint64_t size = 0;
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 */);
fprintf(stdout, "Encode time:%llu\n", encode_time);
fprintf(stdout, "Encode time: %" PRIu64 "\n", encode_time);
if (decode) {
unique_ptr<WritableFile> decoded_out_file;
if (!FLAGS_decoded_file.empty()) {
......@@ -124,7 +129,7 @@ class ColumnAwareEncodingExp {
&encoded_blocks);
}
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 {
fprintf(stdout, "Unsupported compression type: %s.\n",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册