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::MinMaxNOperation Struct Reference

Static Public Member Functions

template<class STATE>
static void Initialize (STATE &state)
template<class STATE, class OP>
static void Combine (const STATE &source, STATE &target, AggregateInputData &aggr_input)
template<class STATE>
static void Finalize (Vector &state_vector, AggregateInputData &input_data, Vector &result, idx_t count, idx_t offset)
template<class STATE>
static void Destroy (STATE &state, AggregateInputData &aggr_input_data)
static bool IgnoreNull ()

Member Function Documentation

◆ Initialize()

template<class STATE>
void duckdb::MinMaxNOperation::Initialize ( STATE & state)
inlinestatic
210188 {
210189 new (&state) STATE();
210190 }

◆ Combine()

template<class STATE, class OP>
void duckdb::MinMaxNOperation::Combine ( const STATE & source,
STATE & target,
AggregateInputData & aggr_input )
inlinestatic
210193 {
210194 if (!source.is_initialized) {
210195 // source is empty, nothing to do
210196 return;
210197 }
210198
210199 if (!target.is_initialized) {
210200 target.Initialize(aggr_input.allocator, source.heap.Capacity());
210201 } else if (source.heap.Capacity() != target.heap.Capacity()) {
210202 throw InvalidInputException("Mismatched n values in min/max/arg_min/arg_max");
210203 }
210204
210205 // Merge the heaps
210206 target.heap.Insert(aggr_input.allocator, source.heap);
210207 }

◆ Finalize()

template<class STATE>
void duckdb::MinMaxNOperation::Finalize ( Vector & state_vector,
AggregateInputData & input_data,
Vector & result,
idx_t count,
idx_t offset )
inlinestatic
210211 {
210212 // We only expect bind data from arg_max, otherwise nulls last is the default
210213 const bool nulls_last =
210214 input_data.bind_data ? input_data.bind_data->Cast<ArgMinMaxFunctionData>().nulls_last : true;
210215
210216 UnifiedVectorFormat state_format;
210217 state_vector.ToUnifiedFormat(count, state_format);
210218
210219 const auto states = UnifiedVectorFormat::GetData<STATE *>(state_format);
210220 auto &mask = FlatVector::Validity(result);
210221
210222 const auto old_len = ListVector::GetListSize(result);
210223
210224 // Count the number of new entries
210225 idx_t new_entries = 0;
210226 for (idx_t i = 0; i < count; i++) {
210227 const auto state_idx = state_format.sel->get_index(i);
210228 auto &state = *states[state_idx];
210229 new_entries += state.heap.Size();
210230 }
210231
210232 // Resize the list vector to fit the new entries
210233 ListVector::Reserve(result, old_len + new_entries);
210234
210235 const auto list_entries = FlatVector::GetData<list_entry_t>(result);
210236 auto &child_data = ListVector::GetEntry(result);
210237
210238 idx_t current_offset = old_len;
210239 for (idx_t i = 0; i < count; i++) {
210240 const auto rid = i + offset;
210241 const auto state_idx = state_format.sel->get_index(i);
210242 auto &state = *states[state_idx];
210243
210244 if (!state.is_initialized || state.heap.IsEmpty()) {
210245 mask.SetInvalid(rid);
210246 continue;
210247 }
210248
210249 // Add the entries to the list vector
210250 auto &list_entry = list_entries[rid];
210251 list_entry.offset = current_offset;
210252 list_entry.length = state.heap.Size();
210253
210254 // Turn the heap into a sorted list, invalidating the heap property
210255 auto heap = state.heap.SortAndGetHeap();
210256
210257 for (idx_t slot = 0; slot < state.heap.Size(); slot++) {
210258 STATE::VAL_TYPE::Assign(child_data, current_offset++, state.heap.GetValue(heap[slot]), nulls_last);
210259 }
210260 }
210261
210262 D_ASSERT(current_offset == old_len + new_entries);
210263 ListVector::SetListSize(result, current_offset);
210264 result.Verify(count);
210265 }
GMat mask(const GMat &src, const GMat &mask)
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 void SetListSize(Vector &vec, idx_t size)
Sets the total size of the underlying child-vector of a list.
Definition duckdb.cpp:138248
static DUCKDB_API void Reserve(Vector &vec, idx_t required_capacity)
Sets the total capacity of the underlying child-vector of a list.
Definition duckdb.cpp:138211
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

◆ Destroy()

template<class STATE>
void duckdb::MinMaxNOperation::Destroy ( STATE & state,
AggregateInputData & aggr_input_data )
inlinestatic
210268 {
210269 state.~STATE();
210270 }

◆ IgnoreNull()

bool duckdb::MinMaxNOperation::IgnoreNull ( )
inlinestatic
210272 {
210273 return true;
210274 }

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