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

Public Member Functions

 SingleFileStorageCommitState (StorageManager &storage, WriteAheadLog &log)
void RevertCommit () override
 Revert the commit.
void FlushCommit () override
void AddRowGroupData (DataTable &table, idx_t start_index, idx_t count, unique_ptr< PersistentCollectionData > row_group_data) override
optional_ptr< PersistentCollectionData > GetRowGroupData (DataTable &table, idx_t start_index, idx_t &count) override
bool HasRowGroupData () override

Private Attributes

idx_t initial_wal_size = 0
idx_t initial_written = 0
WriteAheadLog & wal
WALCommitState state
reference_map_t< DataTable, unordered_map< idx_t, OptimisticallyWrittenRowGroupData > > optimistically_written_data

Constructor & Destructor Documentation

◆ SingleFileStorageCommitState()

duckdb::SingleFileStorageCommitState::SingleFileStorageCommitState ( StorageManager & storage,
WriteAheadLog & log )
426757 : wal(wal), state(WALCommitState::IN_PROGRESS) {
426758 auto initial_size = storage.GetWALSize();
426759 initial_written = wal.GetTotalWritten();
426760 initial_wal_size = initial_size;
426761}

◆ ~SingleFileStorageCommitState()

duckdb::SingleFileStorageCommitState::~SingleFileStorageCommitState ( )
override
426763 {
426764 if (state != WALCommitState::IN_PROGRESS) {
426765 return;
426766 }
426767 try {
426768 // Truncate the WAL in case of a destructor.
426769 RevertCommit();
426770 } catch (std::exception &ex) {
426771 ErrorData data(ex);
426772 try {
426773 DUCKDB_LOG_ERROR(wal.GetDatabase().GetDatabase(),
426774 "SingleFileStorageCommitState::~SingleFileStorageCommitState()\t\t" + data.Message());
426775 } catch (...) { // NOLINT
426776 }
426777 } catch (...) { // NOLINT
426778 }
426779}
void RevertCommit() override
Revert the commit.
Definition duckdb.cpp:426781

Member Function Documentation

◆ RevertCommit()

void duckdb::SingleFileStorageCommitState::RevertCommit ( )
overridevirtual

Revert the commit.

Implements duckdb::StorageCommitState.

426781 {
426782 if (state != WALCommitState::IN_PROGRESS) {
426783 return;
426784 }
426785 if (wal.GetTotalWritten() > initial_written) {
426786 // remove any entries written into the WAL by truncating it
426787 wal.Truncate(initial_wal_size);
426788 }
426789 state = WALCommitState::TRUNCATED;
426790}

◆ FlushCommit()

void duckdb::SingleFileStorageCommitState::FlushCommit ( )
overridevirtual

Implements duckdb::StorageCommitState.

426792 {
426793 if (state != WALCommitState::IN_PROGRESS) {
426794 return;
426795 }
426796 // Move the blocks in this COMMIT into the WAL and mark them as "in use".
426797 wal.Flush();
426798 state = WALCommitState::FLUSHED;
426799}

◆ AddRowGroupData()

void duckdb::SingleFileStorageCommitState::AddRowGroupData ( DataTable & table,
idx_t start_index,
idx_t count,
unique_ptr< PersistentCollectionData > row_group_data )
overridevirtual

Implements duckdb::StorageCommitState.

426802 {
426803 if (row_group_data->HasUpdates()) {
426804 // cannot serialize optimistic block pointers if in-memory updates exist
426805 return;
426806 }
426807 auto &entries = optimistically_written_data[table];
426808 auto entry = entries.find(start_index);
426809 if (entry != entries.end()) {
426810 throw InternalException("FIXME: AddOptimisticallyWrittenRowGroup is writing a duplicate row group");
426811 }
426812 entries.insert(
426813 make_pair(start_index, OptimisticallyWrittenRowGroupData(start_index, count, std::move(row_group_data))));
426814}

◆ GetRowGroupData()

optional_ptr< PersistentCollectionData > duckdb::SingleFileStorageCommitState::GetRowGroupData ( DataTable & table,
idx_t start_index,
idx_t & count )
overridevirtual

Implements duckdb::StorageCommitState.

426817 {
426818 auto entry = optimistically_written_data.find(table);
426819 if (entry == optimistically_written_data.end()) {
426820 // no data for this table
426821 return nullptr;
426822 }
426823 auto &row_groups = entry->second;
426824 auto start_entry = row_groups.find(start_index);
426825 if (start_entry == row_groups.end()) {
426826 // this row group was not optimistically written
426827 return nullptr;
426828 }
426829 count = start_entry->second.count;
426830 return start_entry->second.row_group_data.get();
426831}

◆ HasRowGroupData()

bool duckdb::SingleFileStorageCommitState::HasRowGroupData ( )
overridevirtual

Reimplemented from duckdb::StorageCommitState.

426833 {
426834 return !optimistically_written_data.empty();
426835}

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