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

Public Member Functions

 SortedRun (ClientContext &context, const Sort &sort, bool is_index_sort)
unique_ptr< SortedRun > CreateRunForMaterialization () const
void Sink (DataChunk &key, DataChunk &payload)
 Appends data to key/data collections.
void Finalize (bool external)
 Sorts the data (physically reorder data if external).
void DestroyData (idx_t tuple_idx_begin, idx_t tuple_idx_end)
 Destroy data between these tuple indices.
idx_t Count () const
 Number of tuples.
idx_t SizeInBytes () const
 Size of this sorted run.

Public Attributes

ClientContext & context
const Sort & sort
unique_ptr< TupleDataCollection > key_data
 Key and payload collections (and associated append states).
unique_ptr< TupleDataCollection > payload_data
TupleDataAppendState key_append_state
TupleDataAppendState payload_append_state
const bool is_index_sort
 Whether this is an (approximate) index sort.
bool finalized
 Whether this run has been finalized.

Private Attributes

mutex merger_global_state_lock
unique_ptr< GlobalSourceState > merge_global_state

Constructor & Destructor Documentation

◆ SortedRun()

duckdb::SortedRun::SortedRun ( ClientContext & context,
const Sort & sort,
bool is_index_sort )
106713 : context(context_p), sort(sort_p),
106714 key_data(make_uniq<TupleDataCollection>(context, sort.key_layout, MemoryTag::ORDER_BY)),
106715 payload_data(sort.payload_layout && sort.payload_layout->ColumnCount() != 0
106716 ? make_uniq<TupleDataCollection>(context, sort.payload_layout, MemoryTag::ORDER_BY)
106717 : nullptr),
106718 is_index_sort(is_index_sort_p), finalized(false) {
106719 key_data->InitializeAppend(key_append_state, TupleDataPinProperties::KEEP_EVERYTHING_PINNED);
106720 if (payload_data) {
106721 payload_data->InitializeAppend(payload_append_state, TupleDataPinProperties::KEEP_EVERYTHING_PINNED);
106722 }
106723}
unique_ptr< TupleDataCollection > key_data
Key and payload collections (and associated append states).
Definition duckdb.cpp:101331
bool finalized
Whether this run has been finalized.
Definition duckdb.cpp:101340
const bool is_index_sort
Whether this is an (approximate) index sort.
Definition duckdb.cpp:101337
@ KEEP_EVERYTHING_PINNED
Keeps all passed blocks pinned while scanning/iterating over the chunks (for both reading/writing).
Definition duckdb.cpp:56599

◆ ~SortedRun()

duckdb::SortedRun::~SortedRun ( )
106733 {
106734}

Member Function Documentation

◆ CreateRunForMaterialization()

unique_ptr< SortedRun > duckdb::SortedRun::CreateRunForMaterialization ( ) const
106725 {
106726 auto res = make_uniq<SortedRun>(context, sort, is_index_sort);
106727 res->key_append_state.pin_state.properties = TupleDataPinProperties::UNPIN_AFTER_DONE;
106728 res->payload_append_state.pin_state.properties = TupleDataPinProperties::UNPIN_AFTER_DONE;
106729 res->finalized = true;
106730 return res;
106731}
@ UNPIN_AFTER_DONE
Unpins blocks after they are done (for both reading/writing).
Definition duckdb.cpp:56601

◆ Sink()

void duckdb::SortedRun::Sink ( DataChunk & key,
DataChunk & payload )

Appends data to key/data collections.

106764 {
106765 D_ASSERT(!finalized);
106766 key_data->Append(key_append_state, key);
106767 if (payload_data) {
106768 D_ASSERT(key.size() == payload.size());
106769 payload_data->Append(payload_append_state, payload);
106770 SetPayloadPointer(key_append_state.chunk_state.row_locations, payload_append_state.chunk_state.row_locations,
106771 key.size(), key_data->GetLayout().GetSortKeyType());
106772 }
106773}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Finalize()

void duckdb::SortedRun::Finalize ( bool external)

Sorts the data (physically reorder data if external).

106990 {
106991 D_ASSERT(!finalized);
106992
106993 // Finalize the append
106994 key_data->FinalizePinState(key_append_state.pin_state);
106995 key_data->VerifyEverythingPinned();
106996 if (payload_data) {
106997 D_ASSERT(key_data->Count() == payload_data->Count());
106998 payload_data->FinalizePinState(payload_append_state.pin_state);
106999 payload_data->VerifyEverythingPinned();
107000 }
107001
107002 // Sort the fixed-size portion of the keys
107003 SortSwitch(context, *key_data, is_index_sort);
107004
107005 if (external) {
107006 // Reorder variable-size portion of keys and/or payload data (if necessary)
107007 const auto sort_key_type = key_data->GetLayout().GetSortKeyType();
107008 if (!SortKeyUtils::IsConstantSize(sort_key_type) || SortKeyUtils::HasPayload(sort_key_type)) {
107009 Reorder(context, key_data, payload_data);
107010 } else {
107011 // This ensures keys are unpinned even if they are constant size and have no payload
107012 key_data->Unpin();
107013 }
107014 }
107015
107016 finalized = true;
107017}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DestroyData()

void duckdb::SortedRun::DestroyData ( idx_t tuple_idx_begin,
idx_t tuple_idx_end )

Destroy data between these tuple indices.

107019 {
107020 // We always have full chunks for sorting, so we can just use the vector size
107021 const auto chunk_idx_start = tuple_idx_begin / STANDARD_VECTOR_SIZE;
107022 const auto chunk_idx_end = tuple_idx_end / STANDARD_VECTOR_SIZE;
107023 if (chunk_idx_start == chunk_idx_end) {
107024 return;
107025 }
107026 key_data->DestroyChunks(chunk_idx_start, chunk_idx_end);
107027 if (payload_data) {
107028 payload_data->DestroyChunks(chunk_idx_start, chunk_idx_end);
107029 }
107030}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Count()

idx_t duckdb::SortedRun::Count ( ) const

Number of tuples.

107032 {
107033 return key_data->Count();
107034}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SizeInBytes()

idx_t duckdb::SortedRun::SizeInBytes ( ) const

Size of this sorted run.

107036 {
107037 idx_t size = key_data->SizeInBytes();
107038 if (payload_data) {
107039 size += payload_data->SizeInBytes();
107040 }
107041 return size;
107042}
GOpaque< Size > size(const GMat &src)
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
Here is the call graph for this function:
Here is the caller graph for this function:

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