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::UnnestOperatorState Class Reference
Inheritance diagram for duckdb::UnnestOperatorState:
Collaboration diagram for duckdb::UnnestOperatorState:

Public Member Functions

 UnnestOperatorState (ClientContext &context, const vector< unique_ptr< Expression > > &select_list)
void Reset ()
 Reset the fields of the unnest operator state.
void PrepareInput (DataChunk &input, const vector< unique_ptr< Expression > > &select_list)
 Prepare the input for the next unnest.
Public Member Functions inherited from duckdb::OperatorState
virtual void Finalize (const PhysicalOperator &op, ExecutionContext &context)
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const

Public Attributes

idx_t current_row
idx_t list_position
unsafe_vector< idx_t > unnest_lengths
bool first_fetch
SelectionVector input_sel
vector< SelectionVector > unnest_sels
vector< SelectionVector > null_sels
vector< idx_t > null_counts
ExpressionExecutor executor
DataChunk list_data
vector< UnifiedVectorFormat > list_vector_data
vector< UnifiedVectorFormat > list_child_data

Constructor & Destructor Documentation

◆ UnnestOperatorState()

duckdb::UnnestOperatorState::UnnestOperatorState ( ClientContext & context,
const vector< unique_ptr< Expression > > & select_list )
inline
197900 : current_row(0), list_position(0), first_fetch(true), input_sel(STANDARD_VECTOR_SIZE), executor(context) {
197901 // for each UNNEST in the select_list, we add the child expression to the expression executor
197902 // and set the return type in the list_data chunk, which will contain the evaluated expression results
197903 vector<LogicalType> list_data_types;
197904 for (auto &exp : select_list) {
197905 D_ASSERT(exp->GetExpressionType() == ExpressionType::BOUND_UNNEST);
197906 auto &bue = exp->Cast<BoundUnnestExpression>();
197907 list_data_types.push_back(bue.child->return_type);
197908 executor.AddExpression(*bue.child.get());
197909
197910 unnest_sels.emplace_back(STANDARD_VECTOR_SIZE);
197911 null_sels.emplace_back(STANDARD_VECTOR_SIZE);
197912 }
197913 null_counts.resize(list_data_types.size());
197914
197915 auto &allocator = Allocator::Get(context);
197916 list_data.Initialize(allocator, list_data_types);
197917
197918 list_vector_data.resize(list_data.ColumnCount());
197919 list_child_data.resize(list_data.ColumnCount());
197920 }
void exp(InputArray src, OutputArray dst)

Member Function Documentation

◆ Reset()

void duckdb::UnnestOperatorState::Reset ( )

Reset the fields of the unnest operator state.

197943 {
197944 current_row = 0;
197945 list_position = 0;
197946 first_fetch = true;
197947}

◆ PrepareInput()

void duckdb::UnnestOperatorState::PrepareInput ( DataChunk & input,
const vector< unique_ptr< Expression > > & select_list )

Prepare the input for the next unnest.

197957 {
197958 list_data.Reset();
197959 // execute the expressions inside each UNNEST in the select_list to get the list data
197960 // execution results (lists) are kept in list_data chunk
197961 executor.Execute(input, list_data);
197962
197963 // verify incoming lists
197964 list_data.Verify();
197965 D_ASSERT(input.size() == list_data.size());
197966 D_ASSERT(list_data.ColumnCount() == select_list.size());
197967 D_ASSERT(list_vector_data.size() == list_data.ColumnCount());
197968 D_ASSERT(list_child_data.size() == list_data.ColumnCount());
197969
197970 // get the UnifiedVectorFormat of each list_data vector (LIST vectors for the different UNNESTs)
197971 // both for the vector itself and its child vector
197972 for (idx_t col_idx = 0; col_idx < list_data.ColumnCount(); col_idx++) {
197973 auto &list_vector = list_data.data[col_idx];
197974 list_vector.ToUnifiedFormat(list_data.size(), list_vector_data[col_idx]);
197975
197976 if (list_vector.GetType() == LogicalType::SQLNULL) {
197977 // UNNEST(NULL): SQLNULL vectors don't have child vectors, but we need to point to the child vector of
197978 // each vector, so we just get the UnifiedVectorFormat of the vector itself
197979 auto &child_vector = list_vector;
197980 child_vector.ToUnifiedFormat(0, list_child_data[col_idx]);
197981 } else {
197982 auto list_size = ListVector::GetListSize(list_vector);
197983 auto &child_vector = ListVector::GetEntry(list_vector);
197984 child_vector.ToUnifiedFormat(list_size, list_child_data[col_idx]);
197985 }
197986 }
197987 // get the unnest lengths
197988 if (list_data.size() > unnest_lengths.size()) {
197989 unnest_lengths.resize(list_data.size());
197990 }
197991 for (idx_t r = 0; r < list_data.size(); r++) {
197992 unnest_lengths[r] = 0;
197993 }
197994 for (idx_t col_idx = 0; col_idx < list_data.ColumnCount(); col_idx++) {
197995 auto &vector_data = list_vector_data[col_idx];
197996 for (idx_t r = 0; r < list_data.size(); r++) {
197997 auto current_idx = vector_data.sel->get_index(r);
197998 if (!vector_data.validity.RowIsValid(current_idx)) {
197999 continue;
198000 }
198001 // check if this list is longer than the current unnest length
198002 auto list_data_entries = UnifiedVectorFormat::GetData<list_entry_t>(vector_data);
198003 auto list_entry = list_data_entries[current_idx];
198004 if (list_entry.length > unnest_lengths[r]) {
198005 unnest_lengths[r] = list_entry.length;
198006 }
198007 }
198008 }
198009
198010 first_fetch = false;
198011}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
static DUCKDB_API const Vector & GetEntry(const Vector &vector)
Gets a reference to the underlying child-vector of a list.
Definition duckdb.cpp:138203
static DUCKDB_API idx_t GetListSize(const Vector &vector)
Gets the total size of the underlying child-vector of a list.
Definition duckdb.cpp:138221
Here is the call graph for this function:

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