0012-Correctly-find-and-use-system-metrohash-library.patch 4.22 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
From: Alexander GQ Gerasiov <gq@cs.msu.su>
Date: Fri, 11 Jan 2019 03:27:28 +0300
Subject: Correctly find and use system metrohash library.

Also fix test conflict with new version of metrahash headers.

I think it would be bundle latest metrohash library into CH's contrib to keep
the codebase synced. (At least it breaks nothing.)

Signed-off-by: Alexander GQ Gerasiov <gq@cs.msu.su>
---
 cmake/Modules/Findmetrohash.cmake                 | 2 +-
 dbms/src/Functions/CMakeLists.txt                 | 4 +---
 dbms/src/Interpreters/tests/CMakeLists.txt        | 2 ++
 dbms/src/Interpreters/tests/hash_map_string_3.cpp | 6 +++---
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/cmake/Modules/Findmetrohash.cmake b/cmake/Modules/Findmetrohash.cmake
index 9efc1ed..c516657 100644
--- a/cmake/Modules/Findmetrohash.cmake
+++ b/cmake/Modules/Findmetrohash.cmake
@@ -28,7 +28,7 @@ find_library(METROHASH_LIBRARIES
 
 find_path(METROHASH_INCLUDE_DIR
     NAMES metrohash.h
-    PATHS ${METROHASH_ROOT_DIR}/include ${METROHASH_INCLUDE_PATHS}
+    PATHS ${METROHASH_ROOT_DIR}/include PATH_SUFFIXES metrohash ${METROHASH_INCLUDE_PATHS}
 )
 
 include(FindPackageHandleStandardArgs)
diff --git a/dbms/src/Functions/CMakeLists.txt b/dbms/src/Functions/CMakeLists.txt
index b4163c2..67e59e1 100644
--- a/dbms/src/Functions/CMakeLists.txt
+++ b/dbms/src/Functions/CMakeLists.txt
@@ -21,9 +21,7 @@ target_link_libraries(clickhouse_functions
         ${OPENSSL_CRYPTO_LIBRARY}
 	${CITYHASH_LIBRARIES})
 
-target_include_directories (clickhouse_functions SYSTEM BEFORE PUBLIC ${DBMS_INCLUDE_DIR} ${COMMON_INCLUDE_DIR} ${PCG_RANDOM_INCLUDE_DIR})
-
-target_include_directories (clickhouse_functions SYSTEM BEFORE PUBLIC ${DIVIDE_INCLUDE_DIR})
+target_include_directories (clickhouse_functions SYSTEM BEFORE PUBLIC ${DBMS_INCLUDE_DIR} ${COMMON_INCLUDE_DIR} ${PCG_RANDOM_INCLUDE_DIR} ${METROHASH_INCLUDE_DIR} ${DIVIDE_INCLUDE_DIR})
 
 if (CONSISTENT_HASHING_INCLUDE_DIR)
     target_include_directories (clickhouse_functions PRIVATE ${CONSISTENT_HASHING_INCLUDE_DIR})
diff --git a/dbms/src/Interpreters/tests/CMakeLists.txt b/dbms/src/Interpreters/tests/CMakeLists.txt
index 7660527..0211fc4 100644
--- a/dbms/src/Interpreters/tests/CMakeLists.txt
+++ b/dbms/src/Interpreters/tests/CMakeLists.txt
@@ -15,6 +15,7 @@ target_include_directories (hash_map SYSTEM BEFORE PRIVATE ${SPARCEHASH_INCLUDE_
 target_link_libraries (hash_map PRIVATE dbms)
 
 add_executable (hash_map3 hash_map3.cpp)
+target_include_directories(hash_map3 SYSTEM BEFORE PRIVATE ${METROHASH_INCLUDE_DIR})
 target_link_libraries (hash_map3 PRIVATE dbms ${FARMHASH_LIBRARIES} ${METROHASH_LIBRARIES})
 
 add_executable (hash_map_string hash_map_string.cpp)
@@ -25,6 +26,7 @@ add_executable (hash_map_string_2 hash_map_string_2.cpp)
 target_link_libraries (hash_map_string_2 PRIVATE dbms)
 
 add_executable (hash_map_string_3 hash_map_string_3.cpp)
+target_include_directories(hash_map_string_3 SYSTEM BEFORE PRIVATE ${METROHASH_INCLUDE_DIR})
 target_link_libraries (hash_map_string_3 PRIVATE dbms ${FARMHASH_LIBRARIES} ${METROHASH_LIBRARIES})
 
 add_executable (hash_map_string_small hash_map_string_small.cpp)
diff --git a/dbms/src/Interpreters/tests/hash_map_string_3.cpp b/dbms/src/Interpreters/tests/hash_map_string_3.cpp
index 24c923d..f242539 100644
--- a/dbms/src/Interpreters/tests/hash_map_string_3.cpp
+++ b/dbms/src/Interpreters/tests/hash_map_string_3.cpp
@@ -325,7 +325,7 @@ struct FarmHash64
 
 
 template <void metrohash64(const uint8_t * key, uint64_t len, uint32_t seed, uint8_t * out)>
-struct MetroHash64
+struct SMetroHash64
 {
     size_t operator() (StringRef x) const
     {
@@ -507,8 +507,8 @@ int main(int argc, char ** argv)
 
     if (!m || m == 8) bench<StringRef, VerySimpleHash> (data, "StringRef_VerySimpleHash");
     if (!m || m == 9) bench<StringRef, FarmHash64>     (data, "StringRef_FarmHash64");
-    if (!m || m == 10) bench<StringRef, MetroHash64<metrohash64_1>>(data, "StringRef_MetroHash64_1");
-    if (!m || m == 11) bench<StringRef, MetroHash64<metrohash64_2>>(data, "StringRef_MetroHash64_2");
+    if (!m || m == 10) bench<StringRef, SMetroHash64<metrohash64_1>>(data, "StringRef_MetroHash64_1");
+    if (!m || m == 11) bench<StringRef, SMetroHash64<metrohash64_2>>(data, "StringRef_MetroHash64_2");
 
     return 0;
 }