From f14f794e7dcf31225b079a39cd6a42edebb86125 Mon Sep 17 00:00:00 2001 From: Alexander Gololobov Date: Sat, 23 Nov 2024 20:32:37 +0100 Subject: [PATCH] Undo changes to IColumnImpl.h --- src/Columns/ColumnLowCardinality.cpp | 27 +++++++++++++-------------- src/Columns/ColumnLowCardinality.h | 5 +++++ src/Columns/IColumnImpl.h | 20 +++----------------- 3 files changed, 21 insertions(+), 31 deletions(-) diff --git a/src/Columns/ColumnLowCardinality.cpp b/src/Columns/ColumnLowCardinality.cpp index f038f682f36..cbc02570381 100644 --- a/src/Columns/ColumnLowCardinality.cpp +++ b/src/Columns/ColumnLowCardinality.cpp @@ -429,7 +429,7 @@ void ColumnLowCardinality::getPermutation(IColumn::PermutationSortDirection dire namespace { -/// Comapator for sorting LowCardinality column with the help of sorted dictionary. +/// Compator for sorting LowCardinality column with the help of sorted dictionary. /// NOTE: Dictionary itself must be sorted in ASC or DESC order depending on the requested direction. template struct LowCardinalityComparator @@ -456,17 +456,18 @@ struct LowCardinalityComparator } }; +} + template -void updatePermutationWithIndexType( - const ColumnLowCardinality & column, +void ColumnLowCardinality::updatePermutationWithIndexType( IColumn::PermutationSortDirection direction, IColumn::PermutationSortStability stability, - size_t limit, int nan_direction_hint, IColumn::Permutation & res, EqualRanges & equal_ranges) + size_t limit, int nan_direction_hint, IColumn::Permutation & res, EqualRanges & equal_ranges) const { /// Cast indexes column to the real type so that compareAt and getUInt methods can be inlined. - const IndexColumn * real_indexes = assert_cast(&column.getIndexes()); + const IndexColumn * real_indexes = assert_cast(&getIndexes()); IColumn::Permutation dict_perm; - column.getDictionary().getNestedColumn()->getPermutation(direction, stability, 0, nan_direction_hint, dict_perm); + getDictionary().getNestedColumn()->getPermutation(direction, stability, 0, nan_direction_hint, dict_perm); PaddedPODArray position_by_index(dict_perm.size()); for (size_t i = 0; i < dict_perm.size(); ++i) @@ -479,11 +480,9 @@ void updatePermutationWithIndexType( const bool stable = (stability == IColumn::PermutationSortStability::Stable); if (stable) - updateColumnPermutationImpl(limit, column.size(), res, equal_ranges, LowCardinalityComparator{*real_indexes, position_by_index}, equal_comparator, DefaultSort(), DefaultPartialSort()); + updatePermutationImpl(limit, res, equal_ranges, LowCardinalityComparator{*real_indexes, position_by_index}, equal_comparator, DefaultSort(), DefaultPartialSort()); else - updateColumnPermutationImpl(limit, column.size(), res, equal_ranges, LowCardinalityComparator{*real_indexes, position_by_index}, equal_comparator, DefaultSort(), DefaultPartialSort()); -} - + updatePermutationImpl(limit, res, equal_ranges, LowCardinalityComparator{*real_indexes, position_by_index}, equal_comparator, DefaultSort(), DefaultPartialSort()); } void ColumnLowCardinality::updatePermutation(IColumn::PermutationSortDirection direction, IColumn::PermutationSortStability stability, @@ -493,16 +492,16 @@ void ColumnLowCardinality::updatePermutation(IColumn::PermutationSortDirection d switch (idx.getSizeOfIndexType()) { case sizeof(UInt8): - updatePermutationWithIndexType(*this, direction, stability, limit, nan_direction_hint, res, equal_ranges); + updatePermutationWithIndexType(direction, stability, limit, nan_direction_hint, res, equal_ranges); return; case sizeof(UInt16): - updatePermutationWithIndexType(*this, direction, stability, limit, nan_direction_hint, res, equal_ranges); + updatePermutationWithIndexType(direction, stability, limit, nan_direction_hint, res, equal_ranges); return; case sizeof(UInt32): - updatePermutationWithIndexType(*this, direction, stability, limit, nan_direction_hint, res, equal_ranges); + updatePermutationWithIndexType(direction, stability, limit, nan_direction_hint, res, equal_ranges); return; case sizeof(UInt64): - updatePermutationWithIndexType(*this, direction, stability, limit, nan_direction_hint, res, equal_ranges); + updatePermutationWithIndexType(direction, stability, limit, nan_direction_hint, res, equal_ranges); return; default: throw Exception(ErrorCodes::LOGICAL_ERROR, "Unexpected size of index type for low cardinality column."); } diff --git a/src/Columns/ColumnLowCardinality.h b/src/Columns/ColumnLowCardinality.h index 3cc1c8919c0..7380b5eff07 100644 --- a/src/Columns/ColumnLowCardinality.h +++ b/src/Columns/ColumnLowCardinality.h @@ -389,6 +389,11 @@ private: int compareAtImpl(size_t n, size_t m, const IColumn & rhs, int nan_direction_hint, const Collator * collator=nullptr) const; void getPermutationImpl(IColumn::PermutationSortDirection direction, IColumn::PermutationSortStability stability, size_t limit, int nan_direction_hint, Permutation & res, const Collator * collator = nullptr) const; + + template + void updatePermutationWithIndexType( + IColumn::PermutationSortDirection direction, IColumn::PermutationSortStability stability, + size_t limit, int nan_direction_hint, IColumn::Permutation & res, EqualRanges & equal_ranges) const; }; bool isColumnLowCardinalityNullable(const IColumn & column); diff --git a/src/Columns/IColumnImpl.h b/src/Columns/IColumnImpl.h index c50338cc5da..4515e7a48e8 100644 --- a/src/Columns/IColumnImpl.h +++ b/src/Columns/IColumnImpl.h @@ -127,20 +127,19 @@ void IColumn::getPermutationImpl( } template -void updateColumnPermutationImpl( +void IColumn::updatePermutationImpl( size_t limit, - size_t size, IColumn::Permutation & res, EqualRanges & equal_ranges, Compare compare, Equals equals, Sort full_sort, - PartialSort partial_sort) + PartialSort partial_sort) const { if (equal_ranges.empty()) return; - if (limit >= size || limit > equal_ranges.back().to) + if (limit >= size() || limit > equal_ranges.back().to) limit = 0; EqualRanges new_ranges; @@ -211,17 +210,4 @@ void updateColumnPermutationImpl( equal_ranges = std::move(new_ranges); } -template -void IColumn::updatePermutationImpl( - size_t limit, - Permutation & res, - EqualRanges & equal_ranges, - Compare compare, - Equals equals, - Sort full_sort, - PartialSort partial_sort) const -{ - updateColumnPermutationImpl(limit, size(), res, equal_ranges, compare, equals, full_sort, partial_sort); -} - }