![]() |
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.
|
SingleFileBlockManager is an implementation for a BlockManager which manages blocks in a single file. More...


Public Member Functions | |
| SingleFileBlockManager (AttachedDatabase &db_p, const string &path_p, const StorageManagerOptions &options_p) | |
| FileOpenFlags | GetFileFlags (bool create_new) const |
| void | CreateNewDatabase (QueryContext context) |
| Creates a new database. | |
| void | LoadExistingDatabase (QueryContext context) |
| unique_ptr< Block > | ConvertBlock (block_id_t block_id, FileBuffer &source_buffer) override |
| Creates a new Block using the specified block_id and returns a pointer. | |
| unique_ptr< Block > | CreateBlock (block_id_t block_id, FileBuffer *source_buffer) override |
| block_id_t | GetFreeBlockId () override |
| Return the next free block id. | |
| block_id_t | GetFreeBlockIdForCheckpoint () override |
| Return the next free block id. | |
| block_id_t | PeekFreeBlockId () override |
| Check the next free block id - but do not assign or allocate it. | |
| bool | IsRootBlock (MetaBlockPointer root) override |
| Returns whether or not a specified block is the root block. | |
| void | MarkBlockAsCheckpointed (block_id_t block_id) override |
| Mark a block as included in a checkpoint. | |
| void | MarkBlockAsUsed (block_id_t block_id) override |
| Mark a block as used (no longer re-writeable). | |
| void | MarkBlockAsModified (block_id_t block_id) override |
| Mark a block as modified (re-writeable after a checkpoint). | |
| void | IncreaseBlockReferenceCount (block_id_t block_id) override |
| Increase the reference count of a block. The block should hold at least one reference. | |
| void | UnregisterBlock (block_id_t id) override |
| UnregisterBlock, only accepts non-temporary block ids. | |
| idx_t | GetMetaBlock () override |
| Return the meta block id. | |
| void | Read (QueryContext context, Block &block) override |
| Read the content of the block from disk. | |
| void | ReadBlock (Block &block, bool skip_block_header=false) const |
| Read individual blocks. | |
| void | ReadBlock (data_ptr_t internal_buffer, uint64_t block_size, bool skip_block_header=false) const |
| void | ReadBlocks (FileBuffer &buffer, block_id_t start_block, idx_t block_count) override |
| Read the content of a range of blocks into a buffer. | |
| void | Write (FileBuffer &buffer, block_id_t block_id) override |
| Write the block to disk. Use Write with client context instead. | |
| void | Write (QueryContext context, FileBuffer &buffer, block_id_t block_id) override |
| Write the block to disk. | |
| void | WriteHeader (QueryContext context, DatabaseHeader header) override |
| Write the header to disk, this is the final step of the checkpointing process. | |
| void | FileSync () override |
| Sync changes to the underlying file. | |
| void | Truncate () override |
| Truncate the underlying database file after a checkpoint. | |
| bool | InMemory () override |
| Whether or not the attached database is in-memory. | |
| idx_t | TotalBlocks () override |
| Returns the number of total blocks. | |
| idx_t | FreeBlocks () override |
| Returns the number of free blocks. | |
| bool | IsRemote () override |
| Whether or not the attached database is a remote file. | |
| bool | Prefetch () override |
| Whether or not to prefetch. | |
| uint64_t | GetCheckpointIteration () const |
| Return the checkpoint iteration of the file. | |
| uint64_t | GetVersionNumber () const |
| Return the version number of the file. | |
| data_ptr_t | GetDBIdentifier () |
| Return the database identifier. | |
| Public Member Functions inherited from duckdb::BlockManager | |
| BlockManager (BufferManager &buffer_manager, const optional_idx block_alloc_size_p, const optional_idx block_header_size_p) | |
| BufferManager & | GetBufferManager () const |
| void | Write (Block &block) |
| Writes the block to disk. | |
| shared_ptr< BlockHandle > | RegisterBlock (block_id_t block_id) |
| Register a block with the given block id in the base file. | |
| shared_ptr< BlockHandle > | ConvertToPersistent (QueryContext context, block_id_t block_id, shared_ptr< BlockHandle > old_block, BufferHandle old_handle, ConvertToPersistentMode mode=ConvertToPersistentMode::DESTRUCTIVE) |
| Convert an existing in-memory buffer into a persistent disk-backed block If mode is set to destructive (default) - the old_block will be destroyed as part of this method This can only be safely used when there is no other (lingering) usage of old_block If there is concurrent usage of the block elsewhere - use the THREAD_SAFE mode which creates an extra copy. | |
| shared_ptr< BlockHandle > | ConvertToPersistent (QueryContext context, block_id_t block_id, shared_ptr< BlockHandle > old_block, ConvertToPersistentMode mode=ConvertToPersistentMode::DESTRUCTIVE) |
| void | UnregisterPersistentBlock (BlockHandle &block) |
| MetadataManager & | GetMetadataManager () |
| Returns a reference to the metadata manager of this block manager. | |
| idx_t | GetBlockAllocSize () const |
| Returns the block allocation size of this block manager. | |
| optional_idx | GetOptionalBlockAllocSize () const |
| Returns the possibly invalid block allocation size of this block manager. | |
| optional_idx | GetOptionalBlockHeaderSize () const |
| Returns the possibly invalid block header size of this block manager. | |
| idx_t | GetBlockHeaderSize () const |
| Returns the block header size including the 8-byte checksum of this block manager. | |
| idx_t | GetBlockSize () const |
| Returns the size of the block that is available for usage. | |
| void | SetBlockAllocSize (const optional_idx block_alloc_size_p) |
| Sets the block allocation size. This should only happen when initializing an existing database. When initializing an existing database, we construct the block manager before reading the file header, which contains the file's actual block allocation size. | |
| void | SetBlockHeaderSize (const optional_idx block_header_size_p) |
| Sets the block header size. Idem as above. This is only set once upon initialization of the database For now this method is unused. | |
| template<class TARGET> | |
| TARGET & | Cast () |
| template<class TARGET> | |
| const TARGET & | Cast () const |
Private Member Functions | |
| void | LoadFreeList (QueryContext context) |
| Loads the free list of the file. | |
| void | Initialize (const DatabaseHeader &header, const optional_idx block_alloc_size) |
| void | CheckChecksum (FileBuffer &block, uint64_t location, uint64_t delta, bool skip_block_header=false) const |
| void | CheckChecksum (data_ptr_t start_ptr, uint64_t delta, bool skip_block_header=false) const |
| void | ReadAndChecksum (QueryContext context, FileBuffer &handle, uint64_t location, bool skip_block_header=false) const |
| void | ChecksumAndWrite (QueryContext context, FileBuffer &handle, uint64_t location, bool skip_block_header=false) const |
| idx_t | GetBlockLocation (block_id_t block_id) const |
| void | StoreEncryptionMetadata (MainHeader &main_header) const |
| void | CheckAndAddEncryptionKey (MainHeader &main_header, string &user_key) |
| Check and adding Encryption Keys. | |
| void | CheckAndAddEncryptionKey (MainHeader &main_header) |
| vector< MetadataHandle > | GetFreeListBlocks () |
| Return the blocks to which we will write the free list and modified blocks. | |
| void | TrimFreeBlocks (const set< block_id_t > &blocks) |
| void | TrimFreeBlockRange (block_id_t start, block_id_t end) |
| void | IncreaseBlockReferenceCountInternal (block_id_t block_id) |
| void | VerifyBlocks (const unordered_map< block_id_t, idx_t > &block_usage_count) override |
| Verify the block usage count. | |
| void | AddStorageVersionTag () |
| block_id_t | GetFreeBlockIdInternal (FreeBlockType type) |
| bool | AddFreeBlock (unique_lock< mutex > &lock, block_id_t block_id) |
| Adds a free block to the free_list, returns true if it was added to the regular free_list. | |
Static Private Member Functions | |
| static void | StoreEncryptedCanary (AttachedDatabase &db, MainHeader &main_header, const string &key_id) |
| static void | StoreDBIdentifier (MainHeader &main_header, const data_ptr_t db_identifier) |
| template<typename T> | |
| static void | WriteEncryptionData (MemoryStream &stream, const T &val) |
Private Attributes | |
| AttachedDatabase & | db |
| uint8_t | active_header |
| The active DatabaseHeader, either 0 (h1) or 1 (h2). | |
| string | path |
| The path where the file is stored. | |
| unique_ptr< FileHandle > | handle |
| The file handle. | |
| FileBuffer | header_buffer |
| The buffer used to read/write to the headers. | |
| set< block_id_t > | free_list |
| The list of free blocks that can be written to currently. | |
| set< block_id_t > | free_blocks_in_use |
| The list of blocks that have been freed, but cannot yet be re-used because they are still in-use. | |
| set< block_id_t > | newly_used_blocks |
| The list of blocks that are in-use, but haven't been written as part of a checkpoint yet. | |
| unordered_map< block_id_t, uint32_t > | multi_use_blocks |
| unordered_set< block_id_t > | modified_blocks |
| The list of blocks that are no longer in-use, but cannot be re-used until the next checkpoint. | |
| idx_t | meta_block |
| The current meta block id. | |
| block_id_t | max_block |
| The current maximum block id, this id will be given away first after the free_list runs out. | |
| idx_t | free_list_id |
| The block id where the free list can be found. | |
| uint64_t | iteration_count |
| The current header iteration count. | |
| StorageManagerOptions | options |
| The storage manager options. | |
| mutex | single_file_block_lock |
| Lock for performing various operations in the single file block manager. | |
Static Private Attributes | |
| static constexpr uint64_t | BLOCK_START = Storage::FILE_HEADER_SIZE * 3 |
| The location in the file where the block writing starts. | |
Additional Inherited Members | |
| Public Attributes inherited from duckdb::BlockManager | |
| BufferManager & | buffer_manager |
| The buffer manager. | |
| Protected Member Functions inherited from duckdb::BlockManager | |
| bool | BlockIsRegistered (block_id_t block_id) |
| shared_ptr< BlockHandle > | TryGetBlock (block_id_t block_id) |
| Protected Attributes inherited from duckdb::BlockManager | |
| bool | in_destruction = false |
| A flag to be flipped in the destructor of the subclass, which is called first. Relevant for some Windows edge cases. | |
SingleFileBlockManager is an implementation for a BlockManager which manages blocks in a single file.
| duckdb::SingleFileBlockManager::SingleFileBlockManager | ( | AttachedDatabase & | db_p, |
| const string & | path_p, | ||
| const StorageManagerOptions & | options_p ) |
|
override |
| FileOpenFlags duckdb::SingleFileBlockManager::GetFileFlags | ( | bool | create_new | ) | const |
| void duckdb::SingleFileBlockManager::CreateNewDatabase | ( | QueryContext | context | ) |
Creates a new database.


| void duckdb::SingleFileBlockManager::LoadExistingDatabase | ( | QueryContext | context | ) |
Loads an existing database. We pass the provided block allocation size as a parameter to detect inconsistencies with the file header.
Encryption is set
Check if our encryption module can write, if not, we throw
Check if the given key upon attach is correct


|
overridevirtual |
Creates a new Block using the specified block_id and returns a pointer.
Implements duckdb::BlockManager.


|
overridevirtual |
Implements duckdb::BlockManager.
|
overridevirtual |
Return the next free block id.
Implements duckdb::BlockManager.


|
overridevirtual |
Return the next free block id.
Implements duckdb::BlockManager.


|
overridevirtual |
Check the next free block id - but do not assign or allocate it.
Implements duckdb::BlockManager.


|
overridevirtual |
Returns whether or not a specified block is the root block.
Implements duckdb::BlockManager.


|
overridevirtual |
Mark a block as included in a checkpoint.
Implements duckdb::BlockManager.


|
overridevirtual |
Mark a block as used (no longer re-writeable).
Implements duckdb::BlockManager.


|
overridevirtual |
Mark a block as modified (re-writeable after a checkpoint).
Implements duckdb::BlockManager.


|
overridevirtual |
Increase the reference count of a block. The block should hold at least one reference.
Implements duckdb::BlockManager.


|
overridevirtual |
UnregisterBlock, only accepts non-temporary block ids.
Reimplemented from duckdb::BlockManager.


|
overridevirtual |
Return the meta block id.
Implements duckdb::BlockManager.


|
overridevirtual |
Read the content of the block from disk.
Implements duckdb::BlockManager.


| void duckdb::SingleFileBlockManager::ReadBlock | ( | Block & | block, |
| bool | skip_block_header = false ) const |
Read individual blocks.
calculate delta header bytes (if any)


| void duckdb::SingleFileBlockManager::ReadBlock | ( | data_ptr_t | internal_buffer, |
| uint64_t | block_size, | ||
| bool | skip_block_header = false ) const |
calculate delta header bytes (if any)

|
overridevirtual |
Read the content of a range of blocks into a buffer.
Implements duckdb::BlockManager.


|
overridevirtual |
Write the block to disk. Use Write with client context instead.
Implements duckdb::BlockManager.


|
overridevirtual |
Write the block to disk.
Reimplemented from duckdb::BlockManager.

|
overridevirtual |
Write the header to disk, this is the final step of the checkpointing process.
Ensure the header write ends up on disk
Implements duckdb::BlockManager.


|
overridevirtual |
Sync changes to the underlying file.
Implements duckdb::BlockManager.


|
overridevirtual |
Truncate the underlying database file after a checkpoint.
Reimplemented from duckdb::BlockManager.


|
inlineoverridevirtual |
Whether or not the attached database is in-memory.
Implements duckdb::BlockManager.

|
overridevirtual |
Returns the number of total blocks.
Implements duckdb::BlockManager.


|
overridevirtual |
Returns the number of free blocks.
Implements duckdb::BlockManager.


|
overridevirtual |
Whether or not the attached database is a remote file.
Reimplemented from duckdb::BlockManager.


|
overridevirtual |
Whether or not to prefetch.
Reimplemented from duckdb::BlockManager.


|
inline |
Return the checkpoint iteration of the file.

| uint64_t duckdb::SingleFileBlockManager::GetVersionNumber | ( | ) | const |
Return the version number of the file.


|
inline |
Return the database identifier.
|
private |
Loads the free list of the file.


|
private |
Initializes the database header. We pass the provided block allocation size as a parameter to detect inconsistencies with the file header.


|
private |
Even with encryption enabled, the main header should be plaintext
We do have to decrypt other headers


|
private |
Even with encryption enabled, the main header should be plaintext
We do have to decrypt other headers

|
private |
calculate delta header bytes (if any)


|
private |
This happens only for the main database header We do not encrypt the main database header
zero out the last bytes of the block


|
private |
|
staticprivate |
|
staticprivate |
|
private |
|
staticprivate |
|
private |
Check and adding Encryption Keys.
Get the database identifier.
Check if the correct key is used to decrypt the database


|
private |
|
private |
Return the blocks to which we will write the free list and modified blocks.


|
private |
|
private |
|
private |
|
overrideprivatevirtual |
Verify the block usage count.
Reimplemented from duckdb::BlockManager.


|
private |
|
private |
|
private |
Adds a free block to the free_list, returns true if it was added to the regular free_list.


|
private |
The list of multi-use blocks (i.e. blocks that have >1 reference in the file) When a multi-use block is marked as modified, the reference count is decreased by 1 instead of directly Appending the block to the modified_blocks list