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

Public Member Functions

 PhysicalBufferedBatchCollector (PhysicalPlan &physical_plan, PreparedStatementData &data)
unique_ptr< QueryResult > GetResult (GlobalSinkState &state) const override
 The final method used to fetch the query result from this operator.
SinkResultType Sink (ExecutionContext &context, DataChunk &chunk, OperatorSinkInput &input) const override
SinkCombineResultType Combine (ExecutionContext &context, OperatorSinkCombineInput &input) const override
SinkNextBatchType NextBatch (ExecutionContext &context, OperatorSinkNextBatchInput &input) const override
unique_ptr< LocalSinkState > GetLocalSinkState (ExecutionContext &context) const override
unique_ptr< GlobalSinkState > GetGlobalSinkState (ClientContext &context) const override
OperatorPartitionInfo RequiredPartitionInfo () const override
bool ParallelSink () const override
bool IsStreaming () const override
 Whether this is a streaming result collector.
Public Member Functions inherited from duckdb::PhysicalResultCollector
 PhysicalResultCollector (PhysicalPlan &physical_plan, PreparedStatementData &data)
bool IsSink () const override
vector< const_reference< PhysicalOperator > > GetChildren () const override
void BuildPipelines (Pipeline &current, MetaPipeline &meta_pipeline) override
bool IsSource () 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 InsertionOrderPreservingMap< string > ParamsToString () const
virtual string ToString (ExplainFormat format=ExplainFormat::DEFAULT) const
void Print () 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).
virtual unique_ptr< LocalSourceState > GetLocalSourceState (ExecutionContext &context, GlobalSourceState &gstate) const
virtual unique_ptr< GlobalSourceState > GetGlobalSourceState (ClientContext &context) const
SourceResultType GetData (ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const
virtual OperatorPartitionData GetPartitionData (ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate, LocalSourceState &lstate, const OperatorPartitionInfo &partition_info) const
virtual bool ParallelSource () const
virtual bool SupportsPartitioning (const OperatorPartitionInfo &partition_info) const
virtual OrderPreservationType SourceOrder () const
 The type of order emitted by the operator (as a source).
virtual ProgressData GetProgress (ClientContext &context, GlobalSourceState &gstate) const
 Returns the current progress percentage, or a negative value if progress bars are not supported.
virtual ProgressData GetSinkProgress (ClientContext &context, GlobalSinkState &gstate, const ProgressData source_progress) const
 Returns the current progress percentage, or a negative value if progress bars are not supported.
virtual InsertionOrderPreservingMap< string > ExtraSourceParams (GlobalSourceState &gstate, LocalSourceState &lstate) const
virtual void PrepareFinalize (ClientContext &context, GlobalSinkState &sink_state) const
virtual SinkFinalizeType Finalize (Pipeline &pipeline, Event &event, ClientContext &context, OperatorSinkFinalizeInput &input) const
virtual bool SinkOrderDependent () const
virtual vector< const_reference< PhysicalOperator > > GetSources () const
bool AllSourcesSupportBatchIndex () const
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const

Additional Inherited Members

Static Public Member Functions inherited from duckdb::PhysicalResultCollector
static unique_ptr< PhysicalOperator > GetResultCollector (ClientContext &context, PreparedStatementData &data)
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.
Public Attributes inherited from duckdb::PhysicalResultCollector
StatementType statement_type
StatementProperties properties
QueryResultMemoryType memory_type
PhysicalOperator & plan
vector< string > names
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 inherited from duckdb::PhysicalResultCollector
static constexpr const PhysicalOperatorType TYPE = PhysicalOperatorType::RESULT_COLLECTOR
Static Public Attributes inherited from duckdb::PhysicalOperator
static constexpr const PhysicalOperatorType TYPE = PhysicalOperatorType::INVALID
Protected Member Functions inherited from duckdb::PhysicalResultCollector
unique_ptr< ColumnDataCollection > CreateCollection (ClientContext &context) const
Protected Member Functions inherited from duckdb::PhysicalOperator
virtual SourceResultType GetDataInternal (ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const

Constructor & Destructor Documentation

◆ PhysicalBufferedBatchCollector()

duckdb::PhysicalBufferedBatchCollector::PhysicalBufferedBatchCollector ( PhysicalPlan & physical_plan,
PreparedStatementData & data )
177356 : PhysicalResultCollector(physical_plan, data) {
177357}

Member Function Documentation

◆ GetResult()

unique_ptr< QueryResult > duckdb::PhysicalBufferedBatchCollector::GetResult ( GlobalSinkState & state) const
overridevirtual

The final method used to fetch the query result from this operator.

Implements duckdb::PhysicalResultCollector.

177443 {
177444 auto &gstate = state.Cast<BufferedBatchCollectorGlobalState>();
177445 auto cc = gstate.context.lock();
177446 auto result = make_uniq<StreamQueryResult>(statement_type, properties, types, names, cc->GetClientProperties(),
177447 gstate.buffered_data);
177448 return std::move(result);
177449}
vector< LogicalType > types
The return types.
Definition duckdb.hpp:22152

◆ Sink()

SinkResultType duckdb::PhysicalBufferedBatchCollector::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.

177372 {
177373 auto &gstate = input.global_state.Cast<BufferedBatchCollectorGlobalState>();
177374 auto &lstate = input.local_state.Cast<BufferedBatchCollectorLocalState>();
177375
177376 lstate.current_batch = lstate.partition_info.batch_index.GetIndex();
177377 auto batch = lstate.partition_info.batch_index.GetIndex();
177378 auto min_batch_index = lstate.partition_info.min_batch_index.GetIndex();
177379
177380 auto &buffered_data = gstate.buffered_data->Cast<BatchedBufferedData>();
177381 buffered_data.UpdateMinBatchIndex(min_batch_index);
177382
177383 if (buffered_data.ShouldBlockBatch(batch)) {
177384 auto callback_state = input.interrupt_state;
177385 buffered_data.BlockSink(callback_state, batch);
177386 return SinkResultType::BLOCKED;
177387 }
177388
177389 // FIXME: if we want to make this more accurate, we should grab a reservation on the buffer space
177390 // while we're unlocked some other thread could also append, causing us to potentially cross our buffer size
177391
177392 buffered_data.Append(chunk, batch);
177393
177394 return SinkResultType::NEED_MORE_INPUT;
177395}

◆ Combine()

SinkCombineResultType duckdb::PhysicalBufferedBatchCollector::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.

177417 {
177418 auto &gstate = input.global_state.Cast<BufferedBatchCollectorGlobalState>();
177419 auto &lstate = input.local_state.Cast<BufferedBatchCollectorLocalState>();
177420
177421 auto min_batch_index = lstate.partition_info.min_batch_index.GetIndex();
177422 auto &buffered_data = gstate.buffered_data->Cast<BatchedBufferedData>();
177423
177424 // FIXME: this can move from the buffer to the read queue, increasing the 'read_queue_byte_count'
177425 // We might want to block here if 'read_queue_byte_count' has already reached the ReadQueueCapacity()
177426 // So we don't completely disregard the 'streaming_buffer_size' that was set
177427 buffered_data.UpdateMinBatchIndex(min_batch_index);
177428 return SinkCombineResultType::FINISHED;
177429}

◆ NextBatch()

SinkNextBatchType duckdb::PhysicalBufferedBatchCollector::NextBatch ( ExecutionContext & context,
OperatorSinkNextBatchInput & input ) const
overridevirtual

For sinks with RequiresBatchIndex set to true, when a new batch starts being processed this method is called This allows flushing of the current batch (e.g. to disk)

Reimplemented from duckdb::PhysicalOperator.

177398 {
177399 auto &gstate = input.global_state.Cast<BufferedBatchCollectorGlobalState>();
177400 auto &lstate = input.local_state.Cast<BufferedBatchCollectorLocalState>();
177401
177402 auto batch = lstate.current_batch;
177403 auto min_batch_index = lstate.partition_info.min_batch_index.GetIndex();
177404 auto new_index = lstate.partition_info.batch_index.GetIndex();
177405
177406 auto &buffered_data = gstate.buffered_data->Cast<BatchedBufferedData>();
177407 buffered_data.CompleteBatch(batch);
177408 lstate.current_batch = new_index;
177409 // FIXME: this can move from the buffer to the read queue, increasing the 'read_queue_byte_count'
177410 // We might want to block here if 'read_queue_byte_count' has already reached the ReadQueueCapacity()
177411 // So we don't completely disregard the 'streaming_buffer_size' that was set
177412 buffered_data.UpdateMinBatchIndex(min_batch_index);
177413 return SinkNextBatchType::READY;
177414}

◆ GetLocalSinkState()

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

Reimplemented from duckdb::PhysicalOperator.

177431 {
177432 auto state = make_uniq<BufferedBatchCollectorLocalState>();
177433 return std::move(state);
177434}

◆ GetGlobalSinkState()

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

Reimplemented from duckdb::PhysicalOperator.

177436 {
177437 auto state = make_uniq<BufferedBatchCollectorGlobalState>();
177438 state->context = context.shared_from_this();
177439 state->buffered_data = make_shared_ptr<BatchedBufferedData>(context);
177440 return std::move(state);
177441}

◆ RequiredPartitionInfo()

OperatorPartitionInfo duckdb::PhysicalBufferedBatchCollector::RequiredPartitionInfo ( ) const
inlineoverridevirtual

Reimplemented from duckdb::PhysicalOperator.

177251 {
177252 return OperatorPartitionInfo::BatchIndex();
177253 }

◆ ParallelSink()

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

Reimplemented from duckdb::PhysicalOperator.

177255 {
177256 return true;
177257 }

◆ IsStreaming()

bool duckdb::PhysicalBufferedBatchCollector::IsStreaming ( ) const
inlineoverridevirtual

Whether this is a streaming result collector.

Reimplemented from duckdb::PhysicalResultCollector.

177259 {
177260 return true;
177261 }

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