mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-12 02:23:14 +00:00
More strict aliasing
This commit is contained in:
parent
b55ba35731
commit
d3867ac5fa
@ -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);
|
||||
|
@ -24,9 +24,9 @@ CompressionCodecDelta::CompressionCodecDelta(UInt8 delta_bytes_size_)
|
||||
{
|
||||
}
|
||||
|
||||
UInt8 CompressionCodecDelta::getMethodByte() const
|
||||
uint8_t CompressionCodecDelta::getMethodByte() const
|
||||
{
|
||||
return static_cast<UInt8>(CompressionMethodByte::Delta);
|
||||
return static_cast<uint8_t>(CompressionMethodByte::Delta);
|
||||
}
|
||||
|
||||
String CompressionCodecDelta::getCodecDesc() const
|
||||
|
@ -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;
|
||||
|
||||
|
@ -324,9 +324,9 @@ CompressionCodecDoubleDelta::CompressionCodecDoubleDelta(UInt8 data_bytes_size_)
|
||||
{
|
||||
}
|
||||
|
||||
UInt8 CompressionCodecDoubleDelta::getMethodByte() const
|
||||
uint8_t CompressionCodecDoubleDelta::getMethodByte() const
|
||||
{
|
||||
return static_cast<UInt8>(CompressionMethodByte::DoubleDelta);
|
||||
return static_cast<uint8_t>(CompressionMethodByte::DoubleDelta);
|
||||
}
|
||||
|
||||
String CompressionCodecDoubleDelta::getCodecDesc() const
|
||||
|
@ -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;
|
||||
|
||||
|
@ -242,9 +242,9 @@ CompressionCodecGorilla::CompressionCodecGorilla(UInt8 data_bytes_size_)
|
||||
{
|
||||
}
|
||||
|
||||
UInt8 CompressionCodecGorilla::getMethodByte() const
|
||||
uint8_t CompressionCodecGorilla::getMethodByte() const
|
||||
{
|
||||
return static_cast<UInt8>(CompressionMethodByte::Gorilla);
|
||||
return static_cast<uint8_t>(CompressionMethodByte::Gorilla);
|
||||
}
|
||||
|
||||
String CompressionCodecGorilla::getCodecDesc() const
|
||||
|
@ -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;
|
||||
|
||||
|
@ -23,9 +23,9 @@ extern const int ILLEGAL_CODEC_PARAMETER;
|
||||
}
|
||||
|
||||
|
||||
UInt8 CompressionCodecLZ4::getMethodByte() const
|
||||
uint8_t CompressionCodecLZ4::getMethodByte() const
|
||||
{
|
||||
return static_cast<UInt8>(CompressionMethodByte::LZ4);
|
||||
return static_cast<uint8_t>(CompressionMethodByte::LZ4);
|
||||
}
|
||||
|
||||
String CompressionCodecLZ4::getCodecDesc() const
|
||||
|
@ -12,7 +12,7 @@ namespace DB
|
||||
class CompressionCodecLZ4 : public ICompressionCodec
|
||||
{
|
||||
public:
|
||||
UInt8 getMethodByte() const override;
|
||||
uint8_t getMethodByte() const override;
|
||||
|
||||
String getCodecDesc() const override;
|
||||
|
||||
|
@ -26,9 +26,9 @@ CompressionCodecMultiple::CompressionCodecMultiple(Codecs codecs_)
|
||||
{
|
||||
}
|
||||
|
||||
UInt8 CompressionCodecMultiple::getMethodByte() const
|
||||
uint8_t CompressionCodecMultiple::getMethodByte() const
|
||||
{
|
||||
return static_cast<UInt8>(CompressionMethodByte::Multiple);
|
||||
return static_cast<uint8_t>(CompressionMethodByte::Multiple);
|
||||
}
|
||||
|
||||
String CompressionCodecMultiple::getCodecDesc() const
|
||||
|
@ -11,7 +11,7 @@ public:
|
||||
CompressionCodecMultiple() = default;
|
||||
explicit CompressionCodecMultiple(Codecs codecs_);
|
||||
|
||||
UInt8 getMethodByte() const override;
|
||||
uint8_t getMethodByte() const override;
|
||||
|
||||
String getCodecDesc() const override;
|
||||
|
||||
|
@ -6,9 +6,9 @@
|
||||
namespace DB
|
||||
{
|
||||
|
||||
UInt8 CompressionCodecNone::getMethodByte() const
|
||||
uint8_t CompressionCodecNone::getMethodByte() const
|
||||
{
|
||||
return static_cast<UInt8>(CompressionMethodByte::NONE);
|
||||
return static_cast<uint8_t>(CompressionMethodByte::NONE);
|
||||
}
|
||||
|
||||
String CompressionCodecNone::getCodecDesc() const
|
||||
|
@ -11,7 +11,7 @@ namespace DB
|
||||
class CompressionCodecNone : public ICompressionCodec
|
||||
{
|
||||
public:
|
||||
UInt8 getMethodByte() const override;
|
||||
uint8_t getMethodByte() const override;
|
||||
|
||||
String getCodecDesc() const override;
|
||||
|
||||
|
@ -640,7 +640,7 @@ void CompressionCodecT64::useInfoAboutType(DataTypePtr data_type)
|
||||
}
|
||||
}
|
||||
|
||||
UInt8 CompressionCodecT64::getMethodByte() const
|
||||
uint8_t CompressionCodecT64::getMethodByte() const
|
||||
{
|
||||
return codecId();
|
||||
}
|
||||
|
@ -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\')");
|
||||
|
@ -21,9 +21,9 @@ namespace ErrorCodes
|
||||
extern const int ILLEGAL_CODEC_PARAMETER;
|
||||
}
|
||||
|
||||
UInt8 CompressionCodecZSTD::getMethodByte() const
|
||||
uint8_t CompressionCodecZSTD::getMethodByte() const
|
||||
{
|
||||
return static_cast<UInt8>(CompressionMethodByte::ZSTD);
|
||||
return static_cast<uint8_t>(CompressionMethodByte::ZSTD);
|
||||
}
|
||||
|
||||
String CompressionCodecZSTD::getCodecDesc() const
|
||||
|
@ -15,7 +15,7 @@ public:
|
||||
|
||||
CompressionCodecZSTD(int level_);
|
||||
|
||||
UInt8 getMethodByte() const override;
|
||||
uint8_t getMethodByte() const override;
|
||||
|
||||
String getCodecDesc() const override;
|
||||
|
||||
|
@ -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<UInt8> byte_code,
|
||||
std::optional<uint8_t> 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<UInt8> byte_code, Creator creator)
|
||||
void CompressionCodecFactory::registerCompressionCodec(const String & family_name, std::optional<uint8_t> 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<UInt8> byte_code,
|
||||
std::optional<uint8_t> byte_code,
|
||||
SimpleCreator creator)
|
||||
{
|
||||
registerCompressionCodec(family_name, byte_code, [family_name, creator](const ASTPtr & ast)
|
||||
|
@ -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<UInt8>(source[0]);
|
||||
return static_cast<uint8_t>(source[0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 */) { }
|
||||
|
Loading…
Reference in New Issue
Block a user