-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Для запроса %% pragma UseBlocks; SELECT RemoteIP as r FROM `yq-clickbench-local`.`hits_*.parquet` WITH ( format=parquet, SCHEMA ( RemoteIP INTEGER NOT NULL, ) ) order by r limit 5 ; %% время уменьшилось с 0.47c до 0,34с
- Loading branch information
Showing
23 changed files
with
559 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# List of authors for copyright purposes, in no particular order | ||
Danila Kutenin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
# This file was generated by the build system used internally in the Yandex monorepo. | ||
# Only simple modifications are allowed (adding source-files to targets, adding simple properties | ||
# like target_include_directories). These modifications will be ported to original | ||
# ya.make files by maintainers. Any complex modifications which can't be ported back to the | ||
# original buildsystem will not be accepted. | ||
|
||
|
||
|
||
add_library(contrib-libs-miniselect INTERFACE) | ||
target_link_libraries(contrib-libs-miniselect INTERFACE | ||
contrib-libs-cxxsupp | ||
yutil | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
# This file was generated by the build system used internally in the Yandex monorepo. | ||
# Only simple modifications are allowed (adding source-files to targets, adding simple properties | ||
# like target_include_directories). These modifications will be ported to original | ||
# ya.make files by maintainers. Any complex modifications which can't be ported back to the | ||
# original buildsystem will not be accepted. | ||
|
||
|
||
|
||
add_library(contrib-libs-miniselect INTERFACE) | ||
target_link_libraries(contrib-libs-miniselect INTERFACE | ||
contrib-libs-linux-headers | ||
contrib-libs-cxxsupp | ||
yutil | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
# This file was generated by the build system used internally in the Yandex monorepo. | ||
# Only simple modifications are allowed (adding source-files to targets, adding simple properties | ||
# like target_include_directories). These modifications will be ported to original | ||
# ya.make files by maintainers. Any complex modifications which can't be ported back to the | ||
# original buildsystem will not be accepted. | ||
|
||
|
||
|
||
add_library(contrib-libs-miniselect INTERFACE) | ||
target_link_libraries(contrib-libs-miniselect INTERFACE | ||
contrib-libs-linux-headers | ||
contrib-libs-cxxsupp | ||
yutil | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
# This file was generated by the build system used internally in the Yandex monorepo. | ||
# Only simple modifications are allowed (adding source-files to targets, adding simple properties | ||
# like target_include_directories). These modifications will be ported to original | ||
# ya.make files by maintainers. Any complex modifications which can't be ported back to the | ||
# original buildsystem will not be accepted. | ||
|
||
|
||
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND UNIX AND NOT APPLE AND NOT ANDROID) | ||
include(CMakeLists.linux-aarch64.txt) | ||
elseif (APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") | ||
include(CMakeLists.darwin.txt) | ||
elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND UNIX AND NOT APPLE AND NOT ANDROID) | ||
include(CMakeLists.linux.txt) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Boost Software License - Version 1.0 - August 17th, 2003 | ||
|
||
Permission is hereby granted, free of charge, to any person or organization | ||
obtaining a copy of the software and accompanying documentation covered by | ||
this license (the "Software") to use, reproduce, display, distribute, | ||
execute, and transmit the Software, and to prepare derivative works of the | ||
Software, and to permit third-parties to whom the Software is furnished to | ||
do so, all subject to the following: | ||
|
||
The copyright notices in the Software and this entire statement, including | ||
the above license grant, this restriction and the following disclaimer, | ||
must be included in all copies of the Software, in whole or in part, and | ||
all derivative works of the Software, unless such copies or derivative | ||
works are solely in the form of machine-executable object code generated by | ||
a source language processor. | ||
|
||
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, TITLE AND NON-INFRINGEMENT. IN NO EVENT | ||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE | ||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
DEALINGS IN THE SOFTWARE. |
Large diffs are not rendered by default.
Oops, something went wrong.
129 changes: 129 additions & 0 deletions
129
contrib/libs/miniselect/include/miniselect/floyd_rivest_select.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
/* Copyright Danila Kutenin, 2020-. | ||
* Distributed under the Boost Software License, Version 1.0. | ||
* (See accompanying file LICENSE_1_0.txt or copy at | ||
* https://boost.org/LICENSE_1_0.txt) | ||
*/ | ||
#pragma once | ||
|
||
#include <algorithm> | ||
#include <cmath> | ||
#include <cstddef> | ||
#include <functional> | ||
#include <iterator> | ||
#include <type_traits> | ||
#include <utility> | ||
|
||
namespace miniselect { | ||
namespace floyd_rivest_detail { | ||
|
||
enum floyd_rivest_constants { | ||
kQCap = 600, | ||
}; | ||
|
||
template <class Compare> | ||
struct CompareRefType { | ||
// Pass the comparator by lvalue reference. Or in debug mode, using a | ||
// debugging wrapper that stores a reference. | ||
using type = typename std::add_lvalue_reference<Compare>::type; | ||
}; | ||
|
||
template <class Iter, class Compare, | ||
class DiffType = typename std::iterator_traits<Iter>::difference_type> | ||
inline void floyd_rivest_select_loop(Iter begin, DiffType left, DiffType right, | ||
DiffType k, Compare comp) { | ||
while (right > left) { | ||
DiffType size = right - left; | ||
if (size > floyd_rivest_constants::kQCap) { | ||
DiffType n = right - left + 1; | ||
DiffType i = k - left + 1; | ||
|
||
double z = log(n); | ||
double s = 0.5 * exp(2 * z / 3); | ||
double sd = 0.5 * sqrt(z * s * (n - s) / n); | ||
if (i < n / 2) { | ||
sd *= -1.0; | ||
} | ||
DiffType new_left = | ||
std::max(left, static_cast<DiffType>(k - i * s / n + sd)); | ||
DiffType new_right = | ||
std::min(right, static_cast<DiffType>(k + (n - i) * s / n + sd)); | ||
floyd_rivest_select_loop<Iter, Compare, DiffType>(begin, new_left, | ||
new_right, k, comp); | ||
} | ||
DiffType i = left; | ||
DiffType j = right; | ||
|
||
std::swap(begin[left], begin[k]); | ||
const bool to_swap = comp(begin[left], begin[right]); | ||
if (to_swap) { | ||
std::swap(begin[left], begin[right]); | ||
} | ||
// Make sure that non copyable types compile. | ||
const auto& t = to_swap ? begin[left] : begin[right]; | ||
while (i < j) { | ||
std::swap(begin[i], begin[j]); | ||
i++; | ||
j--; | ||
while (comp(begin[i], t)) { | ||
i++; | ||
} | ||
while (comp(t, begin[j])) { | ||
j--; | ||
} | ||
} | ||
|
||
if (to_swap) { | ||
std::swap(begin[left], begin[j]); | ||
} else { | ||
j++; | ||
std::swap(begin[right], begin[j]); | ||
} | ||
|
||
if (j <= k) { | ||
left = j + 1; | ||
} | ||
if (k <= j) { | ||
right = j - 1; | ||
} | ||
} | ||
} | ||
|
||
} // namespace floyd_rivest_detail | ||
|
||
template <class Iter, class Compare> | ||
inline void floyd_rivest_partial_sort(Iter begin, Iter mid, Iter end, | ||
Compare comp) { | ||
if (begin == end) return; | ||
if (begin == mid) return; | ||
using CompType = typename floyd_rivest_detail::CompareRefType<Compare>::type; | ||
using DiffType = typename std::iterator_traits<Iter>::difference_type; | ||
floyd_rivest_detail::floyd_rivest_select_loop<Iter, CompType>( | ||
begin, DiffType{0}, static_cast<DiffType>(end - begin - 1), | ||
static_cast<DiffType>(mid - begin - 1), comp); | ||
// std::sort proved to be better than other sorts because of pivoting. | ||
std::sort<Iter, CompType>(begin, mid, comp); | ||
} | ||
|
||
template <class Iter> | ||
inline void floyd_rivest_partial_sort(Iter begin, Iter mid, Iter end) { | ||
typedef typename std::iterator_traits<Iter>::value_type T; | ||
floyd_rivest_partial_sort(begin, mid, end, std::less<T>()); | ||
} | ||
|
||
template <class Iter, class Compare> | ||
inline void floyd_rivest_select(Iter begin, Iter mid, Iter end, Compare comp) { | ||
if (mid == end) return; | ||
using CompType = typename floyd_rivest_detail::CompareRefType<Compare>::type; | ||
using DiffType = typename std::iterator_traits<Iter>::difference_type; | ||
floyd_rivest_detail::floyd_rivest_select_loop<Iter, CompType>( | ||
begin, DiffType{0}, static_cast<DiffType>(end - begin - 1), | ||
static_cast<DiffType>(mid - begin), comp); | ||
} | ||
|
||
template <class Iter> | ||
inline void floyd_rivest_select(Iter begin, Iter mid, Iter end) { | ||
typedef typename std::iterator_traits<Iter>::value_type T; | ||
floyd_rivest_select(begin, mid, end, std::less<T>()); | ||
} | ||
|
||
} // namespace miniselect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.