From 380f748358077de8e0b17818eb3ee50a163df11b Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Thu, 9 Jul 2020 08:08:41 +0300 Subject: [PATCH] Fix issues --- src/Compression/CompressionCodecMultiple.cpp | 9 +++++++++ src/Compression/CompressionCodecMultiple.h | 1 + src/Compression/CompressionFactory.cpp | 2 ++ .../00804_test_custom_compression_codecs.reference | 2 +- .../00804_test_custom_compression_codecs.sql | 14 ++++++++++---- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/Compression/CompressionCodecMultiple.cpp b/src/Compression/CompressionCodecMultiple.cpp index 1db6b22bbc2..e5adacb6173 100644 --- a/src/Compression/CompressionCodecMultiple.cpp +++ b/src/Compression/CompressionCodecMultiple.cpp @@ -153,4 +153,13 @@ bool CompressionCodecMultiple::isCompression() const return false; } + +void registerCodecMultiple(CompressionCodecFactory & factory) +{ + factory.registerSimpleCompressionCodec("Multiple", static_cast(CompressionMethodByte::Multiple), [&] () + { + return std::make_shared(); + }); +} + } diff --git a/src/Compression/CompressionCodecMultiple.h b/src/Compression/CompressionCodecMultiple.h index 9bc87577f8d..7737e91ad92 100644 --- a/src/Compression/CompressionCodecMultiple.h +++ b/src/Compression/CompressionCodecMultiple.h @@ -8,6 +8,7 @@ namespace DB class CompressionCodecMultiple final : public ICompressionCodec { public: + CompressionCodecMultiple() = default; /// Need for CompressionFactory to register codec by method byte. CompressionCodecMultiple(Codecs codecs_, bool sanity_check); uint8_t getMethodByte() const override; diff --git a/src/Compression/CompressionFactory.cpp b/src/Compression/CompressionFactory.cpp index d284e79cdef..e9dee053c2c 100644 --- a/src/Compression/CompressionFactory.cpp +++ b/src/Compression/CompressionFactory.cpp @@ -152,6 +152,7 @@ void registerCodecDelta(CompressionCodecFactory & factory); void registerCodecT64(CompressionCodecFactory & factory); void registerCodecDoubleDelta(CompressionCodecFactory & factory); void registerCodecGorilla(CompressionCodecFactory & factory); +void registerCodecMultiple(CompressionCodecFactory & factory); CompressionCodecFactory::CompressionCodecFactory() { @@ -163,6 +164,7 @@ CompressionCodecFactory::CompressionCodecFactory() registerCodecT64(*this); registerCodecDoubleDelta(*this); registerCodecGorilla(*this); + registerCodecMultiple(*this); default_codec = get("LZ4", {}, false); } diff --git a/tests/queries/0_stateless/00804_test_custom_compression_codecs.reference b/tests/queries/0_stateless/00804_test_custom_compression_codecs.reference index 00556b0f8c9..a0c13b9ca47 100644 --- a/tests/queries/0_stateless/00804_test_custom_compression_codecs.reference +++ b/tests/queries/0_stateless/00804_test_custom_compression_codecs.reference @@ -9,7 +9,7 @@ 10003 274972506.6 9175437371954010821 -CREATE TABLE default.compression_codec_multiple_more_types\n(\n `id` Decimal(38, 13) CODEC(ZSTD(1), LZ4, ZSTD(1), ZSTD(1), Delta(2), Delta(4), Delta(1), LZ4HC(0)),\n `data` FixedString(12) CODEC(ZSTD(1), ZSTD(1), Delta(1), Delta(1), Delta(1), NONE, NONE, NONE, LZ4HC(0)),\n `ddd.age` Array(UInt8) CODEC(LZ4, LZ4HC(0), NONE, NONE, NONE, ZSTD(1), Delta(8)),\n `ddd.Name` Array(String) CODEC(LZ4, LZ4HC(0), NONE, NONE, NONE, ZSTD(1), Delta(8))\n)\nENGINE = MergeTree()\nORDER BY tuple()\nSETTINGS index_granularity = 8192 +CREATE TABLE default.compression_codec_multiple_more_types\n(\n `id` Decimal(38, 13) CODEC(ZSTD(1), LZ4, ZSTD(1), ZSTD(1), Delta(2), Delta(4), Delta(1), LZ4HC(0)),\n `data` FixedString(12) CODEC(ZSTD(1), ZSTD(1), NONE, NONE, NONE, LZ4HC(0)),\n `ddd.age` Array(UInt8) CODEC(LZ4, LZ4HC(0), NONE, NONE, NONE, ZSTD(1), Delta(8)),\n `ddd.Name` Array(String) CODEC(LZ4, LZ4HC(0), NONE, NONE, NONE, ZSTD(1), Delta(8))\n)\nENGINE = MergeTree()\nORDER BY tuple()\nSETTINGS index_granularity = 8192 1.5555555555555 hello world! [77] ['John'] 7.1000000000000 xxxxxxxxxxxx [127] ['Henry'] ! diff --git a/tests/queries/0_stateless/00804_test_custom_compression_codecs.sql b/tests/queries/0_stateless/00804_test_custom_compression_codecs.sql index 61298de2548..87862f46e05 100644 --- a/tests/queries/0_stateless/00804_test_custom_compression_codecs.sql +++ b/tests/queries/0_stateless/00804_test_custom_compression_codecs.sql @@ -88,6 +88,12 @@ CREATE TABLE compression_codec_multiple_more_types ( id Decimal128(13) CODEC(ZSTD, LZ4, ZSTD, ZSTD, Delta(2), Delta(4), Delta(1), LZ4HC), data FixedString(12) CODEC(ZSTD, ZSTD, Delta, Delta, Delta, NONE, NONE, NONE, LZ4HC), ddd Nested (age UInt8, Name String) CODEC(LZ4, LZ4HC, NONE, NONE, NONE, ZSTD, Delta(8)) +) ENGINE = MergeTree() ORDER BY tuple(); -- { serverError 36 } + +CREATE TABLE compression_codec_multiple_more_types ( + id Decimal128(13) CODEC(ZSTD, LZ4, ZSTD, ZSTD, Delta(2), Delta(4), Delta(1), LZ4HC), + data FixedString(12) CODEC(ZSTD, ZSTD, NONE, NONE, NONE, LZ4HC), + ddd Nested (age UInt8, Name String) CODEC(LZ4, LZ4HC, NONE, NONE, NONE, ZSTD, Delta(8)) ) ENGINE = MergeTree() ORDER BY tuple(); SHOW CREATE TABLE compression_codec_multiple_more_types; @@ -105,7 +111,7 @@ SET network_zstd_compression_level = 5; CREATE TABLE compression_codec_multiple_with_key ( somedate Date CODEC(ZSTD, ZSTD, ZSTD(12), LZ4HC(12), Delta, Delta), id UInt64 CODEC(LZ4, ZSTD, Delta, NONE, LZ4HC, Delta), - data String CODEC(ZSTD(2), Delta, LZ4HC, NONE, LZ4, LZ4) + data String CODEC(ZSTD(2), Delta(1), LZ4HC, NONE, LZ4, LZ4) ) ENGINE = MergeTree() PARTITION BY somedate ORDER BY id SETTINGS index_granularity = 2; @@ -131,13 +137,13 @@ DROP TABLE IF EXISTS test_default_delta; CREATE TABLE test_default_delta( id UInt64 CODEC(Delta), - data String CODEC(Delta), + data String CODEC(Delta(1)), somedate Date CODEC(Delta), somenum Float64 CODEC(Delta), - somestr FixedString(3) CODEC(Delta), + somestr FixedString(3) CODEC(Delta(1)), othernum Int64 CODEC(Delta), yetothernum Float32 CODEC(Delta), - ddd Nested (age UInt8, Name String, OName String, BName String) CODEC(Delta) + ddd Nested (age UInt8, Name String, OName String, BName String) CODEC(Delta(1)) ) ENGINE = MergeTree() ORDER BY tuple(); SHOW CREATE TABLE test_default_delta;