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

Public Member Functions

 WindowCustomAggregator (const BoundWindowExpression &wexpr, WindowSharedExpressions &shared)
unique_ptr< GlobalSinkState > GetGlobalState (ClientContext &context, idx_t group_count, const ValidityMask &partition_mask) const override
void Finalize (ExecutionContext &context, CollectionPtr collection, const FrameStats &stats, OperatorSinkInput &sink) override
unique_ptr< LocalSinkState > GetLocalState (ExecutionContext &context, const GlobalSinkState &gstate) const override
void Evaluate (ExecutionContext &context, const DataChunk &bounds, Vector &result, idx_t count, idx_t row_idx, OperatorSinkInput &sink) const override
Public Member Functions inherited from duckdb::WindowAggregator
 WindowAggregator (const BoundWindowExpression &wexpr)
 WindowAggregator (const BoundWindowExpression &wexpr, WindowSharedExpressions &shared)
virtual void Sink (ExecutionContext &context, DataChunk &sink_chunk, DataChunk &coll_chunk, idx_t input_idx, optional_ptr< SelectionVector > filter_sel, idx_t filtered, OperatorSinkInput &sink)

Static Public Member Functions

static bool CanAggregate (const BoundWindowExpression &wexpr, WindowAggregationMode mode)
Static Public Member Functions inherited from duckdb::WindowAggregator
template<typename OP>
static void EvaluateSubFrames (const DataChunk &bounds, const WindowExcludeMode exclude_mode, idx_t count, idx_t row_idx, SubFrames &frames, OP operation)

Additional Inherited Members

Public Types inherited from duckdb::WindowAggregator
using CollectionPtr = optional_ptr<WindowCollection>
Public Attributes inherited from duckdb::WindowAggregator
const BoundWindowExpression & wexpr
 The window function.
const AggregateObject aggr
 A description of the aggregator.
vector< LogicalType > arg_types
 The argument types for the function.
const LogicalType result_type
 The result type of the window function.
const idx_t state_size
 The size of a single aggregate state.
const WindowExcludeMode exclude_mode
 The window exclusion clause.
vector< column_t > child_idx
 Partition collection column indicies.

Constructor & Destructor Documentation

◆ WindowCustomAggregator()

duckdb::WindowCustomAggregator::WindowCustomAggregator ( const BoundWindowExpression & wexpr,
WindowSharedExpressions & shared )
255285 : WindowAggregator(wexpr, shared) {
255286}
const BoundWindowExpression & wexpr
The window function.
Definition duckdb.cpp:164034

◆ ~WindowCustomAggregator()

duckdb::WindowCustomAggregator::~WindowCustomAggregator ( )
override
255288 {
255289}

Member Function Documentation

◆ CanAggregate()

bool duckdb::WindowCustomAggregator::CanAggregate ( const BoundWindowExpression & wexpr,
WindowAggregationMode mode )
static
255267 {
255268 if (!wexpr.aggregate) {
255269 return false;
255270 }
255271
255272 if (!wexpr.aggregate->CanWindow()) {
255273 return false;
255274 }
255275
255276 // ORDER BY arguments are not currently supported
255277 if (!wexpr.arg_orders.empty()) {
255278 return false;
255279 }
255280
255281 return (mode < WindowAggregationMode::COMBINE);
255282}
@ COMBINE
Don't use window, but use combine if available.
Definition duckdb.cpp:52966

◆ GetGlobalState()

unique_ptr< GlobalSinkState > duckdb::WindowCustomAggregator::GetGlobalState ( ClientContext & context,
idx_t group_count,
const ValidityMask & partition_mask ) const
overridevirtual

Reimplemented from duckdb::WindowAggregator.

255348 {
255349 return make_uniq<WindowCustomAggregatorGlobalState>(context, *this, group_count);
255350}

◆ Finalize()

void duckdb::WindowCustomAggregator::Finalize ( ExecutionContext & context,
CollectionPtr collection,
const FrameStats & stats,
OperatorSinkInput & sink )
overridevirtual

Reimplemented from duckdb::WindowAggregator.

255353 {
255354 // Single threaded Finalize for now
255355 auto &gcsink = sink.global_state.Cast<WindowCustomAggregatorGlobalState>();
255356 lock_guard<mutex> gestate_guard(gcsink.lock);
255357 if (gcsink.finalized) {
255358 return;
255359 }
255360
255361 WindowAggregator::Finalize(context, collection, stats, sink);
255362
255363 gcsink.collection = collection;
255364 auto inputs = collection->inputs.get();
255365 const auto count = collection->size();
255366 auto &all_valids = gcsink.all_valids;
255367 for (auto col_idx : child_idx) {
255368 all_valids.push_back(collection->all_valids[col_idx]);
255369 }
255370 auto &filter_mask = gcsink.filter_mask;
255371 auto &filter_packed = gcsink.filter_packed;
255372 filter_mask.Pack(filter_packed, filter_mask.Capacity());
255373 gcsink.glstate = GetLocalState(context, gcsink);
255374
255375 if (aggr.function.HasWindowInitCallback()) {
255376 auto &gcstate = gcsink.glstate->Cast<WindowCustomAggregatorLocalState>();
255377 WindowPartitionInput partition(context, inputs, count, child_idx, all_valids, filter_packed, stats,
255378 sink.interrupt_state);
255379
255380 AggregateInputData aggr_input_data(aggr.GetFunctionData(), gcstate.allocator);
255381 aggr.function.GetWindowInitCallback()(aggr_input_data, partition, gcstate.state.data());
255382 }
255383
255384 ++gcsink.finalized;
255385}
vector< column_t > child_idx
Partition collection column indicies.
Definition duckdb.cpp:164046
const AggregateObject aggr
A description of the aggregator.
Definition duckdb.cpp:164036
int partition(const std::vector< _Tp > &_vec, std::vector< int > &labels, _EqPredicate predicate=_EqPredicate())

◆ GetLocalState()

unique_ptr< LocalSinkState > duckdb::WindowCustomAggregator::GetLocalState ( ExecutionContext & context,
const GlobalSinkState & gstate ) const
overridevirtual

Implements duckdb::WindowAggregator.

255388 {
255389 return make_uniq<WindowCustomAggregatorLocalState>(context, aggr, exclude_mode);
255390}
const WindowExcludeMode exclude_mode
The window exclusion clause.
Definition duckdb.cpp:164044

◆ Evaluate()

void duckdb::WindowCustomAggregator::Evaluate ( ExecutionContext & context,
const DataChunk & bounds,
Vector & result,
idx_t count,
idx_t row_idx,
OperatorSinkInput & sink ) const
overridevirtual

Implements duckdb::WindowAggregator.

255393 {
255394 auto &lcstate = sink.local_state.Cast<WindowCustomAggregatorLocalState>();
255395 auto &frames = lcstate.frames;
255396 const_data_ptr_t gstate_p = nullptr;
255397 auto &gcsink = sink.global_state.Cast<WindowCustomAggregatorGlobalState>();
255398 if (gcsink.glstate) {
255399 auto &gcstate = gcsink.glstate->Cast<WindowCustomAggregatorLocalState>();
255400 gstate_p = gcstate.state.data();
255401 }
255402
255403 auto collection = gcsink.collection;
255404 auto inputs = collection->inputs.get();
255405 auto &all_valids = gcsink.all_valids;
255406 auto &filter_packed = gcsink.filter_packed;
255407 auto &stats = gcsink.stats;
255408 WindowPartitionInput partition(context, inputs, collection->size(), child_idx, all_valids, filter_packed, stats,
255409 sink.interrupt_state);
255410 EvaluateSubFrames(bounds, exclude_mode, count, row_idx, frames, [&](idx_t i) {
255411 // Extract the range
255412 AggregateInputData aggr_input_data(aggr.GetFunctionData(), lcstate.allocator);
255413 aggr.function.GetWindowCallback()(aggr_input_data, partition, gstate_p, lcstate.state.data(), frames, result,
255414 i);
255415 });
255416}
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: