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

Public Member Functions

 CollectionMerger (ClientContext &context, DataTable &data_table)
void AddCollection (const PhysicalIndex collection_index, RowGroupBatchType type)
bool Empty ()
PhysicalIndex Flush (OptimisticDataWriter &writer)

Public Attributes

ClientContext & context
 The transaction context.
DataTable & data_table
 The data table.
vector< PhysicalIndex > collection_indexes
 Indexes to the optimistic row group collection vector of the local table storage for this transaction.
RowGroupBatchType batch_type
 The batch type for merging collections.

Constructor & Destructor Documentation

◆ CollectionMerger()

duckdb::CollectionMerger::CollectionMerger ( ClientContext & context,
DataTable & data_table )
inlineexplicit
192979 : context(context), data_table(data_table), batch_type(RowGroupBatchType::NOT_FLUSHED) {
192980 }
RowGroupBatchType batch_type
The batch type for merging collections.
Definition duckdb.cpp:192989
DataTable & data_table
The data table.
Definition duckdb.cpp:192985
ClientContext & context
The transaction context.
Definition duckdb.cpp:192983

Member Function Documentation

◆ AddCollection()

void duckdb::CollectionMerger::AddCollection ( const PhysicalIndex collection_index,
RowGroupBatchType type )
inline
192992 {
192993 collection_indexes.push_back(collection_index);
192994 if (type == RowGroupBatchType::FLUSHED) {
192995 batch_type = RowGroupBatchType::FLUSHED;
192996 if (collection_indexes.size() > 1) {
192997 throw InternalException("Cannot merge flushed collections");
192998 }
192999 }
193000 }
vector< PhysicalIndex > collection_indexes
Indexes to the optimistic row group collection vector of the local table storage for this transaction...
Definition duckdb.cpp:192987

◆ Empty()

bool duckdb::CollectionMerger::Empty ( )
inline
193002 {
193003 return collection_indexes.empty();
193004 }

◆ Flush()

PhysicalIndex duckdb::CollectionMerger::Flush ( OptimisticDataWriter & writer)
inline
193006 {
193007 if (Empty()) {
193008 return PhysicalIndex(DConstants::INVALID_INDEX);
193009 }
193010
193011 auto result_collection_index = collection_indexes[0];
193012 auto &optimistic_collection = data_table.GetOptimisticCollection(context, result_collection_index);
193013 auto &result_collection = *optimistic_collection.collection;
193014
193015 if (collection_indexes.size() > 1) {
193016 // Merge all collections into one result collection.
193017 auto &types = result_collection.GetTypes();
193018 TableAppendState append_state;
193019 result_collection.InitializeAppend(append_state);
193020
193021 DataChunk scan_chunk;
193022 scan_chunk.Initialize(context, types);
193023
193024 vector<StorageIndex> column_ids;
193025 for (idx_t i = 0; i < types.size(); i++) {
193026 column_ids.emplace_back(i);
193027 }
193028 for (idx_t i = 1; i < collection_indexes.size(); i++) {
193029 auto &collection = data_table.GetOptimisticCollection(context, collection_indexes[i]);
193030 TableScanState scan_state;
193031 scan_state.Initialize(column_ids);
193032 collection.collection->InitializeScan(context, scan_state.local_state, column_ids, nullptr);
193033
193034 while (true) {
193035 scan_chunk.Reset();
193036 scan_state.local_state.Scan(scan_chunk, TableScanType::TABLE_SCAN_ALL_ROWS);
193037 if (scan_chunk.size() == 0) {
193038 break;
193039 }
193040 auto new_row_group = result_collection.Append(scan_chunk, append_state);
193041 if (new_row_group) {
193042 writer.WriteNewRowGroup(optimistic_collection);
193043 }
193044 }
193045 data_table.ResetOptimisticCollection(context, collection_indexes[i]);
193046 }
193047 result_collection.FinalizeAppend(TransactionData(0, 0), append_state);
193048 writer.WriteUnflushedRowGroups(optimistic_collection);
193049 } else if (batch_type == RowGroupBatchType::NOT_FLUSHED) {
193050 writer.WriteUnflushedRowGroups(optimistic_collection);
193051 }
193052
193053 collection_indexes.clear();
193054 return result_collection_index;
193055 }
DUCKDB_API void Reset()
Definition duckdb.cpp:116840
DUCKDB_API void Initialize(ClientContext &context, const vector< LogicalType > &types, idx_t capacity=STANDARD_VECTOR_SIZE)
Definition duckdb.cpp:116791
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
@ TABLE_SCAN_ALL_ROWS
Scan all rows, including any deleted rows. Committed updates are merged in.
Definition duckdb.hpp:22673
static constexpr const idx_t INVALID_INDEX
The value used to signify an invalid index entry.
Definition duckdb.hpp:1117

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