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

Public Member Functions

 SortedRunMerger (const Sort &sort, vector< unique_ptr< SortedRun > > &&sorted_runs, idx_t partition_size, bool external, bool is_index_sort)
unique_ptr< LocalSourceState > GetLocalSourceState (ExecutionContext &context, GlobalSourceState &gstate) const
unique_ptr< GlobalSourceState > GetGlobalSourceState (ClientContext &context) const
SourceResultType GetData (ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const
OperatorPartitionData GetPartitionData (ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate, LocalSourceState &lstate, const OperatorPartitionInfo &partition_info) const
ProgressData GetProgress (ClientContext &context, GlobalSourceState &gstate) const
SourceResultType MaterializeSortedRun (ExecutionContext &context, OperatorSourceInput &input) const
unique_ptr< SortedRun > GetSortedRun (GlobalSourceState &global_state)

Public Attributes

const Sort & sort
vector< unique_ptr< SortedRun > > sorted_runs
const idx_t total_count
const idx_t partition_size
const bool external
const bool is_index_sort

Private Attributes

TaskScheduler & scheduler

Friends

class SortedRunMergerLocalState
class SortedRunMergerGlobalState

Constructor & Destructor Documentation

◆ SortedRunMerger()

duckdb::SortedRunMerger::SortedRunMerger ( const Sort & sort,
vector< unique_ptr< SortedRun > > && sorted_runs,
idx_t partition_size,
bool external,
bool is_index_sort )
107926 : scheduler(TaskScheduler::GetScheduler(*sort_p.context.db)), sort(sort_p), sorted_runs(std::move(sorted_runs_p)),
107927 total_count(SortedRunsTotalCount(sorted_runs)), partition_size(partition_size_p), external(external_p),
107928 is_index_sort(is_index_sort_p) {
107929}

◆ ~SortedRunMerger()

duckdb::SortedRunMerger::~SortedRunMerger ( )
107931 {
107932 ParallelDestroyTask<decltype(sorted_runs)>::Schedule(scheduler, sorted_runs);
107933}

Member Function Documentation

◆ GetLocalSourceState()

unique_ptr< LocalSourceState > duckdb::SortedRunMerger::GetLocalSourceState ( ExecutionContext & context,
GlobalSourceState & gstate ) const
107936 {
107937 auto &gstate = gstate_p.Cast<SortedRunMergerGlobalState>();
107938 auto guard = gstate.Lock();
107939 return make_uniq<SortedRunMergerLocalState>(gstate);
107940}

◆ GetGlobalSourceState()

unique_ptr< GlobalSourceState > duckdb::SortedRunMerger::GetGlobalSourceState ( ClientContext & context) const
107942 {
107943 return make_uniq<SortedRunMergerGlobalState>(context, *this);
107944}

◆ GetData()

SourceResultType duckdb::SortedRunMerger::GetData ( ExecutionContext & context,
DataChunk & chunk,
OperatorSourceInput & input ) const
107946 {
107947 auto &gstate = input.global_state.Cast<SortedRunMergerGlobalState>();
107948 auto &lstate = input.local_state.Cast<SortedRunMergerLocalState>();
107949
107950 while (chunk.size() == 0) {
107951 if (!lstate.TaskFinished() || gstate.AssignTask(lstate)) {
107952 lstate.ExecuteTask(gstate, &chunk);
107953 } else {
107954 break;
107955 }
107956 }
107957
107958 if (chunk.size() != 0) {
107959 return SourceResultType::HAVE_MORE_OUTPUT;
107960 }
107961
107962 // Done
107963 lstate.Clear();
107964 return SourceResultType::FINISHED;
107965}

◆ GetPartitionData()

OperatorPartitionData duckdb::SortedRunMerger::GetPartitionData ( ExecutionContext & context,
DataChunk & chunk,
GlobalSourceState & gstate,
LocalSourceState & lstate,
const OperatorPartitionInfo & partition_info ) const
107969 {
107970 auto &lstate = lstate_p.Cast<SortedRunMergerLocalState>();
107971 return OperatorPartitionData(lstate.partition_idx.GetIndex());
107972}

◆ GetProgress()

ProgressData duckdb::SortedRunMerger::GetProgress ( ClientContext & context,
GlobalSourceState & gstate ) const
107974 {
107975 auto &gstate = gstate_p.Cast<SortedRunMergerGlobalState>();
107976 ProgressData res;
107977 res.done = static_cast<double>(gstate.total_scanned);
107978 res.total = static_cast<double>(total_count);
107979 res.invalid = false;
107980 return res;
107981}

◆ MaterializeSortedRun()

SourceResultType duckdb::SortedRunMerger::MaterializeSortedRun ( ExecutionContext & context,
OperatorSourceInput & input ) const
107986 {
107987 auto &gstate = input.global_state.Cast<SortedRunMergerGlobalState>();
107988 auto &lstate = input.local_state.Cast<SortedRunMergerLocalState>();
107989
107990 SourceResultType res = SourceResultType::HAVE_MORE_OUTPUT;
107991 while (true) {
107992 if (!lstate.TaskFinished() || gstate.AssignTask(lstate)) {
107993 res = lstate.ExecuteTask(gstate, nullptr);
107994 } else {
107995 break;
107996 }
107997 }
107998 lstate.Clear(); // Done
107999
108000 // The thread that completes the materialization returns FINISHED, all other threads return HAVE_MORE_OUTPUT
108001 return res;
108002}
SourceResultType
Definition duckdb.hpp:20201

◆ GetSortedRun()

unique_ptr< SortedRun > duckdb::SortedRunMerger::GetSortedRun ( GlobalSourceState & global_state)
108004 {
108005 auto &gstate = global_state.Cast<SortedRunMergerGlobalState>();
108006 D_ASSERT(total_count != 0);
108007 lock_guard<mutex> guard(gstate.materialized_partition_lock);
108008 if (gstate.materialized_partitions.empty()) {
108009 return nullptr;
108010 }
108011 auto &target = *gstate.materialized_partitions[0];
108012 for (idx_t i = 1; i < gstate.materialized_partitions.size(); i++) {
108013 auto &source = gstate.materialized_partitions[i];
108014 target.key_data->Combine(*source->key_data);
108015 if (target.payload_data) {
108016 target.payload_data->Combine(*source->payload_data);
108017 }
108018 source.reset();
108019 }
108020 auto res = std::move(gstate.materialized_partitions[0]);
108021 gstate.materialized_partitions.clear();
108022 return res;
108023}
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: