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

Public Member Functions

 SortedRunScanState (ClientContext &context, const Sort &sort)
void Scan (const SortedRun &sorted_run, const Vector &sort_key_pointers, const idx_t &count, DataChunk &chunk)
void Clear ()

Private Member Functions

template<SortKeyType sort_key_type>
void TemplatedScan (const SortedRun &sorted_run, const Vector &sort_key_pointers, const idx_t &count, DataChunk &chunk)

Private Attributes

const Sort & sort
ExpressionExecutor key_executor
DataChunk key
DataChunk decoded_key
TupleDataScanState payload_state
vector< char > key_buffer

Constructor & Destructor Documentation

◆ SortedRunScanState()

duckdb::SortedRunScanState::SortedRunScanState ( ClientContext & context,
const Sort & sort )
106578 : sort(sort_p), key_executor(context, *sort.decode_sort_key) {
106579 key.Initialize(context, {sort.key_layout->GetTypes()[0]});
106580 decoded_key.Initialize(context, {sort.decode_sort_key->return_type});
106581}

Member Function Documentation

◆ Scan()

void duckdb::SortedRunScanState::Scan ( const SortedRun & sorted_run,
const Vector & sort_key_pointers,
const idx_t & count,
DataChunk & chunk )
106584 {
106585 const auto sort_key_type = sort.key_layout->GetSortKeyType();
106586 switch (sort_key_type) {
106588 return TemplatedScan<SortKeyType::NO_PAYLOAD_FIXED_8>(sorted_run, sort_key_pointers, count, chunk);
106589 case SortKeyType::NO_PAYLOAD_FIXED_16:
106590 return TemplatedScan<SortKeyType::NO_PAYLOAD_FIXED_16>(sorted_run, sort_key_pointers, count, chunk);
106591 case SortKeyType::NO_PAYLOAD_FIXED_24:
106592 return TemplatedScan<SortKeyType::NO_PAYLOAD_FIXED_24>(sorted_run, sort_key_pointers, count, chunk);
106593 case SortKeyType::NO_PAYLOAD_FIXED_32:
106594 return TemplatedScan<SortKeyType::NO_PAYLOAD_FIXED_32>(sorted_run, sort_key_pointers, count, chunk);
106595 case SortKeyType::NO_PAYLOAD_VARIABLE_32:
106596 return TemplatedScan<SortKeyType::NO_PAYLOAD_VARIABLE_32>(sorted_run, sort_key_pointers, count, chunk);
106598 return TemplatedScan<SortKeyType::PAYLOAD_FIXED_16>(sorted_run, sort_key_pointers, count, chunk);
106599 case SortKeyType::PAYLOAD_FIXED_24:
106600 return TemplatedScan<SortKeyType::PAYLOAD_FIXED_24>(sorted_run, sort_key_pointers, count, chunk);
106601 case SortKeyType::PAYLOAD_FIXED_32:
106602 return TemplatedScan<SortKeyType::PAYLOAD_FIXED_32>(sorted_run, sort_key_pointers, count, chunk);
106603 case SortKeyType::PAYLOAD_VARIABLE_32:
106604 return TemplatedScan<SortKeyType::PAYLOAD_VARIABLE_32>(sorted_run, sort_key_pointers, count, chunk);
106605 default:
106606 throw NotImplementedException("SortedRunMergerLocalState::ScanPartition for %s",
106607 EnumUtil::ToString(sort_key_type));
106608 }
106609}
@ NO_PAYLOAD_FIXED_8
Without payload.
Definition duckdb.cpp:55338
@ PAYLOAD_FIXED_16
With payload (requires row pointer in key).
Definition duckdb.cpp:55344

◆ Clear()

void duckdb::SortedRunScanState::Clear ( )
106611 {
106612 payload_state.pin_state.row_handles.clear();
106613 payload_state.pin_state.heap_handles.clear();
106614}

◆ TemplatedScan()

template<SortKeyType SORT_KEY_TYPE>
void duckdb::SortedRunScanState::TemplatedScan ( const SortedRun & sorted_run,
const Vector & sort_key_pointers,
const idx_t & count,
DataChunk & chunk )
private
106647 {
106648 using SORT_KEY = SortKey<SORT_KEY_TYPE>;
106649
106650 const auto &output_projection_columns = sort.output_projection_columns;
106651 idx_t opc_idx = 0;
106652
106653 const auto sort_keys = FlatVector::GetData<SORT_KEY *const>(sort_key_pointers);
106654 const auto payload_ptrs = FlatVector::GetData<data_ptr_t>(payload_state.chunk_state.row_locations);
106655 bool gathered_payload = false;
106656
106657 // Decode from key
106658 if (!output_projection_columns[0].is_payload) {
106659 key.Reset();
106660 key_buffer.resize(count * sizeof(SORT_KEY));
106661 auto temp_keys = reinterpret_cast<SORT_KEY *>(key_buffer.data());
106662 GetKeyAndPayload(sort_keys, temp_keys, count, key, payload_ptrs);
106663
106664 decoded_key.Reset();
106665 key_executor.Execute(key, decoded_key);
106666
106667 const auto &decoded_key_entries = StructVector::GetEntries(decoded_key.data[0]);
106668 for (; opc_idx < output_projection_columns.size(); opc_idx++) {
106669 const auto &opc = output_projection_columns[opc_idx];
106670 if (opc.is_payload) {
106671 break;
106672 }
106673 chunk.data[opc.output_col_idx].Reference(*decoded_key_entries[opc.layout_col_idx]);
106674 }
106675
106676 gathered_payload = true;
106677 }
106678
106679 // If there are no payload columns, we're done here
106680 if (opc_idx != output_projection_columns.size()) {
106681 if (!gathered_payload) {
106682 // Gather row pointers from keys
106683 for (idx_t i = 0; i < count; i++) {
106684 payload_ptrs[i] = sort_keys[i]->GetPayload();
106685 }
106686 }
106687
106688 // Init scan state
106689 auto &payload_data = *sorted_run.payload_data;
106690 if (payload_state.pin_state.properties == TupleDataPinProperties::INVALID) {
106691 payload_data.InitializeScan(payload_state, TupleDataPinProperties::ALREADY_PINNED);
106692 }
106693 TupleDataCollection::ResetCachedCastVectors(payload_state.chunk_state, payload_state.chunk_state.column_ids);
106694
106695 // Now gather from payload
106696 for (; opc_idx < output_projection_columns.size(); opc_idx++) {
106697 const auto &opc = output_projection_columns[opc_idx];
106698 D_ASSERT(opc.is_payload);
106699 payload_data.Gather(payload_state.chunk_state.row_locations, *FlatVector::IncrementalSelectionVector(),
106700 count, opc.layout_col_idx, chunk.data[opc.output_col_idx],
106701 *FlatVector::IncrementalSelectionVector(),
106702 payload_state.chunk_state.cached_cast_vectors[opc.layout_col_idx]);
106703 }
106704 }
106705
106706 chunk.SetCardinality(count);
106707}
vector< Vector > data
The vectors owned by the DataChunk.
Definition duckdb.hpp:11445
static void ResetCachedCastVectors(TupleDataChunkState &chunk_state, const vector< column_t > &column_ids)
Resets the cached cache vectors (used for ARRAY/LIST casts).
Definition duckdb.cpp:126370
@ ALREADY_PINNED
Assumes all blocks are already pinned (for reading only).
Definition duckdb.cpp:56605
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: