mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-17 11:52:27 +00:00
Added params
This commit is contained in:
parent
e8a3914baa
commit
480d2df4e8
@ -45,8 +45,9 @@ namespace ErrorCodes
|
|||||||
{
|
{
|
||||||
extern const int CANNOT_COMPRESS;
|
extern const int CANNOT_COMPRESS;
|
||||||
extern const int CANNOT_DECOMPRESS;
|
extern const int CANNOT_DECOMPRESS;
|
||||||
extern const int BAD_ARGUMENTS;
|
|
||||||
extern const int ILLEGAL_SYNTAX_FOR_CODEC_TYPE;
|
extern const int ILLEGAL_SYNTAX_FOR_CODEC_TYPE;
|
||||||
|
extern const int ILLEGAL_CODEC_PARAMETER;
|
||||||
|
extern const int BAD_ARGUMENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt32 CompressionCodecGCD::getMaxCompressedDataSize(UInt32 uncompressed_size) const
|
UInt32 CompressionCodecGCD::getMaxCompressedDataSize(UInt32 uncompressed_size) const
|
||||||
@ -255,13 +256,27 @@ void registerCodecGCD(CompressionCodecFactory & factory)
|
|||||||
{
|
{
|
||||||
/// Default bytes size is 1.
|
/// Default bytes size is 1.
|
||||||
UInt8 gcd_bytes_size = 1;
|
UInt8 gcd_bytes_size = 1;
|
||||||
if (column_type)
|
|
||||||
|
if (arguments && !arguments->children.empty())
|
||||||
|
{
|
||||||
|
if (arguments->children.size() > 1)
|
||||||
|
throw Exception(ErrorCodes::ILLEGAL_SYNTAX_FOR_CODEC_TYPE, "GCD codec must have 1 parameter, given {}", arguments->children.size());
|
||||||
|
|
||||||
|
const auto children = arguments->children;
|
||||||
|
const auto * literal = children[0]->as<ASTLiteral>();
|
||||||
|
if (!literal || literal->value.getType() != Field::Types::Which::UInt64)
|
||||||
|
throw Exception(ErrorCodes::ILLEGAL_CODEC_PARAMETER, "GCD codec argument must be unsigned integer");
|
||||||
|
|
||||||
|
size_t user_bytes_size = literal->value.safeGet<UInt64>();
|
||||||
|
if (user_bytes_size != 1 && user_bytes_size != 2 && user_bytes_size != 4 && user_bytes_size != 8 && user_bytes_size != 16 && user_bytes_size != 32)
|
||||||
|
throw Exception(ErrorCodes::ILLEGAL_CODEC_PARAMETER, "GCD value for gcd codec can be 1, 2, 4, 8, 16 or 32, given {}", user_bytes_size);
|
||||||
|
gcd_bytes_size = static_cast<UInt8>(user_bytes_size);
|
||||||
|
}
|
||||||
|
else if (column_type)
|
||||||
{
|
{
|
||||||
gcd_bytes_size = getGCDBytesSize(column_type);
|
gcd_bytes_size = getGCDBytesSize(column_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arguments && !arguments->children.empty())
|
|
||||||
throw Exception(ErrorCodes::ILLEGAL_SYNTAX_FOR_CODEC_TYPE, "GCD codec must have 0 parameters, given {}", arguments->children.size());
|
|
||||||
return std::make_shared<CompressionCodecGCD>(gcd_bytes_size);
|
return std::make_shared<CompressionCodecGCD>(gcd_bytes_size);
|
||||||
};
|
};
|
||||||
factory.registerCompressionCodecWithType("GCD", method_code, codec_builder);
|
factory.registerCompressionCodecWithType("GCD", method_code, codec_builder);
|
||||||
|
9
tests/performance/codec_gcd.xml
Normal file
9
tests/performance/codec_gcd.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<test>
|
||||||
|
<create_query>CREATE TABLE gcd_codec (n UInt64 CODEC(GCD, LZ4)) ENGINE = MergeTree ORDER BY tuple()</create_query>
|
||||||
|
|
||||||
|
<query>INSERT INTO gcd_codec SELECT number FROM system.numbers LIMIT 20000000 SETTINGS max_threads=1</query>
|
||||||
|
<query>INSERT INTO gcd_codec SELECT number*1000 FROM system.numbers LIMIT 20000000 SETTINGS max_threads=1</query>
|
||||||
|
<query>INSERT INTO gcd_codec SELECT intHash64(number) FROM system.numbers LIMIT 20000000 SETTINGS max_threads=1</query>
|
||||||
|
|
||||||
|
<drop_query>DROP TABLE gcd_codec</drop_query>
|
||||||
|
</test>
|
Loading…
Reference in New Issue
Block a user