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

PhysicalStreamingSample represents a streaming sample using either system or bernoulli sampling. More...

Inheritance diagram for duckdb::PhysicalStreamingSample:
Collaboration diagram for duckdb::PhysicalStreamingSample:

Public Member Functions

 PhysicalStreamingSample (PhysicalPlan &physical_plan, vector< LogicalType > types, unique_ptr< SampleOptions > options, idx_t estimated_cardinality)
unique_ptr< OperatorState > GetOperatorState (ExecutionContext &context) const override
OperatorResultType Execute (ExecutionContext &context, DataChunk &input, DataChunk &chunk, GlobalOperatorState &gstate, OperatorState &state) const override
bool ParallelOperator () 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< GlobalOperatorState > GetGlobalOperatorState (ClientContext &context) 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 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 IsSource () 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 SinkResultType Sink (ExecutionContext &context, DataChunk &chunk, OperatorSinkInput &input) const
virtual SinkCombineResultType Combine (ExecutionContext &context, OperatorSinkCombineInput &input) const
virtual void PrepareFinalize (ClientContext &context, GlobalSinkState &sink_state) const
virtual SinkFinalizeType Finalize (Pipeline &pipeline, Event &event, ClientContext &context, OperatorSinkFinalizeInput &input) const
virtual SinkNextBatchType NextBatch (ExecutionContext &context, OperatorSinkNextBatchInput &input) const
virtual unique_ptr< LocalSinkState > GetLocalSinkState (ExecutionContext &context) const
virtual unique_ptr< GlobalSinkState > GetGlobalSinkState (ClientContext &context) const
virtual bool IsSink () const
virtual bool ParallelSink () const
virtual OperatorPartitionInfo RequiredPartitionInfo () const
virtual bool SinkOrderDependent () 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

unique_ptr< SampleOptions > sample_options
double percentage
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::STREAMING_SAMPLE
Static Public Attributes inherited from duckdb::PhysicalOperator
static constexpr const PhysicalOperatorType TYPE = PhysicalOperatorType::INVALID

Private Member Functions

void SystemSample (DataChunk &input, DataChunk &result, OperatorState &state) const
void BernoulliSample (DataChunk &input, DataChunk &result, OperatorState &state) const

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.
Protected Member Functions inherited from duckdb::PhysicalOperator
virtual SourceResultType GetDataInternal (ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const

Detailed Description

PhysicalStreamingSample represents a streaming sample using either system or bernoulli sampling.

Constructor & Destructor Documentation

◆ PhysicalStreamingSample()

duckdb::PhysicalStreamingSample::PhysicalStreamingSample ( PhysicalPlan & physical_plan,
vector< LogicalType > types,
unique_ptr< SampleOptions > options,
idx_t estimated_cardinality )
179925 : PhysicalOperator(physical_plan, PhysicalOperatorType::STREAMING_SAMPLE, std::move(types), estimated_cardinality),
179926 sample_options(std::move(options)) {
179927 percentage = sample_options->sample_size.GetValue<double>() / 100;
179928}
vector< LogicalType > types
The return types.
Definition duckdb.hpp:22152
idx_t estimated_cardinality
The estimated cardinality.
Definition duckdb.hpp:22154

Member Function Documentation

◆ GetOperatorState()

unique_ptr< OperatorState > duckdb::PhysicalStreamingSample::GetOperatorState ( ExecutionContext & context) const
overridevirtual

Reimplemented from duckdb::PhysicalOperator.

179972 {
179973 if (!ParallelOperator()) {
179974 return make_uniq<StreamingSampleOperatorState>(static_cast<int64_t>(sample_options->seed.GetIndex()));
179975 }
179976 RandomEngine random;
179977 return make_uniq<StreamingSampleOperatorState>(static_cast<int64_t>(random.NextRandomInteger64()));
179978}
::int64_t int64_t

◆ Execute()

OperatorResultType duckdb::PhysicalStreamingSample::Execute ( ExecutionContext & context,
DataChunk & input,
DataChunk & chunk,
GlobalOperatorState & gstate,
OperatorState & state ) const
overridevirtual

Reimplemented from duckdb::PhysicalOperator.

179981 {
179982 switch (sample_options->method) {
179983 case SampleMethod::BERNOULLI_SAMPLE:
179984 BernoulliSample(input, chunk, state);
179985 break;
179986 case SampleMethod::SYSTEM_SAMPLE:
179987 SystemSample(input, chunk, state);
179988 break;
179989 default:
179990 throw InternalException("Unsupported sample method for streaming sample");
179991 }
179992 return OperatorResultType::NEED_MORE_INPUT;
179993}

◆ ParallelOperator()

bool duckdb::PhysicalStreamingSample::ParallelOperator ( ) const
overridevirtual

Reimplemented from duckdb::PhysicalOperator.

179968 {
179969 return !(sample_options->repeatable || sample_options->seed.IsValid());
179970}

◆ ParamsToString()

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

Reimplemented from duckdb::PhysicalOperator.

179995 {
179996 InsertionOrderPreservingMap<string> result;
179997 result["Sample Method"] = EnumUtil::ToString(sample_options->method) + ": " + to_string(100 * percentage) + "%";
179998 return result;
179999}
std::string to_string(const T &value)
Definition duckdb.cpp:19425

◆ SystemSample()

void duckdb::PhysicalStreamingSample::SystemSample ( DataChunk & input,
DataChunk & result,
OperatorState & state ) const
private
179941 {
179942 // system sampling: we throw one dice per chunk
179943 auto &state = state_p.Cast<StreamingSampleOperatorState>();
179944 double rand = state.random.NextRandom();
179945 if (rand <= percentage) {
179946 // rand is smaller than sample_size: output chunk
179947 result.Reference(input);
179948 }
179949}

◆ BernoulliSample()

void duckdb::PhysicalStreamingSample::BernoulliSample ( DataChunk & input,
DataChunk & result,
OperatorState & state ) const
private
179951 {
179952 // bernoulli sampling: we throw one dice per tuple
179953 // then slice the result chunk
179954 auto &state = state_p.Cast<StreamingSampleOperatorState>();
179955 idx_t result_count = 0;
179956 SelectionVector sel(STANDARD_VECTOR_SIZE);
179957 for (idx_t i = 0; i < input.size(); i++) {
179958 double rand = state.random.NextRandom();
179959 if (rand <= percentage) {
179960 sel.set_index(result_count++, i);
179961 }
179962 }
179963 if (result_count > 0) {
179964 result.Slice(input, sel, result_count);
179965 }
179966}
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: