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

Public Member Functions

 UngroupedDistinctAggregateFinalizeTask (Executor &executor, shared_ptr< Event > event_p, const PhysicalUngroupedAggregate &op, UngroupedAggregateGlobalSinkState &state_p)
TaskExecutionResult ExecuteTask (TaskExecutionMode mode) override
string TaskType () const override
Public Member Functions inherited from duckdb::ExecutorTask
 ExecutorTask (Executor &executor, shared_ptr< Event > event)
 ExecutorTask (ClientContext &context, shared_ptr< Event > event, const PhysicalOperator &op)
void Deschedule () override
void Reschedule () override
 Ensures a task is rescheduled to the correct queue.
TaskExecutionResult Execute (TaskExecutionMode mode) override
Public Member Functions inherited from duckdb::Task
virtual bool TaskBlockedOnResult () const
Public Member Functions inherited from duckdb::enable_shared_from_this< Task >
shared_ptr< Task > shared_from_this ()

Private Member Functions

TaskExecutionResult AggregateDistinct ()

Private Attributes

const PhysicalUngroupedAggregate & op
UngroupedAggregateGlobalSinkState & gstate
LocalUngroupedAggregateState aggregate_state
idx_t aggregation_idx = 0
unique_ptr< LocalSourceState > radix_table_lstate
bool blocked = false

Additional Inherited Members

Public Attributes inherited from duckdb::ExecutorTask
Executor & executor
shared_ptr< Event > event
unique_ptr< ThreadContext > thread_context
optional_ptr< const PhysicalOperator > op
Public Attributes inherited from duckdb::Task
optional_ptr< ProducerToken > token
Protected Member Functions inherited from duckdb::enable_shared_from_this< Task >
enable_shared_from_this & operator= (enable_shared_from_this const &) noexcept

Constructor & Destructor Documentation

◆ UngroupedDistinctAggregateFinalizeTask()

duckdb::UngroupedDistinctAggregateFinalizeTask::UngroupedDistinctAggregateFinalizeTask ( Executor & executor,
shared_ptr< Event > event_p,
const PhysicalUngroupedAggregate & op,
UngroupedAggregateGlobalSinkState & state_p )
inline
163029 : ExecutorTask(executor, std::move(event_p)), op(op), gstate(state_p), aggregate_state(gstate.state) {
163030 }

Member Function Documentation

◆ ExecuteTask()

TaskExecutionResult duckdb::UngroupedDistinctAggregateFinalizeTask::ExecuteTask ( TaskExecutionMode mode)
overridevirtual

Implements duckdb::ExecutorTask.

163092 {
163093 auto res = AggregateDistinct();
163094 if (res == TaskExecutionResult::TASK_BLOCKED) {
163095 return res;
163096 }
163097 event->FinishTask();
163098 return TaskExecutionResult::TASK_FINISHED;
163099}

◆ TaskType()

string duckdb::UngroupedDistinctAggregateFinalizeTask::TaskType ( ) const
inlineoverridevirtual

Reimplemented from duckdb::Task.

163034 {
163035 return "UngroupedDistinctAggregateFinalizeTask";
163036 }

◆ AggregateDistinct()

TaskExecutionResult duckdb::UngroupedDistinctAggregateFinalizeTask::AggregateDistinct ( )
private
163101 {
163102 D_ASSERT(gstate.distinct_state);
163103 auto &distinct_state = *gstate.distinct_state;
163104 auto &distinct_data = *op.distinct_data;
163105
163106 auto &aggregates = op.aggregates;
163107 auto &state = aggregate_state;
163108
163109 // Thread-local contexts
163110 ThreadContext thread_context(executor.context);
163111 ExecutionContext execution_context(executor.context, thread_context, nullptr);
163112
163113 auto &finalize_event = event->Cast<UngroupedDistinctAggregateFinalizeEvent>();
163114
163115 // Now loop through the distinct aggregates, scanning the distinct HTs
163116
163117 // This needs to be preserved in case the radix_table.GetData blocks
163118 auto &agg_idx = aggregation_idx;
163119
163120 for (; agg_idx < aggregates.size(); agg_idx++) {
163121 auto &aggregate = aggregates[agg_idx]->Cast<BoundAggregateExpression>();
163122
163123 // If aggregate is not distinct, skip it
163124 if (!distinct_data.IsDistinct(agg_idx)) {
163125 continue;
163126 }
163127
163128 const auto table_idx = distinct_data.info.table_map.at(agg_idx);
163129 auto &radix_table = *distinct_data.radix_tables[table_idx];
163130 if (!blocked) {
163131 // Because we can block, we need to make sure we preserve this state
163132 radix_table_lstate = radix_table.GetLocalSourceState(execution_context);
163133 }
163134 auto &lstate = *radix_table_lstate;
163135
163136 auto &sink = *distinct_state.radix_states[table_idx];
163137 InterruptState interrupt_state(shared_from_this());
163138 OperatorSourceInput source_input {*finalize_event.global_source_states[agg_idx], lstate, interrupt_state};
163139
163140 DataChunk output_chunk;
163141 output_chunk.Initialize(executor.context, distinct_state.distinct_output_chunks[table_idx]->GetTypes());
163142
163143 DataChunk payload_chunk;
163144 payload_chunk.InitializeEmpty(distinct_data.grouped_aggregate_data[table_idx]->group_types);
163145 payload_chunk.SetCardinality(0);
163146
163147 while (true) {
163148 output_chunk.Reset();
163149
163150 auto res = radix_table.GetData(execution_context, output_chunk, sink, source_input);
163151 if (res == SourceResultType::FINISHED) {
163152 D_ASSERT(output_chunk.size() == 0);
163153 break;
163154 } else if (res == SourceResultType::BLOCKED) {
163155 blocked = true;
163156 return TaskExecutionResult::TASK_BLOCKED;
163157 }
163158
163159 // We dont need to resolve the filter, we already did this in Sink
163160 idx_t payload_cnt = aggregate.children.size();
163161 for (idx_t i = 0; i < payload_cnt; i++) {
163162 payload_chunk.data[i].Reference(output_chunk.data[i]);
163163 }
163164 payload_chunk.SetCardinality(output_chunk);
163165
163166 // Update the aggregate state
163167 state.Sink(payload_chunk, 0, agg_idx);
163168 }
163169 blocked = false;
163170 }
163171
163172 // After scanning the distinct HTs, we can combine the thread-local agg states with the thread-global
163173 gstate.state.CombineDistinct(state, distinct_data);
163174 finalize_event.FinalizeTask();
163175 return TaskExecutionResult::TASK_FINISHED;
163176}
DUCKDB_API void InitializeEmpty(const vector< LogicalType > &types)
Initializes a DataChunk with the given types and without any vector data allocation.
Definition duckdb.cpp:116783
DUCKDB_API void Reset()
Definition duckdb.cpp:116840
DUCKDB_API void Initialize(ClientContext &context, const vector< LogicalType > &types, idx_t capacity=STANDARD_VECTOR_SIZE)
Definition duckdb.cpp:116791
vector< Vector > data
The vectors owned by the DataChunk.
Definition duckdb.hpp:11445
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

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