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

Public Member Functions

 GlobalUngroupedAggregateState (Allocator &client_allocator, const vector< unique_ptr< Expression > > &aggregates)
ArenaAllocator & CreateAllocator () const
 Create an ArenaAllocator with cross-thread lifetime.
void Combine (LocalUngroupedAggregateState &other)
void CombineDistinct (LocalUngroupedAggregateState &other, DistinctAggregateData &distinct_data)
void Finalize (DataChunk &result, idx_t column_offset=0)

Public Attributes

mutex lock
Allocator & client_allocator
 Client allocator.
ArenaAllocator allocator
 Global arena allocator.
vector< unique_ptr< ArenaAllocator > > stored_allocators
 Allocator pool.
UngroupedAggregateState state
 The global aggregate state.

Constructor & Destructor Documentation

◆ GlobalUngroupedAggregateState()

duckdb::GlobalUngroupedAggregateState::GlobalUngroupedAggregateState ( Allocator & client_allocator,
const vector< unique_ptr< Expression > > & aggregates )
inline
161008 }
UngroupedAggregateState state
The global aggregate state.
Definition duckdb.cpp:161018
Allocator & client_allocator
Client allocator.
Definition duckdb.cpp:161012
ArenaAllocator allocator
Global arena allocator.
Definition duckdb.cpp:161014

Member Function Documentation

◆ CreateAllocator()

ArenaAllocator & duckdb::GlobalUngroupedAggregateState::CreateAllocator ( ) const

Create an ArenaAllocator with cross-thread lifetime.

162676 {
162677 lock_guard<mutex> glock(lock);
162678 stored_allocators.emplace_back(make_uniq<ArenaAllocator>(client_allocator));
162679 return *stored_allocators.back();
162680}
vector< unique_ptr< ArenaAllocator > > stored_allocators
Allocator pool.
Definition duckdb.cpp:161016

◆ Combine()

void duckdb::GlobalUngroupedAggregateState::Combine ( LocalUngroupedAggregateState & other)
162682 {
162683 lock_guard<mutex> glock(lock);
162684 for (idx_t aggr_idx = 0; aggr_idx < state.aggregate_expressions.size(); aggr_idx++) {
162685 auto &aggregate = state.aggregate_expressions[aggr_idx]->Cast<BoundAggregateExpression>();
162686
162687 if (aggregate.IsDistinct()) {
162688 continue;
162689 }
162690
162691 Vector source_state(Value::POINTER(CastPointerToValue(other.state.aggregate_data[aggr_idx].get())));
162692 Vector dest_state(Value::POINTER(CastPointerToValue(state.aggregate_data[aggr_idx].get())));
162693
162694 AggregateInputData aggr_input_data(aggregate.bind_info.get(), allocator,
162695 AggregateCombineType::ALLOW_DESTRUCTIVE);
162696 if (!aggregate.function.HasStateCombineCallback()) {
162697 throw InternalException("Aggregate function " + aggregate.function.name +
162698 " does not support combining of states");
162699 }
162700 aggregate.function.GetStateCombineCallback()(source_state, dest_state, aggr_input_data, 1);
162701#ifdef DEBUG
162702 state.counts[aggr_idx] += other.state.counts[aggr_idx];
162703#endif
162704 }
162705}
static DUCKDB_API Value POINTER(uintptr_t value)
Create a pointer Value from a specified value.
Definition duckdb.cpp:132331
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ CombineDistinct()

void duckdb::GlobalUngroupedAggregateState::CombineDistinct ( LocalUngroupedAggregateState & other,
DistinctAggregateData & distinct_data )
162708 {
162709 lock_guard<mutex> glock(lock);
162710 for (idx_t aggr_idx = 0; aggr_idx < state.aggregate_expressions.size(); aggr_idx++) {
162711 if (!distinct_data.IsDistinct(aggr_idx)) {
162712 continue;
162713 }
162714
162715 auto &aggregate = state.aggregate_expressions[aggr_idx]->Cast<BoundAggregateExpression>();
162716 AggregateInputData aggr_input_data(aggregate.bind_info.get(), allocator,
162717 AggregateCombineType::ALLOW_DESTRUCTIVE);
162718
162719 Vector state_vec(Value::POINTER(CastPointerToValue(other.state.aggregate_data[aggr_idx].get())));
162720 Vector combined_vec(Value::POINTER(CastPointerToValue(state.aggregate_data[aggr_idx].get())));
162721 if (!aggregate.function.HasStateCombineCallback()) {
162722 throw InternalException("Aggregate function " + aggregate.function.name +
162723 " does not support combining of states");
162724 }
162725 aggregate.function.GetStateCombineCallback()(state_vec, combined_vec, aggr_input_data, 1);
162726#ifdef DEBUG
162727 state.counts[aggr_idx] += other.state.counts[aggr_idx];
162728#endif
162729 }
162730}

◆ Finalize()

void duckdb::GlobalUngroupedAggregateState::Finalize ( DataChunk & result,
idx_t column_offset = 0 )
163226 {
163227 result.SetCardinality(1);
163228 for (idx_t aggr_idx = 0; aggr_idx < state.aggregate_expressions.size(); aggr_idx++) {
163229 auto &aggregate = state.aggregate_expressions[aggr_idx]->Cast<BoundAggregateExpression>();
163230
163231 Vector state_vector(Value::POINTER(CastPointerToValue(state.aggregate_data[aggr_idx].get())));
163232 AggregateInputData aggr_input_data(aggregate.bind_info.get(), allocator);
163233 aggregate.function.GetStateFinalizeCallback()(state_vector, aggr_input_data,
163234 result.data[column_offset + aggr_idx], 1, 0);
163235 }
163236}

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