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

Public Member Functions

 WindowLastValueExecutor (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

◆ WindowLastValueExecutor()

duckdb::WindowLastValueExecutor::WindowLastValueExecutor ( BoundWindowExpression & wexpr,
WindowSharedExpressions & shared )
258865 : WindowValueExecutor(wexpr, shared) {
258866}

Member Function Documentation

◆ EvaluateInternal()

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

Implements duckdb::WindowExecutor.

258869 {
258870 auto &gvstate = sink.global_state.Cast<WindowValueGlobalState>();
258871 auto &lvstate = sink.local_state.Cast<WindowValueLocalState>();
258872 auto &cursor = *lvstate.cursor;
258873 auto &bounds = lvstate.bounds;
258874 auto &frames = lvstate.frames;
258875 auto &ignore_nulls = *gvstate.ignore_nulls;
258876 auto exclude_mode = gvstate.executor.wexpr.exclude_clause;
258877 WindowAggregator::EvaluateSubFrames(bounds, exclude_mode, count, row_idx, frames, [&](idx_t i) {
258878 if (gvstate.value_tree) {
258879 idx_t frame_width = 0;
258880 for (const auto &frame : frames) {
258881 frame_width += frame.end - frame.start;
258882 }
258883
258884 if (frame_width) {
258885 auto n = frame_width - 1;
258886 auto last_idx = gvstate.value_tree->SelectNth(frames, n);
258887 if (last_idx.second && last_idx.second <= n) {
258888 // Frame larger than data. Since we want last, we back off by the overflow
258889 n -= last_idx.second;
258890 last_idx = gvstate.value_tree->SelectNth(frames, n);
258891 }
258892 if (last_idx.second || last_idx.first >= cursor.Count()) {
258893 // No last value - give up.
258894 FlatVector::SetNull(result, i, true);
258895 } else {
258896 cursor.CopyCell(0, last_idx.first, result, i);
258897 }
258898 } else {
258899 FlatVector::SetNull(result, i, true);
258900 }
258901 return;
258902 }
258903
258904 for (idx_t f = frames.size(); f-- > 0;) {
258905 const auto &frame = frames[f];
258906 if (frame.start >= frame.end) {
258907 continue;
258908 }
258909
258910 idx_t n = 1;
258911 const auto last_idx = WindowBoundariesState::FindPrevStart(ignore_nulls, frame.start, frame.end, n);
258912 if (!n) {
258913 cursor.CopyCell(0, last_idx, result, i);
258914 return;
258915 }
258916 }
258917
258918 // Didn't find one
258919 FlatVector::SetNull(result, i, true);
258920 });
258921}
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: