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

Public Member Functions

 StructBoundCastData (vector< BoundCastInfo > child_casts, LogicalType target_p, vector< idx_t > source_indexes_p, vector< idx_t > target_indexes_p, vector< idx_t > target_null_indexes_p)
 StructBoundCastData (vector< BoundCastInfo > child_casts, LogicalType target_p)
unique_ptr< BoundCastData > Copy () const override
Public Member Functions inherited from duckdb::BoundCastData
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const

Static Public Member Functions

static unique_ptr< BoundCastData > BindStructToStructCast (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static unique_ptr< FunctionLocalState > InitStructCastLocalState (CastLocalStateParameters &parameters)

Public Attributes

vector< BoundCastInfo > child_cast_info
LogicalType target
vector< idx_t > source_indexes
vector< idx_t > target_indexes
vector< idx_t > target_null_indexes

Constructor & Destructor Documentation

◆ StructBoundCastData() [1/2]

duckdb::StructBoundCastData::StructBoundCastData ( vector< BoundCastInfo > child_casts,
LogicalType target_p,
vector< idx_t > source_indexes_p,
vector< idx_t > target_indexes_p,
vector< idx_t > target_null_indexes_p )
inline
211902 : child_cast_info(std::move(child_casts)), target(std::move(target_p)),
211903 source_indexes(std::move(source_indexes_p)), target_indexes(std::move(target_indexes_p)),
211904 target_null_indexes(std::move(target_null_indexes_p)) {
211905 D_ASSERT(child_cast_info.size() == source_indexes.size());
211906 D_ASSERT(source_indexes.size() == target_indexes.size());
211907 }

◆ StructBoundCastData() [2/2]

duckdb::StructBoundCastData::StructBoundCastData ( vector< BoundCastInfo > child_casts,
LogicalType target_p )
inline
211909 : child_cast_info(std::move(child_casts)), target(std::move(target_p)) {
211910 for (idx_t i = 0; i < child_cast_info.size(); i++) {
211911 source_indexes.push_back(i);
211912 target_indexes.push_back(i);
211913 }
211914 }
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

Member Function Documentation

◆ BindStructToStructCast()

unique_ptr< BoundCastData > duckdb::StructBoundCastData::BindStructToStructCast ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
static
215162 {
215163 vector<BoundCastInfo> child_cast_info;
215164 auto &source_children = StructType::GetChildTypes(source);
215165 auto &target_children = StructType::GetChildTypes(target);
215166
215167 auto target_is_unnamed = target_children.empty() || StructType::IsUnnamed(target);
215168 auto source_is_unnamed = source_children.empty() || StructType::IsUnnamed(source);
215169
215170 auto is_unnamed = target_is_unnamed || source_is_unnamed;
215171 if (is_unnamed && source_children.size() != target_children.size()) {
215172 throw TypeMismatchException(input.query_location, source, target, "Cannot cast STRUCTs of different size");
215173 }
215174
215175 InsertionOrderPreservingMap<idx_t> target_children_map;
215176 if (!is_unnamed) {
215177 for (idx_t i = 0; i < target_children.size(); i++) {
215178 auto &name = target_children[i].first;
215179 if (target_children_map.find(name) != target_children_map.end()) {
215180 throw NotImplementedException("Error while casting - duplicate name \"%s\" in struct", name);
215181 }
215182 target_children_map[name] = i;
215183 }
215184 }
215185
215186 vector<idx_t> source_indexes;
215187 vector<idx_t> target_indexes;
215188 vector<idx_t> target_null_indexes;
215189 bool has_any_match = is_unnamed;
215190
215191 for (idx_t i = 0; i < source_children.size(); i++) {
215192 auto &source_child = source_children[i];
215193 auto target_idx = i;
215194
215195 // Map to the correct index for names structs.
215196 if (!is_unnamed) {
215197 auto target_child = target_children_map.find(source_child.first);
215198 if (target_child == target_children_map.end()) {
215199 // Skip any children that have no target.
215200 continue;
215201 }
215202 target_idx = target_child->second;
215203 target_children_map.erase(target_child);
215204 has_any_match = true;
215205 }
215206
215207 source_indexes.push_back(i);
215208 target_indexes.push_back(target_idx);
215209 auto child_cast = input.GetCastFunction(source_child.second, target_children[target_idx].second);
215210 child_cast_info.push_back(std::move(child_cast));
215211 }
215212
215213 if (!has_any_match) {
215214 throw BinderException("STRUCT to STRUCT cast must have at least one matching member");
215215 }
215216
215217 // The remaining target children have no match in the source struct.
215218 // Thus, they become NULL.
215219 for (const auto &target_child : target_children_map) {
215220 target_null_indexes.push_back(target_child.second);
215221 }
215222
215223 return make_uniq<StructBoundCastData>(std::move(child_cast_info), target, std::move(source_indexes),
215224 std::move(target_indexes), std::move(target_null_indexes));
215225}

◆ InitStructCastLocalState()

unique_ptr< FunctionLocalState > duckdb::StructBoundCastData::InitStructCastLocalState ( CastLocalStateParameters & parameters)
static
215227 {
215228 auto &cast_data = parameters.cast_data->Cast<StructBoundCastData>();
215229 auto result = make_uniq<StructCastLocalState>();
215230
215231 for (auto &entry : cast_data.child_cast_info) {
215232 unique_ptr<FunctionLocalState> child_state;
215233 if (entry.init_local_state) {
215234 CastLocalStateParameters child_params(parameters, entry.cast_data);
215235 child_state = entry.init_local_state(child_params);
215236 }
215237 result->local_states.push_back(std::move(child_state));
215238 }
215239 return std::move(result);
215240}

◆ Copy()

unique_ptr< BoundCastData > duckdb::StructBoundCastData::Copy ( ) const
inlineoverridevirtual

Implements duckdb::BoundCastData.

211927 {
211928 vector<BoundCastInfo> copy_info;
211929 for (auto &info : child_cast_info) {
211930 copy_info.push_back(info.Copy());
211931 }
211932 return make_uniq<StructBoundCastData>(std::move(copy_info), target, source_indexes, target_indexes,
211933 target_null_indexes);
211934 }

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