From aa2e89611d9ca60f2984ea1db98277bdd4d21917 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Thu, 31 Dec 2020 02:22:04 +0300 Subject: [PATCH] Remove sumburConsistentHash function --- contrib/CMakeLists.txt | 1 - .../consistent-hashing-sumbur/CMakeLists.txt | 2 - contrib/consistent-hashing-sumbur/sumbur.cpp | 113 ------------------ contrib/consistent-hashing-sumbur/sumbur.h | 28 ----- src/Functions/CMakeLists.txt | 1 - .../registerFunctionsConsistentHashing.cpp | 8 -- src/Functions/sumburConsistentHash.cpp | 38 ------ src/Functions/ya.make.in | 2 +- utils/check-style/check-include | 1 - 9 files changed, 1 insertion(+), 193 deletions(-) delete mode 100644 contrib/consistent-hashing-sumbur/CMakeLists.txt delete mode 100644 contrib/consistent-hashing-sumbur/sumbur.cpp delete mode 100644 contrib/consistent-hashing-sumbur/sumbur.h delete mode 100644 src/Functions/sumburConsistentHash.cpp diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 3bd08de01b2..be3d3f86348 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -31,7 +31,6 @@ set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL 1) add_subdirectory (antlr4-runtime-cmake) add_subdirectory (boost-cmake) add_subdirectory (cctz-cmake) -add_subdirectory (consistent-hashing-sumbur) add_subdirectory (consistent-hashing) add_subdirectory (dragonbox-cmake) add_subdirectory (FastMemcpy) diff --git a/contrib/consistent-hashing-sumbur/CMakeLists.txt b/contrib/consistent-hashing-sumbur/CMakeLists.txt deleted file mode 100644 index f11b5095f51..00000000000 --- a/contrib/consistent-hashing-sumbur/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_library(consistent-hashing-sumbur sumbur.cpp) -target_include_directories(consistent-hashing-sumbur PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/contrib/consistent-hashing-sumbur/sumbur.cpp b/contrib/consistent-hashing-sumbur/sumbur.cpp deleted file mode 100644 index 78f59ca875f..00000000000 --- a/contrib/consistent-hashing-sumbur/sumbur.cpp +++ /dev/null @@ -1,113 +0,0 @@ -//Copyright (c) 2011-2012 Mail.RU -//Copyright (c) 2011-2012 Maksim Kalinchenko -//Copyright (c) 2012 Sokolov Yura aka funny-falcon -// -//MIT License -// -//Permission is hereby granted, free of charge, to any person obtaining -//a copy of this software and associated documentation files (the -//"Software"), to deal in the Software without restriction, including -//without limitation the rights to use, copy, modify, merge, publish, -//distribute, sublicense, and/or sell copies of the Software, and to -//permit persons to whom the Software is furnished to do so, subject to -//the following conditions: -// -//The above copyright notice and this permission notice shall be -//included in all copies or substantial portions of the Software. -// -//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -//EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -//MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -//NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -//LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -//OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -//WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -#include - - -#define L 0xFFFFFFFF - -static unsigned int L27_38[] = {L / 27, L / 28, L / 29, L / 30, L / 31, L / 32, - L / 33, L / 34, L / 35, L / 36, L / 37, L / 38, - L / 39, L / 40, L / 41, L / 42, L / 43, L / 44, - L / 45, L / 46, L / 47, L / 48, L / 49, L / 50, - L / 51, L / 52, L / 53, L / 54, L / 55, L / 56, - L / 57, L / 58, L / 59, L / 60, L / 61, L / 62 - }; -static unsigned int LL27_38[] = {L/(26*27), L/(27*28), L/(28*29), L/(29*30), L/(30*31), L/(31*32), - L/(32*33), L/(33*34), L/(34*35), L/(35*36), L/(36*37), L/(37*38), - L/(38*39), L/(39*40), L/(40*41), L/(41*42), L/(42*43), L/(43*44), - L/(44*45), L/(45*46), L/(46*47), L/(47*48), L/(48*49), L/(49*50), - L/(50*51), L/(51*52), L/(52*53), L/(53*54), L/(54*55), L/(55*56), - L/(56*57), L/(57*58), L/(58*59), L/(59*60), L/(60*61), L/(61*62) - }; - -unsigned int sumburConsistentHash(unsigned int hashed_int, unsigned int capacity) -{ - unsigned int h = hashed_int; - unsigned int capa = capacity; - unsigned int part, n, i, c; - - if (capa == 0) - throw std::runtime_error("Sumbur is not applicable to empty cluster"); - - part = L / capa; - - if (L - h < part) return 0; - - n = 1; - - do { - if (h >= L / 2) h -= L / 2; - else { - n = 2; - if (L / 2 - h < part) return 1; - } - if (capa == 2) return 1; - -#define curslice(i) (L / (i * (i - 1))) -#define unroll(i) \ - if (curslice(i) <= h) h -= curslice(i); \ - else { \ - h += curslice(i) * (i - n - 1); \ - n = i; \ - if (L / i - h < part) return n-1; \ - } \ - if (capa == i) return (n-1) - - unroll(3); unroll(4); unroll(5); - unroll(6); unroll(7); unroll(8); - unroll(9); unroll(10); unroll(11); - unroll(12); unroll(13); unroll(14); - unroll(15); unroll(16); unroll(17); - unroll(18); unroll(19); unroll(20); - unroll(21); unroll(22); unroll(23); - unroll(24); unroll(25); unroll(26); - - for (i = 27; i <= capa && i <= 62; i++) { - c = LL27_38[i-27]; - if (c <= h) { - h -= c; - } - else { - h += c * (i - n - 1); - n = i; - if (L27_38[i-27] - h < part) return n-1; - } - } - - for(i = 63; i <= capa; i++) { - c = L / (i * (i - 1)); - if (c <= h) { - h -= c; - } - else { - h += c * (i - n - 1); - n = i; - if (L / i - h < part) return n - 1; - } - } - } while(false); - return n - 1; -} diff --git a/contrib/consistent-hashing-sumbur/sumbur.h b/contrib/consistent-hashing-sumbur/sumbur.h deleted file mode 100644 index 1632665a073..00000000000 --- a/contrib/consistent-hashing-sumbur/sumbur.h +++ /dev/null @@ -1,28 +0,0 @@ -//Copyright (c) 2011-2012 Mail.RU -//Copyright (c) 2011-2012 Maksim Kalinchenko -//Copyright (c) 2012 Sokolov Yura aka funny-falcon -// -//MIT License -// -//Permission is hereby granted, free of charge, to any person obtaining -//a copy of this software and associated documentation files (the -//"Software"), to deal in the Software without restriction, including -//without limitation the rights to use, copy, modify, merge, publish, -//distribute, sublicense, and/or sell copies of the Software, and to -//permit persons to whom the Software is furnished to do so, subject to -//the following conditions: -// -//The above copyright notice and this permission notice shall be -//included in all copies or substantial portions of the Software. -// -//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -//EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -//MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -//NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -//LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -//OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -//WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -/// Source code: https://github.com/mailru/sumbur-ruby/blob/master/ext/sumbur/sumbur.c - -unsigned int sumburConsistentHash(unsigned int hashed_int, unsigned int capacity); diff --git a/src/Functions/CMakeLists.txt b/src/Functions/CMakeLists.txt index 126e4c7c57d..321aa5e2196 100644 --- a/src/Functions/CMakeLists.txt +++ b/src/Functions/CMakeLists.txt @@ -18,7 +18,6 @@ target_link_libraries(clickhouse_functions clickhouse_dictionaries_embedded clickhouse_parsers consistent-hashing - consistent-hashing-sumbur dbms metrohash murmurhash diff --git a/src/Functions/registerFunctionsConsistentHashing.cpp b/src/Functions/registerFunctionsConsistentHashing.cpp index ceec6dca5e6..d4d740bc92f 100644 --- a/src/Functions/registerFunctionsConsistentHashing.cpp +++ b/src/Functions/registerFunctionsConsistentHashing.cpp @@ -1,22 +1,14 @@ namespace DB - { class FunctionFactory; void registerFunctionYandexConsistentHash(FunctionFactory & factory); void registerFunctionJumpConsistentHash(FunctionFactory & factory); -#if !defined(ARCADIA_BUILD) -void registerFunctionSumburConsistentHash(FunctionFactory & factory); -#endif - void registerFunctionsConsistentHashing(FunctionFactory & factory) { registerFunctionYandexConsistentHash(factory); registerFunctionJumpConsistentHash(factory); -#if !defined(ARCADIA_BUILD) - registerFunctionSumburConsistentHash(factory); -#endif } } diff --git a/src/Functions/sumburConsistentHash.cpp b/src/Functions/sumburConsistentHash.cpp deleted file mode 100644 index 88de93f65d9..00000000000 --- a/src/Functions/sumburConsistentHash.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "FunctionsConsistentHashing.h" -#include - -#include - - -namespace DB -{ -namespace -{ - -struct SumburConsistentHashImpl -{ - static constexpr auto name = "sumburConsistentHash"; - - using HashType = UInt32; - using ResultType = UInt16; - using BucketsType = ResultType; - static constexpr auto max_buckets = static_cast(std::numeric_limits::max()); - - static inline ResultType apply(HashType hash, BucketsType n) - { - return static_cast(sumburConsistentHash(hash, n)); - } -}; - -using FunctionSumburConsistentHash = FunctionConsistentHashImpl; - -} - -void registerFunctionSumburConsistentHash(FunctionFactory & factory) -{ - factory.registerFunction(); -} - -} - - diff --git a/src/Functions/ya.make.in b/src/Functions/ya.make.in index 9a646afc14b..5a3369c55a1 100644 --- a/src/Functions/ya.make.in +++ b/src/Functions/ya.make.in @@ -35,7 +35,7 @@ PEERDIR( # "Arcadia" build is slightly deficient. It lacks many libraries that we need. SRCS( - + ) END() diff --git a/utils/check-style/check-include b/utils/check-style/check-include index 6c7b3d02e6a..3c0c6103958 100755 --- a/utils/check-style/check-include +++ b/utils/check-style/check-include @@ -50,7 +50,6 @@ inc="-I. \ -I${BUILD_DIR}/base \ -I./base/daemon \ -I./base/consistent-hashing \ --I./base/consistent-hashing-sumbur \ -I./contrib/libhdfs3/include \ -I./contrib/base64/include \ -I./contrib/protobuf/src \