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::VariantShreddingStats Struct Reference
Collaboration diagram for duckdb::VariantShreddingStats:

Public Member Functions

VariantColumnStatsData & GetOrCreateElement (idx_t parent_index)
VariantColumnStatsData & GetOrCreateField (idx_t parent_index, const string &name)
VariantColumnStatsData & GetColumnStats (idx_t index)
const VariantColumnStatsData & GetColumnStats (idx_t index) const
void Update (Vector &input, idx_t count)
LogicalType GetShreddedType () const

Private Member Functions

bool GetShreddedTypeInternal (const VariantColumnStatsData &column, LogicalType &out_type, optional_idx parent_count=optional_idx()) const

Private Attributes

vector< VariantColumnStatsData > columns
 Nested type analysis.

Constructor & Destructor Documentation

◆ VariantShreddingStats()

duckdb::VariantShreddingStats::VariantShreddingStats ( )
inline
252563 {
252564 columns.emplace_back(0);
252565 }
vector< VariantColumnStatsData > columns
Nested type analysis.
Definition duckdb.cpp:252584

Member Function Documentation

◆ GetOrCreateElement()

VariantColumnStatsData & duckdb::VariantShreddingStats::GetOrCreateElement ( idx_t parent_index)
440629 {
440630 auto &parent_column = GetColumnStats(parent_index);
440631
440632 idx_t element_stats = parent_column.element_stats;
440633 if (parent_column.element_stats == DConstants::INVALID_INDEX) {
440634 parent_column.element_stats = columns.size();
440635 element_stats = parent_column.element_stats;
440636 columns.emplace_back(element_stats);
440637 }
440638 return GetColumnStats(element_stats);
440639}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
static constexpr const idx_t INVALID_INDEX
The value used to signify an invalid index entry.
Definition duckdb.hpp:1117

◆ GetOrCreateField()

VariantColumnStatsData & duckdb::VariantShreddingStats::GetOrCreateField ( idx_t parent_index,
const string & name )
440641 {
440642 auto &parent_column = columns[parent_index];
440643 auto it = parent_column.field_stats.find(name);
440644
440645 idx_t field_stats;
440646 if (it == parent_column.field_stats.end()) {
440647 it = parent_column.field_stats.emplace(name, columns.size()).first;
440648 field_stats = it->second;
440649 columns.emplace_back(field_stats);
440650 } else {
440651 field_stats = it->second;
440652 }
440653 return GetColumnStats(field_stats);
440654}

◆ GetColumnStats() [1/2]

VariantColumnStatsData & duckdb::VariantShreddingStats::GetColumnStats ( idx_t index)
440656 {
440657 D_ASSERT(columns.size() > index);
440658 return columns[index];
440659}
index

◆ GetColumnStats() [2/2]

const VariantColumnStatsData & duckdb::VariantShreddingStats::GetColumnStats ( idx_t index) const
440661 {
440662 D_ASSERT(columns.size() > index);
440663 return columns[index];
440664}

◆ Update()

void duckdb::VariantShreddingStats::Update ( Vector & input,
idx_t count )
440847 {
440848 RecursiveUnifiedVectorFormat recursive_format;
440849 Vector::RecursiveToUnifiedFormat(input, count, recursive_format);
440850 UnifiedVariantVectorData variant(recursive_format);
440851
440852 for (idx_t i = 0; i < count; i++) {
440853 VariantVisitor<VariantStatsVisitor>::Visit(variant, i, 0, *this, static_cast<idx_t>(0));
440854 }
440855}
static void RecursiveToUnifiedFormat(Vector &input, idx_t count, RecursiveUnifiedVectorFormat &data)
Recursively calls UnifiedVectorFormat on a vector and its child vectors (for nested types).
Definition duckdb.cpp:136924

◆ GetShreddedType()

LogicalType duckdb::VariantShreddingStats::GetShreddedType ( ) const
440835 {
440836 auto &root_column = GetColumnStats(0);
440837
440838 child_list_t<LogicalType> child_types;
440839 child_types.emplace_back("unshredded", VariantShredding::GetUnshreddedType());
440840 LogicalType shredded_type;
440841 if (GetShreddedTypeInternal(root_column, shredded_type)) {
440842 child_types.emplace_back("shredded", shredded_type);
440843 }
440844 return LogicalType::STRUCT(child_types);
440845}
bool GetShreddedTypeInternal(const VariantColumnStatsData &column, LogicalType &out_type, optional_idx parent_count=optional_idx()) const
Definition duckdb.cpp:440759

◆ GetShreddedTypeInternal()

bool duckdb::VariantShreddingStats::GetShreddedTypeInternal ( const VariantColumnStatsData & column,
LogicalType & out_type,
optional_idx parent_count = optional_idx() ) const
private

All NULL, emit INT32

Skip the 'VARIANT_NULL' type, we can't shred on NULL

Can't shred on DECIMAL, not consistent

440760 {
440761 if (parent_count.IsValid() && column.total_count > parent_count.GetIndex()) {
440762 throw InternalException("Column count is larger than parent count - this should not be possible");
440763 }
440764 auto total_value_count = parent_count.IsValid() ? parent_count.GetIndex() : column.total_count;
440765 const auto null_count = column.type_counts[0];
440766 if (null_count == column.total_count) {
440768 auto fully_consistent = null_count == total_value_count;
440769 out_type = SetShreddedType(LogicalTypeId::INTEGER, fully_consistent);
440770 return true;
440771 }
440772
440773 idx_t max_count = 0;
440774 uint8_t type_index = 0;
440776 for (uint8_t i = 1; i < static_cast<uint8_t>(VariantLogicalType::ENUM_SIZE); i++) {
440777 if (i == static_cast<uint8_t>(VariantLogicalType::DECIMAL) && !column.decimal_consistent) {
440779 continue;
440780 }
440781 idx_t count = column.type_counts[i] + null_count;
440782 if (!max_count || count > max_count) {
440783 max_count = count;
440784 type_index = i;
440785 }
440786 }
440787
440788 if (!max_count) {
440789 return false;
440790 }
440791
440792 bool fully_consistent = max_count == total_value_count;
440793 if (type_index == static_cast<uint8_t>(VariantLogicalType::OBJECT)) {
440794 child_list_t<LogicalType> child_types;
440795 for (auto &entry : column.field_stats) {
440796 auto &child_column = GetColumnStats(entry.second);
440797 LogicalType child_type;
440798 if (GetShreddedTypeInternal(child_column, child_type, total_value_count)) {
440799 child_types.emplace_back(entry.first, child_type);
440800 }
440801 }
440802 if (child_types.empty()) {
440803 return false;
440804 }
440805 // always set objects as not being fully consistent
440806 fully_consistent = false;
440807 auto shredded_type = LogicalType::STRUCT(child_types);
440808 out_type = SetShreddedType(shredded_type, fully_consistent);
440809 return true;
440810 }
440811 if (type_index == static_cast<uint8_t>(VariantLogicalType::ARRAY)) {
440812 D_ASSERT(column.element_stats != DConstants::INVALID_INDEX);
440813 auto &element_column = GetColumnStats(column.element_stats);
440814 LogicalType element_type;
440815 if (!GetShreddedTypeInternal(element_column, element_type)) {
440816 return false;
440817 }
440818 auto shredded_type = LogicalType::LIST(element_type);
440819 out_type = SetShreddedType(shredded_type, fully_consistent);
440820 return true;
440821 }
440822 if (type_index == static_cast<uint8_t>(VariantLogicalType::DECIMAL)) {
440823 auto shredded_type = LogicalType::DECIMAL(static_cast<uint8_t>(column.decimal_width),
440824 static_cast<uint8_t>(column.decimal_scale));
440825 out_type = SetShreddedType(shredded_type, fully_consistent);
440826 return true;
440827 }
440828 auto type_id = static_cast<VariantLogicalType>(type_index);
440829
440830 auto shredded_type = ProduceShreddedType(type_id);
440831 out_type = SetShreddedType(shredded_type, fully_consistent);
440832 return true;
440833}
::uint8_t uint8_t
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this struct was generated from the following file: