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

Public Member Functions

 ColumnIndex ()
 FIXME: this initializes the index to COLUMN_IDENTIFIER_ROW_ID (same numeric representation as INVALID_INDEX)
 
 ColumnIndex (idx_t index)
 
 ColumnIndex (const string &field)
 
 ColumnIndex (idx_t index, vector< ColumnIndex > child_indexes_p)
 
 ColumnIndex (const string &field, vector< ColumnIndex > child_indexes_p)
 
bool operator== (const ColumnIndex &rhs) const
 
bool operator!= (const ColumnIndex &rhs) const
 
bool operator< (const ColumnIndex &rhs) const
 
bool HasPrimaryIndex () const
 
idx_t GetPrimaryIndex () const
 
const string & GetFieldName () const
 
LogicalIndex ToLogical () const
 
bool HasChildren () const
 
bool HasType () const
 
idx_t ChildIndexCount () const
 
const ColumnIndexGetChildIndex (idx_t idx) const
 
ColumnIndexGetChildIndex (idx_t idx)
 
const vector< ColumnIndex > & GetChildIndexes () const
 
vector< ColumnIndex > & GetChildIndexesMutable ()
 
bool IsPushdownExtract () const
 
void SetType (const LogicalType &type_information)
 
void SetPushdownExtractType (const LogicalType &type_information, optional_ptr< const LogicalType > cast_type=nullptr)
 
const LogicalTypeGetScanType () const
 
const LogicalTypeGetType () const
 
void AddChildIndex (ColumnIndex new_index)
 
bool IsRowIdColumn () const
 
bool IsEmptyColumn () const
 
bool IsVirtualColumn () const
 
void VerifySinglePath () const
 
bool IsChildPathOf (const ColumnIndex &path) const
 
void Serialize (Serializer &serializer) const
 

Static Public Member Functions

static ColumnIndex Deserialize (Deserializer &deserializer)
 

Private Attributes

bool has_index = true
 The column/field index (if structured type)
 
idx_t index
 
string field
 The column/field name (if semi-structured type)
 
LogicalType type = LogicalType::INVALID
 The logical type of the column this references (if pushdown extract)
 
ColumnIndexType index_type
 The type of index, controlling how it's interpreted.
 
vector< ColumnIndexchild_indexes
 

Constructor & Destructor Documentation

◆ ColumnIndex() [1/5]

duckdb::ColumnIndex::ColumnIndex ( )
inline

FIXME: this initializes the index to COLUMN_IDENTIFIER_ROW_ID (same numeric representation as INVALID_INDEX)

14607 }
@ FULL_READ
Regular column index, refers to a column in its entirety.
bool has_index
The column/field index (if structured type)
Definition duckdb.hpp:14839
ColumnIndexType index_type
The type of index, controlling how it's interpreted.
Definition duckdb.hpp:14847
static constexpr const idx_t INVALID_INDEX
The value used to signify an invalid index entry.
Definition duckdb.hpp:1117

◆ ColumnIndex() [2/5]

duckdb::ColumnIndex::ColumnIndex ( idx_t  index)
inlineexplicit
14609 : has_index(true), index(index), type(LogicalType::INVALID), index_type(ColumnIndexType::FULL_READ) {
14610 }
LogicalType type
The logical type of the column this references (if pushdown extract)
Definition duckdb.hpp:14845

◆ ColumnIndex() [3/5]

duckdb::ColumnIndex::ColumnIndex ( const string &  field)
inlineexplicit
14612 : has_index(false), field(field), type(LogicalType::INVALID), index_type(ColumnIndexType::FULL_READ) {
14613 }
string field
The column/field name (if semi-structured type)
Definition duckdb.hpp:14842

◆ ColumnIndex() [4/5]

duckdb::ColumnIndex::ColumnIndex ( idx_t  index,
vector< ColumnIndex child_indexes_p 
)
inline
14616 : has_index(true), index(index), index_type(ColumnIndexType::FULL_READ),
14617 child_indexes(std::move(child_indexes_p)) {
14618 }

◆ ColumnIndex() [5/5]

duckdb::ColumnIndex::ColumnIndex ( const string &  field,
vector< ColumnIndex child_indexes_p 
)
inline
14621 child_indexes(std::move(child_indexes_p)) {
14622 }

Member Function Documentation

◆ operator==()

bool duckdb::ColumnIndex::operator== ( const ColumnIndex rhs) const
inline
14624 {
14625 if (has_index != rhs.has_index) {
14626 return false;
14627 }
14628 if (has_index) {
14629 if (index != rhs.index) {
14630 return false;
14631 }
14632 } else {
14633 if (field != rhs.field) {
14634 return false;
14635 }
14636 }
14637 if (type != rhs.type) {
14638 return false;
14639 }
14640 if (index_type != rhs.index_type) {
14641 return false;
14642 }
14643
14644 if (child_indexes.size() != rhs.child_indexes.size()) {
14645 return false;
14646 }
14647 for (idx_t i = 0; i < child_indexes.size(); i++) {
14648 auto &a = child_indexes[i];
14649 auto &b = rhs.child_indexes[i];
14650 if (a != b) {
14651 return false;
14652 }
14653 }
14654 return true;
14655 }
float index_type

◆ operator!=()

bool duckdb::ColumnIndex::operator!= ( const ColumnIndex rhs) const
inline
14656 {
14657 return !(*this == rhs);
14658 }

◆ operator<()

bool duckdb::ColumnIndex::operator< ( const ColumnIndex rhs) const
inline

FIXME: does it make sense to check children here?

14659 {
14661 return index < rhs.index;
14662 }

◆ HasPrimaryIndex()

bool duckdb::ColumnIndex::HasPrimaryIndex ( ) const
inline
14665 {
14666 return has_index;
14667 }

◆ GetPrimaryIndex()

idx_t duckdb::ColumnIndex::GetPrimaryIndex ( ) const
inline
14668 {
14669 if (!has_index) {
14670 throw InternalException("Attempted to get the primary index (numeric) for an index that consists of a "
14671 "field identifier (string: %s)",
14672 field);
14673 }
14674 return index;
14675 }

◆ GetFieldName()

const string & duckdb::ColumnIndex::GetFieldName ( ) const
inline
14676 {
14677 if (has_index) {
14678 throw InternalException("Attempted to get the field identifier (string) for an index that consists of a "
14679 "primary index (numeric: %d)",
14680 index);
14681 }
14682 return field;
14683 }

◆ ToLogical()

LogicalIndex duckdb::ColumnIndex::ToLogical ( ) const
inline
14684 {
14685 return LogicalIndex(GetPrimaryIndex());
14686 }

◆ HasChildren()

bool duckdb::ColumnIndex::HasChildren ( ) const
inline
14687 {
14688 return !child_indexes.empty();
14689 }

◆ HasType()

bool duckdb::ColumnIndex::HasType ( ) const
inline
14690 {
14691 return type.id() != LogicalTypeId::INVALID;
14692 }

◆ ChildIndexCount()

idx_t duckdb::ColumnIndex::ChildIndexCount ( ) const
inline
14693 {
14694 return child_indexes.size();
14695 }

◆ GetChildIndex() [1/2]

const ColumnIndex & duckdb::ColumnIndex::GetChildIndex ( idx_t  idx) const
inline
14696 {
14697 return child_indexes[idx];
14698 }

◆ GetChildIndex() [2/2]

ColumnIndex & duckdb::ColumnIndex::GetChildIndex ( idx_t  idx)
inline
14699 {
14700 return child_indexes[idx];
14701 }

◆ GetChildIndexes()

const vector< ColumnIndex > & duckdb::ColumnIndex::GetChildIndexes ( ) const
inline
14702 {
14703 return child_indexes;
14704 }

◆ GetChildIndexesMutable()

vector< ColumnIndex > & duckdb::ColumnIndex::GetChildIndexesMutable ( )
inline
14705 {
14706 return child_indexes;
14707 }

◆ IsPushdownExtract()

bool duckdb::ColumnIndex::IsPushdownExtract ( ) const
inline
14709 {
14711 }
@ PUSHDOWN_EXTRACT
This index references a struct/variant field that MUST be extracted by the scan and emitted directly.

◆ SetType()

void duckdb::ColumnIndex::SetType ( const LogicalType type_information)
inline
14712 {
14713 type = type_information;
14714 }

◆ SetPushdownExtractType()

void duckdb::ColumnIndex::SetPushdownExtractType ( const LogicalType type_information,
optional_ptr< const LogicalType cast_type = nullptr 
)
inline

We can upgrade the optional prune hint to a PUSHDOWN_EXTRACT, which is no longer optional

Without a cast, the child will always be VARIANT

14716 {
14719 type = type_information;
14720 D_ASSERT(child_indexes.size() == 1);
14721
14722 auto &child = child_indexes[0];
14723 if (child.HasPrimaryIndex()) {
14724 auto &child_types = StructType::GetChildTypes(type);
14725 auto &child_type = child_types[child.GetPrimaryIndex()].second;
14726 if (child.child_indexes.empty()) {
14727 if (cast_type) {
14728 child.SetType(*cast_type);
14729 } else {
14730 child.SetType(child_type);
14731 }
14732 } else {
14733 child.SetPushdownExtractType(child_type, cast_type);
14734 }
14735 } else {
14736 D_ASSERT(type_information.id() == LogicalTypeId::VARIANT);
14737 if (child.child_indexes.empty()) {
14738 if (cast_type) {
14739 child.SetType(*cast_type);
14740 } else {
14742 child.SetType(type_information);
14743 }
14744 } else {
14745 child.SetPushdownExtractType(type_information, cast_type);
14746 }
14747 }
14748 }

◆ GetScanType()

const LogicalType & duckdb::ColumnIndex::GetScanType ( ) const
inline
14749 {
14750 D_ASSERT(HasType());
14751 if (IsPushdownExtract()) {
14752 return child_indexes[0].GetScanType();
14753 }
14754 return GetType();
14755 }

◆ GetType()

const LogicalType & duckdb::ColumnIndex::GetType ( ) const
inline
14756 {
14757 D_ASSERT(type.id() != LogicalTypeId::INVALID);
14758 return type;
14759 }

◆ AddChildIndex()

void duckdb::ColumnIndex::AddChildIndex ( ColumnIndex  new_index)
inline
14760 {
14761 this->child_indexes.push_back(std::move(new_index));
14762 }

◆ IsRowIdColumn()

bool duckdb::ColumnIndex::IsRowIdColumn ( ) const
inline
14763 {
14764 if (!has_index) {
14765 return false;
14766 }
14767 return index == COLUMN_IDENTIFIER_ROW_ID;
14768 }
const column_t COLUMN_IDENTIFIER_ROW_ID
Special value used to signify the ROW ID of a table.
Definition duckdb.cpp:50303

◆ IsEmptyColumn()

bool duckdb::ColumnIndex::IsEmptyColumn ( ) const
inline
14769 {
14770 if (!has_index) {
14771 return false;
14772 }
14773 return index == COLUMN_IDENTIFIER_EMPTY;
14774 }
const column_t COLUMN_IDENTIFIER_EMPTY
Special value used to signify an empty column (used for e.g. COUNT(*))
Definition duckdb.cpp:50304

◆ IsVirtualColumn()

bool duckdb::ColumnIndex::IsVirtualColumn ( ) const
inline
14775 {
14776 if (!has_index) {
14777 return false;
14778 }
14779 return index >= VIRTUAL_COLUMN_START;
14780 }

◆ VerifySinglePath()

void duckdb::ColumnIndex::VerifySinglePath ( ) const
inline
14781 {
14782 if (child_indexes.empty()) {
14783 return;
14784 }
14785 if (child_indexes.size() != 1) {
14786 throw InternalException(
14787 "We were expecting to find a single path in the index, meaning 0 or 1 children, found: %d",
14788 child_indexes.size());
14789 }
14790 child_indexes[0].VerifySinglePath();
14791 }

◆ IsChildPathOf()

bool duckdb::ColumnIndex::IsChildPathOf ( const ColumnIndex path) const
inline

a's path has stopped short of b's path

b's path is a subset of a's path, so it's a parent path

14792 {
14793 VerifySinglePath();
14794 path.VerifySinglePath();
14795 reference<const ColumnIndex> a(*this);
14796 reference<const ColumnIndex> b(path);
14797
14798 while (true) {
14799 if (a.get().HasPrimaryIndex()) {
14800 if (!b.get().HasPrimaryIndex()) {
14801 return false;
14802 }
14803 if (a.get().GetPrimaryIndex() != b.get().GetPrimaryIndex()) {
14804 return false;
14805 }
14806 } else {
14807 if (b.get().HasPrimaryIndex()) {
14808 return false;
14809 }
14810 if (a.get().GetFieldName() != b.get().GetFieldName()) {
14811 return false;
14812 }
14813 }
14814 const bool a_has_children = a.get().HasChildren();
14815 const bool b_has_children = b.get().HasChildren();
14816 if (!a_has_children && !b_has_children) {
14817 return false;
14818 }
14819 if (!a_has_children) {
14821 return false;
14822 }
14823 if (!b_has_children) {
14825 return true;
14826 }
14827 a = a.get().GetChildIndexes()[0];
14828 b = b.get().GetChildIndexes()[0];
14829 }
14830 return true;
14831 }

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