Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
  • Loading branch information
Lloyd-Pottiger committed Jul 8, 2024
1 parent 14bcfcf commit fa828aa
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions dbms/src/IO/Compression/CompressionFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,20 @@ extern const int UNKNOWN_COMPRESSION_METHOD;
class CompressionFactory
{
public:
template <bool IGNORE_DATA_TYPE = false>
static CompressionCodecPtr create(const CompressionSetting & setting)
{
// LZ4 and LZ4HC have the same format, the difference is only in compression.
// So they have the same method byte.
if (setting.method == CompressionMethod::LZ4HC)
return std::make_unique<CompressionCodecLZ4HC>(setting.level);

if (setting.data_type == CompressionDataType::String || setting.data_type == CompressionDataType::Float32
|| setting.data_type == CompressionDataType::Float64)
return std::make_unique<CompressionCodecLZ4>(setting.level);
if constexpr (!IGNORE_DATA_TYPE)
{
if (setting.data_type == CompressionDataType::String || setting.data_type == CompressionDataType::Float32
|| setting.data_type == CompressionDataType::Float64)
return std::make_unique<CompressionCodecLZ4>(setting.level);
}

switch (setting.method_byte)
{
Expand Down Expand Up @@ -92,7 +96,7 @@ class CompressionFactory
static CompressionCodecPtr createForDecompress(UInt8 method_byte)
{
CompressionSetting setting(static_cast<CompressionMethodByte>(method_byte));
return create(setting);
return create</*IGNORE_DATA_TYPE*/ true>(setting);
}

private:
Expand Down

0 comments on commit fa828aa

Please sign in to comment.