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

Public Member Functions

 SetOpAliasGatherer (SelectBindState &bind_state_p)
void GatherAliases (BoundStatement &stmt, const vector< idx_t > &reorder_idx)
void GatherSetOpAliases (SetOperationType setop_type, const vector< string > &names, vector< BoundStatement > &bound_children, const vector< idx_t > &reorder_idx)

Private Attributes

SelectBindState & bind_state

Constructor & Destructor Documentation

◆ SetOpAliasGatherer()

duckdb::SetOpAliasGatherer::SetOpAliasGatherer ( SelectBindState & bind_state_p)
inlineexplicit
364880 : bind_state(bind_state_p) {
364881 }

Member Function Documentation

◆ GatherAliases()

void duckdb::SetOpAliasGatherer::GatherAliases ( BoundStatement & stmt,
const vector< idx_t > & reorder_idx )
364891 {
364892 if (stmt.extra_info.setop_type != SetOperationType::NONE) {
364893 GatherSetOpAliases(stmt.extra_info.setop_type, stmt.names, stmt.extra_info.bound_children, reorder_idx);
364894 return;
364895 }
364896
364897 // query node
364898 auto &select_names = stmt.names;
364899 // fill the alias lists with the names
364900 D_ASSERT(reorder_idx.size() == select_names.size());
364901 for (idx_t i = 0; i < select_names.size(); i++) {
364902 auto &name = select_names[i];
364903 // first check if the alias is already in there
364904 auto entry = bind_state.alias_map.find(name);
364905
364906 idx_t index = reorder_idx[i];
364907
364908 if (entry == bind_state.alias_map.end()) {
364909 // the alias is not in there yet, just assign it
364910 bind_state.alias_map[name] = index;
364911 }
364912 }
364913 // check if the expression matches one of the expressions in the original expression list
364914 auto &select_list = stmt.extra_info.original_expressions;
364915 for (idx_t i = 0; i < select_list.size(); i++) {
364916 auto &expr = select_list[i];
364917 idx_t index = reorder_idx[i];
364918 // now check if the node is already in the set of expressions
364919 auto expr_entry = bind_state.projection_map.find(*expr);
364920 if (expr_entry != bind_state.projection_map.end()) {
364921 // the node is in there
364922 // repeat the same as with the alias: if there is an ambiguity we insert "-1"
364923 if (expr_entry->second != index) {
364924 bind_state.projection_map[*expr] = DConstants::INVALID_INDEX;
364925 }
364926 } else {
364927 // not in there yet, just place it in there
364928 bind_state.projection_map[*expr] = index;
364929 }
364930 }
364931}
index
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

◆ GatherSetOpAliases()

void duckdb::SetOpAliasGatherer::GatherSetOpAliases ( SetOperationType setop_type,
const vector< string > & names,
vector< BoundStatement > & bound_children,
const vector< idx_t > & reorder_idx )
364934 {
364935 // create new reorder index
364936 if (setop_type == SetOperationType::UNION_BY_NAME) {
364937 auto &setop_names = stmt_names;
364938 // for UNION BY NAME - create a new re-order index
364939 case_insensitive_map_t<idx_t> reorder_map;
364940 for (idx_t col_idx = 0; col_idx < setop_names.size(); ++col_idx) {
364941 reorder_map[setop_names[col_idx]] = reorder_idx[col_idx];
364942 }
364943
364944 // use new reorder index
364945 for (auto &child : bound_children) {
364946 vector<idx_t> new_reorder_idx;
364947 auto &child_names = child.names;
364948 for (idx_t col_idx = 0; col_idx < child_names.size(); col_idx++) {
364949 auto &col_name = child_names[col_idx];
364950 auto entry = reorder_map.find(col_name);
364951 if (entry == reorder_map.end()) {
364952 throw InternalException("SetOp - Column name not found in reorder_map in UNION BY NAME");
364953 }
364954 new_reorder_idx.push_back(entry->second);
364955 }
364956 GatherAliases(child, new_reorder_idx);
364957 }
364958 } else {
364959 for (auto &child : bound_children) {
364960 GatherAliases(child, reorder_idx);
364961 }
364962 }
364963}

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