mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 09:02:00 +00:00
Add estimateCardinalityInPermutedRange for ColumnFixedString
This commit is contained in:
parent
9d7c470d4e
commit
9202e46ff5
@ -5,6 +5,7 @@
|
|||||||
#include <IO/WriteHelpers.h>
|
#include <IO/WriteHelpers.h>
|
||||||
#include <Common/Arena.h>
|
#include <Common/Arena.h>
|
||||||
#include <Common/HashTable/Hash.h>
|
#include <Common/HashTable/Hash.h>
|
||||||
|
#include <Common/HashTable/StringHashSet.h>
|
||||||
#include <Common/SipHash.h>
|
#include <Common/SipHash.h>
|
||||||
#include <Common/WeakHash.h>
|
#include <Common/WeakHash.h>
|
||||||
#include <Common/assert_cast.h>
|
#include <Common/assert_cast.h>
|
||||||
@ -200,6 +201,24 @@ void ColumnFixedString::updatePermutation(IColumn::PermutationSortDirection dire
|
|||||||
updatePermutationImpl(limit, res, equal_ranges, ComparatorDescendingStable(*this), comparator_equal, DefaultSort(), DefaultPartialSort());
|
updatePermutationImpl(limit, res, equal_ranges, ComparatorDescendingStable(*this), comparator_equal, DefaultSort(), DefaultPartialSort());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t ColumnFixedString::estimateCardinalityInPermutedRange(const Permutation & permutation, const EqualRange & equal_range) const
|
||||||
|
{
|
||||||
|
const size_t range_size = equal_range.size();
|
||||||
|
if (range_size <= 1)
|
||||||
|
return range_size;
|
||||||
|
|
||||||
|
/// TODO use sampling if the range is too large (e.g. 16k elements, but configurable)
|
||||||
|
StringHashSet elements;
|
||||||
|
bool inserted = false;
|
||||||
|
for (size_t i = equal_range.from; i < equal_range.to; ++i)
|
||||||
|
{
|
||||||
|
size_t id = permutation[i];
|
||||||
|
StringRef ref = getDataAt(id);
|
||||||
|
elements.emplace(ref, inserted);
|
||||||
|
}
|
||||||
|
return elements.size();
|
||||||
|
}
|
||||||
|
|
||||||
void ColumnFixedString::insertRangeFrom(const IColumn & src, size_t start, size_t length)
|
void ColumnFixedString::insertRangeFrom(const IColumn & src, size_t start, size_t length)
|
||||||
{
|
{
|
||||||
const ColumnFixedString & src_concrete = assert_cast<const ColumnFixedString &>(src);
|
const ColumnFixedString & src_concrete = assert_cast<const ColumnFixedString &>(src);
|
||||||
|
@ -142,6 +142,8 @@ public:
|
|||||||
void updatePermutation(IColumn::PermutationSortDirection direction, IColumn::PermutationSortStability stability,
|
void updatePermutation(IColumn::PermutationSortDirection direction, IColumn::PermutationSortStability stability,
|
||||||
size_t limit, int nan_direction_hint, Permutation & res, EqualRanges & equal_ranges) const override;
|
size_t limit, int nan_direction_hint, Permutation & res, EqualRanges & equal_ranges) const override;
|
||||||
|
|
||||||
|
size_t estimateCardinalityInPermutedRange(const Permutation & permutation, const EqualRange & equal_range) const override;
|
||||||
|
|
||||||
void insertRangeFrom(const IColumn & src, size_t start, size_t length) override;
|
void insertRangeFrom(const IColumn & src, size_t start, size_t length) override;
|
||||||
|
|
||||||
ColumnPtr filter(const IColumn::Filter & filt, ssize_t result_size_hint) const override;
|
ColumnPtr filter(const IColumn::Filter & filt, ssize_t result_size_hint) const override;
|
||||||
|
Loading…
Reference in New Issue
Block a user