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

Public Member Functions

 WindowConstantAggregatorLocalState (ExecutionContext &context, const WindowConstantAggregatorGlobalState &gstate)
void Sink (ExecutionContext &context, DataChunk &sink_chunk, DataChunk &coll_chunk, idx_t input_idx, optional_ptr< SelectionVector > filter_sel, idx_t filtered)
void Combine (WindowConstantAggregatorGlobalState &gstate)
Public Member Functions inherited from duckdb::WindowAggregatorLocalState
 WindowAggregatorLocalState (ExecutionContext &context)
void Sink (ExecutionContext &context, WindowAggregatorGlobalState &gastate, DataChunk &sink_chunk, DataChunk &coll_chunk, idx_t row_idx)
virtual void Finalize (ExecutionContext &context, WindowAggregatorGlobalState &gastate, CollectionPtr collection)
Public Member Functions inherited from duckdb::LocalSinkState
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const

Public Attributes

const WindowConstantAggregatorGlobalState & gstate
 The global state we are sharing.
DataChunk inputs
 Reusable chunk for sinking.
DataChunk payload_chunk
 Chunk for referencing the input columns.
Vector statep
 A vector of pointers to "state", used for intermediate window segment aggregation.
WindowAggregateStates statef
 Reused result state container for the window functions.
idx_t partition
 The current result partition being read.
SelectionVector matches
 Shared SV for evaluation.
Public Attributes inherited from duckdb::WindowAggregatorLocalState
ArenaAllocator allocator
 Global allocator.
unique_ptr< WindowCursor > cursor
 The state used for reading the collection.
Public Attributes inherited from duckdb::LocalSinkState
SourcePartitionInfo partition_info
 Source partition info.

Additional Inherited Members

Public Types inherited from duckdb::WindowAggregatorLocalState
using CollectionPtr = optional_ptr<WindowCollection>
Static Public Member Functions inherited from duckdb::WindowAggregatorLocalState
static void InitSubFrames (SubFrames &frames, const WindowExcludeMode exclude_mode)

Constructor & Destructor Documentation

◆ WindowConstantAggregatorLocalState()

duckdb::WindowConstantAggregatorLocalState::WindowConstantAggregatorLocalState ( ExecutionContext & context,
const WindowConstantAggregatorGlobalState & gstate )
254996 : WindowAggregatorLocalState(context), gstate(gstate), statep(Value::POINTER(0)),
254997 statef(context.client, gstate.statef.aggr), partition(0) {
254998 matches.Initialize();
254999
255000 // Start the aggregates
255001 auto &partition_offsets = gstate.partition_offsets;
255002 auto &aggregator = gstate.aggregator;
255003 statef.Initialize(partition_offsets.size() - 1);
255004
255005 // Set up shared buffer
255006 inputs.Initialize(context.client, aggregator.arg_types);
255007 payload_chunk.InitializeEmpty(inputs.GetTypes());
255008
255009 gstate.locals++;
255010}
static DUCKDB_API Value POINTER(uintptr_t value)
Create a pointer Value from a specified value.
Definition duckdb.cpp:132331
idx_t partition
The current result partition being read.
Definition duckdb.cpp:254989
DataChunk payload_chunk
Chunk for referencing the input columns.
Definition duckdb.cpp:254983
DataChunk inputs
Reusable chunk for sinking.
Definition duckdb.cpp:254981
SelectionVector matches
Shared SV for evaluation.
Definition duckdb.cpp:254991
Vector statep
A vector of pointers to "state", used for intermediate window segment aggregation.
Definition duckdb.cpp:254985
const WindowConstantAggregatorGlobalState & gstate
The global state we are sharing.
Definition duckdb.cpp:254979
WindowAggregateStates statef
Reused result state container for the window functions.
Definition duckdb.cpp:254987

◆ ~WindowConstantAggregatorLocalState()

duckdb::WindowConstantAggregatorLocalState::~WindowConstantAggregatorLocalState ( )
inlineoverride
254970 {
254971 }

Member Function Documentation

◆ Sink()

void duckdb::WindowConstantAggregatorLocalState::Sink ( ExecutionContext & context,
DataChunk & sink_chunk,
DataChunk & coll_chunk,
idx_t input_idx,
optional_ptr< SelectionVector > filter_sel,
idx_t filtered )
255113 {
255114 auto &partition_offsets = gstate.partition_offsets;
255115 const auto &aggr = gstate.aggr;
255116 const auto chunk_begin = row;
255117 const auto chunk_end = chunk_begin + sink_chunk.size();
255118 idx_t partition =
255119 idx_t(std::upper_bound(partition_offsets.begin(), partition_offsets.end(), row) - partition_offsets.begin()) -
255120 1;
255121
255122 auto state_f_data = statef.GetData();
255123 auto state_p_data = FlatVector::GetData<data_ptr_t>(statep);
255124
255125 auto &child_idx = gstate.aggregator.child_idx;
255126 for (column_t c = 0; c < child_idx.size(); ++c) {
255127 payload_chunk.data[c].Reference(sink_chunk.data[child_idx[c]]);
255128 }
255129
255130 AggregateInputData aggr_input_data(aggr.GetFunctionData(), statef.allocator);
255131 idx_t begin = 0;
255132 idx_t filter_idx = 0;
255133 auto partition_end = partition_offsets[partition + 1];
255134 while (row < chunk_end) {
255135 if (row == partition_end) {
255136 ++partition;
255137 partition_end = partition_offsets[partition + 1];
255138 }
255139 partition_end = MinValue(partition_end, chunk_end);
255140 auto end = partition_end - chunk_begin;
255141
255142 inputs.Reset();
255143 if (filter_sel) {
255144 // Slice to any filtered rows in [begin, end)
255145 SelectionVector sel;
255146
255147 // Find the first value in [begin, end)
255148 for (; filter_idx < filtered; ++filter_idx) {
255149 auto idx = filter_sel->get_index(filter_idx);
255150 if (idx >= begin) {
255151 break;
255152 }
255153 }
255154
255155 // Find the first value in [end, filtered)
255156 sel.Initialize(filter_sel->data() + filter_idx);
255157 idx_t nsel = 0;
255158 for (; filter_idx < filtered; ++filter_idx, ++nsel) {
255159 auto idx = filter_sel->get_index(filter_idx);
255160 if (idx >= end) {
255161 break;
255162 }
255163 }
255164
255165 if (nsel != inputs.size()) {
255166 inputs.Slice(payload_chunk, sel, nsel);
255167 }
255168 } else {
255169 // Slice to [begin, end)
255170 if (begin) {
255171 for (idx_t c = 0; c < payload_chunk.ColumnCount(); ++c) {
255172 inputs.data[c].Slice(payload_chunk.data[c], begin, end);
255173 }
255174 } else {
255175 inputs.Reference(payload_chunk);
255176 }
255177 inputs.SetCardinality(end - begin);
255178 }
255179
255180 // Aggregate the filtered rows into a single state
255181 const auto count = inputs.size();
255182 auto state = state_f_data[partition];
255183 if (aggr.function.HasStateSimpleUpdateCallback()) {
255184 aggr.function.GetStateSimpleUpdateCallback()(inputs.data.data(), aggr_input_data, inputs.ColumnCount(),
255185 state, count);
255186 } else {
255187 state_p_data[0] = state_f_data[partition];
255188 aggr.function.GetStateUpdateCallback()(inputs.data.data(), aggr_input_data, inputs.ColumnCount(), statep,
255189 count);
255190 }
255191
255192 // Skip filtered rows too!
255193 row += end - begin;
255194 begin = end;
255195 }
255196}
vector< Vector > data
The vectors owned by the DataChunk.
Definition duckdb.hpp:11445
idx_t column_t
Type used for column identifiers.
Definition duckdb.hpp:259
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: