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::PhysicalOrder Class Reference

PhysicalOrder sorts the input data. More...

Inheritance diagram for duckdb::PhysicalOrder:
Collaboration diagram for duckdb::PhysicalOrder:

Public Member Functions

 PhysicalOrder (PhysicalPlan &physical_plan, vector< LogicalType > types, vector< BoundOrderByNode > orders, vector< idx_t > projections, idx_t estimated_cardinality, bool is_index_sort=false)
unique_ptr< LocalSourceState > GetLocalSourceState (ExecutionContext &context, GlobalSourceState &gstate) const override
unique_ptr< GlobalSourceState > GetGlobalSourceState (ClientContext &context) const override
SourceResultType GetDataInternal (ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const override
OperatorPartitionData GetPartitionData (ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate, LocalSourceState &lstate, const OperatorPartitionInfo &partition_info) const override
ProgressData GetProgress (ClientContext &context, GlobalSourceState &gstate) const override
 Returns the current progress percentage, or a negative value if progress bars are not supported.
bool IsSource () const override
bool ParallelSource () const override
bool SupportsPartitioning (const OperatorPartitionInfo &partition_info) const override
OrderPreservationType SourceOrder () const override
 The type of order emitted by the operator (as a source).
unique_ptr< LocalSinkState > GetLocalSinkState (ExecutionContext &context) const override
unique_ptr< GlobalSinkState > GetGlobalSinkState (ClientContext &context) const override
SinkResultType Sink (ExecutionContext &context, DataChunk &chunk, OperatorSinkInput &input) const override
SinkCombineResultType Combine (ExecutionContext &context, OperatorSinkCombineInput &input) const override
SinkFinalizeType Finalize (Pipeline &pipeline, Event &event, ClientContext &context, OperatorSinkFinalizeInput &input) const override
ProgressData GetSinkProgress (ClientContext &context, GlobalSinkState &gstate, const ProgressData source_progress) const override
 Returns the current progress percentage, or a negative value if progress bars are not supported.
bool IsSink () const override
bool ParallelSink () const override
bool SinkOrderDependent () const override
InsertionOrderPreservingMap< string > ParamsToString () const override
Public Member Functions inherited from duckdb::PhysicalOperator
 PhysicalOperator (PhysicalPlan &physical_plan, PhysicalOperatorType type, vector< LogicalType > types, idx_t estimated_cardinality)
 PhysicalOperator (const PhysicalOperator &other)=delete
 Deleted copy constructors.
PhysicalOperator & operator= (const PhysicalOperator &)=delete
virtual string GetName () const
virtual string ToString (ExplainFormat format=ExplainFormat::DEFAULT) const
void Print () const
virtual vector< const_reference< PhysicalOperator > > GetChildren () const
const vector< LogicalType > & GetTypes () const
 Return a vector of the types that will be returned by this operator.
virtual bool Equals (const PhysicalOperator &other) const
idx_t EstimatedThreadCount () const
 Functions to help decide how to set up pipeline dependencies.
bool CanSaturateThreads (ClientContext &context) const
virtual void Verify ()
virtual unique_ptr< OperatorState > GetOperatorState (ExecutionContext &context) const
virtual unique_ptr< GlobalOperatorState > GetGlobalOperatorState (ClientContext &context) const
virtual OperatorResultType Execute (ExecutionContext &context, DataChunk &input, DataChunk &chunk, GlobalOperatorState &gstate, OperatorState &state) const
virtual OperatorFinalizeResultType FinalExecute (ExecutionContext &context, DataChunk &chunk, GlobalOperatorState &gstate, OperatorState &state) const
virtual OperatorFinalResultType OperatorFinalize (Pipeline &pipeline, Event &event, ClientContext &context, OperatorFinalizeInput &input) const
virtual bool ParallelOperator () const
virtual bool RequiresFinalExecute () const
virtual bool RequiresOperatorFinalize () const
virtual OrderPreservationType OperatorOrder () const
 The influence the operator has on order (insertion order means no influence).
SourceResultType GetData (ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const
virtual InsertionOrderPreservingMap< string > ExtraSourceParams (GlobalSourceState &gstate, LocalSourceState &lstate) const
virtual void PrepareFinalize (ClientContext &context, GlobalSinkState &sink_state) const
virtual SinkNextBatchType NextBatch (ExecutionContext &context, OperatorSinkNextBatchInput &input) const
virtual OperatorPartitionInfo RequiredPartitionInfo () const
virtual vector< const_reference< PhysicalOperator > > GetSources () const
bool AllSourcesSupportBatchIndex () const
virtual void BuildPipelines (Pipeline &current, MetaPipeline &meta_pipeline)
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const

Public Attributes

vector< BoundOrderByNode > orders
vector< idx_t > projections
bool is_index_sort
Public Attributes inherited from duckdb::PhysicalOperator
ArenaLinkedList< reference< PhysicalOperator > > children
 The child operators.
PhysicalOperatorType type
 The physical operator type.
vector< LogicalType > types
 The return types.
idx_t estimated_cardinality
 The estimated cardinality.
unique_ptr< GlobalSinkState > sink_state
 The global sink state.
unique_ptr< GlobalOperatorState > op_state
 The global operator state.
mutex lock
 Lock for (re)setting any of the operator states.

Static Public Attributes

static constexpr const PhysicalOperatorType TYPE = PhysicalOperatorType::ORDER_BY
Static Public Attributes inherited from duckdb::PhysicalOperator
static constexpr const PhysicalOperatorType TYPE = PhysicalOperatorType::INVALID

Additional Inherited Members

Static Public Member Functions inherited from duckdb::PhysicalOperator
static void SetEstimatedCardinality (InsertionOrderPreservingMap< string > &result, idx_t estimated_cardinality)
static idx_t GetMaxThreadMemory (ClientContext &context)
 The maximum amount of memory the operator should use per thread.
static OperatorCachingMode SelectOperatorCachingMode (ExecutionContext &context)
 Whether operator caching is allowed in the current execution context.

Detailed Description

PhysicalOrder sorts the input data.

Constructor & Destructor Documentation

◆ PhysicalOrder()

duckdb::PhysicalOrder::PhysicalOrder ( PhysicalPlan & physical_plan,
vector< LogicalType > types,
vector< BoundOrderByNode > orders,
vector< idx_t > projections,
idx_t estimated_cardinality,
bool is_index_sort = false )
190622 : PhysicalOperator(physical_plan, PhysicalOperatorType::ORDER_BY, std::move(types), estimated_cardinality),
190623 orders(std::move(orders)), projections(std::move(projections)), is_index_sort(is_index_sort_p) {
190624}
vector< LogicalType > types
The return types.
Definition duckdb.hpp:22152
idx_t estimated_cardinality
The estimated cardinality.
Definition duckdb.hpp:22154

Member Function Documentation

◆ GetLocalSourceState()

unique_ptr< LocalSourceState > duckdb::PhysicalOrder::GetLocalSourceState ( ExecutionContext & context,
GlobalSourceState & gstate ) const
overridevirtual

Reimplemented from duckdb::PhysicalOperator.

190721 {
190722 auto &gstate = gstate_p.Cast<OrderGlobalSourceState>();
190723 return make_uniq<OrderLocalSourceState>(context, gstate);
190724}

◆ GetGlobalSourceState()

unique_ptr< GlobalSourceState > duckdb::PhysicalOrder::GetGlobalSourceState ( ClientContext & context) const
overridevirtual

Reimplemented from duckdb::PhysicalOperator.

190726 {
190727 return make_uniq<OrderGlobalSourceState>(context, sink_state->Cast<OrderGlobalSinkState>());
190728}
unique_ptr< GlobalSinkState > sink_state
The global sink state.
Definition duckdb.hpp:22157

◆ GetDataInternal()

SourceResultType duckdb::PhysicalOrder::GetDataInternal ( ExecutionContext & context,
DataChunk & chunk,
OperatorSourceInput & input ) const
overridevirtual

Reimplemented from duckdb::PhysicalOperator.

190731 {
190732 auto &gstate = input.global_state.Cast<OrderGlobalSourceState>();
190733 auto &lstate = input.local_state.Cast<OrderLocalSourceState>();
190734 OperatorSourceInput sort_input {*gstate.state, *lstate.state, input.interrupt_state};
190735 return gstate.sort.GetData(context, chunk, sort_input);
190736}

◆ GetPartitionData()

OperatorPartitionData duckdb::PhysicalOrder::GetPartitionData ( ExecutionContext & context,
DataChunk & chunk,
GlobalSourceState & gstate,
LocalSourceState & lstate,
const OperatorPartitionInfo & partition_info ) const
overridevirtual

Reimplemented from duckdb::PhysicalOperator.

190740 {
190741 auto &gstate = gstate_p.Cast<OrderGlobalSourceState>();
190742 auto &lstate = lstate_p.Cast<OrderLocalSourceState>();
190743 if (partition_info.RequiresPartitionColumns()) {
190744 throw InternalException("PhysicalOrder::GetPartitionData: partition columns not supported");
190745 }
190746 return gstate.sort.GetPartitionData(context, chunk, *gstate.state, *lstate.state, partition_info);
190747}

◆ GetProgress()

ProgressData duckdb::PhysicalOrder::GetProgress ( ClientContext & context,
GlobalSourceState & gstate ) const
overridevirtual

Returns the current progress percentage, or a negative value if progress bars are not supported.

Reimplemented from duckdb::PhysicalOperator.

190749 {
190750 auto &gstate = gstate_p.Cast<OrderGlobalSourceState>();
190751 return gstate.sort.GetProgress(context, *gstate.state);
190752}

◆ IsSource()

bool duckdb::PhysicalOrder::IsSource ( ) const
inlineoverridevirtual

Reimplemented from duckdb::PhysicalOperator.

190567 {
190568 return true;
190569 }

◆ ParallelSource()

bool duckdb::PhysicalOrder::ParallelSource ( ) const
inlineoverridevirtual

Reimplemented from duckdb::PhysicalOperator.

190571 {
190572 return true;
190573 }

◆ SupportsPartitioning()

bool duckdb::PhysicalOrder::SupportsPartitioning ( const OperatorPartitionInfo & partition_info) const
inlineoverridevirtual

Reimplemented from duckdb::PhysicalOperator.

190575 {
190576 if (partition_info.RequiresPartitionColumns()) {
190577 return false;
190578 }
190579 return true;
190580 }

◆ SourceOrder()

OrderPreservationType duckdb::PhysicalOrder::SourceOrder ( ) const
inlineoverridevirtual

The type of order emitted by the operator (as a source).

Reimplemented from duckdb::PhysicalOperator.

190582 {
190583 return OrderPreservationType::FIXED_ORDER;
190584 }

◆ GetLocalSinkState()

unique_ptr< LocalSinkState > duckdb::PhysicalOrder::GetLocalSinkState ( ExecutionContext & context) const
overridevirtual

Reimplemented from duckdb::PhysicalOperator.

190650 {
190651 return make_uniq<OrderLocalSinkState>();
190652}

◆ GetGlobalSinkState()

unique_ptr< GlobalSinkState > duckdb::PhysicalOrder::GetGlobalSinkState ( ClientContext & context) const
overridevirtual

Reimplemented from duckdb::PhysicalOperator.

190654 {
190655 return make_uniq<OrderGlobalSinkState>(*this, context);
190656}

◆ Sink()

SinkResultType duckdb::PhysicalOrder::Sink ( ExecutionContext & context,
DataChunk & chunk,
OperatorSinkInput & input ) const
overridevirtual

The sink method is called constantly with new input, as long as new input is available. Note that this method CAN be called in parallel, proper locking is needed when accessing dat a inside the GlobalSinkState.

Reimplemented from duckdb::PhysicalOperator.

190658 {
190659 auto &gstate = input.global_state.Cast<OrderGlobalSinkState>();
190660 auto &lstate = input.local_state.Cast<OrderLocalSinkState>();
190661 if (!lstate.state) {
190662 lstate.state = gstate.sort.GetLocalSinkState(context);
190663 }
190664 OperatorSinkInput sort_input {*gstate.state, *lstate.state, input.interrupt_state};
190665 return gstate.sort.Sink(context, chunk, sort_input);
190666}

◆ Combine()

SinkCombineResultType duckdb::PhysicalOrder::Combine ( ExecutionContext & context,
OperatorSinkCombineInput & input ) const
overridevirtual

The combine is called when a single thread has completed execution of its part of the pipeline, it is the final time that a specific LocalSinkState is accessible. This method can be called in parallel while other Sink() or Combine() calls are active on the same GlobalSinkState.

Reimplemented from duckdb::PhysicalOperator.

190668 {
190669 auto &gstate = input.global_state.Cast<OrderGlobalSinkState>();
190670 auto &lstate = input.local_state.Cast<OrderLocalSinkState>();
190671 if (!lstate.state) {
190672 return SinkCombineResultType::FINISHED;
190673 }
190674 OperatorSinkCombineInput sort_input {*gstate.state, *lstate.state, input.interrupt_state};
190675 return gstate.sort.Combine(context, sort_input);
190676}

◆ Finalize()

SinkFinalizeType duckdb::PhysicalOrder::Finalize ( Pipeline & pipeline,
Event & event,
ClientContext & context,
OperatorSinkFinalizeInput & input ) const
overridevirtual

The finalize is called when ALL threads are finished execution. It is called only once per pipeline, and is entirely single threaded. If Finalize returns SinkResultType::Finished, the sink is marked as finished

Reimplemented from duckdb::PhysicalOperator.

190679 {
190680 auto &gstate = input.global_state.Cast<OrderGlobalSinkState>();
190681 OperatorSinkFinalizeInput sort_input {*gstate.state, input.interrupt_state};
190682 return gstate.sort.Finalize(context, sort_input);
190683}

◆ GetSinkProgress()

ProgressData duckdb::PhysicalOrder::GetSinkProgress ( ClientContext & context,
GlobalSinkState & gstate,
const ProgressData source_progress ) const
overridevirtual

Returns the current progress percentage, or a negative value if progress bars are not supported.

Reimplemented from duckdb::PhysicalOperator.

190686 {
190687 auto &gstate = gstate_p.Cast<OrderGlobalSinkState>();
190688 return gstate.sort.GetSinkProgress(context, *gstate.state, source_progress);
190689}

◆ IsSink()

bool duckdb::PhysicalOrder::IsSink ( ) const
inlineoverridevirtual

Reimplemented from duckdb::PhysicalOperator.

190599 {
190600 return true;
190601 }

◆ ParallelSink()

bool duckdb::PhysicalOrder::ParallelSink ( ) const
inlineoverridevirtual

Reimplemented from duckdb::PhysicalOperator.

190602 {
190603 return true;
190604 }

◆ SinkOrderDependent()

bool duckdb::PhysicalOrder::SinkOrderDependent ( ) const
inlineoverridevirtual

Whether or not the sink operator depends on the order of the input chunks If this is set to true, we cannot do things like caching intermediate vectors

Reimplemented from duckdb::PhysicalOperator.

190605 {
190606 return false;
190607 }

◆ ParamsToString()

InsertionOrderPreservingMap< string > duckdb::PhysicalOrder::ParamsToString ( ) const
overridevirtual

Reimplemented from duckdb::PhysicalOperator.

190754 {
190755 InsertionOrderPreservingMap<string> result;
190756 string orders_info;
190757 for (idx_t i = 0; i < orders.size(); i++) {
190758 if (i > 0) {
190759 orders_info += "\n";
190760 }
190761 orders_info += orders[i].expression->ToString() + " ";
190762 orders_info += orders[i].type == OrderType::DESCENDING ? "DESC" : "ASC";
190763 }
190764 result["__order_by__"] = orders_info;
190765 return result;
190766}
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: