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::StorageManager Class Referenceabstract

StorageManager is responsible for managing the physical storage of a persistent database. More...

Inheritance diagram for duckdb::StorageManager:
Collaboration diagram for duckdb::StorageManager:

Public Member Functions

 StorageManager (AttachedDatabase &db, string path, AttachOptions &options)
 
void Initialize (QueryContext context)
 
DatabaseInstanceGetDatabase ()
 
AttachedDatabaseGetAttached () const
 
idx_t GetWALSize ()
 Gets the size of the WAL, or zero, if there is no WAL.
 
bool HasWAL () const
 
void AddWALSize (idx_t size)
 
void SetWALSize (idx_t size)
 
idx_t GetWALEntriesCount () const
 Gets the number of WAL entries since last checkpoint.
 
void ResetWALEntriesCount ()
 
void IncrementWALEntriesCount ()
 
optional_ptr< WriteAheadLogGetWAL ()
 Gets the WAL of the StorageManager, or nullptr, if there is no WAL.
 
bool WALStartCheckpoint (MetaBlockPointer meta_block, CheckpointOptions &options)
 Write that we started a checkpoint to the WAL if there is one - returns whether or not there is a WAL.
 
void WALFinishCheckpoint (lock_guard< mutex > &wal_lock)
 Finishes a checkpoint.
 
unique_ptr< lock_guard< mutex > > GetWALLock ()
 
string GetDBPath () const
 Returns the database file path.
 
bool IsLoaded () const
 
string GetWALPath (const string &suffix=".wal")
 The path to the WAL, derived from the database file path.
 
string GetCheckpointWALPath ()
 The path to the WAL that is used while a checkpoint is running.
 
string GetRecoveryWALPath ()
 The path to the WAL that is used while recovering from a crash involving the checkpoint WAL.
 
bool InMemory () const
 
virtual bool AutomaticCheckpoint (idx_t estimated_wal_bytes)=0
 
virtual unique_ptr< StorageCommitStateGenStorageCommitState (WriteAheadLog &wal)=0
 
virtual bool IsCheckpointClean (MetaBlockPointer checkpoint_id)=0
 
virtual void CreateCheckpoint (QueryContext context, CheckpointOptions options=CheckpointOptions())=0
 
virtual DatabaseSize GetDatabaseSize ()=0
 
virtual vector< MetadataBlockInfoGetMetadataInfo ()=0
 
virtual shared_ptr< TableIOManagerGetTableIOManager (BoundCreateTableInfo *info)=0
 
virtual BlockManagerGetBlockManager ()=0
 
virtual void Destroy ()
 
void SetStorageVersion (idx_t version)
 
bool HasStorageVersion () const
 
idx_t GetStorageVersion () const
 
bool CompressionIsEnabled () const
 
EncryptionTypes::CipherType GetCipher () const
 
void SetCipher (EncryptionTypes::CipherType cipher_p)
 
void SetEncryptionVersion (EncryptionTypes::EncryptionVersion version)
 
bool IsEncrypted () const
 
EncryptionTypes::EncryptionVersion GetEncryptionVersion () const
 
template<class TARGET >
TARGETCast ()
 
template<class TARGET >
const TARGETCast () const
 

Static Public Member Functions

static StorageManagerGet (AttachedDatabase &db)
 
static StorageManagerGet (Catalog &catalog)
 

Protected Member Functions

virtual void LoadDatabase (QueryContext context)=0
 

Protected Attributes

AttachedDatabasedb
 The attached database managed by this storage manager.
 
string path
 The path of the database.
 
string wal_path
 The WAL path.
 
unique_ptr< WriteAheadLogwal
 The WriteAheadLog of the storage manager.
 
mutex wal_lock
 Mutex used to control writes to the WAL.
 
bool read_only
 Whether or not the database is opened in read-only mode.
 
bool load_complete = false
 
optional_idx storage_version
 The serialization compatibility version when reading and writing from this database.
 
atomic< idx_twal_size
 
atomic< idx_twal_entries_count
 
StorageOptions storage_options
 Storage options passed in through configuration.
 

Detailed Description

StorageManager is responsible for managing the physical storage of a persistent database.

Member Function Documentation

◆ Initialize()

void duckdb::StorageManager::Initialize ( QueryContext  context)

Initialize a database or load an existing database from the database file path. The block_alloc_size is either set, or invalid. If invalid, then DuckDB defaults to the default_block_alloc_size (DBConfig), or the file's block allocation size, if it is an existing database.

◆ GetAttached()

AttachedDatabase & duckdb::StorageManager::GetAttached ( ) const
inline
11117 {
11118 return db;
11119 }
AttachedDatabase & db
The attached database managed by this storage manager.
Definition duckdb.cpp:11205

◆ GetDBPath()

string duckdb::StorageManager::GetDBPath ( ) const
inline

Returns the database file path.

11140 {
11141 return path;
11142 }
string path
The path of the database.
Definition duckdb.cpp:11207

◆ IsLoaded()

bool duckdb::StorageManager::IsLoaded ( ) const
inline
11143 {
11144 return load_complete;
11145 }
bool load_complete
Definition duckdb.cpp:11218

◆ SetStorageVersion()

void duckdb::StorageManager::SetStorageVersion ( idx_t  version)
inline
11164 {
11165 storage_version = version;
11166 }
optional_idx storage_version
The serialization compatibility version when reading and writing from this database.
Definition duckdb.cpp:11220

◆ HasStorageVersion()

bool duckdb::StorageManager::HasStorageVersion ( ) const
inline
11167 {
11168 return storage_version.IsValid();
11169 }

◆ GetStorageVersion()

idx_t duckdb::StorageManager::GetStorageVersion ( ) const
inline
11170 {
11171 D_ASSERT(HasStorageVersion());
11172 return storage_version.GetIndex();
11173 }

◆ CompressionIsEnabled()

bool duckdb::StorageManager::CompressionIsEnabled ( ) const
inline
11174 {
11175 return storage_options.compress_in_memory == CompressInMemory::COMPRESS;
11176 }
StorageOptions storage_options
Storage options passed in through configuration.
Definition duckdb.cpp:11226

◆ GetCipher()

EncryptionTypes::CipherType duckdb::StorageManager::GetCipher ( ) const
inline
11177 {
11179 }
EncryptionTypes::CipherType encryption_cipher
Encryption algorithm.
Definition duckdb.cpp:11057

◆ SetCipher()

void duckdb::StorageManager::SetCipher ( EncryptionTypes::CipherType  cipher_p)
inline
11180 {
11181 D_ASSERT(cipher_p != EncryptionTypes::INVALID);
11182 if (cipher_p == EncryptionTypes::CBC) {
11183 throw InvalidInputException("CBC cipher is disabled");
11184 }
11186 }

◆ SetEncryptionVersion()

void duckdb::StorageManager::SetEncryptionVersion ( EncryptionTypes::EncryptionVersion  version)
inline
11188 {
11190 }
EncryptionTypes::EncryptionVersion encryption_version
encryption version (set default to 1)
Definition duckdb.cpp:11062

◆ IsEncrypted()

bool duckdb::StorageManager::IsEncrypted ( ) const
inline
11192 {
11194 }
bool encryption
Whether the database is encrypted.
Definition duckdb.cpp:11055

◆ GetEncryptionVersion()

EncryptionTypes::EncryptionVersion duckdb::StorageManager::GetEncryptionVersion ( ) const
inline
11196 {
11198 }

◆ Cast() [1/2]

template<class TARGET >
TARGET & duckdb::StorageManager::Cast ( )
inline
11230 {
11231 DynamicCastCheck<TARGET>(this);
11232 return reinterpret_cast<TARGET &>(*this);
11233 }

◆ Cast() [2/2]

template<class TARGET >
const TARGET & duckdb::StorageManager::Cast ( ) const
inline
11235 {
11236 DynamicCastCheck<TARGET>(this);
11237 return reinterpret_cast<const TARGET &>(*this);
11238 }

Member Data Documentation

◆ load_complete

bool duckdb::StorageManager::load_complete = false
protected

When loading a database, we do not yet set the wal-field. Therefore, GetWriteAheadLog must return nullptr when loading a database

◆ wal_size

atomic<idx_t> duckdb::StorageManager::wal_size
protected

Estimated size of changes for determining automatic checkpointing on in-memory databases and databases without a WAL.


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