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

Classes

struct  AggregateState
struct  LeadLagState

Public Member Functions

 StreamingWindowState (ClientContext &client)
Value GetFirstValue (ClientContext &client, DataChunk &input, BoundWindowExpression &wexpr) const
void Initialize (ClientContext &context, DataChunk &input, const vector< unique_ptr< Expression > > &expressions)
Public Member Functions inherited from duckdb::OperatorState
virtual void Finalize (const PhysicalOperator &op, ExecutionContext &context)
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const

Static Public Member Functions

static void Reset (DataChunk &chunk)

Public Attributes

bool initialized
 We can't initialise until we have an input chunk.
vector< unique_ptr< Vector > > const_vectors
 The values that are determined by the first row.
vector< unique_ptr< AggregateState > > aggregate_states
 Aggregation states.
Allocator & allocator
vector< unique_ptr< LeadLagState > > lead_lag_states
 Lead/Lag states.
idx_t lead_count = 0
 The number of rows ahead to buffer for LEAD.
DataChunk delayed
 A buffer for delayed input.
DataChunk shifted
 A buffer for shifting delayed input.
SelectionVector sel
 A temporary selection vector.

Constructor & Destructor Documentation

◆ StreamingWindowState()

duckdb::StreamingWindowState::StreamingWindowState ( ClientContext & client)
inlineexplicit
161997 : initialized(false), allocator(Allocator::Get(client)), sel(STANDARD_VECTOR_SIZE) {
161998 }
bool initialized
We can't initialise until we have an input chunk.
Definition duckdb.cpp:162069
SelectionVector sel
A temporary selection vector.
Definition duckdb.cpp:162084

◆ ~StreamingWindowState()

duckdb::StreamingWindowState::~StreamingWindowState ( )
inlineoverride
162000 {
162001 }

Member Function Documentation

◆ GetFirstValue()

Value duckdb::StreamingWindowState::GetFirstValue ( ClientContext & client,
DataChunk & input,
BoundWindowExpression & wexpr ) const
inline
162003 {
162004 // Just execute the expression once
162005 ExpressionExecutor executor(client);
162006 executor.AddExpression(*wexpr.children[0]);
162007 DataChunk result;
162008 result.Initialize(client, {wexpr.children[0]->return_type});
162009 executor.Execute(input, result);
162010
162011 return result.GetValue(0, 0);
162012 }

◆ Initialize()

void duckdb::StreamingWindowState::Initialize ( ClientContext & context,
DataChunk & input,
const vector< unique_ptr< Expression > > & expressions )
inline
162014 {
162015 const_vectors.resize(expressions.size());
162016 aggregate_states.resize(expressions.size());
162017 lead_lag_states.resize(expressions.size());
162018
162019 for (idx_t expr_idx = 0; expr_idx < expressions.size(); expr_idx++) {
162020 auto &expr = *expressions[expr_idx];
162021 auto &wexpr = expr.Cast<BoundWindowExpression>();
162022 switch (expr.GetExpressionType()) {
162023 case ExpressionType::WINDOW_AGGREGATE:
162024 aggregate_states[expr_idx] = make_uniq<AggregateState>(context, wexpr, allocator);
162025 break;
162026 case ExpressionType::WINDOW_FIRST_VALUE:
162027 case ExpressionType::WINDOW_LAST_VALUE:
162028 // Just execute the expression once
162029 const_vectors[expr_idx] = make_uniq<Vector>(GetFirstValue(context, input, wexpr));
162030 break;
162031 case ExpressionType::WINDOW_PERCENT_RANK: {
162032 const_vectors[expr_idx] = make_uniq<Vector>(Value((double)0));
162033 break;
162034 }
162035 case ExpressionType::WINDOW_RANK:
162036 case ExpressionType::WINDOW_RANK_DENSE: {
162037 const_vectors[expr_idx] = make_uniq<Vector>(Value((int64_t)1));
162038 break;
162039 }
162040 case ExpressionType::WINDOW_LAG:
162041 case ExpressionType::WINDOW_LEAD: {
162042 lead_lag_states[expr_idx] = make_uniq<LeadLagState>(context, wexpr);
162043 const auto offset = lead_lag_states[expr_idx]->offset;
162044 if (offset < 0) {
162045 lead_count = MaxValue<idx_t>(idx_t(-offset), lead_count);
162046 }
162047 break;
162048 }
162049 default:
162050 break;
162051 }
162052 }
162053 if (lead_count) {
162054 delayed.Initialize(context, input.GetTypes(), lead_count + STANDARD_VECTOR_SIZE);
162055 shifted.Initialize(context, input.GetTypes(), lead_count + STANDARD_VECTOR_SIZE);
162056 }
162057 initialized = true;
162058 }
DUCKDB_API vector< LogicalType > GetTypes() const
Returns a list of types of the vectors of this data chunk.
Definition duckdb.cpp:116995
vector< unique_ptr< AggregateState > > aggregate_states
Aggregation states.
Definition duckdb.cpp:162073
DataChunk delayed
A buffer for delayed input.
Definition duckdb.cpp:162080
vector< unique_ptr< LeadLagState > > lead_lag_states
Lead/Lag states.
Definition duckdb.cpp:162076
DataChunk shifted
A buffer for shifting delayed input.
Definition duckdb.cpp:162082
vector< unique_ptr< Vector > > const_vectors
The values that are determined by the first row.
Definition duckdb.cpp:162071
idx_t lead_count
The number of rows ahead to buffer for LEAD.
Definition duckdb.cpp:162078
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ Reset()

void duckdb::StreamingWindowState::Reset ( DataChunk & chunk)
inlinestatic
162060 {
162061 // Reset trashes the capacity...
162062 const auto capacity = chunk.GetCapacity();
162063 chunk.Reset();
162064 chunk.SetCapacity(capacity);
162065 }
DUCKDB_API void Reset()
Definition duckdb.cpp:116840

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