Use pdqsort instead of std::sort in ORDER BY

This commit is contained in:
Evgenii Pravda 2019-02-02 16:52:20 +03:00
parent fdfb60318c
commit 67d26f6528
7 changed files with 15 additions and 5 deletions

3
.gitmodules vendored
View File

@ -64,3 +64,6 @@
[submodule "contrib/cppkafka"]
path = contrib/cppkafka
url = https://github.com/mfontanini/cppkafka.git
[submodule "contrib/pdqsort"]
path = contrib/pdqsort
url = https://github.com/orlp/pdqsort

View File

@ -253,6 +253,7 @@ endif()
include (cmake/find_libgsasl.cmake)
include (cmake/find_libxml2.cmake)
include (cmake/find_protobuf.cmake)
include (cmake/find_pdqsort.cmake)
include (cmake/find_hdfs3.cmake)
include (cmake/find_consistent-hashing.cmake)
include (cmake/find_base64.cmake)

2
cmake/find_pdqsort.cmake Normal file
View File

@ -0,0 +1,2 @@
set(PDQSORT_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/contrib/pdqsort)
message(STATUS "Using pdqsort: ${ICU_INCLUDE_DIR}")

1
contrib/pdqsort vendored Submodule

@ -0,0 +1 @@
Subproject commit 08879029ab8dcb80a70142acb709e3df02de5d37

View File

@ -206,6 +206,8 @@ target_link_libraries (clickhouse_common_io
${CMAKE_DL_LIBS}
)
target_include_directories(clickhouse_common_io SYSTEM BEFORE PUBLIC ${PDQSORT_INCLUDE_DIR})
target_include_directories(clickhouse_common_io SYSTEM BEFORE PUBLIC ${RE2_INCLUDE_DIR})
if(CPUID_LIBRARY)

View File

@ -12,6 +12,7 @@
#include <Columns/ColumnsCommon.h>
#include <DataStreams/ColumnGathererStream.h>
#include <ext/bit_cast.h>
#include <pdqsort.h>
#ifdef __SSE2__
#include <emmintrin.h>
@ -90,9 +91,9 @@ void ColumnVector<T>::getPermutation(bool reverse, size_t limit, int nan_directi
else
{
if (reverse)
std::sort(res.begin(), res.end(), greater(*this, nan_direction_hint));
pdqsort(res.begin(), res.end(), greater(*this, nan_direction_hint));
else
std::sort(res.begin(), res.end(), less(*this, nan_direction_hint));
pdqsort(res.begin(), res.end(), less(*this, nan_direction_hint));
}
}

View File

@ -3,6 +3,7 @@
#include <Columns/ColumnString.h>
#include <Common/typeid_cast.h>
#include <pdqsort.h>
namespace DB
{
@ -94,7 +95,6 @@ struct PartialSortingLessWithCollation
}
};
void sortBlock(Block & block, const SortDescription & description, size_t limit)
{
if (!block)
@ -151,7 +151,7 @@ void sortBlock(Block & block, const SortDescription & description, size_t limit)
if (limit)
std::partial_sort(perm.begin(), perm.begin() + limit, perm.end(), less_with_collation);
else
std::sort(perm.begin(), perm.end(), less_with_collation);
pdqsort(perm.begin(), perm.end(), less_with_collation);
}
else
{
@ -160,7 +160,7 @@ void sortBlock(Block & block, const SortDescription & description, size_t limit)
if (limit)
std::partial_sort(perm.begin(), perm.begin() + limit, perm.end(), less);
else
std::sort(perm.begin(), perm.end(), less);
pdqsort(perm.begin(), perm.end(), less);
}
size_t columns = block.columns();