mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Rename XStatistics to StatisticsX
Makes the naming more consistent with the rest of the codebase, e.g. - MergeTreeIndexSet - MergeTreeIndexMinMax or - StorageJoin - StorageMergeTree etc.
This commit is contained in:
parent
337871e0ec
commit
9f4e44bfc4
@ -1,7 +1,7 @@
|
|||||||
#include <Storages/Statistics/Statistics.h>
|
#include <Storages/Statistics/Statistics.h>
|
||||||
#include <Storages/Statistics/ConditionSelectivityEstimator.h>
|
#include <Storages/Statistics/ConditionSelectivityEstimator.h>
|
||||||
#include <Storages/Statistics/TDigestStatistics.h>
|
#include <Storages/Statistics/StatisticsTDigest.h>
|
||||||
#include <Storages/Statistics/UniqStatistics.h>
|
#include <Storages/Statistics/StatisticsUniq.h>
|
||||||
#include <Storages/StatisticsDescription.h>
|
#include <Storages/StatisticsDescription.h>
|
||||||
#include <Storages/ColumnsDescription.h>
|
#include <Storages/ColumnsDescription.h>
|
||||||
#include <IO/ReadHelpers.h>
|
#include <IO/ReadHelpers.h>
|
||||||
@ -44,7 +44,7 @@ void ColumnStatistics::update(const ColumnPtr & column)
|
|||||||
Float64 ColumnStatistics::estimateLess(Float64 val) const
|
Float64 ColumnStatistics::estimateLess(Float64 val) const
|
||||||
{
|
{
|
||||||
if (stats.contains(StatisticsType::TDigest))
|
if (stats.contains(StatisticsType::TDigest))
|
||||||
return std::static_pointer_cast<TDigestStatistics>(stats.at(StatisticsType::TDigest))->estimateLess(val);
|
return std::static_pointer_cast<StatisticsTDigest>(stats.at(StatisticsType::TDigest))->estimateLess(val);
|
||||||
return rows * ConditionSelectivityEstimator::default_normal_cond_factor;
|
return rows * ConditionSelectivityEstimator::default_normal_cond_factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,12 +57,12 @@ Float64 ColumnStatistics::estimateEqual(Float64 val) const
|
|||||||
{
|
{
|
||||||
if (stats.contains(StatisticsType::Uniq) && stats.contains(StatisticsType::TDigest))
|
if (stats.contains(StatisticsType::Uniq) && stats.contains(StatisticsType::TDigest))
|
||||||
{
|
{
|
||||||
auto uniq_static = std::static_pointer_cast<UniqStatistics>(stats.at(StatisticsType::Uniq));
|
auto statistics_uniq = std::static_pointer_cast<StatisticsUniq>(stats.at(StatisticsType::Uniq));
|
||||||
/// 2048 is the default number of buckets in TDigest. In this case, TDigest stores exactly one value (with many rows)
|
/// 2048 is the default number of buckets in TDigest. In this case, TDigest stores exactly one value (with many rows)
|
||||||
/// for every bucket.
|
/// for every bucket.
|
||||||
if (uniq_static->getCardinality() < 2048)
|
if (statistics_uniq->getCardinality() < 2048)
|
||||||
{
|
{
|
||||||
auto tdigest_static = std::static_pointer_cast<TDigestStatistics>(stats.at(StatisticsType::TDigest));
|
auto tdigest_static = std::static_pointer_cast<StatisticsTDigest>(stats.at(StatisticsType::TDigest));
|
||||||
return tdigest_static->estimateEqual(val);
|
return tdigest_static->estimateEqual(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <Storages/Statistics/TDigestStatistics.h>
|
#include <Storages/Statistics/StatisticsTDigest.h>
|
||||||
#include <DataTypes/DataTypeNullable.h>
|
#include <DataTypes/DataTypeNullable.h>
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
@ -8,12 +8,12 @@ namespace ErrorCodes
|
|||||||
extern const int ILLEGAL_STATISTICS;
|
extern const int ILLEGAL_STATISTICS;
|
||||||
}
|
}
|
||||||
|
|
||||||
TDigestStatistics::TDigestStatistics(const SingleStatisticsDescription & stat_)
|
StatisticsTDigest::StatisticsTDigest(const SingleStatisticsDescription & stat_)
|
||||||
: IStatistics(stat_)
|
: IStatistics(stat_)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDigestStatistics::update(const ColumnPtr & column)
|
void StatisticsTDigest::update(const ColumnPtr & column)
|
||||||
{
|
{
|
||||||
size_t rows = column->size();
|
size_t rows = column->size();
|
||||||
|
|
||||||
@ -25,22 +25,22 @@ void TDigestStatistics::update(const ColumnPtr & column)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDigestStatistics::serialize(WriteBuffer & buf)
|
void StatisticsTDigest::serialize(WriteBuffer & buf)
|
||||||
{
|
{
|
||||||
t_digest.serialize(buf);
|
t_digest.serialize(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDigestStatistics::deserialize(ReadBuffer & buf)
|
void StatisticsTDigest::deserialize(ReadBuffer & buf)
|
||||||
{
|
{
|
||||||
t_digest.deserialize(buf);
|
t_digest.deserialize(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
Float64 TDigestStatistics::estimateLess(Float64 val) const
|
Float64 StatisticsTDigest::estimateLess(Float64 val) const
|
||||||
{
|
{
|
||||||
return t_digest.getCountLessThan(val);
|
return t_digest.getCountLessThan(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
Float64 TDigestStatistics::estimateEqual(Float64 val) const
|
Float64 StatisticsTDigest::estimateEqual(Float64 val) const
|
||||||
{
|
{
|
||||||
return t_digest.getCountEqual(val);
|
return t_digest.getCountEqual(val);
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ void TDigestValidator(const SingleStatisticsDescription &, DataTypePtr data_type
|
|||||||
|
|
||||||
StatisticsPtr TDigestCreator(const SingleStatisticsDescription & stat, DataTypePtr)
|
StatisticsPtr TDigestCreator(const SingleStatisticsDescription & stat, DataTypePtr)
|
||||||
{
|
{
|
||||||
return std::make_shared<TDigestStatistics>(stat);
|
return std::make_shared<StatisticsTDigest>(stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -6,10 +6,10 @@
|
|||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
|
|
||||||
class TDigestStatistics : public IStatistics
|
class StatisticsTDigest : public IStatistics
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit TDigestStatistics(const SingleStatisticsDescription & stat_);
|
explicit StatisticsTDigest(const SingleStatisticsDescription & stat_);
|
||||||
|
|
||||||
void update(const ColumnPtr & column) override;
|
void update(const ColumnPtr & column) override;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
#include <Storages/Statistics/UniqStatistics.h>
|
#include <Storages/Statistics/StatisticsUniq.h>
|
||||||
#include <DataTypes/DataTypesNumber.h>
|
#include <DataTypes/DataTypesNumber.h>
|
||||||
#include <DataTypes/DataTypeNullable.h>
|
#include <DataTypes/DataTypeNullable.h>
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ namespace ErrorCodes
|
|||||||
extern const int ILLEGAL_STATISTICS;
|
extern const int ILLEGAL_STATISTICS;
|
||||||
}
|
}
|
||||||
|
|
||||||
UniqStatistics::UniqStatistics(const SingleStatisticsDescription & stat_, const DataTypePtr & data_type)
|
StatisticsUniq::StatisticsUniq(const SingleStatisticsDescription & stat_, const DataTypePtr & data_type)
|
||||||
: IStatistics(stat_)
|
: IStatistics(stat_)
|
||||||
{
|
{
|
||||||
arena = std::make_unique<Arena>();
|
arena = std::make_unique<Arena>();
|
||||||
@ -20,12 +20,12 @@ UniqStatistics::UniqStatistics(const SingleStatisticsDescription & stat_, const
|
|||||||
collector->create(data);
|
collector->create(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
UniqStatistics::~UniqStatistics()
|
StatisticsUniq::~StatisticsUniq()
|
||||||
{
|
{
|
||||||
collector->destroy(data);
|
collector->destroy(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UniqStatistics::update(const ColumnPtr & column)
|
void StatisticsUniq::update(const ColumnPtr & column)
|
||||||
{
|
{
|
||||||
/// TODO(hanfei): For low cardinality, it's very slow to convert to full column. We can read the dictionary directly.
|
/// TODO(hanfei): For low cardinality, it's very slow to convert to full column. We can read the dictionary directly.
|
||||||
/// Here we intend to avoid crash in CI.
|
/// Here we intend to avoid crash in CI.
|
||||||
@ -34,17 +34,17 @@ void UniqStatistics::update(const ColumnPtr & column)
|
|||||||
collector->addBatchSinglePlace(0, column->size(), data, &(raw_ptr), nullptr);
|
collector->addBatchSinglePlace(0, column->size(), data, &(raw_ptr), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UniqStatistics::serialize(WriteBuffer & buf)
|
void StatisticsUniq::serialize(WriteBuffer & buf)
|
||||||
{
|
{
|
||||||
collector->serialize(data, buf);
|
collector->serialize(data, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UniqStatistics::deserialize(ReadBuffer & buf)
|
void StatisticsUniq::deserialize(ReadBuffer & buf)
|
||||||
{
|
{
|
||||||
collector->deserialize(data, buf);
|
collector->deserialize(data, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt64 UniqStatistics::getCardinality()
|
UInt64 StatisticsUniq::getCardinality()
|
||||||
{
|
{
|
||||||
auto column = DataTypeUInt64().createColumn();
|
auto column = DataTypeUInt64().createColumn();
|
||||||
collector->insertResultInto(data, *column, nullptr);
|
collector->insertResultInto(data, *column, nullptr);
|
||||||
@ -60,7 +60,7 @@ void UniqValidator(const SingleStatisticsDescription &, DataTypePtr data_type)
|
|||||||
|
|
||||||
StatisticsPtr UniqCreator(const SingleStatisticsDescription & stat, DataTypePtr data_type)
|
StatisticsPtr UniqCreator(const SingleStatisticsDescription & stat, DataTypePtr data_type)
|
||||||
{
|
{
|
||||||
return std::make_shared<UniqStatistics>(stat, data_type);
|
return std::make_shared<StatisticsUniq>(stat, data_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -7,11 +7,11 @@
|
|||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
|
|
||||||
class UniqStatistics : public IStatistics
|
class StatisticsUniq : public IStatistics
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
UniqStatistics(const SingleStatisticsDescription & stat_, const DataTypePtr & data_type);
|
StatisticsUniq(const SingleStatisticsDescription & stat_, const DataTypePtr & data_type);
|
||||||
~UniqStatistics() override;
|
~StatisticsUniq() override;
|
||||||
|
|
||||||
void update(const ColumnPtr & column) override;
|
void update(const ColumnPtr & column) override;
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <Storages/Statistics/TDigestStatistics.h>
|
#include <Storages/Statistics/StatisticsTDigest.h>
|
||||||
|
|
||||||
TEST(Statistics, TDigestLessThan)
|
TEST(Statistics, TDigestLessThan)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user