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::BlockingSample Class Referenceabstract
Inheritance diagram for duckdb::BlockingSample:
Collaboration diagram for duckdb::BlockingSample:

Public Member Functions

 BlockingSample (int64_t seed=-1)
virtual void AddToReservoir (DataChunk &input)=0
 Add a chunk of data to the sample.
virtual unique_ptr< BlockingSample > Copy () const =0
virtual void Finalize ()=0
virtual void Destroy ()
virtual unique_ptr< DataChunk > GetChunk ()=0
 Fetches a chunk from the sample. destroy = true should only be used when querying from a sample defined in a query and not a duckdb_table_sample.
virtual void Serialize (Serializer &serializer) const
std::pair< double, idx_t > PopFromWeightQueue ()
 Helper functions needed to merge two reservoirs while respecting weights of sampled rows.
double GetMinWeightThreshold ()
idx_t GetPriorityQueueSize ()
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const

Static Public Member Functions

static unique_ptr< BlockingSample > Deserialize (Deserializer &deserializer)

Public Attributes

unique_ptr< BaseReservoirSampling > base_reservoir_sample
SampleType type
 The sample type.
bool destroyed
 has the sample been destroyed due to updates to the referenced table

Static Public Attributes

static constexpr const SampleType TYPE = SampleType::BLOCKING_SAMPLE

Constructor & Destructor Documentation

◆ BlockingSample()

duckdb::BlockingSample::BlockingSample ( int64_t seed = -1)
inlineexplicit
47815 : base_reservoir_sample(make_uniq<BaseReservoirSampling>(seed)), type(SampleType::BLOCKING_SAMPLE),
47816 destroyed(false) {
47817 }
bool destroyed
has the sample been destroyed due to updates to the referenced table
Definition duckdb.hpp:47811
SampleType type
The sample type.
Definition duckdb.hpp:47809

◆ ~BlockingSample()

virtual duckdb::BlockingSample::~BlockingSample ( )
inlinevirtual
47818 {
47819 }

Member Function Documentation

◆ AddToReservoir()

virtual void duckdb::BlockingSample::AddToReservoir ( DataChunk & input)
pure virtual

Add a chunk of data to the sample.

Implemented in duckdb::ReservoirSample, and duckdb::ReservoirSamplePercentage.

◆ Copy()

virtual unique_ptr< BlockingSample > duckdb::BlockingSample::Copy ( ) const
pure virtual

Implemented in duckdb::ReservoirSample.

◆ Destroy()

void duckdb::BlockingSample::Destroy ( )
virtual
208179 {
208180 destroyed = true;
208181}

◆ GetChunk()

virtual unique_ptr< DataChunk > duckdb::BlockingSample::GetChunk ( )
pure virtual

Fetches a chunk from the sample. destroy = true should only be used when querying from a sample defined in a query and not a duckdb_table_sample.

Implemented in duckdb::ReservoirSample, and duckdb::ReservoirSamplePercentage.

◆ Serialize()

void duckdb::BlockingSample::Serialize ( Serializer & serializer) const
virtual
417218 {
417219 serializer.WritePropertyWithDefault<unique_ptr<BaseReservoirSampling>>(100, "base_reservoir_sample", base_reservoir_sample);
417220 serializer.WriteProperty<SampleType>(101, "type", type);
417221 serializer.WritePropertyWithDefault<bool>(102, "destroyed", destroyed);
417222}

◆ Deserialize()

unique_ptr< BlockingSample > duckdb::BlockingSample::Deserialize ( Deserializer & deserializer)
static
417224 {
417225 auto base_reservoir_sample = deserializer.ReadPropertyWithDefault<unique_ptr<BaseReservoirSampling>>(100, "base_reservoir_sample");
417226 auto type = deserializer.ReadProperty<SampleType>(101, "type");
417227 auto destroyed = deserializer.ReadPropertyWithDefault<bool>(102, "destroyed");
417228 unique_ptr<BlockingSample> result;
417229 switch (type) {
417230 case SampleType::RESERVOIR_PERCENTAGE_SAMPLE:
417231 result = ReservoirSamplePercentage::Deserialize(deserializer);
417232 break;
417233 case SampleType::RESERVOIR_SAMPLE:
417234 result = ReservoirSample::Deserialize(deserializer);
417235 break;
417236 default:
417237 throw SerializationException("Unsupported type for deserialization of BlockingSample!");
417238 }
417239 result->base_reservoir_sample = std::move(base_reservoir_sample);
417240 result->destroyed = destroyed;
417241 return result;
417242}

◆ PopFromWeightQueue()

std::pair< double, idx_t > duckdb::BlockingSample::PopFromWeightQueue ( )

Helper functions needed to merge two reservoirs while respecting weights of sampled rows.

208161 {
208162 D_ASSERT(base_reservoir_sample && !base_reservoir_sample->reservoir_weights.empty());
208163 auto ret = base_reservoir_sample->reservoir_weights.top();
208164 base_reservoir_sample->reservoir_weights.pop();
208165
208166 base_reservoir_sample->UpdateMinWeightThreshold();
208167 D_ASSERT(base_reservoir_sample->min_weight_threshold > 0);
208168 return ret;
208169}
Here is the caller graph for this function:

◆ GetMinWeightThreshold()

double duckdb::BlockingSample::GetMinWeightThreshold ( )
208171 {
208172 return base_reservoir_sample->min_weight_threshold;
208173}

◆ GetPriorityQueueSize()

idx_t duckdb::BlockingSample::GetPriorityQueueSize ( )
208175 {
208176 return base_reservoir_sample->reservoir_weights.size();
208177}

◆ Cast() [1/2]

template<class TARGET>
TARGET & duckdb::BlockingSample::Cast ( )
inline
47841 {
47842 if (type != TARGET::TYPE && TARGET::TYPE != SampleType::BLOCKING_SAMPLE) {
47843 throw InternalException("Failed to cast sample to type - sample type mismatch");
47844 }
47845 return reinterpret_cast<TARGET &>(*this);
47846 }

◆ Cast() [2/2]

template<class TARGET>
const TARGET & duckdb::BlockingSample::Cast ( ) const
inline
47849 {
47850 if (type != TARGET::TYPE && TARGET::TYPE != SampleType::BLOCKING_SAMPLE) {
47851 throw InternalException("Failed to cast sample to type - sample type mismatch");
47852 }
47853 return reinterpret_cast<const TARGET &>(*this);
47854 }

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