From d3867ac5fa423448329ff197c2a309466cab3119 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Fri, 3 Jan 2020 17:39:24 +0300 Subject: [PATCH] More strict aliasing --- dbms/src/Compression/CompressedReadBufferBase.cpp | 4 ++-- dbms/src/Compression/CompressionCodecDelta.cpp | 4 ++-- dbms/src/Compression/CompressionCodecDelta.h | 2 +- dbms/src/Compression/CompressionCodecDoubleDelta.cpp | 4 ++-- dbms/src/Compression/CompressionCodecDoubleDelta.h | 2 +- dbms/src/Compression/CompressionCodecGorilla.cpp | 4 ++-- dbms/src/Compression/CompressionCodecGorilla.h | 2 +- dbms/src/Compression/CompressionCodecLZ4.cpp | 4 ++-- dbms/src/Compression/CompressionCodecLZ4.h | 2 +- dbms/src/Compression/CompressionCodecMultiple.cpp | 4 ++-- dbms/src/Compression/CompressionCodecMultiple.h | 2 +- dbms/src/Compression/CompressionCodecNone.cpp | 4 ++-- dbms/src/Compression/CompressionCodecNone.h | 2 +- dbms/src/Compression/CompressionCodecT64.cpp | 2 +- dbms/src/Compression/CompressionCodecT64.h | 2 +- dbms/src/Compression/CompressionCodecZSTD.cpp | 4 ++-- dbms/src/Compression/CompressionCodecZSTD.h | 2 +- dbms/src/Compression/CompressionFactory.cpp | 8 ++++---- dbms/src/Compression/ICompressionCodec.cpp | 6 +++--- dbms/src/Compression/ICompressionCodec.h | 4 ++-- 20 files changed, 34 insertions(+), 34 deletions(-) diff --git a/dbms/src/Compression/CompressedReadBufferBase.cpp b/dbms/src/Compression/CompressedReadBufferBase.cpp index d4e8ea34768..c85f9768736 100644 --- a/dbms/src/Compression/CompressedReadBufferBase.cpp +++ b/dbms/src/Compression/CompressedReadBufferBase.cpp @@ -105,7 +105,7 @@ size_t CompressedReadBufferBase::readCompressedData(size_t & size_decompressed, own_compressed_buffer.resize(header_size); compressed_in->readStrict(own_compressed_buffer.data(), header_size); - UInt8 method = ICompressionCodec::readMethod(own_compressed_buffer.data()); + uint8_t method = ICompressionCodec::readMethod(own_compressed_buffer.data()); if (!codec) codec = CompressionCodecFactory::instance().get(method); @@ -158,7 +158,7 @@ void CompressedReadBufferBase::decompress(char * to, size_t size_decompressed, s ProfileEvents::increment(ProfileEvents::CompressedReadBufferBlocks); ProfileEvents::increment(ProfileEvents::CompressedReadBufferBytes, size_decompressed); - UInt8 method = ICompressionCodec::readMethod(compressed_buffer); + uint8_t method = ICompressionCodec::readMethod(compressed_buffer); if (!codec) codec = CompressionCodecFactory::instance().get(method); diff --git a/dbms/src/Compression/CompressionCodecDelta.cpp b/dbms/src/Compression/CompressionCodecDelta.cpp index abf0b79f9c8..2369e2ca232 100644 --- a/dbms/src/Compression/CompressionCodecDelta.cpp +++ b/dbms/src/Compression/CompressionCodecDelta.cpp @@ -24,9 +24,9 @@ CompressionCodecDelta::CompressionCodecDelta(UInt8 delta_bytes_size_) { } -UInt8 CompressionCodecDelta::getMethodByte() const +uint8_t CompressionCodecDelta::getMethodByte() const { - return static_cast(CompressionMethodByte::Delta); + return static_cast(CompressionMethodByte::Delta); } String CompressionCodecDelta::getCodecDesc() const diff --git a/dbms/src/Compression/CompressionCodecDelta.h b/dbms/src/Compression/CompressionCodecDelta.h index 27b433f6e76..6a5ad9330e2 100644 --- a/dbms/src/Compression/CompressionCodecDelta.h +++ b/dbms/src/Compression/CompressionCodecDelta.h @@ -10,7 +10,7 @@ class CompressionCodecDelta : public ICompressionCodec public: CompressionCodecDelta(UInt8 delta_bytes_size_); - UInt8 getMethodByte() const override; + uint8_t getMethodByte() const override; String getCodecDesc() const override; diff --git a/dbms/src/Compression/CompressionCodecDoubleDelta.cpp b/dbms/src/Compression/CompressionCodecDoubleDelta.cpp index 84ada57e5b7..6bf434c5163 100644 --- a/dbms/src/Compression/CompressionCodecDoubleDelta.cpp +++ b/dbms/src/Compression/CompressionCodecDoubleDelta.cpp @@ -324,9 +324,9 @@ CompressionCodecDoubleDelta::CompressionCodecDoubleDelta(UInt8 data_bytes_size_) { } -UInt8 CompressionCodecDoubleDelta::getMethodByte() const +uint8_t CompressionCodecDoubleDelta::getMethodByte() const { - return static_cast(CompressionMethodByte::DoubleDelta); + return static_cast(CompressionMethodByte::DoubleDelta); } String CompressionCodecDoubleDelta::getCodecDesc() const diff --git a/dbms/src/Compression/CompressionCodecDoubleDelta.h b/dbms/src/Compression/CompressionCodecDoubleDelta.h index edbe2eea01d..04bc112360e 100644 --- a/dbms/src/Compression/CompressionCodecDoubleDelta.h +++ b/dbms/src/Compression/CompressionCodecDoubleDelta.h @@ -96,7 +96,7 @@ class CompressionCodecDoubleDelta : public ICompressionCodec public: CompressionCodecDoubleDelta(UInt8 data_bytes_size_); - UInt8 getMethodByte() const override; + uint8_t getMethodByte() const override; String getCodecDesc() const override; diff --git a/dbms/src/Compression/CompressionCodecGorilla.cpp b/dbms/src/Compression/CompressionCodecGorilla.cpp index a0fa414b144..ba8e9c4e37b 100644 --- a/dbms/src/Compression/CompressionCodecGorilla.cpp +++ b/dbms/src/Compression/CompressionCodecGorilla.cpp @@ -242,9 +242,9 @@ CompressionCodecGorilla::CompressionCodecGorilla(UInt8 data_bytes_size_) { } -UInt8 CompressionCodecGorilla::getMethodByte() const +uint8_t CompressionCodecGorilla::getMethodByte() const { - return static_cast(CompressionMethodByte::Gorilla); + return static_cast(CompressionMethodByte::Gorilla); } String CompressionCodecGorilla::getCodecDesc() const diff --git a/dbms/src/Compression/CompressionCodecGorilla.h b/dbms/src/Compression/CompressionCodecGorilla.h index 94941b7aa06..e95de81afb0 100644 --- a/dbms/src/Compression/CompressionCodecGorilla.h +++ b/dbms/src/Compression/CompressionCodecGorilla.h @@ -93,7 +93,7 @@ class CompressionCodecGorilla : public ICompressionCodec public: CompressionCodecGorilla(UInt8 data_bytes_size_); - UInt8 getMethodByte() const override; + uint8_t getMethodByte() const override; String getCodecDesc() const override; diff --git a/dbms/src/Compression/CompressionCodecLZ4.cpp b/dbms/src/Compression/CompressionCodecLZ4.cpp index df3e6d6c088..450ca7b335a 100644 --- a/dbms/src/Compression/CompressionCodecLZ4.cpp +++ b/dbms/src/Compression/CompressionCodecLZ4.cpp @@ -23,9 +23,9 @@ extern const int ILLEGAL_CODEC_PARAMETER; } -UInt8 CompressionCodecLZ4::getMethodByte() const +uint8_t CompressionCodecLZ4::getMethodByte() const { - return static_cast(CompressionMethodByte::LZ4); + return static_cast(CompressionMethodByte::LZ4); } String CompressionCodecLZ4::getCodecDesc() const diff --git a/dbms/src/Compression/CompressionCodecLZ4.h b/dbms/src/Compression/CompressionCodecLZ4.h index 59e6096faf1..d53fced3681 100644 --- a/dbms/src/Compression/CompressionCodecLZ4.h +++ b/dbms/src/Compression/CompressionCodecLZ4.h @@ -12,7 +12,7 @@ namespace DB class CompressionCodecLZ4 : public ICompressionCodec { public: - UInt8 getMethodByte() const override; + uint8_t getMethodByte() const override; String getCodecDesc() const override; diff --git a/dbms/src/Compression/CompressionCodecMultiple.cpp b/dbms/src/Compression/CompressionCodecMultiple.cpp index 4cdd7c2e8e8..c6a009eede4 100644 --- a/dbms/src/Compression/CompressionCodecMultiple.cpp +++ b/dbms/src/Compression/CompressionCodecMultiple.cpp @@ -26,9 +26,9 @@ CompressionCodecMultiple::CompressionCodecMultiple(Codecs codecs_) { } -UInt8 CompressionCodecMultiple::getMethodByte() const +uint8_t CompressionCodecMultiple::getMethodByte() const { - return static_cast(CompressionMethodByte::Multiple); + return static_cast(CompressionMethodByte::Multiple); } String CompressionCodecMultiple::getCodecDesc() const diff --git a/dbms/src/Compression/CompressionCodecMultiple.h b/dbms/src/Compression/CompressionCodecMultiple.h index 5f6d18df01c..b8c33bd4f6b 100644 --- a/dbms/src/Compression/CompressionCodecMultiple.h +++ b/dbms/src/Compression/CompressionCodecMultiple.h @@ -11,7 +11,7 @@ public: CompressionCodecMultiple() = default; explicit CompressionCodecMultiple(Codecs codecs_); - UInt8 getMethodByte() const override; + uint8_t getMethodByte() const override; String getCodecDesc() const override; diff --git a/dbms/src/Compression/CompressionCodecNone.cpp b/dbms/src/Compression/CompressionCodecNone.cpp index 7c5a4628539..3bee1c77276 100644 --- a/dbms/src/Compression/CompressionCodecNone.cpp +++ b/dbms/src/Compression/CompressionCodecNone.cpp @@ -6,9 +6,9 @@ namespace DB { -UInt8 CompressionCodecNone::getMethodByte() const +uint8_t CompressionCodecNone::getMethodByte() const { - return static_cast(CompressionMethodByte::NONE); + return static_cast(CompressionMethodByte::NONE); } String CompressionCodecNone::getCodecDesc() const diff --git a/dbms/src/Compression/CompressionCodecNone.h b/dbms/src/Compression/CompressionCodecNone.h index 81046f77070..168a15bec2f 100644 --- a/dbms/src/Compression/CompressionCodecNone.h +++ b/dbms/src/Compression/CompressionCodecNone.h @@ -11,7 +11,7 @@ namespace DB class CompressionCodecNone : public ICompressionCodec { public: - UInt8 getMethodByte() const override; + uint8_t getMethodByte() const override; String getCodecDesc() const override; diff --git a/dbms/src/Compression/CompressionCodecT64.cpp b/dbms/src/Compression/CompressionCodecT64.cpp index 7d6090dda07..4ae3ee95ebc 100644 --- a/dbms/src/Compression/CompressionCodecT64.cpp +++ b/dbms/src/Compression/CompressionCodecT64.cpp @@ -640,7 +640,7 @@ void CompressionCodecT64::useInfoAboutType(DataTypePtr data_type) } } -UInt8 CompressionCodecT64::getMethodByte() const +uint8_t CompressionCodecT64::getMethodByte() const { return codecId(); } diff --git a/dbms/src/Compression/CompressionCodecT64.h b/dbms/src/Compression/CompressionCodecT64.h index 048057f9e79..8bfdcc766cf 100644 --- a/dbms/src/Compression/CompressionCodecT64.h +++ b/dbms/src/Compression/CompressionCodecT64.h @@ -30,7 +30,7 @@ public: , variant(variant_) {} - UInt8 getMethodByte() const override; + uint8_t getMethodByte() const override; String getCodecDesc() const override { return String("T64") + ((variant == Variant::Byte) ? "" : "(\'bit\')"); diff --git a/dbms/src/Compression/CompressionCodecZSTD.cpp b/dbms/src/Compression/CompressionCodecZSTD.cpp index 9e7e66a5e6e..e5f950347e1 100644 --- a/dbms/src/Compression/CompressionCodecZSTD.cpp +++ b/dbms/src/Compression/CompressionCodecZSTD.cpp @@ -21,9 +21,9 @@ namespace ErrorCodes extern const int ILLEGAL_CODEC_PARAMETER; } -UInt8 CompressionCodecZSTD::getMethodByte() const +uint8_t CompressionCodecZSTD::getMethodByte() const { - return static_cast(CompressionMethodByte::ZSTD); + return static_cast(CompressionMethodByte::ZSTD); } String CompressionCodecZSTD::getCodecDesc() const diff --git a/dbms/src/Compression/CompressionCodecZSTD.h b/dbms/src/Compression/CompressionCodecZSTD.h index 3244e4ec886..045602c66ea 100644 --- a/dbms/src/Compression/CompressionCodecZSTD.h +++ b/dbms/src/Compression/CompressionCodecZSTD.h @@ -15,7 +15,7 @@ public: CompressionCodecZSTD(int level_); - UInt8 getMethodByte() const override; + uint8_t getMethodByte() const override; String getCodecDesc() const override; diff --git a/dbms/src/Compression/CompressionFactory.cpp b/dbms/src/Compression/CompressionFactory.cpp index 3a02c3b4540..98595f1347c 100644 --- a/dbms/src/Compression/CompressionFactory.cpp +++ b/dbms/src/Compression/CompressionFactory.cpp @@ -68,7 +68,7 @@ CompressionCodecPtr CompressionCodecFactory::get(const ASTPtr & ast, DataTypePtr throw Exception("Unknown codec family: " + queryToString(ast), ErrorCodes::UNKNOWN_CODEC); } -CompressionCodecPtr CompressionCodecFactory::get(const UInt8 byte_code) const +CompressionCodecPtr CompressionCodecFactory::get(const uint8_t byte_code) const { const auto family_code_and_creator = family_code_with_codec.find(byte_code); @@ -94,7 +94,7 @@ CompressionCodecPtr CompressionCodecFactory::getImpl(const String & family_name, void CompressionCodecFactory::registerCompressionCodecWithType( const String & family_name, - std::optional byte_code, + std::optional byte_code, CreatorWithType creator) { if (creator == nullptr) @@ -109,7 +109,7 @@ void CompressionCodecFactory::registerCompressionCodecWithType( throw Exception("CompressionCodecFactory: the codec family name '" + family_name + "' is not unique", ErrorCodes::LOGICAL_ERROR); } -void CompressionCodecFactory::registerCompressionCodec(const String & family_name, std::optional byte_code, Creator creator) +void CompressionCodecFactory::registerCompressionCodec(const String & family_name, std::optional byte_code, Creator creator) { registerCompressionCodecWithType(family_name, byte_code, [family_name, creator](const ASTPtr & ast, DataTypePtr /* data_type */) { @@ -119,7 +119,7 @@ void CompressionCodecFactory::registerCompressionCodec(const String & family_nam void CompressionCodecFactory::registerSimpleCompressionCodec( const String & family_name, - std::optional byte_code, + std::optional byte_code, SimpleCreator creator) { registerCompressionCodec(family_name, byte_code, [family_name, creator](const ASTPtr & ast) diff --git a/dbms/src/Compression/ICompressionCodec.cpp b/dbms/src/Compression/ICompressionCodec.cpp index ea3a74c18a5..64e6051b8d5 100644 --- a/dbms/src/Compression/ICompressionCodec.cpp +++ b/dbms/src/Compression/ICompressionCodec.cpp @@ -39,7 +39,7 @@ UInt32 ICompressionCodec::decompress(const char * source, UInt32 source_size, ch throw Exception("Can't decompress data: the compressed data size (" + toString(source_size) + ", this should include header size) is less than the header size (" + toString(header_size) + ")", ErrorCodes::CORRUPTED_DATA); - UInt8 method = source[0]; + uint8_t method = source[0]; if (method != getMethodByte()) throw Exception("Can't decompress data with codec byte " + toString(method) + " from codec with byte " + toString(method), ErrorCodes::CANNOT_DECOMPRESS); @@ -61,9 +61,9 @@ UInt32 ICompressionCodec::readDecompressedBlockSize(const char * source) } -UInt8 ICompressionCodec::readMethod(const char * source) +uint8_t ICompressionCodec::readMethod(const char * source) { - return static_cast(source[0]); + return static_cast(source[0]); } } diff --git a/dbms/src/Compression/ICompressionCodec.h b/dbms/src/Compression/ICompressionCodec.h index 107149bde38..083824cf0ca 100644 --- a/dbms/src/Compression/ICompressionCodec.h +++ b/dbms/src/Compression/ICompressionCodec.h @@ -27,7 +27,7 @@ public: virtual ~ICompressionCodec() = default; /// Byte which indicates codec in compressed file - virtual UInt8 getMethodByte() const = 0; + virtual uint8_t getMethodByte() const = 0; /// Codec description, for example "ZSTD(2)" or "LZ4,LZ4HC(5)" virtual String getCodecDesc() const = 0; @@ -54,7 +54,7 @@ public: static UInt32 readDecompressedBlockSize(const char * source); /// Read method byte from compressed source - static UInt8 readMethod(const char * source); + static uint8_t readMethod(const char * source); /// Some codecs may use information about column type which appears after codec creation virtual void useInfoAboutType(DataTypePtr /* data_type */) { }