Remove ridiculous code

This commit is contained in:
Alexey Milovidov 2020-07-09 03:46:00 +03:00
parent 9dc91e3ee4
commit 0c8e12affd
14 changed files with 26 additions and 44 deletions

View File

@ -166,7 +166,8 @@ void registerCodecDelta(CompressionCodecFactory & factory)
UInt8 method_code = UInt8(CompressionMethodByte::Delta);
factory.registerCompressionCodecWithType("Delta", method_code, [&](const ASTPtr & arguments, DataTypePtr column_type) -> CompressionCodecPtr
{
UInt8 delta_bytes_size = getDeltaBytesSize(column_type);
UInt8 delta_bytes_size;
if (arguments && !arguments->children.empty())
{
if (arguments->children.size() > 1)
@ -182,6 +183,11 @@ void registerCodecDelta(CompressionCodecFactory & factory)
throw Exception("Delta value for delta codec can be 1, 2, 4 or 8, given " + toString(user_bytes_size), ErrorCodes::ILLEGAL_CODEC_PARAMETER);
delta_bytes_size = static_cast<UInt8>(user_bytes_size);
}
else
{
delta_bytes_size = getDeltaBytesSize(column_type);
}
return std::make_shared<CompressionCodecDelta>(delta_bytes_size);
});
}

View File

@ -30,7 +30,4 @@ private:
UInt8 delta_bytes_size;
};
class CompressionCodecFactory;
void registerCodecDelta(CompressionCodecFactory & factory);
}

View File

@ -419,8 +419,12 @@ void CompressionCodecDoubleDelta::useInfoAboutType(DataTypePtr data_type)
void registerCodecDoubleDelta(CompressionCodecFactory & factory)
{
UInt8 method_code = UInt8(CompressionMethodByte::DoubleDelta);
factory.registerCompressionCodecWithType("DoubleDelta", method_code, [&](const ASTPtr &, DataTypePtr column_type) -> CompressionCodecPtr
factory.registerCompressionCodecWithType("DoubleDelta", method_code,
[&](const ASTPtr & arguments, DataTypePtr column_type) -> CompressionCodecPtr
{
if (arguments)
throw Exception("Codec DoubleDelta does not accept any arguments", ErrorCodes::BAD_ARGUMENTS);
UInt8 delta_bytes_size = getDataBytesSize(column_type);
return std::make_shared<CompressionCodecDoubleDelta>(delta_bytes_size);
});

View File

@ -116,7 +116,4 @@ private:
UInt8 data_bytes_size;
};
class CompressionCodecFactory;
void registerCodecDoubleDelta(CompressionCodecFactory & factory);
}

View File

@ -336,10 +336,14 @@ void CompressionCodecGorilla::useInfoAboutType(DataTypePtr data_type)
void registerCodecGorilla(CompressionCodecFactory & factory)
{
UInt8 method_code = UInt8(CompressionMethodByte::Gorilla);
factory.registerCompressionCodecWithType("Gorilla", method_code, [&](const ASTPtr &, DataTypePtr column_type) -> CompressionCodecPtr
factory.registerCompressionCodecWithType("Gorilla", method_code,
[&](const ASTPtr & arguments, DataTypePtr column_type) -> CompressionCodecPtr
{
UInt8 delta_bytes_size = getDataBytesSize(column_type);
return std::make_shared<CompressionCodecGorilla>(delta_bytes_size);
if (arguments)
throw Exception("Codec Gorilla does not accept any arguments", ErrorCodes::BAD_ARGUMENTS);
UInt8 data_bytes_size = getDataBytesSize(column_type);
return std::make_shared<CompressionCodecGorilla>(data_bytes_size);
});
}
}

View File

@ -113,7 +113,4 @@ private:
UInt8 data_bytes_size;
};
class CompressionCodecFactory;
void registerCodecGorilla(CompressionCodecFactory & factory);
}

View File

@ -32,8 +32,6 @@ private:
mutable LZ4::PerformanceStatistics lz4_stat;
};
class CompressionCodecFactory;
void registerCodecLZ4(CompressionCodecFactory & factory);
class CompressionCodecLZ4HC : public CompressionCodecLZ4
{
@ -50,7 +48,4 @@ private:
const int level;
};
class CompressionCodecFactory;
void registerCodecLZ4HC(CompressionCodecFactory & factory);
}

View File

@ -155,12 +155,4 @@ bool CompressionCodecMultiple::isCompression() const
return false;
}
void registerCodecMultiple(CompressionCodecFactory & factory)
{
factory.registerSimpleCompressionCodec("Multiple", static_cast<UInt8>(CompressionMethodByte::Multiple), [&] ()
{
return std::make_shared<CompressionCodecMultiple>();
});
}
}

View File

@ -8,7 +8,6 @@ namespace DB
class CompressionCodecMultiple final : public ICompressionCodec
{
public:
CompressionCodecMultiple() = default;
CompressionCodecMultiple(Codecs codecs_, bool sanity_check);
uint8_t getMethodByte() const override;
@ -33,8 +32,4 @@ private:
String getCodecDescImpl() const;
};
class CompressionCodecFactory;
void registerCodecMultiple(CompressionCodecFactory & factory);
}

View File

@ -25,6 +25,4 @@ protected:
bool isNone() const override { return true; }
};
class CompressionCodecFactory;
void registerCodecNone(CompressionCodecFactory & factory);
}

View File

@ -56,7 +56,4 @@ private:
Variant variant;
};
class CompressionCodecFactory;
void registerCodecT64(CompressionCodecFactory & factory);
}

View File

@ -33,8 +33,4 @@ private:
const int level;
};
class CompressionCodecFactory;
void registerCodecZSTD(CompressionCodecFactory & factory);
}

View File

@ -9,7 +9,6 @@
#include <IO/ReadBuffer.h>
#include <Parsers/queryToString.h>
#include <Compression/CompressionCodecMultiple.h>
#include <Compression/CompressionCodecLZ4.h>
#include <IO/WriteHelpers.h>
@ -146,6 +145,8 @@ void CompressionCodecFactory::registerSimpleCompressionCodec(
void registerCodecNone(CompressionCodecFactory & factory);
void registerCodecLZ4(CompressionCodecFactory & factory);
void registerCodecLZ4HC(CompressionCodecFactory & factory);
void registerCodecZSTD(CompressionCodecFactory & factory);
void registerCodecDelta(CompressionCodecFactory & factory);
void registerCodecT64(CompressionCodecFactory & factory);
@ -154,16 +155,16 @@ void registerCodecGorilla(CompressionCodecFactory & factory);
CompressionCodecFactory::CompressionCodecFactory()
{
default_codec = std::make_shared<CompressionCodecLZ4>();
registerCodecLZ4(*this);
registerCodecNone(*this);
registerCodecZSTD(*this);
registerCodecMultiple(*this);
registerCodecLZ4HC(*this);
registerCodecDelta(*this);
registerCodecT64(*this);
registerCodecDoubleDelta(*this);
registerCodecGorilla(*this);
default_codec = get("LZ4", {}, false);
}
CompressionCodecFactory & CompressionCodecFactory::instance()

View File

@ -5,3 +5,6 @@ CREATE TABLE delta_codec_synthetic (`id` UInt64 NULL CODEC(Gorilla, ZSTD(22))) E
CREATE TABLE delta_codec_synthetic (`id` Decimal(38, 10) CODEC(Delta, ZSTD(22))) ENGINE = MergeTree() ORDER BY tuple(); -- { serverError 36 }
CREATE TABLE delta_codec_synthetic (`id` Decimal(38, 10) CODEC(DoubleDelta, ZSTD(22))) ENGINE = MergeTree() ORDER BY tuple(); -- { serverError 36 }
CREATE TABLE delta_codec_synthetic (`id` Decimal(38, 10) CODEC(Gorilla, ZSTD(22))) ENGINE = MergeTree() ORDER BY tuple(); -- { serverError 36 }
CREATE TABLE delta_codec_synthetic (`id` UInt64 CODEC(DoubleDelta(3), ZSTD(22))) ENGINE = MergeTree() ORDER BY tuple(); -- { serverError 36 }
CREATE TABLE delta_codec_synthetic (`id` UInt64 CODEC(Gorilla('hello, world'), ZSTD(22))) ENGINE = MergeTree() ORDER BY tuple(); -- { serverError 36 }