From 6ec1592a9fb265f422824b0e2ed48aa2facec6a1 Mon Sep 17 00:00:00 2001 From: Yakov Olkhovskiy Date: Sun, 8 Jan 2023 20:58:09 +0000 Subject: [PATCH 1/7] fix hash functions for IPv4 --- src/DataTypes/DataTypeIPv4andIPv6.h | 3 +++ src/Functions/FunctionsConsistentHashing.h | 5 ++++- src/Functions/FunctionsHashing.h | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/DataTypes/DataTypeIPv4andIPv6.h b/src/DataTypes/DataTypeIPv4andIPv6.h index b8eacc3ee80..87d3023e613 100644 --- a/src/DataTypes/DataTypeIPv4andIPv6.h +++ b/src/DataTypes/DataTypeIPv4andIPv6.h @@ -37,6 +37,9 @@ public: bool shouldAlignRightInPrettyFormats() const override { return false; } bool textCanContainOnlyValidUTF8() const override { return true; } bool isComparable() const override { return true; } + bool isValueRepresentedByNumber() const override { return true; } + bool isValueRepresentedByInteger() const override { return true; } + bool isValueRepresentedByUnsignedInteger() const override { return true; } bool isValueUnambiguouslyRepresentedInContiguousMemoryRegion() const override { return true; } bool isValueUnambiguouslyRepresentedInFixedSizeContiguousMemoryRegion() const override { return true; } bool haveMaximumSizeOfValue() const override { return true; } diff --git a/src/Functions/FunctionsConsistentHashing.h b/src/Functions/FunctionsConsistentHashing.h index 5e41303d822..cee711df62b 100644 --- a/src/Functions/FunctionsConsistentHashing.h +++ b/src/Functions/FunctionsConsistentHashing.h @@ -6,6 +6,7 @@ #include #include #include +#include #include @@ -43,7 +44,7 @@ public: DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override { - if (!isInteger(arguments[0])) + if (!isInteger(arguments[0]) && !isIPv4(arguments[0])) throw Exception("Illegal type " + arguments[0]->getName() + " of the first argument of function " + getName(), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); @@ -132,6 +133,8 @@ private: executeType(hash_col, num_buckets, res_col.get()); else if (which.isInt64()) executeType(hash_col, num_buckets, res_col.get()); + else if (which.isIPv4()) + executeType(hash_col, num_buckets, res_col.get()); else throw Exception("Illegal type " + hash_type->getName() + " of the first argument of function " + getName(), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); diff --git a/src/Functions/FunctionsHashing.h b/src/Functions/FunctionsHashing.h index c61d219dcd3..7e4ce8d49b3 100644 --- a/src/Functions/FunctionsHashing.h +++ b/src/Functions/FunctionsHashing.h @@ -52,6 +52,7 @@ #include #include #include +#include #include #include @@ -838,6 +839,8 @@ public: return executeType(arguments); else if (which.isDecimal64()) return executeType(arguments); + else if (which.isIPv4()) + return executeType(arguments); else throw Exception("Illegal type " + arguments[0].type->getName() + " of argument of function " + getName(), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); From 50ecf0233e33a2e0a6e8de0a9a4a2333266c2a34 Mon Sep 17 00:00:00 2001 From: Yakov Olkhovskiy Date: Sun, 8 Jan 2023 21:45:19 +0000 Subject: [PATCH 2/7] test is added --- ...2184_hash_functions_and_ip_types.reference | 43 ++++++++++++++++++ .../02184_hash_functions_and_ip_types.sql | 44 +++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 tests/queries/0_stateless/02184_hash_functions_and_ip_types.reference create mode 100644 tests/queries/0_stateless/02184_hash_functions_and_ip_types.sql diff --git a/tests/queries/0_stateless/02184_hash_functions_and_ip_types.reference b/tests/queries/0_stateless/02184_hash_functions_and_ip_types.reference new file mode 100644 index 00000000000..240ffd2675f --- /dev/null +++ b/tests/queries/0_stateless/02184_hash_functions_and_ip_types.reference @@ -0,0 +1,43 @@ +Row 1: +────── +ipv4: 1.2.3.4 +wyHash64(toIPv4('1.2.3.4')): 13096729196120951355 +xxHash32(toIPv4('1.2.3.4')): 2430391091 +gccMurmurHash(toIPv4('1.2.3.4')): 5478801830569062645 +murmurHash2_32(toIPv4('1.2.3.4')): 1658978282 +javaHashUTF16LE(toIPv4('1.2.3.4')): 24190 +intHash64(toIPv4('1.2.3.4')): 5715546585361069049 +intHash32(toIPv4('1.2.3.4')): 3152671896 +metroHash64(toIPv4('1.2.3.4')): 5715546585361069049 +farmHash64(toIPv4('1.2.3.4')): 5715546585361069049 +hex(sipHash128(toIPv4('1.2.3.4'))): DBB6A76B92B59789EFB42185DC32311D +hex(murmurHash3_128(toIPv4('1.2.3.4'))): 549E9EF692591F6BB55874EF9A0DE88E +jumpConsistentHash(toIPv4('1.2.3.4'), 42): 37 +sipHash64(toIPv4('1.2.3.4')): 10711397536826262068 +kostikConsistentHash(toIPv4('1.2.3.4'), 42): 0 +xxHash64(toIPv4('1.2.3.4')): 14496144933713060978 +murmurHash2_64(toIPv4('1.2.3.4')): 10829690723193326442 +cityHash64(toIPv4('1.2.3.4')): 5715546585361069049 +hiveHash(toIPv4('1.2.3.4')): 122110 +murmurHash3_64(toIPv4('1.2.3.4')): 16570805747704317665 +murmurHash3_32(toIPv4('1.2.3.4')): 1165084099 +yandexConsistentHash(toIPv4('1.2.3.4'), 42): 0 +Row 1: +────── +ipv6: fe80::62:5aff:fed1:daf0 +wyHash64(toIPv6('fe80::62:5aff:fed1:daf0')): 18071806066582739916 +xxHash32(toIPv6('fe80::62:5aff:fed1:daf0')): 3353862080 +gccMurmurHash(toIPv6('fe80::62:5aff:fed1:daf0')): 11049311547848936878 +murmurHash2_32(toIPv6('fe80::62:5aff:fed1:daf0')): 1039121047 +javaHashUTF16LE(toIPv6('fe80::62:5aff:fed1:daf0')): -666938696 +metroHash64(toIPv6('fe80::62:5aff:fed1:daf0')): 15333045864940909774 +farmHash64(toIPv6('fe80::62:5aff:fed1:daf0')): 6643158734288374888 +hex(sipHash128(toIPv6('fe80::62:5aff:fed1:daf0'))): 31D50562F877B1F92A99B05B646568B7 +hex(murmurHash3_128(toIPv6('fe80::62:5aff:fed1:daf0'))): 6FFEF0C1DF8B5B472FE2EDF0C76C12B9 +sipHash64(toIPv6('fe80::62:5aff:fed1:daf0')): 5681592867096972315 +xxHash64(toIPv6('fe80::62:5aff:fed1:daf0')): 4533874364641685764 +murmurHash2_64(toIPv6('fe80::62:5aff:fed1:daf0')): 11839090601505681839 +cityHash64(toIPv6('fe80::62:5aff:fed1:daf0')): 1599722731594796935 +hiveHash(toIPv6('fe80::62:5aff:fed1:daf0')): 684606770 +murmurHash3_64(toIPv6('fe80::62:5aff:fed1:daf0')): 18323430650022796352 +murmurHash3_32(toIPv6('fe80::62:5aff:fed1:daf0')): 3971193740 diff --git a/tests/queries/0_stateless/02184_hash_functions_and_ip_types.sql b/tests/queries/0_stateless/02184_hash_functions_and_ip_types.sql new file mode 100644 index 00000000000..c202f830043 --- /dev/null +++ b/tests/queries/0_stateless/02184_hash_functions_and_ip_types.sql @@ -0,0 +1,44 @@ +SELECT + toIPv4('1.2.3.4') AS ipv4, + wyHash64(ipv4), + xxHash32(ipv4), + gccMurmurHash(ipv4), + murmurHash2_32(ipv4), + javaHashUTF16LE(ipv4), + intHash64(ipv4), + intHash32(ipv4), + metroHash64(ipv4), + farmHash64(ipv4), + hex(sipHash128(ipv4)), + hex(murmurHash3_128(ipv4)), + jumpConsistentHash(ipv4, 42), + sipHash64(ipv4), + kostikConsistentHash(ipv4, 42), + xxHash64(ipv4), + murmurHash2_64(ipv4), + cityHash64(ipv4), + hiveHash(ipv4), + murmurHash3_64(ipv4), + murmurHash3_32(ipv4), + yandexConsistentHash(ipv4,42) +FORMAT Vertical; + +SELECT + toIPv6('fe80::62:5aff:fed1:daf0') AS ipv6, + wyHash64(ipv6), + xxHash32(ipv6), + gccMurmurHash(ipv6), + murmurHash2_32(ipv6), + javaHashUTF16LE(ipv6), + metroHash64(ipv6), + farmHash64(ipv6), + hex(sipHash128(ipv6)), + hex(murmurHash3_128(ipv6)), + sipHash64(ipv6), + xxHash64(ipv6), + murmurHash2_64(ipv6), + cityHash64(ipv6), + hiveHash(ipv6), + murmurHash3_64(ipv6), + murmurHash3_32(ipv6) +FORMAT Vertical; From 45780644bc74959dcba03e4bd02ad9b4c6f9e256 Mon Sep 17 00:00:00 2001 From: Yakov Olkhovskiy Date: Mon, 9 Jan 2023 07:27:17 +0000 Subject: [PATCH 3/7] fix convert field for IPv4 and IPv6 - as represented by number --- src/Interpreters/convertFieldToType.cpp | 40 +++++++++++++------------ 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/Interpreters/convertFieldToType.cpp b/src/Interpreters/convertFieldToType.cpp index c67de14a189..85ed61bd59f 100644 --- a/src/Interpreters/convertFieldToType.cpp +++ b/src/Interpreters/convertFieldToType.cpp @@ -243,31 +243,33 @@ Field convertFieldToTypeImpl(const Field & src, const IDataType & type, const ID = DecimalUtils::decimalFromComponents(applyVisitor(FieldVisitorConvertToNumber(), src), 0, scale); return Field(DecimalField(decimal_value, scale)); } + + if (which_type.isIPv4() && src.getType() == Field::Types::IPv4) + { + /// Already in needed type. + return src; + } + + if (which_type.isIPv6()) + { + /// Already in needed type. + if (src.getType() == Field::Types::IPv6) + return src; + /// Treat FixedString(16) as a binary representation of IPv6 + if (which_from_type.isFixedString() && assert_cast(from_type_hint)->getN() == IPV6_BINARY_LENGTH) + { + const auto col = type.createColumn(); + ReadBufferFromString in_buffer(src.get()); + type.getDefaultSerialization()->deserializeBinary(*col, in_buffer, {}); + return (*col)[0]; + } + } } else if (which_type.isUUID() && src.getType() == Field::Types::UUID) { /// Already in needed type. return src; } - else if (which_type.isIPv4() && src.getType() == Field::Types::IPv4) - { - /// Already in needed type. - return src; - } - else if (which_type.isIPv6()) - { - /// Already in needed type. - if (src.getType() == Field::Types::IPv6) - return src; - /// Treat FixedString(16) as a binary representation of IPv6 - if (which_from_type.isFixedString() && assert_cast(from_type_hint)->getN() == IPV6_BINARY_LENGTH) - { - const auto col = type.createColumn(); - ReadBufferFromString in_buffer(src.get()); - type.getDefaultSerialization()->deserializeBinary(*col, in_buffer, {}); - return (*col)[0]; - } - } else if (which_type.isStringOrFixedString()) { if (src.getType() == Field::Types::String) From 2559c4981069bedcbb2e31304ffd60b6b87e6f88 Mon Sep 17 00:00:00 2001 From: Yakov Olkhovskiy Date: Tue, 10 Jan 2023 02:03:06 +0000 Subject: [PATCH 4/7] make only IPv4 as numeric, fix hash functions for IPv6, add more hash functions to test --- src/Core/callOnTypeIndex.h | 5 +- src/DataTypes/DataTypeIPv4andIPv6.h | 59 +++++++++++++++---- src/Functions/FunctionsHashing.h | 18 +++++- src/Interpreters/convertFieldToType.cpp | 29 +++++---- ...2184_hash_functions_and_ip_types.reference | 18 +++++- .../02184_hash_functions_and_ip_types.sql | 18 +++++- 6 files changed, 109 insertions(+), 38 deletions(-) diff --git a/src/Core/callOnTypeIndex.h b/src/Core/callOnTypeIndex.h index d01f8907a5c..39ce37c4c13 100644 --- a/src/Core/callOnTypeIndex.h +++ b/src/Core/callOnTypeIndex.h @@ -160,9 +160,8 @@ class DataTypeDate32; class DataTypeString; class DataTypeFixedString; class DataTypeUUID; -template class DataTypeIP; -using DataTypeIPv4 = DataTypeIP; -using DataTypeIPv6 = DataTypeIP; +class DataTypeIPv4; +class DataTypeIPv6; class DataTypeDateTime; class DataTypeDateTime64; template class DataTypeEnum; diff --git a/src/DataTypes/DataTypeIPv4andIPv6.h b/src/DataTypes/DataTypeIPv4andIPv6.h index 87d3023e613..0a0c61d0ad8 100644 --- a/src/DataTypes/DataTypeIPv4andIPv6.h +++ b/src/DataTypes/DataTypeIPv4andIPv6.h @@ -9,22 +9,21 @@ namespace DB { -template -class DataTypeIP : public IDataType +class DataTypeIPv4 : public IDataType { public: static constexpr bool is_parametric = false; - using FieldType = IPv; - using ColumnType = ColumnVector; - static constexpr auto type_id = TypeToTypeIndex; + using FieldType = IPv4; + using ColumnType = ColumnVector; + static constexpr auto type_id = TypeToTypeIndex; - const char * getFamilyName() const override { return TypeName.data(); } + const char * getFamilyName() const override { return TypeName.data(); } TypeIndex getTypeId() const override { return type_id; } - Field getDefault() const override { return IPv{}; } + Field getDefault() const override { return IPv4{}; } - MutableColumnPtr createColumn() const override {return ColumnVector::create();} + MutableColumnPtr createColumn() const override {return ColumnVector::create();} bool isParametric() const override { return false; } bool haveSubtypes() const override { return false; } @@ -38,19 +37,53 @@ public: bool textCanContainOnlyValidUTF8() const override { return true; } bool isComparable() const override { return true; } bool isValueRepresentedByNumber() const override { return true; } - bool isValueRepresentedByInteger() const override { return true; } bool isValueRepresentedByUnsignedInteger() const override { return true; } bool isValueUnambiguouslyRepresentedInContiguousMemoryRegion() const override { return true; } bool isValueUnambiguouslyRepresentedInFixedSizeContiguousMemoryRegion() const override { return true; } bool haveMaximumSizeOfValue() const override { return true; } - size_t getSizeOfValueInMemory() const override { return sizeof(IPv); } + size_t getSizeOfValueInMemory() const override { return sizeof(IPv4); } bool isCategorial() const override { return true; } bool canBeInsideLowCardinality() const override { return true; } - SerializationPtr doGetDefaultSerialization() const override { return std::make_shared>(); } + SerializationPtr doGetDefaultSerialization() const override { return std::make_shared>(); } +}; + +class DataTypeIPv6 : public IDataType +{ +public: + static constexpr bool is_parametric = false; + + using FieldType = IPv6; + using ColumnType = ColumnVector; + static constexpr auto type_id = TypeToTypeIndex; + + const char * getFamilyName() const override { return TypeName.data(); } + TypeIndex getTypeId() const override { return type_id; } + + Field getDefault() const override { return IPv6{}; } + + MutableColumnPtr createColumn() const override {return ColumnVector::create();} + + bool isParametric() const override { return false; } + bool haveSubtypes() const override { return false; } + + bool equals(const IDataType & rhs) const override { return typeid(rhs) == typeid(*this); } + + bool canBeUsedInBitOperations() const override { return true; } + bool canBeInsideNullable() const override { return true; } + bool canBePromoted() const override { return false; } + bool shouldAlignRightInPrettyFormats() const override { return false; } + bool textCanContainOnlyValidUTF8() const override { return true; } + bool isComparable() const override { return true; } + bool isValueUnambiguouslyRepresentedInContiguousMemoryRegion() const override { return true; } + bool isValueUnambiguouslyRepresentedInFixedSizeContiguousMemoryRegion() const override { return true; } + bool haveMaximumSizeOfValue() const override { return true; } + size_t getSizeOfValueInMemory() const override { return sizeof(IPv6); } + bool isCategorial() const override { return true; } + bool canBeInsideLowCardinality() const override { return true; } + + SerializationPtr doGetDefaultSerialization() const override { return std::make_shared>(); } }; -using DataTypeIPv4 = DataTypeIP; -using DataTypeIPv6 = DataTypeIP; } diff --git a/src/Functions/FunctionsHashing.h b/src/Functions/FunctionsHashing.h index 7e4ce8d49b3..3ed90afdb31 100644 --- a/src/Functions/FunctionsHashing.h +++ b/src/Functions/FunctionsHashing.h @@ -691,7 +691,7 @@ public: DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override { - if (!isStringOrFixedString(arguments[0])) + if (!isStringOrFixedString(arguments[0]) && !isIPv6(arguments[0])) throw Exception("Illegal type " + arguments[0]->getName() + " of argument of function " + getName(), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); @@ -743,6 +743,22 @@ public: } return col_to; } + else if ( + const ColumnIPv6 * col_from_ip = checkAndGetColumn(arguments[0].column.get())) + { + auto col_to = ColumnFixedString::create(Impl::length); + const typename ColumnIPv6::Container & data = col_from_ip->getData(); + const auto size = col_from_ip->size(); + auto & chars_to = col_to->getChars(); + const auto length = IPV6_BINARY_LENGTH; + chars_to.resize(size * Impl::length); + for (size_t i = 0; i < size; ++i) + { + Impl::apply( + reinterpret_cast(&data[i * length]), length, reinterpret_cast(&chars_to[i * Impl::length])); + } + return col_to; + } else throw Exception("Illegal column " + arguments[0].column->getName() + " of first argument of function " + getName(), diff --git a/src/Interpreters/convertFieldToType.cpp b/src/Interpreters/convertFieldToType.cpp index 85ed61bd59f..00b01781007 100644 --- a/src/Interpreters/convertFieldToType.cpp +++ b/src/Interpreters/convertFieldToType.cpp @@ -249,27 +249,26 @@ Field convertFieldToTypeImpl(const Field & src, const IDataType & type, const ID /// Already in needed type. return src; } - - if (which_type.isIPv6()) - { - /// Already in needed type. - if (src.getType() == Field::Types::IPv6) - return src; - /// Treat FixedString(16) as a binary representation of IPv6 - if (which_from_type.isFixedString() && assert_cast(from_type_hint)->getN() == IPV6_BINARY_LENGTH) - { - const auto col = type.createColumn(); - ReadBufferFromString in_buffer(src.get()); - type.getDefaultSerialization()->deserializeBinary(*col, in_buffer, {}); - return (*col)[0]; - } - } } else if (which_type.isUUID() && src.getType() == Field::Types::UUID) { /// Already in needed type. return src; } + else if (which_type.isIPv6()) + { + /// Already in needed type. + if (src.getType() == Field::Types::IPv6) + return src; + /// Treat FixedString(16) as a binary representation of IPv6 + if (which_from_type.isFixedString() && assert_cast(from_type_hint)->getN() == IPV6_BINARY_LENGTH) + { + const auto col = type.createColumn(); + ReadBufferFromString in_buffer(src.get()); + type.getDefaultSerialization()->deserializeBinary(*col, in_buffer, {}); + return (*col)[0]; + } + } else if (which_type.isStringOrFixedString()) { if (src.getType() == Field::Types::String) diff --git a/tests/queries/0_stateless/02184_hash_functions_and_ip_types.reference b/tests/queries/0_stateless/02184_hash_functions_and_ip_types.reference index 240ffd2675f..b99d6e74859 100644 --- a/tests/queries/0_stateless/02184_hash_functions_and_ip_types.reference +++ b/tests/queries/0_stateless/02184_hash_functions_and_ip_types.reference @@ -1,6 +1,9 @@ Row 1: ────── ipv4: 1.2.3.4 +halfMD5(toIPv4('1.2.3.4')): 14356538739656272800 +farmFingerprint64(toIPv4('1.2.3.4')): 5715546585361069049 +xxh3(toIPv4('1.2.3.4')): 14355428563589734825 wyHash64(toIPv4('1.2.3.4')): 13096729196120951355 xxHash32(toIPv4('1.2.3.4')): 2430391091 gccMurmurHash(toIPv4('1.2.3.4')): 5478801830569062645 @@ -9,11 +12,10 @@ javaHashUTF16LE(toIPv4('1.2.3.4')): 24190 intHash64(toIPv4('1.2.3.4')): 5715546585361069049 intHash32(toIPv4('1.2.3.4')): 3152671896 metroHash64(toIPv4('1.2.3.4')): 5715546585361069049 -farmHash64(toIPv4('1.2.3.4')): 5715546585361069049 -hex(sipHash128(toIPv4('1.2.3.4'))): DBB6A76B92B59789EFB42185DC32311D hex(murmurHash3_128(toIPv4('1.2.3.4'))): 549E9EF692591F6BB55874EF9A0DE88E jumpConsistentHash(toIPv4('1.2.3.4'), 42): 37 sipHash64(toIPv4('1.2.3.4')): 10711397536826262068 +hex(sipHash128(toIPv4('1.2.3.4'))): DBB6A76B92B59789EFB42185DC32311D kostikConsistentHash(toIPv4('1.2.3.4'), 42): 0 xxHash64(toIPv4('1.2.3.4')): 14496144933713060978 murmurHash2_64(toIPv4('1.2.3.4')): 10829690723193326442 @@ -25,13 +27,23 @@ yandexConsistentHash(toIPv4('1.2.3.4'), 42): 0 Row 1: ────── ipv6: fe80::62:5aff:fed1:daf0 +halfMD5(toIPv6('fe80::62:5aff:fed1:daf0')): 9503062220758009199 +hex(MD4(toIPv6('fe80::62:5aff:fed1:daf0'))): E35A1A4FB3A3953421AB348B2E1A4A1A +hex(MD5(toIPv6('fe80::62:5aff:fed1:daf0'))): 83E1A8BD8AB7456FC229208409F79798 +hex(SHA1(toIPv6('fe80::62:5aff:fed1:daf0'))): A6D5DCE882AC44804382DE4639E6001612E1C8B5 +hex(SHA224(toIPv6('fe80::62:5aff:fed1:daf0'))): F6995FD7BED2BCA21F68DAC6BBABE742DC1BA177BA8594CEF1715C52 +hex(SHA256(toIPv6('fe80::62:5aff:fed1:daf0'))): F75497BAD6F7747BD6B150B6F69BA2DEE354F1C2A34B7BEA6183973B78640250 +hex(SHA512(toIPv6('fe80::62:5aff:fed1:daf0'))): 0C2893CCBF44BC19CCF339AEED5B68CBFD5A2EF38263A48FE21C3379BA4438E7FF7A02F59D7542442C6E6ED538E6D13D65D3573DADB381651D3D8A5DEA232EAC +hex(BLAKE3(toIPv6('fe80::62:5aff:fed1:daf0'))): 1C777D93A6CE1BD71A19F72EBBF1D060D205062552D4E8D536998DC0A0C4ED1C +farmFingerprint64(toIPv6('fe80::62:5aff:fed1:daf0')): 6643158734288374888 +javaHash(toIPv6('fe80::62:5aff:fed1:daf0')): 684606770 +xxh3(toIPv6('fe80::62:5aff:fed1:daf0')): 4051340969481364358 wyHash64(toIPv6('fe80::62:5aff:fed1:daf0')): 18071806066582739916 xxHash32(toIPv6('fe80::62:5aff:fed1:daf0')): 3353862080 gccMurmurHash(toIPv6('fe80::62:5aff:fed1:daf0')): 11049311547848936878 murmurHash2_32(toIPv6('fe80::62:5aff:fed1:daf0')): 1039121047 javaHashUTF16LE(toIPv6('fe80::62:5aff:fed1:daf0')): -666938696 metroHash64(toIPv6('fe80::62:5aff:fed1:daf0')): 15333045864940909774 -farmHash64(toIPv6('fe80::62:5aff:fed1:daf0')): 6643158734288374888 hex(sipHash128(toIPv6('fe80::62:5aff:fed1:daf0'))): 31D50562F877B1F92A99B05B646568B7 hex(murmurHash3_128(toIPv6('fe80::62:5aff:fed1:daf0'))): 6FFEF0C1DF8B5B472FE2EDF0C76C12B9 sipHash64(toIPv6('fe80::62:5aff:fed1:daf0')): 5681592867096972315 diff --git a/tests/queries/0_stateless/02184_hash_functions_and_ip_types.sql b/tests/queries/0_stateless/02184_hash_functions_and_ip_types.sql index c202f830043..85cee82ac4b 100644 --- a/tests/queries/0_stateless/02184_hash_functions_and_ip_types.sql +++ b/tests/queries/0_stateless/02184_hash_functions_and_ip_types.sql @@ -1,5 +1,8 @@ SELECT toIPv4('1.2.3.4') AS ipv4, + halfMD5(ipv4), + farmFingerprint64(ipv4), + xxh3(ipv4), wyHash64(ipv4), xxHash32(ipv4), gccMurmurHash(ipv4), @@ -8,11 +11,10 @@ SELECT intHash64(ipv4), intHash32(ipv4), metroHash64(ipv4), - farmHash64(ipv4), - hex(sipHash128(ipv4)), hex(murmurHash3_128(ipv4)), jumpConsistentHash(ipv4, 42), sipHash64(ipv4), + hex(sipHash128(ipv4)), kostikConsistentHash(ipv4, 42), xxHash64(ipv4), murmurHash2_64(ipv4), @@ -25,13 +27,23 @@ FORMAT Vertical; SELECT toIPv6('fe80::62:5aff:fed1:daf0') AS ipv6, + halfMD5(ipv6), + hex(MD4(ipv6)), + hex(MD5(ipv6)), + hex(SHA1(ipv6)), + hex(SHA224(ipv6)), + hex(SHA256(ipv6)), + hex(SHA512(ipv6)), + hex(BLAKE3(ipv6)), + farmFingerprint64(ipv6), + javaHash(ipv6), + xxh3(ipv6), wyHash64(ipv6), xxHash32(ipv6), gccMurmurHash(ipv6), murmurHash2_32(ipv6), javaHashUTF16LE(ipv6), metroHash64(ipv6), - farmHash64(ipv6), hex(sipHash128(ipv6)), hex(murmurHash3_128(ipv6)), sipHash64(ipv6), From 87f8db89f96afe4a9deb6abdcada2f76b23f88af Mon Sep 17 00:00:00 2001 From: Yakov Olkhovskiy Date: Tue, 10 Jan 2023 02:49:13 +0000 Subject: [PATCH 5/7] remove halfMD5 from test --- .../0_stateless/02184_hash_functions_and_ip_types.reference | 2 -- tests/queries/0_stateless/02184_hash_functions_and_ip_types.sql | 2 -- 2 files changed, 4 deletions(-) diff --git a/tests/queries/0_stateless/02184_hash_functions_and_ip_types.reference b/tests/queries/0_stateless/02184_hash_functions_and_ip_types.reference index b99d6e74859..6e0a9985a5d 100644 --- a/tests/queries/0_stateless/02184_hash_functions_and_ip_types.reference +++ b/tests/queries/0_stateless/02184_hash_functions_and_ip_types.reference @@ -1,7 +1,6 @@ Row 1: ────── ipv4: 1.2.3.4 -halfMD5(toIPv4('1.2.3.4')): 14356538739656272800 farmFingerprint64(toIPv4('1.2.3.4')): 5715546585361069049 xxh3(toIPv4('1.2.3.4')): 14355428563589734825 wyHash64(toIPv4('1.2.3.4')): 13096729196120951355 @@ -27,7 +26,6 @@ yandexConsistentHash(toIPv4('1.2.3.4'), 42): 0 Row 1: ────── ipv6: fe80::62:5aff:fed1:daf0 -halfMD5(toIPv6('fe80::62:5aff:fed1:daf0')): 9503062220758009199 hex(MD4(toIPv6('fe80::62:5aff:fed1:daf0'))): E35A1A4FB3A3953421AB348B2E1A4A1A hex(MD5(toIPv6('fe80::62:5aff:fed1:daf0'))): 83E1A8BD8AB7456FC229208409F79798 hex(SHA1(toIPv6('fe80::62:5aff:fed1:daf0'))): A6D5DCE882AC44804382DE4639E6001612E1C8B5 diff --git a/tests/queries/0_stateless/02184_hash_functions_and_ip_types.sql b/tests/queries/0_stateless/02184_hash_functions_and_ip_types.sql index 85cee82ac4b..0cd4a52abd0 100644 --- a/tests/queries/0_stateless/02184_hash_functions_and_ip_types.sql +++ b/tests/queries/0_stateless/02184_hash_functions_and_ip_types.sql @@ -1,6 +1,5 @@ SELECT toIPv4('1.2.3.4') AS ipv4, - halfMD5(ipv4), farmFingerprint64(ipv4), xxh3(ipv4), wyHash64(ipv4), @@ -27,7 +26,6 @@ FORMAT Vertical; SELECT toIPv6('fe80::62:5aff:fed1:daf0') AS ipv6, - halfMD5(ipv6), hex(MD4(ipv6)), hex(MD5(ipv6)), hex(SHA1(ipv6)), From 795c41381176ba420e3ef8d3925e967c784abfa1 Mon Sep 17 00:00:00 2001 From: Yakov Olkhovskiy Date: Tue, 10 Jan 2023 03:46:16 +0000 Subject: [PATCH 6/7] no-fasttest --- .../0_stateless/02184_hash_functions_and_ip_types.reference | 2 ++ .../queries/0_stateless/02184_hash_functions_and_ip_types.sql | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/tests/queries/0_stateless/02184_hash_functions_and_ip_types.reference b/tests/queries/0_stateless/02184_hash_functions_and_ip_types.reference index 6e0a9985a5d..b99d6e74859 100644 --- a/tests/queries/0_stateless/02184_hash_functions_and_ip_types.reference +++ b/tests/queries/0_stateless/02184_hash_functions_and_ip_types.reference @@ -1,6 +1,7 @@ Row 1: ────── ipv4: 1.2.3.4 +halfMD5(toIPv4('1.2.3.4')): 14356538739656272800 farmFingerprint64(toIPv4('1.2.3.4')): 5715546585361069049 xxh3(toIPv4('1.2.3.4')): 14355428563589734825 wyHash64(toIPv4('1.2.3.4')): 13096729196120951355 @@ -26,6 +27,7 @@ yandexConsistentHash(toIPv4('1.2.3.4'), 42): 0 Row 1: ────── ipv6: fe80::62:5aff:fed1:daf0 +halfMD5(toIPv6('fe80::62:5aff:fed1:daf0')): 9503062220758009199 hex(MD4(toIPv6('fe80::62:5aff:fed1:daf0'))): E35A1A4FB3A3953421AB348B2E1A4A1A hex(MD5(toIPv6('fe80::62:5aff:fed1:daf0'))): 83E1A8BD8AB7456FC229208409F79798 hex(SHA1(toIPv6('fe80::62:5aff:fed1:daf0'))): A6D5DCE882AC44804382DE4639E6001612E1C8B5 diff --git a/tests/queries/0_stateless/02184_hash_functions_and_ip_types.sql b/tests/queries/0_stateless/02184_hash_functions_and_ip_types.sql index 0cd4a52abd0..3d5c030da3e 100644 --- a/tests/queries/0_stateless/02184_hash_functions_and_ip_types.sql +++ b/tests/queries/0_stateless/02184_hash_functions_and_ip_types.sql @@ -1,5 +1,8 @@ +-- Tags: no-fasttest + SELECT toIPv4('1.2.3.4') AS ipv4, + halfMD5(ipv4), farmFingerprint64(ipv4), xxh3(ipv4), wyHash64(ipv4), @@ -26,6 +29,7 @@ FORMAT Vertical; SELECT toIPv6('fe80::62:5aff:fed1:daf0') AS ipv6, + halfMD5(ipv6), hex(MD4(ipv6)), hex(MD5(ipv6)), hex(SHA1(ipv6)), From d6a4affd6e4e367dd8ca5fbe8493a736cc9c2fff Mon Sep 17 00:00:00 2001 From: Yakov Olkhovskiy Date: Tue, 10 Jan 2023 07:10:27 +0000 Subject: [PATCH 7/7] remove BLAKE3 from test --- .../0_stateless/02184_hash_functions_and_ip_types.reference | 1 - tests/queries/0_stateless/02184_hash_functions_and_ip_types.sql | 1 - 2 files changed, 2 deletions(-) diff --git a/tests/queries/0_stateless/02184_hash_functions_and_ip_types.reference b/tests/queries/0_stateless/02184_hash_functions_and_ip_types.reference index b99d6e74859..07705827428 100644 --- a/tests/queries/0_stateless/02184_hash_functions_and_ip_types.reference +++ b/tests/queries/0_stateless/02184_hash_functions_and_ip_types.reference @@ -34,7 +34,6 @@ hex(SHA1(toIPv6('fe80::62:5aff:fed1:daf0'))): A6D5DCE882AC44804382DE4 hex(SHA224(toIPv6('fe80::62:5aff:fed1:daf0'))): F6995FD7BED2BCA21F68DAC6BBABE742DC1BA177BA8594CEF1715C52 hex(SHA256(toIPv6('fe80::62:5aff:fed1:daf0'))): F75497BAD6F7747BD6B150B6F69BA2DEE354F1C2A34B7BEA6183973B78640250 hex(SHA512(toIPv6('fe80::62:5aff:fed1:daf0'))): 0C2893CCBF44BC19CCF339AEED5B68CBFD5A2EF38263A48FE21C3379BA4438E7FF7A02F59D7542442C6E6ED538E6D13D65D3573DADB381651D3D8A5DEA232EAC -hex(BLAKE3(toIPv6('fe80::62:5aff:fed1:daf0'))): 1C777D93A6CE1BD71A19F72EBBF1D060D205062552D4E8D536998DC0A0C4ED1C farmFingerprint64(toIPv6('fe80::62:5aff:fed1:daf0')): 6643158734288374888 javaHash(toIPv6('fe80::62:5aff:fed1:daf0')): 684606770 xxh3(toIPv6('fe80::62:5aff:fed1:daf0')): 4051340969481364358 diff --git a/tests/queries/0_stateless/02184_hash_functions_and_ip_types.sql b/tests/queries/0_stateless/02184_hash_functions_and_ip_types.sql index 3d5c030da3e..67aae812144 100644 --- a/tests/queries/0_stateless/02184_hash_functions_and_ip_types.sql +++ b/tests/queries/0_stateless/02184_hash_functions_and_ip_types.sql @@ -36,7 +36,6 @@ SELECT hex(SHA224(ipv6)), hex(SHA256(ipv6)), hex(SHA512(ipv6)), - hex(BLAKE3(ipv6)), farmFingerprint64(ipv6), javaHash(ipv6), xxh3(ipv6),