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

Public Member Functions

 WindowAggregateExecutor (BoundWindowExpression &wexpr, ClientContext &client, WindowSharedExpressions &shared, WindowAggregationMode mode)
void Sink (ExecutionContext &context, DataChunk &sink_chunk, DataChunk &coll_chunk, const idx_t input_idx, OperatorSinkInput &sink) const override
void Finalize (ExecutionContext &context, CollectionPtr collection, OperatorSinkInput &sink) const override
unique_ptr< GlobalSinkState > GetGlobalState (ClientContext &client, const idx_t payload_count, const ValidityMask &partition_mask, const ValidityMask &order_mask) const override
unique_ptr< LocalSinkState > GetLocalState (ExecutionContext &context, const GlobalSinkState &gstate) const override
Public Member Functions inherited from duckdb::WindowExecutor
 WindowExecutor (BoundWindowExpression &wexpr, WindowSharedExpressions &shared)
virtual bool IgnoreNulls () const
void Evaluate (ExecutionContext &context, idx_t row_idx, DataChunk &eval_chunk, Vector &result, OperatorSinkInput &sink) const

Public Attributes

const WindowAggregationMode mode
unique_ptr< WindowAggregator > aggregator
unique_ptr< Expression > filter_ref
Public Attributes inherited from duckdb::WindowExecutor
const BoundWindowExpression & wexpr
column_t boundary_start_idx = DConstants::INVALID_INDEX
column_t boundary_end_idx = DConstants::INVALID_INDEX
optional_ptr< Expression > range_expr
column_t range_idx = DConstants::INVALID_INDEX

Protected Member Functions

void EvaluateInternal (ExecutionContext &context, DataChunk &eval_chunk, Vector &result, idx_t count, idx_t row_idx, OperatorSinkInput &sink) const override

Additional Inherited Members

Public Types inherited from duckdb::WindowExecutor
using CollectionPtr = optional_ptr<WindowCollection>

Constructor & Destructor Documentation

◆ WindowAggregateExecutor()

duckdb::WindowAggregateExecutor::WindowAggregateExecutor ( BoundWindowExpression & wexpr,
ClientContext & client,
WindowSharedExpressions & shared,
WindowAggregationMode mode )
253240 : WindowExecutor(SimplifyWindowedAggregate(wexpr, client), shared), mode(mode) {
253241 // Force naive for SEPARATE mode or for (currently!) unsupported functionality
253242 if (!ClientConfig::GetConfig(client).enable_optimizer || mode == WindowAggregationMode::SEPARATE) {
253243 if (!WindowNaiveAggregator::CanAggregate(wexpr)) {
253244 throw InvalidInputException("Cannot use non-aggregate window function with naive window executor!");
253245 }
253246 aggregator = make_uniq<WindowNaiveAggregator>(*this, shared);
253247 } else if (WindowDistinctAggregator::CanAggregate(wexpr)) {
253248 // build a merge sort tree
253249 // see https://dl.acm.org/doi/pdf/10.1145/3514221.3526184
253250 aggregator = make_uniq<WindowDistinctAggregator>(wexpr, shared, client);
253251 } else if (WindowConstantAggregator::CanAggregate(wexpr)) {
253252 aggregator = make_uniq<WindowConstantAggregator>(wexpr, shared, client);
253253 } else if (WindowCustomAggregator::CanAggregate(wexpr, mode)) {
253254 aggregator = make_uniq<WindowCustomAggregator>(wexpr, shared);
253255 } else if (WindowSegmentTree::CanAggregate(wexpr)) {
253256 // build a segment tree for frame-adhering aggregates
253257 // see http://www.vldb.org/pvldb/vol8/p1058-leis.pdf
253258 aggregator = make_uniq<WindowSegmentTree>(wexpr, shared);
253259 } else if (WindowNaiveAggregator::CanAggregate(wexpr)) {
253260 // No accelerator can handle this combination, so fall back to naïve.
253261 aggregator = make_uniq<WindowNaiveAggregator>(*this, shared);
253262 } else {
253263 // This shouldn't happen, if we get here, the binder messed up
253264 // Non-aggregate window functions that can't be handled by the WindowCustomAggregator due to e.g. a ORDER BY
253265 // clause should have been caught in the binder.
253266 throw InternalException("Could not create a window aggregator with the given parameters!");
253267 }
253268
253269 // Compute the FILTER with the other eval columns.
253270 // Anyone who needs it can then convert it to the form they need.
253271 if (wexpr.filter_expr) {
253272 const auto filter_idx = shared.RegisterSink(wexpr.filter_expr);
253273 filter_ref = make_uniq<BoundReferenceExpression>(wexpr.filter_expr->return_type, filter_idx);
253274 }
253275}
@ SEPARATE
Don't use combine or window (compute each frame separately).
Definition duckdb.cpp:52968

Member Function Documentation

◆ Sink()

void duckdb::WindowAggregateExecutor::Sink ( ExecutionContext & context,
DataChunk & sink_chunk,
DataChunk & coll_chunk,
const idx_t input_idx,
OperatorSinkInput & sink ) const
overridevirtual

Reimplemented from duckdb::WindowExecutor.

253325 {
253326 auto &gastate = sink.global_state.Cast<WindowAggregateExecutorGlobalState>();
253327 auto &lastate = sink.local_state.Cast<WindowAggregateExecutorLocalState>();
253328 auto &filter_sel = lastate.filter_sel;
253329 auto &filter_executor = lastate.filter_executor;
253330
253331 idx_t filtered = 0;
253332 SelectionVector *filtering = nullptr;
253333 if (gastate.filter_ref) {
253334 filtering = &filter_sel;
253335 filtered = filter_executor.SelectExpression(sink_chunk, filter_sel);
253336 }
253337
253338 D_ASSERT(aggregator);
253339 OperatorSinkInput asink {*gastate.gsink, *lastate.aggregator_state, sink.interrupt_state};
253340 aggregator->Sink(context, sink_chunk, coll_chunk, input_idx, filtering, filtered, asink);
253341
253342 WindowExecutor::Sink(context, sink_chunk, coll_chunk, input_idx, sink);
253343}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ Finalize()

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

Reimplemented from duckdb::WindowExecutor.

253409 {
253410 WindowExecutor::Finalize(context, collection, sink);
253411
253412 auto &gastate = sink.global_state.Cast<WindowAggregateExecutorGlobalState>();
253413 auto &gsink = gastate.gsink;
253414 D_ASSERT(aggregator);
253415
253416 // Estimate the frame statistics
253417 // Default to the entire partition if we don't know anything
253418 FrameStats stats;
253419 const auto count = NumericCast<int64_t>(gastate.payload_count);
253420
253421 // First entry is the frame start
253422 stats[0] = FrameDelta(-count, count);
253423 auto base = wexpr.expr_stats.empty() ? nullptr : wexpr.expr_stats[0].get();
253424 ApplyWindowStats(wexpr.start, stats[0], base, true);
253425
253426 // Second entry is the frame end
253427 stats[1] = FrameDelta(-count, count);
253428 base = wexpr.expr_stats.empty() ? nullptr : wexpr.expr_stats[1].get();
253429 ApplyWindowStats(wexpr.end, stats[1], base, false);
253430
253431 auto &lastate = sink.local_state.Cast<WindowAggregateExecutorLocalState>();
253432 OperatorSinkInput asink {*gsink, *lastate.aggregator_state, sink.interrupt_state};
253433 aggregator->Finalize(context, collection, stats, asink);
253434}
array< FrameDelta, 2 > FrameStats
The half-open ranges of frame boundary values relative to the current row.
Definition duckdb.hpp:17975

◆ GetGlobalState()

unique_ptr< GlobalSinkState > duckdb::WindowAggregateExecutor::GetGlobalState ( ClientContext & client,
const idx_t payload_count,
const ValidityMask & partition_mask,
const ValidityMask & order_mask ) const
overridevirtual

Reimplemented from duckdb::WindowExecutor.

253289 {
253290 return make_uniq<WindowAggregateExecutorGlobalState>(client, *this, payload_count, partition_mask, order_mask);
253291}

◆ GetLocalState()

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

Reimplemented from duckdb::WindowExecutor.

253320 {
253321 return make_uniq<WindowAggregateExecutorLocalState>(context, gstate, *aggregator);
253322}

◆ EvaluateInternal()

void duckdb::WindowAggregateExecutor::EvaluateInternal ( ExecutionContext & context,
DataChunk & eval_chunk,
Vector & result,
idx_t count,
idx_t row_idx,
OperatorSinkInput & sink ) const
overrideprotectedvirtual

Implements duckdb::WindowExecutor.

253437 {
253438 auto &gastate = sink.global_state.Cast<WindowAggregateExecutorGlobalState>();
253439 auto &lastate = sink.local_state.Cast<WindowAggregateExecutorLocalState>();
253440 auto &gsink = gastate.gsink;
253441 D_ASSERT(aggregator);
253442
253443 OperatorSinkInput asink {*gsink, *lastate.aggregator_state, sink.interrupt_state};
253444 aggregator->Evaluate(context, lastate.bounds, result, count, row_idx, asink);
253445}

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