Repository: hadoop Updated Branches: refs/heads/HDFS-8707 d43c9055c -> 3ce42301d
HDFS-9320. libhdfspp should use sizeof(int32_t) instead of sizeof(int) when parsing data. Contributed by James Clampffer. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/3ce42301 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/3ce42301 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/3ce42301 Branch: refs/heads/HDFS-8707 Commit: 3ce42301d5cabc8eba44548850b3c0d18a6e88b0 Parents: d43c905 Author: Haohui Mai <[email protected]> Authored: Mon Nov 2 13:13:29 2015 -0800 Committer: Haohui Mai <[email protected]> Committed: Mon Nov 2 13:13:29 2015 -0800 ---------------------------------------------------------------------- .../src/main/native/libhdfspp/lib/common/base64.cc | 4 ++-- .../src/main/native/libhdfspp/lib/common/continuation/protobuf.h | 2 +- .../main/native/libhdfspp/lib/reader/remote_block_reader_impl.h | 4 ++-- .../src/main/native/libhdfspp/tests/remote_block_reader_test.cc | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/3ce42301/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/base64.cc ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/base64.cc b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/base64.cc index f98fec5..39826bc 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/base64.cc +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/base64.cc @@ -36,10 +36,10 @@ std::string Base64Encode(const std::string &src) { size_t i = 0; while (i + 3 < src.length()) { const char *s = &src[i]; - const int r[4] = {s[0] >> 2, ((s[0] << 4) | (s[1] >> 4)) & 0x3f, + const int32_t r[4] = {s[0] >> 2, ((s[0] << 4) | (s[1] >> 4)) & 0x3f, ((s[1] << 2) | (s[2] >> 6)) & 0x3f, s[2] & 0x3f}; - std::transform(r, r + sizeof(r) / sizeof(int), std::back_inserter(dst), + std::transform(r, r + sizeof(r) / sizeof(int32_t), std::back_inserter(dst), [&r](unsigned char v) { return kDictionary[v]; }); i += 3; } http://git-wip-us.apache.org/repos/asf/hadoop/blob/3ce42301/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/continuation/protobuf.h ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/continuation/protobuf.h b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/continuation/protobuf.h index d30322c..08caf0d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/continuation/protobuf.h +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/continuation/protobuf.h @@ -70,7 +70,7 @@ private: } size_t offset = 0, len = 0; - for (size_t i = 0; i + 1 < transferred && i < sizeof(int); ++i) { + for (size_t i = 0; i + 1 < transferred && i < sizeof(int32_t); ++i) { len = (len << 7) | (buf_[i] & 0x7f); if ((uint8_t)buf_.at(i) < 0x80) { offset = i + 1; http://git-wip-us.apache.org/repos/asf/hadoop/blob/3ce42301/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/reader/remote_block_reader_impl.h ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/reader/remote_block_reader_impl.h b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/reader/remote_block_reader_impl.h index 68ea6ad..35c2ce4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/reader/remote_block_reader_impl.h +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/reader/remote_block_reader_impl.h @@ -122,9 +122,9 @@ struct RemoteBlockReader<Stream>::ReadPacketHeader private: static const size_t kMaxHeaderSize = 512; static const size_t kPayloadLenOffset = 0; - static const size_t kPayloadLenSize = sizeof(int); + static const size_t kPayloadLenSize = sizeof(int32_t); static const size_t kHeaderLenOffset = 4; - static const size_t kHeaderLenSize = sizeof(short); + static const size_t kHeaderLenSize = sizeof(int16_t); static const size_t kHeaderStart = kPayloadLenSize + kHeaderLenSize; RemoteBlockReader<Stream> *parent_; http://git-wip-us.apache.org/repos/asf/hadoop/blob/3ce42301/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/remote_block_reader_test.cc ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/remote_block_reader_test.cc b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/remote_block_reader_test.cc index 388a106..6ae657c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/remote_block_reader_test.cc +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/remote_block_reader_test.cc @@ -82,8 +82,8 @@ ProducePacket(const std::string &data, const std::string &checksum, char prefix[6]; *reinterpret_cast<unsigned *>(prefix) = - htonl(data.size() + checksum.size() + sizeof(int)); - *reinterpret_cast<short *>(prefix + sizeof(int)) = htons(proto.ByteSize()); + htonl(data.size() + checksum.size() + sizeof(int32_t)); + *reinterpret_cast<short *>(prefix + sizeof(int32_t)) = htons(proto.ByteSize()); std::string payload(prefix, sizeof(prefix)); payload.reserve(payload.size() + proto.ByteSize() + checksum.size() + data.size());
