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

Public Member Functions

 GlobalSortedTable (ClientContext &client, const vector< BoundOrderByNode > &orders, const vector< LogicalType > &payload_layout, const PhysicalRangeJoin &op)
idx_t Count () const
idx_t BlockCount () const
idx_t BlockStart (idx_t i) const
idx_t BlockEnd (idx_t i) const
idx_t BlockSize (idx_t i) const
SortKeyType GetSortKeyType () const
void IntializeMatches ()
void Combine (ExecutionContext &context, LocalSortedTable &ltable)
 Combine local states.
void Finalize (ClientContext &client, InterruptState &interrupt)
 Prepare for sorting.
void Materialize (Pipeline &pipeline, Event &event)
 Schedules the materialisation process.
void Materialize (ExecutionContext &context, InterruptState &interrupt)
 Single-threaded materialisation.
void MaterializeSortedRun (ExecutionContext &context, InterruptState &interrupt)
 Parallel materialisation.
void GetSortedRun (ClientContext &client)
 Parallel materialisation finish.
void MaterializeEmpty (ClientContext &client)
 Materialize an empty sorted run.
void Print ()
 Print the table to the console.
unique_ptr< ExternalBlockIteratorState > CreateIteratorState ()
 Create an iteration state.
unique_ptr< SortedRunScanState > CreateScanState (ClientContext &client)
 Create an iteration state.
void InitializePayloadState (TupleDataChunkState &state)
 Initialize a payload scanning state.

Static Public Member Functions

static void Repin (ExternalBlockIteratorState &iter)
 Reset the pins for an iterator so we release memory in a timely manner.

Public Attributes

const PhysicalRangeJoin & op
 The hosting operator.
unique_ptr< Sort > sort
 The sort description.
unique_ptr< GlobalSinkState > global_sink
 The shared sort state.
atomic< idx_t > has_null
 Whether or not the RHS has NULL values.
atomic< idx_t > count
 The total number of rows in the RHS.
atomic< idx_t > tasks_completed
 The number of materialisation tasks completed in parallel.
unique_ptr< GlobalSourceState > global_source
 The shared materialisation state.
unique_ptr< SortedRun > sorted
 The materialized data.
unsafe_unique_array< bool > found_match
 A bool indicating for each tuple in the RHS if they found a match (only used in FULL OUTER JOIN).

Constructor & Destructor Documentation

◆ GlobalSortedTable()

duckdb::PhysicalRangeJoin::GlobalSortedTable::GlobalSortedTable ( ClientContext & client,
const vector< BoundOrderByNode > & orders,
const vector< LogicalType > & payload_layout,
const PhysicalRangeJoin & op )
189894 : op(op), has_null(0), count(0), tasks_completed(0) {
189895 // Set up the sort. We will materialize keys ourselves, so just set up references.
189896 vector<BoundOrderByNode> orders;
189897 vector<LogicalType> input_types;
189898 for (const auto &order_by : order_bys) {
189899 auto order = order_by.Copy();
189900 const auto type = order.expression->return_type;
189901 input_types.emplace_back(type);
189902 order.expression = make_uniq<BoundReferenceExpression>(type, orders.size());
189903 orders.emplace_back(std::move(order));
189904 }
189905
189906 vector<idx_t> projection_map;
189907 for (const auto &type : payload_types) {
189908 projection_map.emplace_back(input_types.size());
189909 input_types.emplace_back(type);
189910 }
189911
189912 sort = make_uniq<Sort>(client, orders, input_types, projection_map);
189913
189914 global_sink = sort->GetGlobalSinkState(client);
189915}
PhysicalOperatorType type
The physical operator type.
Definition duckdb.hpp:22150
unique_ptr< Sort > sort
The sort description.
Definition duckdb.cpp:185968
atomic< idx_t > count
The total number of rows in the RHS.
Definition duckdb.cpp:185974
const PhysicalRangeJoin & op
The hosting operator.
Definition duckdb.cpp:185966
atomic< idx_t > has_null
Whether or not the RHS has NULL values.
Definition duckdb.cpp:185972
atomic< idx_t > tasks_completed
The number of materialisation tasks completed in parallel.
Definition duckdb.cpp:185976
unique_ptr< GlobalSinkState > global_sink
The shared sort state.
Definition duckdb.cpp:185970

Member Function Documentation

◆ Count()

idx_t duckdb::PhysicalRangeJoin::GlobalSortedTable::Count ( ) const
inline
185899 {
185900 return count;
185901 }

◆ BlockCount()

idx_t duckdb::PhysicalRangeJoin::GlobalSortedTable::BlockCount ( ) const
inline
185903 {
185904 return sorted->key_data->ChunkCount();
185905 }
unique_ptr< SortedRun > sorted
The materialized data.
Definition duckdb.cpp:185980

◆ BlockStart()

idx_t duckdb::PhysicalRangeJoin::GlobalSortedTable::BlockStart ( idx_t i) const
inline
185907 {
185908 return MinValue<idx_t>(i * STANDARD_VECTOR_SIZE, count);
185909 }

◆ BlockEnd()

idx_t duckdb::PhysicalRangeJoin::GlobalSortedTable::BlockEnd ( idx_t i) const
inline
185911 {
185912 return BlockStart(i + 1) - 1;
185913 }

◆ BlockSize()

idx_t duckdb::PhysicalRangeJoin::GlobalSortedTable::BlockSize ( idx_t i) const
inline
185915 {
185916 return i < BlockCount() ? MinValue<idx_t>(STANDARD_VECTOR_SIZE, count - BlockStart(i)) : 0;
185917 }

◆ GetSortKeyType()

SortKeyType duckdb::PhysicalRangeJoin::GlobalSortedTable::GetSortKeyType ( ) const
inline
185919 {
185920 return sorted->key_data->GetLayout().GetSortKeyType();
185921 }

◆ IntializeMatches()

void duckdb::PhysicalRangeJoin::GlobalSortedTable::IntializeMatches ( )
189931 {
189932 found_match = make_unsafe_uniq_array_uninitialized<bool>(Count());
189933 memset(found_match.get(), 0, sizeof(bool) * Count());
189934}
unsafe_unique_array< bool > found_match
A bool indicating for each tuple in the RHS if they found a match (only used in FULL OUTER JOIN).
Definition duckdb.cpp:185982

◆ Combine()

void duckdb::PhysicalRangeJoin::GlobalSortedTable::Combine ( ExecutionContext & context,
LocalSortedTable & ltable )

Combine local states.

189917 {
189918 InterruptState interrupt;
189919 OperatorSinkCombineInput combine {*global_sink, *ltable.local_sink, interrupt};
189920 sort->Combine(context, combine);
189921 has_null += ltable.has_null;
189922 count += ltable.count;
189923}
cv::GKernelPackage combine(const cv::GKernelPackage &lhs, const cv::GKernelPackage &rhs)

◆ Finalize()

void duckdb::PhysicalRangeJoin::GlobalSortedTable::Finalize ( ClientContext & client,
InterruptState & interrupt )

Prepare for sorting.

189925 {
189926 OperatorSinkFinalizeInput finalize {*global_sink, interrupt};
189927 sort->Finalize(client, finalize);
189928 global_source = sort->GetGlobalSourceState(client, *global_sink);
189929}
unique_ptr< GlobalSourceState > global_source
The shared materialisation state.
Definition duckdb.cpp:185978

◆ Materialize() [1/2]

void duckdb::PhysicalRangeJoin::GlobalSortedTable::Materialize ( Pipeline & pipeline,
Event & event )

Schedules the materialisation process.

190032 {
190033 // Schedule all the sorts for maximum thread utilisation
190034 auto sort_event = make_shared_ptr<RangeJoinMaterializeEvent>(*this, pipeline);
190035 event.InsertEvent(std::move(sort_event));
190036}

◆ Materialize() [2/2]

void duckdb::PhysicalRangeJoin::GlobalSortedTable::Materialize ( ExecutionContext & context,
InterruptState & interrupt )

Single-threaded materialisation.

190052 {
190053 MaterializeSortedRun(context, interrupt);
190054 GetSortedRun(context.client);
190055}
void MaterializeSortedRun(ExecutionContext &context, InterruptState &interrupt)
Parallel materialisation.
Definition duckdb.cpp:190038
void GetSortedRun(ClientContext &client)
Parallel materialisation finish.
Definition duckdb.cpp:190044
Here is the call graph for this function:

◆ MaterializeSortedRun()

void duckdb::PhysicalRangeJoin::GlobalSortedTable::MaterializeSortedRun ( ExecutionContext & context,
InterruptState & interrupt )

Parallel materialisation.

190038 {
190039 auto local_source = sort->GetLocalSourceState(context, *global_source);
190040 OperatorSourceInput source {*global_source, *local_source, interrupt};
190041 sort->MaterializeSortedRun(context, source);
190042}
Here is the caller graph for this function:

◆ GetSortedRun()

void duckdb::PhysicalRangeJoin::GlobalSortedTable::GetSortedRun ( ClientContext & client)

Parallel materialisation finish.

190044 {
190045 sorted = sort->GetSortedRun(*global_source);
190046 if (!sorted) {
190047 MaterializeEmpty(client);
190048 }
190049 global_source.reset();
190050}
void MaterializeEmpty(ClientContext &client)
Materialize an empty sorted run.
Definition duckdb.cpp:189936
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MaterializeEmpty()

void duckdb::PhysicalRangeJoin::GlobalSortedTable::MaterializeEmpty ( ClientContext & client)

Materialize an empty sorted run.

189936 {
189937 D_ASSERT(!sorted);
189938 sorted = make_uniq<SortedRun>(client, *sort, false);
189939}
Here is the caller graph for this function:

◆ Print()

void duckdb::PhysicalRangeJoin::GlobalSortedTable::Print ( )

Print the table to the console.

189941 {
189942 D_ASSERT(sorted);
189943 auto &collection = *sorted->payload_data;
189944 TupleDataScanState scanner;
189945 collection.InitializeScan(scanner);
189946
189947 DataChunk payload;
189948 collection.InitializeScanChunk(scanner, payload);
189949
189950 while (collection.Scan(scanner, payload)) {
189951 payload.Print();
189952 }
189953}
Here is the call graph for this function:

◆ CreateIteratorState()

unique_ptr< ExternalBlockIteratorState > duckdb::PhysicalRangeJoin::GlobalSortedTable::CreateIteratorState ( )
inline

Create an iteration state.

185943 {
185944 auto state = make_uniq<ExternalBlockIteratorState>(*sorted->key_data, sorted->payload_data.get());
185945
185946 // Unless we do this, we will only get values from the first chunk
185947 Repin(*state);
185948
185949 return state;
185950 }
static void Repin(ExternalBlockIteratorState &iter)
Reset the pins for an iterator so we release memory in a timely manner.
Definition duckdb.cpp:185952
Here is the call graph for this function:

◆ Repin()

void duckdb::PhysicalRangeJoin::GlobalSortedTable::Repin ( ExternalBlockIteratorState & iter)
inlinestatic

Reset the pins for an iterator so we release memory in a timely manner.

185952 {
185953 iter.SetKeepPinned(true);
185954 iter.SetPinPayload(true);
185955 }
Here is the caller graph for this function:

◆ CreateScanState()

unique_ptr< SortedRunScanState > duckdb::PhysicalRangeJoin::GlobalSortedTable::CreateScanState ( ClientContext & client)
inline

Create an iteration state.

185957 {
185958 return make_uniq<SortedRunScanState>(client, *sort);
185959 }

◆ InitializePayloadState()

void duckdb::PhysicalRangeJoin::GlobalSortedTable::InitializePayloadState ( TupleDataChunkState & state)
inline

Initialize a payload scanning state.

185961 {
185962 sorted->payload_data->InitializeChunkState(state);
185963 }

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