Fixed performance tests

This commit is contained in:
Maksim Kita 2022-03-12 18:04:08 +00:00
parent f1d2f2a9e1
commit b67f756a43
8 changed files with 258 additions and 163 deletions

View File

@ -381,24 +381,37 @@ bool ColumnArray::hasEqualValues() const
}
struct ColumnArray::ComparatorBase
{
const ColumnArray & parent;
int nan_direction_hint;
ComparatorBase(const ColumnArray & parent_, int nan_direction_hint_)
: parent(parent_), nan_direction_hint(nan_direction_hint_)
{
}
ALWAYS_INLINE int compare(size_t lhs, size_t rhs) const
{
int res = parent.compareAt(lhs, rhs, parent, nan_direction_hint);
return res;
}
};
struct ColumnArray::ComparatorCollationBase
{
const ColumnArray & parent;
int nan_direction_hint;
const Collator * collator;
ComparatorBase(const ColumnArray & parent_, int nan_direction_hint_, const Collator * collator_ = nullptr)
ComparatorCollationBase(const ColumnArray & parent_, int nan_direction_hint_, const Collator * collator_)
: parent(parent_), nan_direction_hint(nan_direction_hint_), collator(collator_)
{
}
ALWAYS_INLINE int compare(size_t lhs, size_t rhs) const
{
int res;
if (collator)
res = parent.compareAtWithCollation(lhs, rhs, parent, nan_direction_hint, *collator);
else
res = parent.compareAt(lhs, rhs, parent, nan_direction_hint);
int res = parent.compareAtWithCollation(lhs, rhs, parent, nan_direction_hint, *collator);
return res;
}
@ -828,28 +841,56 @@ void ColumnArray::getPermutationWithCollation(const Collator & collator, Permuta
size_t limit, int nan_direction_hint, Permutation & res) const
{
if (direction == IColumn::PermutationSortDirection::Ascending && stability == IColumn::PermutationSortStability::Unstable)
getPermutationImpl(limit, res, ComparatorAscendingUnstable(*this, nan_direction_hint, &collator), DefaultSort(), DefaultPartialSort());
getPermutationImpl(limit, res, ComparatorCollationAscendingUnstable(*this, nan_direction_hint, &collator), DefaultSort(), DefaultPartialSort());
else if (direction == IColumn::PermutationSortDirection::Ascending && stability == IColumn::PermutationSortStability::Stable)
getPermutationImpl(limit, res, ComparatorAscendingStable(*this, nan_direction_hint, &collator), DefaultSort(), DefaultPartialSort());
getPermutationImpl(limit, res, ComparatorCollationAscendingStable(*this, nan_direction_hint, &collator), DefaultSort(), DefaultPartialSort());
else if (direction == IColumn::PermutationSortDirection::Descending && stability == IColumn::PermutationSortStability::Unstable)
getPermutationImpl(limit, res, ComparatorDescendingUnstable(*this, nan_direction_hint, &collator), DefaultSort(), DefaultPartialSort());
getPermutationImpl(limit, res, ComparatorCollationDescendingUnstable(*this, nan_direction_hint, &collator), DefaultSort(), DefaultPartialSort());
else if (direction == IColumn::PermutationSortDirection::Descending && stability == IColumn::PermutationSortStability::Stable)
getPermutationImpl(limit, res, ComparatorDescendingStable(*this, nan_direction_hint, &collator), DefaultSort(), DefaultPartialSort());
getPermutationImpl(limit, res, ComparatorCollationDescendingStable(*this, nan_direction_hint, &collator), DefaultSort(), DefaultPartialSort());
}
void ColumnArray::updatePermutationWithCollation(const Collator & collator, PermutationSortDirection direction, PermutationSortStability stability,
size_t limit, int nan_direction_hint, Permutation & res, EqualRanges & equal_ranges) const
{
auto comparator_equal = ComparatorEqual(*this, nan_direction_hint, &collator);
auto comparator_equal = ComparatorCollationEqual(*this, nan_direction_hint, &collator);
if (direction == IColumn::PermutationSortDirection::Ascending && stability == IColumn::PermutationSortStability::Unstable)
updatePermutationImpl(limit, res, equal_ranges, ComparatorAscendingUnstable(*this, nan_direction_hint, &collator), comparator_equal, DefaultSort(), DefaultPartialSort());
updatePermutationImpl(
limit,
res,
equal_ranges,
ComparatorCollationAscendingUnstable(*this, nan_direction_hint, &collator),
comparator_equal,
DefaultSort(),
DefaultPartialSort());
else if (direction == IColumn::PermutationSortDirection::Ascending && stability == IColumn::PermutationSortStability::Stable)
updatePermutationImpl(limit, res, equal_ranges, ComparatorAscendingStable(*this, nan_direction_hint, &collator), comparator_equal, DefaultSort(), DefaultPartialSort());
updatePermutationImpl(
limit,
res,
equal_ranges,
ComparatorCollationAscendingStable(*this, nan_direction_hint, &collator),
comparator_equal,
DefaultSort(),
DefaultPartialSort());
else if (direction == IColumn::PermutationSortDirection::Descending && stability == IColumn::PermutationSortStability::Unstable)
updatePermutationImpl(limit, res, equal_ranges, ComparatorDescendingUnstable(*this, nan_direction_hint, &collator), comparator_equal, DefaultSort(), DefaultPartialSort());
updatePermutationImpl(
limit,
res,
equal_ranges,
ComparatorCollationDescendingUnstable(*this, nan_direction_hint, &collator),
comparator_equal,
DefaultSort(),
DefaultPartialSort());
else if (direction == IColumn::PermutationSortDirection::Descending && stability == IColumn::PermutationSortStability::Stable)
updatePermutationImpl(limit, res, equal_ranges, ComparatorDescendingStable(*this, nan_direction_hint, &collator), comparator_equal, DefaultSort(), DefaultPartialSort());
updatePermutationImpl(
limit,
res,
equal_ranges,
ComparatorCollationDescendingStable(*this, nan_direction_hint, &collator),
comparator_equal,
DefaultSort(),
DefaultPartialSort());
}
ColumnPtr ColumnArray::compress() const

View File

@ -36,6 +36,14 @@ private:
using ComparatorDescendingStable = ComparatorDescendingStableImpl<ComparatorBase>;
using ComparatorEqual = ComparatorEqualImpl<ComparatorBase>;
struct ComparatorCollationBase;
using ComparatorCollationAscendingUnstable = ComparatorAscendingUnstableImpl<ComparatorCollationBase>;
using ComparatorCollationAscendingStable = ComparatorAscendingStableImpl<ComparatorCollationBase>;
using ComparatorCollationDescendingUnstable = ComparatorDescendingUnstableImpl<ComparatorCollationBase>;
using ComparatorCollationDescendingStable = ComparatorDescendingStableImpl<ComparatorCollationBase>;
using ComparatorCollationEqual = ComparatorEqualImpl<ComparatorCollationBase>;
public:
/** Create immutable column using immutable arguments. This arguments may be shared with other columns.
* Use IColumn::mutate in order to make mutable column and mutate shared nested columns.

View File

@ -501,10 +501,10 @@ void ColumnNullable::updatePermutationImpl(IColumn::PermutationSortDirection dir
equal_ranges = std::move(new_ranges);
if (unlikely(stability == PermutationSortStability::Stable)) {
for (auto & null_range : null_ranges) {
if (unlikely(stability == PermutationSortStability::Stable))
{
for (auto & null_range : null_ranges)
::sort(res.begin() + null_range.first, res.begin() + null_range.second);
}
}
std::move(null_ranges.begin(), null_ranges.end(), std::back_inserter(equal_ranges));

View File

@ -552,7 +552,8 @@ void ColumnSparse::getPermutationImpl(IColumn::PermutationSortDirection directio
void ColumnSparse::getPermutation(IColumn::PermutationSortDirection direction, IColumn::PermutationSortStability stability,
size_t limit, int null_direction_hint, Permutation & res) const
{
if (unlikely(stability == IColumn::PermutationSortStability::Stable)) {
if (unlikely(stability == IColumn::PermutationSortStability::Stable))
{
auto this_full = convertToFullColumnIfSparse();
this_full->getPermutation(direction, stability, limit, null_direction_hint, res);
return;

View File

@ -304,27 +304,39 @@ bool ColumnString::hasEqualValues() const
}
struct ColumnString::ComparatorBase
{
const ColumnString & parent;
explicit ComparatorBase(const ColumnString & parent_)
: parent(parent_)
{
}
ALWAYS_INLINE int compare(size_t lhs, size_t rhs) const
{
int res = memcmpSmallAllowOverflow15(
parent.chars.data() + parent.offsetAt(lhs), parent.sizeAt(lhs) - 1,
parent.chars.data() + parent.offsetAt(rhs), parent.sizeAt(rhs) - 1);
return res;
}
};
struct ColumnString::ComparatorCollationBase
{
const ColumnString & parent;
const Collator * collator;
explicit ComparatorBase(const ColumnString & parent_, const Collator * collator_ = nullptr)
explicit ComparatorCollationBase(const ColumnString & parent_, const Collator * collator_)
: parent(parent_), collator(collator_)
{
}
ALWAYS_INLINE int compare(size_t lhs, size_t rhs) const
{
int res;
if (collator)
res = collator->compare(
reinterpret_cast<const char *>(&parent.chars[parent.offsetAt(lhs)]), parent.sizeAt(lhs),
reinterpret_cast<const char *>(&parent.chars[parent.offsetAt(rhs)]), parent.sizeAt(rhs));
else
res = memcmpSmallAllowOverflow15(
parent.chars.data() + parent.offsetAt(lhs), parent.sizeAt(lhs) - 1,
parent.chars.data() + parent.offsetAt(rhs), parent.sizeAt(rhs) - 1);
int res = collator->compare(
reinterpret_cast<const char *>(&parent.chars[parent.offsetAt(lhs)]), parent.sizeAt(lhs),
reinterpret_cast<const char *>(&parent.chars[parent.offsetAt(rhs)]), parent.sizeAt(rhs));
return res;
}
@ -362,28 +374,56 @@ void ColumnString::getPermutationWithCollation(const Collator & collator, Permut
size_t limit, int /*nan_direction_hint*/, Permutation & res) const
{
if (direction == IColumn::PermutationSortDirection::Ascending && stability == IColumn::PermutationSortStability::Unstable)
getPermutationImpl(limit, res, ComparatorAscendingUnstable(*this, &collator), DefaultSort(), DefaultPartialSort());
getPermutationImpl(limit, res, ComparatorCollationAscendingUnstable(*this, &collator), DefaultSort(), DefaultPartialSort());
else if (direction == IColumn::PermutationSortDirection::Ascending && stability == IColumn::PermutationSortStability::Stable)
getPermutationImpl(limit, res, ComparatorAscendingStable(*this, &collator), DefaultSort(), DefaultPartialSort());
getPermutationImpl(limit, res, ComparatorCollationAscendingStable(*this, &collator), DefaultSort(), DefaultPartialSort());
else if (direction == IColumn::PermutationSortDirection::Descending && stability == IColumn::PermutationSortStability::Unstable)
getPermutationImpl(limit, res, ComparatorDescendingUnstable(*this, &collator), DefaultSort(), DefaultPartialSort());
getPermutationImpl(limit, res, ComparatorCollationDescendingUnstable(*this, &collator), DefaultSort(), DefaultPartialSort());
else if (direction == IColumn::PermutationSortDirection::Descending && stability == IColumn::PermutationSortStability::Stable)
getPermutationImpl(limit, res, ComparatorDescendingStable(*this, &collator), DefaultSort(), DefaultPartialSort());
getPermutationImpl(limit, res, ComparatorCollationDescendingStable(*this, &collator), DefaultSort(), DefaultPartialSort());
}
void ColumnString::updatePermutationWithCollation(const Collator & collator, PermutationSortDirection direction, PermutationSortStability stability,
size_t limit, int /*nan_direction_hint*/, Permutation & res, EqualRanges & equal_ranges) const
{
auto comparator_equal = ComparatorEqual(*this, &collator);
auto comparator_equal = ComparatorCollationEqual(*this, &collator);
if (direction == IColumn::PermutationSortDirection::Ascending && stability == IColumn::PermutationSortStability::Unstable)
updatePermutationImpl(limit, res, equal_ranges, ComparatorAscendingUnstable(*this, &collator), comparator_equal, DefaultSort(), DefaultPartialSort());
updatePermutationImpl(
limit,
res,
equal_ranges,
ComparatorCollationAscendingUnstable(*this, &collator),
comparator_equal,
DefaultSort(),
DefaultPartialSort());
else if (direction == IColumn::PermutationSortDirection::Ascending && stability == IColumn::PermutationSortStability::Stable)
updatePermutationImpl(limit, res, equal_ranges, ComparatorAscendingStable(*this, &collator), comparator_equal, DefaultSort(), DefaultPartialSort());
updatePermutationImpl(
limit,
res,
equal_ranges,
ComparatorCollationAscendingStable(*this, &collator),
comparator_equal,
DefaultSort(),
DefaultPartialSort());
else if (direction == IColumn::PermutationSortDirection::Descending && stability == IColumn::PermutationSortStability::Unstable)
updatePermutationImpl(limit, res, equal_ranges, ComparatorDescendingUnstable(*this, &collator), comparator_equal, DefaultSort(), DefaultPartialSort());
else
updatePermutationImpl(limit, res, equal_ranges, ComparatorDescendingStable(*this, &collator), comparator_equal, DefaultSort(), DefaultPartialSort());
updatePermutationImpl(
limit,
res,
equal_ranges,
ComparatorCollationDescendingUnstable(*this, &collator),
comparator_equal,
DefaultSort(),
DefaultPartialSort());
else if (direction == IColumn::PermutationSortDirection::Descending && stability == IColumn::PermutationSortStability::Stable)
updatePermutationImpl(
limit,
res,
equal_ranges,
ComparatorCollationDescendingStable(*this, &collator),
comparator_equal,
DefaultSort(),
DefaultPartialSort());
}
ColumnPtr ColumnString::replicate(const Offsets & replicate_offsets) const

View File

@ -50,6 +50,14 @@ private:
using ComparatorDescendingStable = ComparatorDescendingStableImpl<ComparatorBase>;
using ComparatorEqual = ComparatorEqualImpl<ComparatorBase>;
struct ComparatorCollationBase;
using ComparatorCollationAscendingUnstable = ComparatorAscendingUnstableImpl<ComparatorCollationBase>;
using ComparatorCollationAscendingStable = ComparatorAscendingStableImpl<ComparatorCollationBase>;
using ComparatorCollationDescendingUnstable = ComparatorDescendingUnstableImpl<ComparatorCollationBase>;
using ComparatorCollationDescendingStable = ComparatorDescendingStableImpl<ComparatorCollationBase>;
using ComparatorCollationEqual = ComparatorEqualImpl<ComparatorCollationBase>;
ColumnString() = default;
ColumnString(const ColumnString & src);

View File

@ -112,7 +112,8 @@ struct ColumnVector<T>::less_stable
if constexpr (std::is_floating_point_v<T>)
{
if (unlikely(std::isnan(parent.data[lhs]) && std::isnan(parent.data[rhs]))) {
if (unlikely(std::isnan(parent.data[lhs]) && std::isnan(parent.data[rhs])))
{
return lhs < rhs;
}
}
@ -143,7 +144,8 @@ struct ColumnVector<T>::greater_stable
if constexpr (std::is_floating_point_v<T>)
{
if (unlikely(std::isnan(parent.data[lhs]) && std::isnan(parent.data[rhs]))) {
if (unlikely(std::isnan(parent.data[lhs]) && std::isnan(parent.data[rhs])))
{
return lhs < rhs;
}
}

View File

@ -2,27 +2,31 @@
#include <vector>
#include <Columns/ColumnVector.h>
#include <Columns/ColumnDecimal.h>
#include <Columns/ColumnUnique.h>
#include <Columns/ColumnString.h>
#include <Columns/ColumnsNumber.h>
#include <Columns/ColumnNullable.h>
#include <Columns/ColumnSparse.h>
#include <Columns/ColumnString.h>
#include <Columns/ColumnUnique.h>
#include <Columns/ColumnVector.h>
#include <Columns/ColumnsNumber.h>
#include <DataTypes/DataTypesNumber.h>
#include <DataTypes/DataTypeString.h>
#include <DataTypes/DataTypeArray.h>
#include <DataTypes/DataTypeNullable.h>
#include <DataTypes/DataTypeLowCardinality.h>
#include <DataTypes/DataTypeTuple.h>
#include <DataTypes/DataTypeMap.h>
#include <DataTypes/DataTypeNullable.h>
#include <DataTypes/DataTypeString.h>
#include <DataTypes/DataTypeTuple.h>
#include <DataTypes/DataTypesNumber.h>
using namespace DB;
void stableGetColumnPermutation(const IColumn & column, IColumn::PermutationSortDirection direction,
size_t limit, int nan_direction_hint, IColumn::Permutation & out_permutation)
void stableGetColumnPermutation(
const IColumn & column,
IColumn::PermutationSortDirection direction,
size_t limit,
int nan_direction_hint,
IColumn::Permutation & out_permutation)
{
(void)(limit);
@ -31,18 +35,26 @@ void stableGetColumnPermutation(const IColumn & column, IColumn::PermutationSort
for (size_t i = 0; i < size; ++i)
out_permutation[i] = i;
std::stable_sort(out_permutation.begin(), out_permutation.end(), [&](size_t lhs, size_t rhs) {
int res = column.compareAt(lhs, rhs, column, nan_direction_hint);
std::stable_sort(
out_permutation.begin(),
out_permutation.end(),
[&](size_t lhs, size_t rhs)
{
int res = column.compareAt(lhs, rhs, column, nan_direction_hint);
if (direction == IColumn::PermutationSortDirection::Ascending)
return res < 0;
else
return res > 0;
});
if (direction == IColumn::PermutationSortDirection::Ascending)
return res < 0;
else
return res > 0;
});
}
void columnGetPermutation(const IColumn & column, IColumn::PermutationSortDirection direction,
size_t limit, int nan_direction_hint, IColumn::Permutation & out_permutation)
void columnGetPermutation(
const IColumn & column,
IColumn::PermutationSortDirection direction,
size_t limit,
int nan_direction_hint,
IColumn::Permutation & out_permutation)
{
column.getPermutation(direction, IColumn::PermutationSortStability::Stable, limit, nan_direction_hint, out_permutation);
}
@ -52,7 +64,8 @@ void printColumn(const IColumn & column)
size_t column_size = column.size();
Field value;
for (size_t i = 0; i < column_size; ++i) {
for (size_t i = 0; i < column_size; ++i)
{
column.get(i, value);
std::cout << value.dump() << ' ';
}
@ -63,7 +76,8 @@ void printColumn(const IColumn & column)
template <typename ValueTransform>
void generateRanges(std::vector<std::vector<Field>> & ranges, size_t range_size, ValueTransform value_transform)
{
for (auto & range : ranges) {
for (auto & range : ranges)
{
range.clear();
}
@ -81,33 +95,43 @@ void generateRanges(std::vector<std::vector<Field>> & ranges, size_t range_size,
void insertRangesIntoColumn(std::vector<std::vector<Field>> & ranges, const std::vector<size_t> & ranges_permutations, IColumn & column)
{
for (const auto & range_permutation : ranges_permutations) {
for (const auto & range_permutation : ranges_permutations)
{
auto & range = ranges[range_permutation];
for (auto & value : range) {
for (auto & value : range)
{
column.insert(value);
}
}
}
void assertPermutationsWithLimit(const IColumn::Permutation & lhs, const IColumn::Permutation & rhs, size_t limit) {
if (limit == 0) {
void assertPermutationsWithLimit(const IColumn::Permutation & lhs, const IColumn::Permutation & rhs, size_t limit)
{
if (limit == 0)
{
limit = lhs.size();
}
for (size_t i = 0; i < limit; ++i) {
for (size_t i = 0; i < limit; ++i)
{
ASSERT_EQ(lhs[i], rhs[i]);
}
}
void assertColumnPermutation(
const IColumn & column, IColumn::PermutationSortDirection direction,
size_t limit, int nan_direction_hint, IColumn::Permutation & actual_permutation, IColumn::Permutation & expected_permutation)
const IColumn & column,
IColumn::PermutationSortDirection direction,
size_t limit,
int nan_direction_hint,
IColumn::Permutation & actual_permutation,
IColumn::Permutation & expected_permutation)
{
stableGetColumnPermutation(column, direction, limit, nan_direction_hint, expected_permutation);
columnGetPermutation(column, direction, limit, nan_direction_hint, actual_permutation);
if (limit == 0) {
if (limit == 0)
{
limit = actual_permutation.size();
}
@ -118,23 +142,20 @@ template <typename ColumnCreateFunc, typename ValueTransform>
void assertColumnPermutations(ColumnCreateFunc column_create_func, ValueTransform value_transform)
{
static constexpr size_t ranges_size = 3;
static const std::vector<size_t> range_sizes = {
1,
5,
50,
500
};
static const std::vector<size_t> range_sizes = {1, 5, 50, 500};
std::vector<std::vector<Field>> ranges(ranges_size);
std::vector<size_t> ranges_permutations(ranges_size);
for (size_t i = 0; i < ranges_size; ++i) {
for (size_t i = 0; i < ranges_size; ++i)
{
ranges_permutations[i] = i;
}
IColumn::Permutation actual_permutation;
IColumn::Permutation expected_permutation;
for (const auto & range_size : range_sizes) {
for (const auto & range_size : range_sizes)
{
generateRanges(ranges, range_size, value_transform);
std::sort(ranges_permutations.begin(), ranges_permutations.end());
@ -151,11 +172,15 @@ void assertColumnPermutations(ColumnCreateFunc column_create_func, ValueTransfor
for (size_t limit = 0; limit < column_size; limit += column_limit_part)
{
assertColumnPermutation(column, IColumn::PermutationSortDirection::Ascending, limit, -1, actual_permutation, expected_permutation);
assertColumnPermutation(column, IColumn::PermutationSortDirection::Ascending, limit, 1, actual_permutation, expected_permutation);
assertColumnPermutation(
column, IColumn::PermutationSortDirection::Ascending, limit, -1, actual_permutation, expected_permutation);
assertColumnPermutation(
column, IColumn::PermutationSortDirection::Ascending, limit, 1, actual_permutation, expected_permutation);
assertColumnPermutation(column, IColumn::PermutationSortDirection::Descending, limit, -1, actual_permutation, expected_permutation);
assertColumnPermutation(column, IColumn::PermutationSortDirection::Descending, limit, 1, actual_permutation, expected_permutation);
assertColumnPermutation(
column, IColumn::PermutationSortDirection::Descending, limit, -1, actual_permutation, expected_permutation);
assertColumnPermutation(
column, IColumn::PermutationSortDirection::Descending, limit, 1, actual_permutation, expected_permutation);
}
assertColumnPermutation(column, IColumn::PermutationSortDirection::Ascending, 0, -1, actual_permutation, expected_permutation);
@ -172,17 +197,12 @@ void assertColumnPermutations(ColumnCreateFunc column_create_func, ValueTransfor
struct IndexInRangeInt64Transform
{
Field operator()(size_t range_index, size_t index_in_range) const
{
return Field(static_cast<Int64>(range_index * index_in_range));
}
Field operator()(size_t range_index, size_t index_in_range) const { return Field(static_cast<Int64>(range_index * index_in_range)); }
};
TEST(StablePermutation, ColumnVectorInteger)
{
auto create_column = []() {
return ColumnVector<Int64>::create();
};
auto create_column = []() { return ColumnVector<Int64>::create(); };
assertColumnPermutations(create_column, IndexInRangeInt64Transform());
}
@ -191,11 +211,16 @@ struct IndexInRangeFloat64Transform
{
Field operator()(size_t range_index, size_t index_in_range) const
{
if (range_index % 2 == 0 && index_in_range % 4 == 0) {
if (range_index % 2 == 0 && index_in_range % 4 == 0)
{
return std::numeric_limits<Float64>::quiet_NaN();
} else if (range_index % 2 == 0 && index_in_range % 5 == 0) {
}
else if (range_index % 2 == 0 && index_in_range % 5 == 0)
{
return -std::numeric_limits<Float64>::infinity();
} else if (range_index % 2 == 0 && index_in_range % 6 == 0) {
}
else if (range_index % 2 == 0 && index_in_range % 6 == 0)
{
return std::numeric_limits<Float64>::infinity();
}
@ -205,9 +230,7 @@ struct IndexInRangeFloat64Transform
TEST(StablePermutation, ColumnVectorFloat)
{
auto create_column = []() {
return ColumnVector<Float64>::create();
};
auto create_column = []() { return ColumnVector<Float64>::create(); };
assertColumnPermutations(create_column, IndexInRangeFloat64Transform());
}
@ -222,9 +245,7 @@ struct IndexInRangeDecimal64Transform
TEST(StablePermutation, ColumnVectorDecimal)
{
auto create_column = []() {
return ColumnDecimal<Decimal64>::create(0, 0);
};
auto create_column = []() { return ColumnDecimal<Decimal64>::create(0, 0); };
assertColumnPermutations(create_column, IndexInRangeDecimal64Transform());
}
@ -232,26 +253,19 @@ TEST(StablePermutation, ColumnVectorDecimal)
struct IndexInRangeStringTransform
{
Field operator()(size_t range_index, size_t index_in_range) const
{
return Field(std::to_string(range_index * index_in_range));
}
Field operator()(size_t range_index, size_t index_in_range) const { return Field(std::to_string(range_index * index_in_range)); }
};
TEST(StablePermutation, ColumnString)
{
auto create_column = []() {
return ColumnString::create();
};
auto create_column = []() { return ColumnString::create(); };
assertColumnPermutations(create_column, IndexInRangeStringTransform());
}
TEST(StablePermutation, ColumnFixedString)
{
auto create_column = []() {
return ColumnFixedString::create(15);
};
auto create_column = []() { return ColumnFixedString::create(15); };
assertColumnPermutations(create_column, IndexInRangeStringTransform());
}
@ -270,9 +284,7 @@ TEST(StablePermutation, ColumnArray)
auto int64_data_type = std::make_shared<DataTypeInt64>();
auto array_data_type = std::make_shared<DataTypeArray>(std::move(int64_data_type));
auto create_column = [&]() {
return array_data_type->createColumn();
};
auto create_column = [&]() { return array_data_type->createColumn(); };
assertColumnPermutations(create_column, IndexInRangeArrayTransform());
}
@ -282,7 +294,8 @@ struct IndexInRangeNullableTransform
{
Field operator()(size_t range_index, size_t index_in_range) const
{
if (range_index % 2 == 0 && index_in_range % 3 == 0) {
if (range_index % 2 == 0 && index_in_range % 3 == 0)
{
return Field();
}
@ -294,10 +307,7 @@ struct IndexInRangeNullableTransform
struct IndexInRangeToNullTransform
{
Field operator()(size_t /*range_index*/, size_t /*index_in_range*/) const
{
return Field();
}
Field operator()(size_t /*range_index*/, size_t /*index_in_range*/) const { return Field(); }
};
TEST(StablePermutation, ColumnNullable)
@ -306,9 +316,7 @@ TEST(StablePermutation, ColumnNullable)
auto int_data_type = std::make_shared<DataTypeInt64>();
auto nullable_data_type = std::make_shared<DataTypeNullable>(std::move(int_data_type));
auto create_column = [&]() {
return nullable_data_type->createColumn();
};
auto create_column = [&]() { return nullable_data_type->createColumn(); };
assertColumnPermutations(create_column, IndexInRangeNullableTransform<IndexInRangeInt64Transform>());
assertColumnPermutations(create_column, IndexInRangeToNullTransform());
@ -318,9 +326,7 @@ TEST(StablePermutation, ColumnNullable)
auto float_data_type = std::make_shared<DataTypeFloat64>();
auto nullable_data_type = std::make_shared<DataTypeNullable>(std::move(float_data_type));
auto create_column = [&]() {
return nullable_data_type->createColumn();
};
auto create_column = [&]() { return nullable_data_type->createColumn(); };
assertColumnPermutations(create_column, IndexInRangeNullableTransform<IndexInRangeFloat64Transform>());
assertColumnPermutations(create_column, IndexInRangeToNullTransform());
@ -334,9 +340,7 @@ TEST(StablePermutation, ColumnLowCardinality)
auto int_data_type = std::make_shared<DataTypeInt64>();
auto low_cardinality_data_type = std::make_shared<DataTypeLowCardinality>(std::move(int_data_type));
auto create_column = [&]() {
return low_cardinality_data_type->createColumn();
};
auto create_column = [&]() { return low_cardinality_data_type->createColumn(); };
assertColumnPermutations(create_column, IndexInRangeInt64Transform());
}
@ -345,9 +349,7 @@ TEST(StablePermutation, ColumnLowCardinality)
auto nullable_data_type = std::make_shared<DataTypeNullable>(std::move(int_data_type));
auto low_cardinality_data_type = std::make_shared<DataTypeLowCardinality>(nullable_data_type);
auto create_column = [&]() {
return low_cardinality_data_type->createColumn();
};
auto create_column = [&]() { return low_cardinality_data_type->createColumn(); };
assertColumnPermutations(create_column, IndexInRangeNullableTransform<IndexInRangeInt64Transform>());
assertColumnPermutations(create_column, IndexInRangeToNullTransform());
@ -358,9 +360,7 @@ TEST(StablePermutation, ColumnLowCardinality)
auto nullable_data_type = std::make_shared<DataTypeNullable>(std::move(float_data_type));
auto low_cardinality_data_type = std::make_shared<DataTypeLowCardinality>(nullable_data_type);
auto create_column = [&]() {
return low_cardinality_data_type->createColumn();
};
auto create_column = [&]() { return low_cardinality_data_type->createColumn(); };
assertColumnPermutations(create_column, IndexInRangeNullableTransform<IndexInRangeFloat64Transform>());
assertColumnPermutations(create_column, IndexInRangeToNullTransform());
@ -391,9 +391,7 @@ TEST(StablePermutation, ColumnTuple)
DataTypes tuple_data_types = {int_data_type, float_data_type};
auto tuple_type = std::make_shared<DataTypeTuple>(tuple_data_types);
auto create_column = [&]() {
return tuple_type->createColumn();
};
auto create_column = [&]() { return tuple_type->createColumn(); };
assertColumnPermutations(create_column, TupleTransform<IndexInRangeInt64Transform, IndexInRangeFloat64Transform>());
}
@ -404,13 +402,14 @@ TEST(StablePermutation, ColumnTuple)
DataTypes tuple_data_types = {nullable_data_type, float_type};
auto tuple_type = std::make_shared<DataTypeTuple>(tuple_data_types);
auto create_column = [&]() {
return tuple_type->createColumn();
};
auto create_column = [&]() { return tuple_type->createColumn(); };
assertColumnPermutations(create_column, TupleTransform<IndexInRangeNullableTransform<IndexInRangeInt64Transform>, IndexInRangeFloat64Transform>());
assertColumnPermutations(create_column, TupleTransform<IndexInRangeNullableTransform<IndexInRangeToNullTransform>, IndexInRangeFloat64Transform>());
assertColumnPermutations(create_column, TupleTransform<IndexInRangeNullableTransform<IndexInRangeInt64Transform>, IndexInRangeFloat64Transform>());
assertColumnPermutations(
create_column, TupleTransform<IndexInRangeNullableTransform<IndexInRangeInt64Transform>, IndexInRangeFloat64Transform>());
assertColumnPermutations(
create_column, TupleTransform<IndexInRangeNullableTransform<IndexInRangeToNullTransform>, IndexInRangeFloat64Transform>());
assertColumnPermutations(
create_column, TupleTransform<IndexInRangeNullableTransform<IndexInRangeInt64Transform>, IndexInRangeFloat64Transform>());
}
{
auto int_data_type = std::make_shared<DataTypeInt64>();
@ -419,13 +418,14 @@ TEST(StablePermutation, ColumnTuple)
DataTypes tuple_data_types = {float_type, nullable_data_type};
auto tuple_type = std::make_shared<DataTypeTuple>(tuple_data_types);
auto create_column = [&]() {
return tuple_type->createColumn();
};
auto create_column = [&]() { return tuple_type->createColumn(); };
assertColumnPermutations(create_column, TupleTransform<IndexInRangeFloat64Transform, IndexInRangeNullableTransform<IndexInRangeInt64Transform>>());
assertColumnPermutations(create_column, TupleTransform<IndexInRangeFloat64Transform, IndexInRangeNullableTransform<IndexInRangeToNullTransform>>());
assertColumnPermutations(create_column, TupleTransform<IndexInRangeFloat64Transform, IndexInRangeNullableTransform<IndexInRangeInt64Transform>>());
assertColumnPermutations(
create_column, TupleTransform<IndexInRangeFloat64Transform, IndexInRangeNullableTransform<IndexInRangeInt64Transform>>());
assertColumnPermutations(
create_column, TupleTransform<IndexInRangeFloat64Transform, IndexInRangeNullableTransform<IndexInRangeToNullTransform>>());
assertColumnPermutations(
create_column, TupleTransform<IndexInRangeFloat64Transform, IndexInRangeNullableTransform<IndexInRangeInt64Transform>>());
}
{
auto float_data_type = std::make_shared<DataTypeFloat64>();
@ -433,13 +433,14 @@ TEST(StablePermutation, ColumnTuple)
DataTypes tuple_data_types = {nullable_data_type, float_data_type};
auto tuple_type = std::make_shared<DataTypeTuple>(tuple_data_types);
auto create_column = [&]() {
return tuple_type->createColumn();
};
auto create_column = [&]() { return tuple_type->createColumn(); };
assertColumnPermutations(create_column, TupleTransform<IndexInRangeNullableTransform<IndexInRangeFloat64Transform>, IndexInRangeFloat64Transform>());
assertColumnPermutations(create_column, TupleTransform<IndexInRangeNullableTransform<IndexInRangeToNullTransform>, IndexInRangeFloat64Transform>());
assertColumnPermutations(create_column, TupleTransform<IndexInRangeNullableTransform<IndexInRangeFloat64Transform>, IndexInRangeFloat64Transform>());
assertColumnPermutations(
create_column, TupleTransform<IndexInRangeNullableTransform<IndexInRangeFloat64Transform>, IndexInRangeFloat64Transform>());
assertColumnPermutations(
create_column, TupleTransform<IndexInRangeNullableTransform<IndexInRangeToNullTransform>, IndexInRangeFloat64Transform>());
assertColumnPermutations(
create_column, TupleTransform<IndexInRangeNullableTransform<IndexInRangeFloat64Transform>, IndexInRangeFloat64Transform>());
}
}
@ -465,9 +466,7 @@ TEST(StablePermutation, ColumnMap)
auto float_data_type = std::make_shared<DataTypeFloat64>();
auto map_type = std::make_shared<DataTypeMap>(int_data_type, float_data_type);
auto create_column = [&]() {
return map_type->createColumn();
};
auto create_column = [&]() { return map_type->createColumn(); };
assertColumnPermutations(create_column, MapTransform<IndexInRangeInt64Transform, IndexInRangeFloat64Transform>());
}
@ -478,18 +477,14 @@ TEST(StablePermutation, ColumnSparse)
{
auto int_data_type = std::make_shared<DataTypeInt64>();
auto create_column = [&]() {
return ColumnSparse::create(int_data_type->createColumn());
};
auto create_column = [&]() { return ColumnSparse::create(int_data_type->createColumn()); };
assertColumnPermutations(create_column, IndexInRangeInt64Transform());
}
{
auto float_data_type = std::make_shared<DataTypeFloat64>();
auto create_column = [&]() {
return ColumnSparse::create(float_data_type->createColumn());
};
auto create_column = [&]() { return ColumnSparse::create(float_data_type->createColumn()); };
assertColumnPermutations(create_column, IndexInRangeFloat64Transform());
}