|
|
unique_ptr< HyperLogLog > | log |
| | The HLL of the table.
|
|
atomic< idx_t > | sample_count |
| | How many values have been sampled into the HLL.
|
|
atomic< idx_t > | total_count |
| | How many values have been inserted (before sampling).
|
|
|
static constexpr double | BASE_SAMPLE_RATE = 0.1 |
| | For distinct statistics we sample the input to speed up insertions.
|
|
static constexpr double | INTEGRAL_SAMPLE_RATE = 0.3 |
| | For integers, we sample more: likely to be join keys (and hashing is cheaper than, e.g., strings).
|
◆ DistinctStatistics() [1/2]
| duckdb::DistinctStatistics::DistinctStatistics |
( |
| ) |
|
423340}
atomic< idx_t > sample_count
How many values have been sampled into the HLL.
Definition duckdb.hpp:48303
unique_ptr< HyperLogLog > log
The HLL of the table.
Definition duckdb.hpp:48301
atomic< idx_t > total_count
How many values have been inserted (before sampling).
Definition duckdb.hpp:48305
◆ DistinctStatistics() [2/2]
◆ Merge()
| void duckdb::DistinctStatistics::Merge |
( |
const DistinctStatistics & | other | ) |
|
423350 {
423351 log->Merge(*other.log);
423354}
◆ Copy()
| unique_ptr< DistinctStatistics > duckdb::DistinctStatistics::Copy |
( |
| ) |
const |
◆ UpdateSample()
| void duckdb::DistinctStatistics::UpdateSample |
( |
Vector & | new_data, |
|
|
idx_t | count, |
|
|
Vector & | hashes ) |
423356 {
423358 const auto original_count = count;
423360
423361 count = MaxValue<idx_t>(LossyNumericCast<idx_t>(sample_rate * static_cast<double>(STANDARD_VECTOR_SIZE)), 1);
423362
423363 count = MinValue<idx_t>(count, original_count);
423364
423365 UpdateInternal(new_data, count, hashes);
423366}
static constexpr double INTEGRAL_SAMPLE_RATE
For integers, we sample more: likely to be join keys (and hashing is cheaper than,...
Definition duckdb.hpp:48330
static constexpr double BASE_SAMPLE_RATE
For distinct statistics we sample the input to speed up insertions.
Definition duckdb.hpp:48328
◆ Update()
| void duckdb::DistinctStatistics::Update |
( |
Vector & | new_data, |
|
|
idx_t | count, |
|
|
Vector & | hashes ) |
423368 {
423370 UpdateInternal(new_data, count, hashes);
423371}
◆ ToString()
| string duckdb::DistinctStatistics::ToString |
( |
| ) |
const |
423380 {
423382}
static string Format(const string fmt_str, ARGS... params)
Format a string using printf semantics.
Definition duckdb.hpp:4002
◆ GetCount()
| idx_t duckdb::DistinctStatistics::GetCount |
( |
| ) |
const |
423384 {
423386 return 0;
423387 }
423388
423389 double u =
static_cast<double>(MinValue<idx_t>(
log->Count(),
sample_count));
423391 double n =
static_cast<double>(
total_count.load());
423392
423393
423394 double u1 =
pow(u / s, 2) * u;
423395
423396
423397 idx_t estimate = LossyNumericCast<idx_t>(u + u1 / s * (n - s));
423399}
void pow(InputArray src, double power, OutputArray dst)
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
◆ TypeIsSupported()
| bool duckdb::DistinctStatistics::TypeIsSupported |
( |
const LogicalType & | type | ) |
|
|
static |
423401 {
423402 switch (type.InternalType()) {
423405 case PhysicalType::ARRAY:
423406 return false;
423409 return false;
423410 default:
423411 return true;
423412 }
423413}
@ LIST
A list of some logical data type.
Definition duckdb.hpp:2813
@ BOOL
Boolean as 8 bit "bool" value.
Definition duckdb.hpp:2743
@ STRUCT
Struct of logical types.
Definition duckdb.hpp:2816
@ BIT
Boolean as 1 bit, LSB bit-packed ordering.
Definition duckdb.hpp:2852
◆ Serialize()
| void duckdb::DistinctStatistics::Serialize |
( |
Serializer & | serializer | ) |
const |
419339 {
419340 serializer.WritePropertyWithDefault<
idx_t>(100,
"sample_count",
sample_count);
419341 serializer.WritePropertyWithDefault<
idx_t>(101,
"total_count",
total_count);
419342 serializer.WritePropertyWithDefault<unique_ptr<HyperLogLog>>(102,
"log",
log);
419343}
◆ Deserialize()
419345 {
419346 auto sample_count = deserializer.ReadPropertyWithDefault<
idx_t>(100,
"sample_count");
419347 auto total_count = deserializer.ReadPropertyWithDefault<
idx_t>(101,
"total_count");
419348 auto log = deserializer.ReadPropertyWithDefault<unique_ptr<HyperLogLog>>(102,
"log");
419350 return result;
419351}
◆ UpdateInternal()
| void duckdb::DistinctStatistics::UpdateInternal |
( |
Vector & | update, |
|
|
idx_t | count, |
|
|
Vector & | hashes ) |
|
private |
423373 {
423375 VectorOperations::Hash(new_data, hashes, count);
423376
423377 log->Update(new_data, hashes, count);
423378}
The documentation for this class was generated from the following files: