Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::BaseStatistics Class Reference
Collaboration diagram for duckdb::BaseStatistics:

Public Member Functions

 BaseStatistics (const BaseStatistics &other)=delete
BaseStatistics & operator= (const BaseStatistics &)=delete
DUCKDB_API BaseStatistics (BaseStatistics &&other) noexcept
 enable move constructors
DUCKDB_API BaseStatistics & operator= (BaseStatistics &&) noexcept
DUCKDB_API StatisticsType GetStatsType () const
DUCKDB_API bool CanHaveNull () const
DUCKDB_API bool CanHaveNoNull () const
void SetDistinctCount (idx_t distinct_count)
bool IsConstant () const
const LogicalType & GetType () const
void Set (StatsInfo info)
void CombineValidity (const BaseStatistics &left, const BaseStatistics &right)
void CopyValidity (const BaseStatistics &stats)
void SetHasNullFast ()
void SetHasNoNullFast ()
void SetHasNull ()
void SetHasNoNull ()
void Merge (const BaseStatistics &other)
void Copy (const BaseStatistics &other)
unique_ptr< BaseStatistics > PushdownExtract (const StorageIndex &index) const
BaseStatistics Copy () const
unique_ptr< BaseStatistics > ToUnique () const
void CopyBase (const BaseStatistics &orig)
void Serialize (Serializer &serializer) const
void Verify (Vector &vector, const SelectionVector &sel, idx_t count, bool ignore_has_null=false) const
 Verify that a vector does not violate the statistics.
void Verify (Vector &vector, idx_t count) const
string ToString () const
idx_t GetDistinctCount ()
template<class T>
void UpdateNumericStats (T new_value)
template<>
void UpdateNumericStats (interval_t new_value)
template<>
void UpdateNumericStats (list_entry_t new_value)

Static Public Member Functions

static BaseStatistics CreateUnknown (LogicalType type)
static BaseStatistics CreateEmpty (LogicalType type)
static DUCKDB_API StatisticsType GetStatsType (const LogicalType &type)
static BaseStatistics Deserialize (Deserializer &deserializer)
static BaseStatistics FromConstant (const Value &input)

Private Member Functions

 BaseStatistics (LogicalType type)
void InitializeUnknown ()
void InitializeEmpty ()

Static Private Member Functions

static void Construct (BaseStatistics &stats, LogicalType type)
static BaseStatistics CreateUnknownType (LogicalType type)
static BaseStatistics CreateEmptyType (LogicalType type)
static BaseStatistics FromConstantType (const Value &input)

Private Attributes

LogicalType type = LogicalType::INVALID
 The type of the logical segment.
bool has_null
 Whether or not the segment can contain NULL values.
bool has_no_null
 Whether or not the segment can contain values that are not null.
idx_t distinct_count
 estimate that one may have even if distinct_stats==nullptr
union { 
   NumericStatsData   numeric_data 
 Numeric stats data, for numeric stats.
   StringStatsData   string_data 
 String stats data, for string stats.
   GeometryStatsData   geometry_data 
 Geometry stats data, for geometry stats.
   VariantStatsData   variant_data 
 Variant stats data, for variant stats.
} stats_union
 Numeric and String stats.
unsafe_unique_array< BaseStatistics > child_stats
 Child stats (for LIST and STRUCT).

Friends

struct NumericStats
struct StringStats
struct StructStats
struct ListStats
struct ArrayStats
struct GeometryStats
struct VariantStats

Constructor & Destructor Documentation

◆ ~BaseStatistics()

duckdb::BaseStatistics::~BaseStatistics ( )
422685 {
422686}

◆ BaseStatistics() [1/3]

duckdb::BaseStatistics::BaseStatistics ( BaseStatistics && other)
noexcept

enable move constructors

422688 {
422689 std::swap(type, other.type);
422690 has_null = other.has_null;
422691 has_no_null = other.has_no_null;
422692 distinct_count = other.distinct_count;
422693 stats_union = other.stats_union;
422694 std::swap(child_stats, other.child_stats);
422695}
union duckdb::BaseStatistics::@232147020202213244144346043267022131017022054334 stats_union
Numeric and String stats.
bool has_no_null
Whether or not the segment can contain values that are not null.
Definition duckdb.hpp:16382
bool has_null
Whether or not the segment can contain NULL values.
Definition duckdb.hpp:16380
idx_t distinct_count
estimate that one may have even if distinct_stats==nullptr
Definition duckdb.hpp:16384
unsafe_unique_array< BaseStatistics > child_stats
Child stats (for LIST and STRUCT).
Definition duckdb.hpp:16397
LogicalType type
The type of the logical segment.
Definition duckdb.hpp:16378

◆ BaseStatistics() [2/3]

duckdb::BaseStatistics::BaseStatistics ( )
private
422657 : type(LogicalType::INVALID) {
422658}

◆ BaseStatistics() [3/3]

duckdb::BaseStatistics::BaseStatistics ( LogicalType type)
explicitprivate
422660 {
422661 Construct(*this, std::move(type));
422662}

Member Function Documentation

◆ operator=()

BaseStatistics & duckdb::BaseStatistics::operator= ( BaseStatistics && other)
noexcept
422697 {
422698 std::swap(type, other.type);
422699 has_null = other.has_null;
422700 has_no_null = other.has_no_null;
422701 distinct_count = other.distinct_count;
422702 stats_union = other.stats_union;
422703 std::swap(child_stats, other.child_stats);
422704 return *this;
422705}

◆ CreateUnknown()

BaseStatistics duckdb::BaseStatistics::CreateUnknown ( LogicalType type)
static

Creates a set of statistics for data that is unknown, i.e. "has_null" is true, "has_no_null" is true, etc This can be used in case nothing is known about the data - or can be used as a baseline when only a few things are known

422865 {
422866 auto result = CreateUnknownType(std::move(type));
422867 result.InitializeUnknown();
422868 return result;
422869}
Here is the caller graph for this function:

◆ CreateEmpty()

BaseStatistics duckdb::BaseStatistics::CreateEmpty ( LogicalType type)
static

Creates statistics for an empty database, i.e. "has_null" is false, "has_no_null" is false, etc This is used when incrementally constructing statistics by constantly adding new values

422871 {
422872 if (type.InternalType() == PhysicalType::BIT) {
422873 // FIXME: this special case should not be necessary
422874 // but currently InitializeEmpty sets StatsInfo::CAN_HAVE_VALID_VALUES
422875 BaseStatistics result(std::move(type));
422876 result.Set(StatsInfo::CANNOT_HAVE_NULL_VALUES);
422877 result.Set(StatsInfo::CANNOT_HAVE_VALID_VALUES);
422878 return result;
422879 }
422880 auto result = CreateEmptyType(std::move(type));
422881 result.InitializeEmpty();
422882 return result;
422883}
@ BIT
Boolean as 1 bit, LSB bit-packed ordering.
Definition duckdb.hpp:2852
Here is the caller graph for this function:

◆ GetStatsType() [1/2]

StatisticsType duckdb::BaseStatistics::GetStatsType ( ) const
422747 {
422748 return GetStatsType(GetType());
422749}

◆ GetStatsType() [2/2]

StatisticsType duckdb::BaseStatistics::GetStatsType ( const LogicalType & type)
static
422707 {
422708 if (type.id() == LogicalTypeId::SQLNULL) {
422709 return StatisticsType::BASE_STATS;
422710 }
422711 if (type.id() == LogicalTypeId::GEOMETRY) {
422712 return StatisticsType::GEOMETRY_STATS;
422713 }
422714 if (type.id() == LogicalTypeId::VARIANT) {
422715 return StatisticsType::VARIANT_STATS;
422716 }
422717 switch (type.InternalType()) {
422718 case PhysicalType::BOOL:
422719 case PhysicalType::INT8:
422720 case PhysicalType::INT16:
422721 case PhysicalType::INT32:
422722 case PhysicalType::INT64:
422723 case PhysicalType::UINT8:
422727 case PhysicalType::INT128:
422728 case PhysicalType::UINT128:
422729 case PhysicalType::FLOAT:
422731 return StatisticsType::NUMERIC_STATS;
422733 return StatisticsType::STRING_STATS;
422735 return StatisticsType::STRUCT_STATS;
422736 case PhysicalType::LIST:
422737 return StatisticsType::LIST_STATS;
422738 case PhysicalType::ARRAY:
422739 return StatisticsType::ARRAY_STATS;
422740 case PhysicalType::BIT:
422742 default:
422743 return StatisticsType::BASE_STATS;
422744 }
422745}
@ UINT32
Unsigned 32-bit little-endian integer.
Definition duckdb.hpp:2758
@ INTERVAL
YEAR_MONTH or DAY_TIME interval in SQL style.
Definition duckdb.hpp:2806
@ LIST
A list of some logical data type.
Definition duckdb.hpp:2813
@ UINT16
Unsigned 16-bit little-endian integer.
Definition duckdb.hpp:2752
@ INT64
Signed 64-bit little-endian integer.
Definition duckdb.hpp:2767
@ INT16
Signed 16-bit little-endian integer.
Definition duckdb.hpp:2755
@ INT32
Signed 32-bit little-endian integer.
Definition duckdb.hpp:2761
@ UINT64
Unsigned 64-bit little-endian integer.
Definition duckdb.hpp:2764
@ BOOL
Boolean as 8 bit "bool" value.
Definition duckdb.hpp:2743
@ STRUCT
Struct of logical types.
Definition duckdb.hpp:2816
@ VARCHAR
DuckDB Extensions.
Definition duckdb.hpp:2847
@ FLOAT
4-byte floating point value
Definition duckdb.hpp:2773
@ UINT8
Unsigned 8-bit little-endian integer.
Definition duckdb.hpp:2746
@ INT8
Signed 8-bit little-endian integer.
Definition duckdb.hpp:2749
@ DOUBLE
8-byte floating point value
Definition duckdb.hpp:2776

◆ CanHaveNull()

bool duckdb::BaseStatistics::CanHaveNull ( ) const
422761 {
422762 return has_null;
422763}

◆ CanHaveNoNull()

bool duckdb::BaseStatistics::CanHaveNoNull ( ) const
422765 {
422766 return has_no_null;
422767}

◆ SetDistinctCount()

void duckdb::BaseStatistics::SetDistinctCount ( idx_t distinct_count)
422998 {
422999 this->distinct_count = count;
423000}

◆ IsConstant()

bool duckdb::BaseStatistics::IsConstant ( ) const
422769 {
422770 if (type.id() == LogicalTypeId::VALIDITY) {
422771 // validity mask
422772 if (CanHaveNull() && !CanHaveNoNull()) {
422773 return true;
422774 }
422775 if (!CanHaveNull() && CanHaveNoNull()) {
422776 return true;
422777 }
422778 return false;
422779 }
422780 switch (GetStatsType()) {
422781 case StatisticsType::NUMERIC_STATS:
422782 return NumericStats::IsConstant(*this);
422783 default:
422784 break;
422785 }
422786 return false;
422787}
static DUCKDB_API bool IsConstant(const BaseStatistics &stats)
Returns true if the stats has a constant value.
Definition duckdb.cpp:424130

◆ GetType()

const LogicalType & duckdb::BaseStatistics::GetType ( ) const
inline
16314 {
16315 return type;
16316 }

◆ Set()

void duckdb::BaseStatistics::Set ( StatsInfo info)
422939 {
422940 switch (info) {
422941 case StatsInfo::CAN_HAVE_NULL_VALUES:
422942 SetHasNull();
422943 break;
422944 case StatsInfo::CANNOT_HAVE_NULL_VALUES:
422945 has_null = false;
422946 break;
422947 case StatsInfo::CAN_HAVE_VALID_VALUES:
422948 SetHasNoNull();
422949 break;
422950 case StatsInfo::CANNOT_HAVE_VALID_VALUES:
422951 has_no_null = false;
422952 break;
422953 case StatsInfo::CAN_HAVE_NULL_AND_VALID_VALUES:
422954 SetHasNull();
422955 SetHasNoNull();
422956 break;
422957 default:
422958 throw InternalException("Unrecognized StatsInfo for BaseStatistics::Set");
422959 }
422960}

◆ CombineValidity()

void duckdb::BaseStatistics::CombineValidity ( const BaseStatistics & left,
const BaseStatistics & right )
422988 {
422989 has_null = left.has_null || right.has_null;
422990 has_no_null = left.has_no_null || right.has_no_null;
422991}

◆ CopyValidity()

void duckdb::BaseStatistics::CopyValidity ( const BaseStatistics & stats)
422993 {
422994 has_null = stats.has_null;
422995 has_no_null = stats.has_no_null;
422996}

◆ SetHasNullFast()

void duckdb::BaseStatistics::SetHasNullFast ( )
inline

Set that the CURRENT level can have null values Note that this is not correct for nested types unless this information is propagated in a different manner Use Set(StatsInfo::CAN_HAVE_NULL_VALUES) in the general case

16324 {
16325 has_null = true;
16326 }

◆ SetHasNoNullFast()

void duckdb::BaseStatistics::SetHasNoNullFast ( )
inline

Set that the CURRENT level can have valid values Note that this is not correct for nested types unless this information is propagated in a different manner Use Set(StatsInfo::CAN_HAVE_VALID_VALUES) in the general case

16330 {
16331 has_no_null = true;
16332 }

◆ SetHasNull()

void duckdb::BaseStatistics::SetHasNull ( )
422962 {
422963 has_null = true;
422964 if (type.id() == LogicalTypeId::VARIANT) {
422965 VariantStats::GetUnshreddedStats(*this).SetHasNull();
422966 return;
422967 }
422968 if (type.InternalType() == PhysicalType::STRUCT) {
422969 for (idx_t c = 0; c < StructType::GetChildCount(type); c++) {
422970 StructStats::GetChildStats(*this, c).SetHasNull();
422971 }
422972 }
422973}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ SetHasNoNull()

void duckdb::BaseStatistics::SetHasNoNull ( )
422975 {
422976 has_no_null = true;
422977 if (type.id() == LogicalTypeId::VARIANT) {
422978 VariantStats::GetUnshreddedStats(*this).SetHasNoNull();
422979 return;
422980 }
422981 if (type.InternalType() == PhysicalType::STRUCT) {
422982 for (idx_t c = 0; c < StructType::GetChildCount(type); c++) {
422983 StructStats::GetChildStats(*this, c).SetHasNoNull();
422984 }
422985 }
422986}

◆ Merge()

void duckdb::BaseStatistics::Merge ( const BaseStatistics & other)
422789 {
422790 has_null = has_null || other.has_null;
422791 has_no_null = has_no_null || other.has_no_null;
422792 switch (GetStatsType()) {
422793 case StatisticsType::NUMERIC_STATS:
422794 NumericStats::Merge(*this, other);
422795 break;
422796 case StatisticsType::STRING_STATS:
422797 StringStats::Merge(*this, other);
422798 break;
422799 case StatisticsType::LIST_STATS:
422800 ListStats::Merge(*this, other);
422801 break;
422802 case StatisticsType::STRUCT_STATS:
422803 StructStats::Merge(*this, other);
422804 break;
422805 case StatisticsType::ARRAY_STATS:
422806 ArrayStats::Merge(*this, other);
422807 break;
422808 case StatisticsType::GEOMETRY_STATS:
422809 GeometryStats::Merge(*this, other);
422810 break;
422811 case StatisticsType::VARIANT_STATS:
422812 VariantStats::Merge(*this, other);
422813 break;
422814 default:
422815 break;
422816 }
422817}
static DUCKDB_API void Merge(BaseStatistics &stats, const BaseStatistics &other)
Definition duckdb.cpp:425557

◆ Copy() [1/2]

void duckdb::BaseStatistics::Copy ( const BaseStatistics & other)
422885 {
422886 D_ASSERT(GetType() == other.GetType());
422887 CopyBase(other);
422888 auto stats_type = GetStatsType();
422889
422890 stats_union = other.stats_union;
422891 switch (stats_type) {
422892 case StatisticsType::LIST_STATS:
422893 ListStats::Copy(*this, other);
422894 break;
422895 case StatisticsType::STRUCT_STATS:
422896 StructStats::Copy(*this, other);
422897 break;
422898 case StatisticsType::ARRAY_STATS:
422899 ArrayStats::Copy(*this, other);
422900 break;
422901 case StatisticsType::VARIANT_STATS:
422902 VariantStats::Copy(*this, other);
422903 break;
422904 default:
422905 break;
422906 }
422907}
static DUCKDB_API void Copy(BaseStatistics &stats, const BaseStatistics &other)
Definition duckdb.cpp:425627

◆ PushdownExtract()

unique_ptr< BaseStatistics > duckdb::BaseStatistics::PushdownExtract ( const StorageIndex & index) const
422909 {
422910 auto stats_type = GetStatsType();
422911 switch (stats_type) {
422912 case StatisticsType::STRUCT_STATS:
422913 return StructStats::PushdownExtract(*this, index);
422914 case StatisticsType::VARIANT_STATS:
422915 return VariantStats::PushdownExtract(*this, index);
422916 default:
422917 throw InternalException("PushdownExtract not supported for StatisticsType::%s", EnumUtil::ToString(stats_type));
422918 }
422919}
static DUCKDB_API unique_ptr< BaseStatistics > PushdownExtract(const BaseStatistics &stats, const StorageIndex &index)
Definition duckdb.cpp:424966
static DUCKDB_API unique_ptr< BaseStatistics > PushdownExtract(const BaseStatistics &stats, const StorageIndex &index)
Definition duckdb.cpp:425662

◆ Copy() [2/2]

BaseStatistics duckdb::BaseStatistics::Copy ( ) const
422921 {
422922 BaseStatistics result(type);
422923 result.Copy(*this);
422924 return result;
422925}

◆ ToUnique()

unique_ptr< BaseStatistics > duckdb::BaseStatistics::ToUnique ( ) const
422927 {
422928 auto result = unique_ptr<BaseStatistics>(new BaseStatistics(type));
422929 result->Copy(*this);
422930 return result;
422931}

◆ CopyBase()

void duckdb::BaseStatistics::CopyBase ( const BaseStatistics & orig)
422933 {
422934 has_null = other.has_null;
422935 has_no_null = other.has_no_null;
422936 distinct_count = other.distinct_count;
422937}

◆ Serialize()

void duckdb::BaseStatistics::Serialize ( Serializer & serializer) const
423002 {
423003 serializer.WriteProperty(100, "has_null", has_null);
423004 serializer.WriteProperty(101, "has_no_null", has_no_null);
423005 serializer.WriteProperty(102, "distinct_count", distinct_count);
423006 serializer.WriteObject(103, "type_stats", [&](Serializer &serializer) {
423007 switch (GetStatsType()) {
423008 case StatisticsType::NUMERIC_STATS:
423009 NumericStats::Serialize(*this, serializer);
423010 break;
423011 case StatisticsType::STRING_STATS:
423012 StringStats::Serialize(*this, serializer);
423013 break;
423014 case StatisticsType::LIST_STATS:
423015 ListStats::Serialize(*this, serializer);
423016 break;
423017 case StatisticsType::STRUCT_STATS:
423018 StructStats::Serialize(*this, serializer);
423019 break;
423020 case StatisticsType::ARRAY_STATS:
423021 ArrayStats::Serialize(*this, serializer);
423022 break;
423023 case StatisticsType::GEOMETRY_STATS:
423024 GeometryStats::Serialize(*this, serializer);
423025 break;
423026 case StatisticsType::VARIANT_STATS:
423027 VariantStats::Serialize(*this, serializer);
423028 break;
423029 default:
423030 break;
423031 }
423032 });
423033}

◆ Deserialize()

BaseStatistics duckdb::BaseStatistics::Deserialize ( Deserializer & deserializer)
static
423035 {
423036 auto has_null = deserializer.ReadProperty<bool>(100, "has_null");
423037 auto has_no_null = deserializer.ReadProperty<bool>(101, "has_no_null");
423038 auto distinct_count = deserializer.ReadProperty<idx_t>(102, "distinct_count");
423039
423040 // Get the logical type from the deserializer context.
423041 auto &type = deserializer.Get<const LogicalType &>();
423042 auto stats_type = GetStatsType(type);
423043
423044 BaseStatistics stats(type);
423045
423046 stats.has_null = has_null;
423047 stats.has_no_null = has_no_null;
423048 stats.distinct_count = distinct_count;
423049
423050 deserializer.ReadObject(103, "type_stats", [&](Deserializer &obj) {
423051 switch (stats_type) {
423052 case StatisticsType::NUMERIC_STATS:
423053 NumericStats::Deserialize(obj, stats);
423054 break;
423055 case StatisticsType::STRING_STATS:
423056 StringStats::Deserialize(obj, stats);
423057 break;
423058 case StatisticsType::LIST_STATS:
423059 ListStats::Deserialize(obj, stats);
423060 break;
423061 case StatisticsType::STRUCT_STATS:
423062 StructStats::Deserialize(obj, stats);
423063 break;
423064 case StatisticsType::ARRAY_STATS:
423065 ArrayStats::Deserialize(obj, stats);
423066 break;
423067 case StatisticsType::GEOMETRY_STATS:
423068 GeometryStats::Deserialize(obj, stats);
423069 break;
423070 case StatisticsType::VARIANT_STATS:
423071 VariantStats::Deserialize(obj, stats);
423072 break;
423073 default:
423074 break;
423075 }
423076 });
423077
423078 return stats;
423079}
static DUCKDB_API void Deserialize(Deserializer &deserializer, BaseStatistics &base)
Definition duckdb.cpp:425317

◆ Verify() [1/2]

void duckdb::BaseStatistics::Verify ( Vector & vector,
const SelectionVector & sel,
idx_t count,
bool ignore_has_null = false ) const

Verify that a vector does not violate the statistics.

423115 {
423116 D_ASSERT(vector.GetType() == this->type);
423117 switch (GetStatsType()) {
423118 case StatisticsType::NUMERIC_STATS:
423119 NumericStats::Verify(*this, vector, sel, count);
423120 break;
423121 case StatisticsType::STRING_STATS:
423122 StringStats::Verify(*this, vector, sel, count);
423123 break;
423124 case StatisticsType::LIST_STATS:
423125 ListStats::Verify(*this, vector, sel, count);
423126 break;
423127 case StatisticsType::STRUCT_STATS:
423128 StructStats::Verify(*this, vector, sel, count);
423129 break;
423130 case StatisticsType::ARRAY_STATS:
423131 ArrayStats::Verify(*this, vector, sel, count);
423132 break;
423133 case StatisticsType::GEOMETRY_STATS:
423134 GeometryStats::Verify(*this, vector, sel, count);
423135 break;
423136 case StatisticsType::VARIANT_STATS:
423137 VariantStats::Verify(*this, vector, sel, count);
423138 break;
423139 default:
423140 break;
423141 }
423142 if (has_null && has_no_null) {
423143 // nothing to verify
423144 return;
423145 }
423146 UnifiedVectorFormat vdata;
423147 vector.ToUnifiedFormat(count, vdata);
423148 for (idx_t i = 0; i < count; i++) {
423149 auto idx = sel.get_index(i);
423150 auto index = vdata.sel->get_index(idx);
423151 bool row_is_valid = vdata.validity.RowIsValid(index);
423152 if (row_is_valid && !has_no_null) {
423153 throw InternalException(
423154 "Statistics mismatch: vector labeled as having only NULL values, but vector contains valid values: %s",
423155 vector.ToString(count));
423156 }
423157 if (!row_is_valid && !has_null && !ignore_has_null) {
423158 throw InternalException(
423159 "Statistics mismatch: vector labeled as not having NULL values, but vector contains null values: %s",
423160 vector.ToString(count));
423161 }
423162 }
423163}
index

◆ Verify() [2/2]

void duckdb::BaseStatistics::Verify ( Vector & vector,
idx_t count ) const
423165 {
423166 auto sel = FlatVector::IncrementalSelectionVector();
423167 Verify(vector, *sel, count, false);
423168}
void Verify(Vector &vector, const SelectionVector &sel, idx_t count, bool ignore_has_null=false) const
Verify that a vector does not violate the statistics.
Definition duckdb.cpp:423115

◆ ToString()

string duckdb::BaseStatistics::ToString ( ) const
423081 {
423082 auto has_n = has_null ? "true" : "false";
423083 auto has_n_n = has_no_null ? "true" : "false";
423084 string result =
423085 StringUtil::Format("%s%s", StringUtil::Format("[Has Null: %s, Has No Null: %s]", has_n, has_n_n),
423086 distinct_count > 0 ? StringUtil::Format("[Approx Unique: %lld]", distinct_count) : "");
423087 switch (GetStatsType()) {
423088 case StatisticsType::NUMERIC_STATS:
423089 result = NumericStats::ToString(*this) + result;
423090 break;
423091 case StatisticsType::STRING_STATS:
423092 result = StringStats::ToString(*this) + result;
423093 break;
423094 case StatisticsType::LIST_STATS:
423095 result = ListStats::ToString(*this) + result;
423096 break;
423097 case StatisticsType::STRUCT_STATS:
423098 result = StructStats::ToString(*this) + result;
423099 break;
423100 case StatisticsType::ARRAY_STATS:
423101 result = ArrayStats::ToString(*this) + result;
423102 break;
423103 case StatisticsType::GEOMETRY_STATS:
423104 result = GeometryStats::ToString(*this) + result;
423105 break;
423106 case StatisticsType::VARIANT_STATS:
423107 result = VariantStats::ToString(*this) + result;
423108 break;
423109 default:
423110 break;
423111 }
423112 return result;
423113}
static string Format(const string fmt_str, ARGS... params)
Format a string using printf semantics.
Definition duckdb.hpp:4002

◆ GetDistinctCount()

idx_t duckdb::BaseStatistics::GetDistinctCount ( )
422819 {
422820 return distinct_count;
422821}

◆ FromConstant()

BaseStatistics duckdb::BaseStatistics::FromConstant ( const Value & input)
static
423247 {
423248 auto result = FromConstantType(input);
423249 result.SetDistinctCount(1);
423250 if (input.IsNull()) {
423251 result.Set(StatsInfo::CAN_HAVE_NULL_VALUES);
423252 result.Set(StatsInfo::CANNOT_HAVE_VALID_VALUES);
423253 } else {
423254 result.Set(StatsInfo::CANNOT_HAVE_NULL_VALUES);
423255 result.Set(StatsInfo::CAN_HAVE_VALID_VALUES);
423256 }
423257 return result;
423258}

◆ UpdateNumericStats() [1/3]

template<class T>
void duckdb::BaseStatistics::UpdateNumericStats ( T new_value)
inline
16358 {
16359 D_ASSERT(GetStatsType() == StatisticsType::NUMERIC_STATS);
16360 NumericStats::Update(stats_union.numeric_data, new_value);
16361 }

◆ Construct()

void duckdb::BaseStatistics::Construct ( BaseStatistics & stats,
LogicalType type )
staticprivate
422664 {
422665 stats.distinct_count = 0;
422666 stats.type = std::move(type);
422667 switch (GetStatsType(stats.type)) {
422668 case StatisticsType::LIST_STATS:
422669 ListStats::Construct(stats);
422670 break;
422671 case StatisticsType::STRUCT_STATS:
422672 StructStats::Construct(stats);
422673 break;
422674 case StatisticsType::ARRAY_STATS:
422675 ArrayStats::Construct(stats);
422676 break;
422677 case StatisticsType::VARIANT_STATS:
422678 VariantStats::Construct(stats);
422679 break;
422680 default:
422681 break;
422682 }
422683}

◆ InitializeUnknown()

void duckdb::BaseStatistics::InitializeUnknown ( )
private
422751 {
422752 has_null = true;
422753 has_no_null = true;
422754}

◆ InitializeEmpty()

void duckdb::BaseStatistics::InitializeEmpty ( )
private
422756 {
422757 has_null = false;
422758 has_no_null = false;
422759}

◆ CreateUnknownType()

BaseStatistics duckdb::BaseStatistics::CreateUnknownType ( LogicalType type)
staticprivate
422823 {
422824 switch (GetStatsType(type)) {
422825 case StatisticsType::NUMERIC_STATS:
422826 return NumericStats::CreateUnknown(std::move(type));
422827 case StatisticsType::STRING_STATS:
422828 return StringStats::CreateUnknown(std::move(type));
422829 case StatisticsType::LIST_STATS:
422830 return ListStats::CreateUnknown(std::move(type));
422831 case StatisticsType::STRUCT_STATS:
422832 return StructStats::CreateUnknown(std::move(type));
422833 case StatisticsType::ARRAY_STATS:
422834 return ArrayStats::CreateUnknown(std::move(type));
422835 case StatisticsType::GEOMETRY_STATS:
422836 return GeometryStats::CreateUnknown(std::move(type));
422837 case StatisticsType::VARIANT_STATS:
422838 return VariantStats::CreateUnknown(std::move(type));
422839 default:
422840 return BaseStatistics(std::move(type));
422841 }
422842}
static DUCKDB_API BaseStatistics CreateUnknown(LogicalType type)
Unknown statistics.
Definition duckdb.cpp:423480
static DUCKDB_API BaseStatistics CreateUnknown(LogicalType type)
Unknown statistics - i.e. "has_min" is false, "has_max" is false.
Definition duckdb.cpp:423870
static DUCKDB_API BaseStatistics CreateUnknown(LogicalType type)
Unknown statistics - i.e. "has_unicode" is true, "max_string_length" is unknown, "min" is \0,...
Definition duckdb.cpp:424515
static DUCKDB_API BaseStatistics CreateUnknown(LogicalType type)
Definition duckdb.cpp:425020

◆ CreateEmptyType()

BaseStatistics duckdb::BaseStatistics::CreateEmptyType ( LogicalType type)
staticprivate
422844 {
422845 switch (GetStatsType(type)) {
422846 case StatisticsType::NUMERIC_STATS:
422847 return NumericStats::CreateEmpty(std::move(type));
422848 case StatisticsType::STRING_STATS:
422849 return StringStats::CreateEmpty(std::move(type));
422850 case StatisticsType::LIST_STATS:
422851 return ListStats::CreateEmpty(std::move(type));
422852 case StatisticsType::STRUCT_STATS:
422853 return StructStats::CreateEmpty(std::move(type));
422854 case StatisticsType::ARRAY_STATS:
422855 return ArrayStats::CreateEmpty(std::move(type));
422856 case StatisticsType::GEOMETRY_STATS:
422857 return GeometryStats::CreateEmpty(std::move(type));
422858 case StatisticsType::VARIANT_STATS:
422859 return VariantStats::CreateEmpty(std::move(type));
422860 default:
422861 return BaseStatistics(std::move(type));
422862 }
422863}
static DUCKDB_API BaseStatistics CreateEmpty(LogicalType type)
Empty statistics.
Definition duckdb.cpp:423487
static DUCKDB_API BaseStatistics CreateEmpty(LogicalType type)
Empty statistics - i.e. "min = MaxValue<type>, max = MinValue<type>".
Definition duckdb.cpp:423878
static DUCKDB_API BaseStatistics CreateEmpty(LogicalType type)
Empty statistics - i.e. "has_unicode" is false, "max_string_length" is 0, "min" is \xFF,...
Definition duckdb.cpp:424529

◆ FromConstantType()

BaseStatistics duckdb::BaseStatistics::FromConstantType ( const Value & input)
staticprivate
423170 {
423171 switch (GetStatsType(input.type())) {
423172 case StatisticsType::NUMERIC_STATS: {
423173 auto result = NumericStats::CreateEmpty(input.type());
423174 NumericStats::SetMin(result, input);
423175 NumericStats::SetMax(result, input);
423176 return result;
423177 }
423178 case StatisticsType::STRING_STATS: {
423179 auto result = StringStats::CreateEmpty(input.type());
423180 if (!input.IsNull()) {
423181 auto &string_value = StringValue::Get(input);
423182 StringStats::Update(result, string_t(string_value));
423183 }
423184 return result;
423185 }
423186 case StatisticsType::LIST_STATS: {
423187 auto result = ListStats::CreateEmpty(input.type());
423188 auto &child_stats = ListStats::GetChildStats(result);
423189 if (!input.IsNull()) {
423190 auto &list_children = ListValue::GetChildren(input);
423191 for (auto &child_element : list_children) {
423192 child_stats.Merge(FromConstant(child_element));
423193 }
423194 }
423195 return result;
423196 }
423197 case StatisticsType::STRUCT_STATS: {
423198 auto result = StructStats::CreateEmpty(input.type());
423199 auto &child_types = StructType::GetChildTypes(input.type());
423200 if (input.IsNull()) {
423201 for (idx_t i = 0; i < child_types.size(); i++) {
423202 StructStats::SetChildStats(result, i, FromConstant(Value(child_types[i].second)));
423203 }
423204 } else {
423205 auto &struct_children = StructValue::GetChildren(input);
423206 for (idx_t i = 0; i < child_types.size(); i++) {
423207 StructStats::SetChildStats(result, i, FromConstant(struct_children[i]));
423208 }
423209 }
423210 return result;
423211 }
423212 case StatisticsType::ARRAY_STATS: {
423213 auto result = ArrayStats::CreateEmpty(input.type());
423214 auto &child_stats = ArrayStats::GetChildStats(result);
423215 if (!input.IsNull()) {
423216 auto &list_children = ArrayValue::GetChildren(input);
423217 for (auto &child_element : list_children) {
423218 child_stats.Merge(FromConstant(child_element));
423219 }
423220 }
423221 return result;
423222 }
423223 case StatisticsType::GEOMETRY_STATS: {
423224 auto result = GeometryStats::CreateEmpty(input.type());
423225 if (!input.IsNull()) {
423226 auto &string_value = StringValue::Get(input);
423227 GeometryStats::Update(result, string_t(string_value));
423228 }
423229 return result;
423230 }
423231 case StatisticsType::VARIANT_STATS: {
423232 auto result = VariantStats::CreateEmpty(input.type());
423233 auto unshredded_type = VariantShredding::GetUnshreddedType();
423234 if (input.IsNull()) {
423235 VariantStats::SetUnshreddedStats(result, FromConstant(Value(unshredded_type)));
423236 } else {
423237 VariantStats::SetUnshreddedStats(
423238 result, FromConstant(Value::STRUCT(unshredded_type, StructValue::GetChildren(input))));
423239 }
423240 return result;
423241 }
423242 default:
423243 return BaseStatistics(input.type());
423244 }
423245}
static DUCKDB_API Value STRUCT(child_list_t< Value > values)
Create a struct value with given list of entries.
Definition duckdb.cpp:132434
static DUCKDB_API void SetMin(BaseStatistics &stats, const Value &val)
Sets the min value of the statistics.
Definition duckdb.cpp:424188
static DUCKDB_API void SetMax(BaseStatistics &stats, const Value &val)
Sets the max value of the statistics.
Definition duckdb.cpp:424193
static DUCKDB_API void Update(BaseStatistics &stats, const string_t &value)
Definition duckdb.cpp:424643

◆ UpdateNumericStats() [2/3]

template<>
void duckdb::BaseStatistics::UpdateNumericStats ( interval_t new_value)
inline
16401 {
16402}

◆ UpdateNumericStats() [3/3]

template<>
void duckdb::BaseStatistics::UpdateNumericStats ( list_entry_t new_value)
inline
16404 {
16405}

The documentation for this class was generated from the following files: