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

Public Member Functions

 WindowNthValueExecutor (BoundWindowExpression &wexpr, WindowSharedExpressions &shared)
Public Member Functions inherited from duckdb::WindowValueExecutor
 WindowValueExecutor (BoundWindowExpression &wexpr, WindowSharedExpressions &shared)
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
virtual void Sink (ExecutionContext &context, DataChunk &sink_chunk, DataChunk &coll_chunk, const idx_t input_idx, OperatorSinkInput &sink) const
void Evaluate (ExecutionContext &context, idx_t row_idx, DataChunk &eval_chunk, Vector &result, OperatorSinkInput &sink) const

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>
Public Attributes inherited from duckdb::WindowValueExecutor
column_t child_idx = DConstants::INVALID_INDEX
 The column index of the value column.
column_t nth_idx = DConstants::INVALID_INDEX
 The column index of the Nth column.
column_t offset_idx = DConstants::INVALID_INDEX
 The column index of the offset column.
column_t default_idx = DConstants::INVALID_INDEX
 The column index of the default value column.
vector< column_t > arg_order_idx
 The column indices of any ORDER BY argument expressions.
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

Constructor & Destructor Documentation

◆ WindowNthValueExecutor()

duckdb::WindowNthValueExecutor::WindowNthValueExecutor ( BoundWindowExpression & wexpr,
WindowSharedExpressions & shared )
258924 : WindowValueExecutor(wexpr, shared) {
258925}

Member Function Documentation

◆ EvaluateInternal()

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

Implements duckdb::WindowExecutor.

258928 {
258929 auto &gvstate = sink.global_state.Cast<WindowValueGlobalState>();
258930 auto &lvstate = sink.local_state.Cast<WindowValueLocalState>();
258931 auto &cursor = *lvstate.cursor;
258932 auto &bounds = lvstate.bounds;
258933 auto &frames = lvstate.frames;
258934 auto &ignore_nulls = *gvstate.ignore_nulls;
258935 auto exclude_mode = gvstate.executor.wexpr.exclude_clause;
258936 D_ASSERT(cursor.chunk.ColumnCount() == 1);
258937 WindowInputExpression nth_col(eval_chunk, nth_idx);
258938 WindowAggregator::EvaluateSubFrames(bounds, exclude_mode, count, row_idx, frames, [&](idx_t i) {
258939 // Returns value evaluated at the row that is the n'th row of the window frame (counting from 1);
258940 // returns NULL if there is no such row.
258941 if (nth_col.CellIsNull(i)) {
258942 FlatVector::SetNull(result, i, true);
258943 return;
258944 }
258945 auto n_param = nth_col.GetCell<int64_t>(i);
258946 if (n_param < 1) {
258947 FlatVector::SetNull(result, i, true);
258948 return;
258949 }
258950
258951 // Decrement as we go along.
258952 auto n = idx_t(n_param);
258953
258954 if (gvstate.value_tree) {
258955 idx_t frame_width = 0;
258956 for (const auto &frame : frames) {
258957 frame_width += frame.end - frame.start;
258958 }
258959
258960 if (--n < frame_width) {
258961 const auto nth_index = gvstate.value_tree->SelectNth(frames, n);
258962 if (nth_index.second || nth_index.first >= cursor.Count()) {
258963 // Past end of frame
258964 FlatVector::SetNull(result, i, true);
258965 } else {
258966 cursor.CopyCell(0, nth_index.first, result, i);
258967 }
258968 } else {
258969 FlatVector::SetNull(result, i, true);
258970 }
258971 return;
258972 }
258973
258974 for (const auto &frame : frames) {
258975 if (frame.start >= frame.end) {
258976 continue;
258977 }
258978
258979 const auto nth_index = WindowBoundariesState::FindNextStart(ignore_nulls, frame.start, frame.end, n);
258980 if (!n) {
258981 cursor.CopyCell(0, nth_index, result, i);
258982 return;
258983 }
258984 }
258985 FlatVector::SetNull(result, i, true);
258986 });
258987}
column_t nth_idx
The column index of the Nth column.
Definition duckdb.cpp:164348
::int64_t int64_t
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: