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::InMemoryBlockManager Class Reference

InMemoryBlockManager is an implementation for a BlockManager. More...

Inheritance diagram for duckdb::InMemoryBlockManager:
Collaboration diagram for duckdb::InMemoryBlockManager:

Public Member Functions

unique_ptr< Block > ConvertBlock (block_id_t block_id, FileBuffer &source_buffer) override
 Creates a new block inside the block manager.
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
 Returns the next free block id and immediately include it in the checkpoint.
block_id_t PeekFreeBlockId () override
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 the next checkpoint.
void MarkBlockAsUsed (block_id_t block_id) override
 Mark a block as "used"; either the block is removed from the free list, or the reference count is incremented.
void MarkBlockAsModified (block_id_t block_id) override
 Mark a block as "modified"; modified blocks are added to the free list after a checkpoint (i.e. their data is assumed to be rewritten).
void IncreaseBlockReferenceCount (block_id_t block_id) override
 Increase the reference count of a block. The block should hold at least one reference before this method is called.
idx_t GetMetaBlock () override
 Get the first meta block id.
void Read (QueryContext context, Block &block) override
 Read the content of the block from disk.
void ReadBlocks (FileBuffer &buffer, block_id_t start_block, idx_t block_count) override
 Read the content of the block from disk.
void Write (FileBuffer &block, block_id_t block_id) override
 Writes the block to disk.
void Write (QueryContext context, FileBuffer &block, block_id_t block_id) override
void WriteHeader (QueryContext context, DatabaseHeader header) override
 Write the header; should be the final step of a checkpoint.
bool InMemory () override
 Whether or not the attached database is in-memory.
void FileSync () override
 Sync changes made to the block manager.
idx_t TotalBlocks () override
 Returns the number of total blocks.
idx_t FreeBlocks () override
 Returns the number of free blocks.
 BlockManager ()=delete
 BlockManager (BufferManager &buffer_manager, const optional_idx block_alloc_size_p, const optional_idx block_header_size_p)
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.
virtual bool IsRemote ()
 Whether or not the attached database is a remote file (e.g. attached over s3/https).
virtual bool Prefetch ()
 Whether or not to prefetch.
virtual void Truncate ()
 Truncate the underlying database file after a checkpoint.
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)
virtual void UnregisterBlock (block_id_t id)
 UnregisterBlock, only accepts non-temporary block ids.
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.
virtual void VerifyBlocks (const unordered_map< block_id_t, idx_t > &block_usage_count)
 Verify the block usage count.
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const

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.

Detailed Description

InMemoryBlockManager is an implementation for a BlockManager.

Member Function Documentation

◆ ConvertBlock()

unique_ptr< Block > duckdb::InMemoryBlockManager::ConvertBlock ( block_id_t block_id,
FileBuffer & source_buffer )
inlineoverridevirtual

Creates a new block inside the block manager.

Implements duckdb::BlockManager.

421668 {
421669 throw InternalException("Cannot perform IO in in-memory database - ConvertBlock!");
421670 }

◆ CreateBlock()

unique_ptr< Block > duckdb::InMemoryBlockManager::CreateBlock ( block_id_t block_id,
FileBuffer * source_buffer )
inlineoverridevirtual

Implements duckdb::BlockManager.

421671 {
421672 throw InternalException("Cannot perform IO in in-memory database - CreateBlock!");
421673 }

◆ GetFreeBlockId()

block_id_t duckdb::InMemoryBlockManager::GetFreeBlockId ( )
inlineoverridevirtual

Return the next free block id.

Implements duckdb::BlockManager.

421674 {
421675 throw InternalException("Cannot perform IO in in-memory database - GetFreeBlockId!");
421676 }

◆ GetFreeBlockIdForCheckpoint()

block_id_t duckdb::InMemoryBlockManager::GetFreeBlockIdForCheckpoint ( )
inlineoverridevirtual

Returns the next free block id and immediately include it in the checkpoint.

Implements duckdb::BlockManager.

421677 {
421678 throw InternalException("Cannot perform IO in in-memory database - GetFreeBlockIdForCheckpoint!");
421679 }

◆ PeekFreeBlockId()

block_id_t duckdb::InMemoryBlockManager::PeekFreeBlockId ( )
inlineoverridevirtual

Implements duckdb::BlockManager.

421680 {
421681 throw InternalException("Cannot perform IO in in-memory database - PeekFreeBlockId!");
421682 }

◆ IsRootBlock()

bool duckdb::InMemoryBlockManager::IsRootBlock ( MetaBlockPointer root)
inlineoverridevirtual

Returns whether or not a specified block is the root block.

Implements duckdb::BlockManager.

421683 {
421684 throw InternalException("Cannot perform IO in in-memory database - IsRootBlock!");
421685 }

◆ MarkBlockAsCheckpointed()

void duckdb::InMemoryBlockManager::MarkBlockAsCheckpointed ( block_id_t block_id)
inlineoverridevirtual

Mark a block as included in the next checkpoint.

Implements duckdb::BlockManager.

421686 {
421687 throw InternalException("Cannot perform IO in in-memory database - MarkBlockAsCheckpointed!");
421688 }

◆ MarkBlockAsUsed()

void duckdb::InMemoryBlockManager::MarkBlockAsUsed ( block_id_t block_id)
inlineoverridevirtual

Mark a block as "used"; either the block is removed from the free list, or the reference count is incremented.

Implements duckdb::BlockManager.

421689 {
421690 throw InternalException("Cannot perform IO in in-memory database - MarkBlockAsUsed!");
421691 }

◆ MarkBlockAsModified()

void duckdb::InMemoryBlockManager::MarkBlockAsModified ( block_id_t block_id)
inlineoverridevirtual

Mark a block as "modified"; modified blocks are added to the free list after a checkpoint (i.e. their data is assumed to be rewritten).

Implements duckdb::BlockManager.

421692 {
421693 throw InternalException("Cannot perform IO in in-memory database - MarkBlockAsModified!");
421694 }

◆ IncreaseBlockReferenceCount()

void duckdb::InMemoryBlockManager::IncreaseBlockReferenceCount ( block_id_t block_id)
inlineoverridevirtual

Increase the reference count of a block. The block should hold at least one reference before this method is called.

Implements duckdb::BlockManager.

421695 {
421696 throw InternalException("Cannot perform IO in in-memory database - IncreaseBlockReferenceCount!");
421697 }

◆ GetMetaBlock()

idx_t duckdb::InMemoryBlockManager::GetMetaBlock ( )
inlineoverridevirtual

Get the first meta block id.

Implements duckdb::BlockManager.

421698 {
421699 throw InternalException("Cannot perform IO in in-memory database - GetMetaBlock!");
421700 }

◆ Read()

void duckdb::InMemoryBlockManager::Read ( QueryContext context,
Block & block )
inlineoverridevirtual

Read the content of the block from disk.

Implements duckdb::BlockManager.

421702 {
421703 throw InternalException("Cannot perform IO in in-memory database - Read!");
421704 }

◆ ReadBlocks()

void duckdb::InMemoryBlockManager::ReadBlocks ( FileBuffer & buffer,
block_id_t start_block,
idx_t block_count )
inlineoverridevirtual

Read the content of the block from disk.

Implements duckdb::BlockManager.

421705 {
421706 throw InternalException("Cannot perform IO in in-memory database - ReadBlocks!");
421707 }

◆ Write() [1/2]

void duckdb::InMemoryBlockManager::Write ( FileBuffer & block,
block_id_t block_id )
inlineoverridevirtual

Writes the block to disk.

Implements duckdb::BlockManager.

421708 {
421709 throw InternalException("Cannot perform IO in in-memory database - Write!");
421710 }

◆ Write() [2/2]

void duckdb::InMemoryBlockManager::Write ( QueryContext context,
FileBuffer & block,
block_id_t block_id )
inlineoverridevirtual

Reimplemented from duckdb::BlockManager.

421711 {
421712 throw InternalException("Cannot perform IO in in-memory database - Write with client context!");
421713 }

◆ WriteHeader()

void duckdb::InMemoryBlockManager::WriteHeader ( QueryContext context,
DatabaseHeader header )
inlineoverridevirtual

Write the header; should be the final step of a checkpoint.

Implements duckdb::BlockManager.

421714 {
421715 throw InternalException("Cannot perform IO in in-memory database - WriteHeader!");
421716 }

◆ InMemory()

bool duckdb::InMemoryBlockManager::InMemory ( )
inlineoverridevirtual

Whether or not the attached database is in-memory.

Implements duckdb::BlockManager.

421717 {
421718 return true;
421719 }

◆ FileSync()

void duckdb::InMemoryBlockManager::FileSync ( )
inlineoverridevirtual

Sync changes made to the block manager.

Implements duckdb::BlockManager.

421720 {
421721 throw InternalException("Cannot perform IO in in-memory database - FileSync!");
421722 }

◆ TotalBlocks()

idx_t duckdb::InMemoryBlockManager::TotalBlocks ( )
inlineoverridevirtual

Returns the number of total blocks.

Implements duckdb::BlockManager.

421723 {
421724 throw InternalException("Cannot perform IO in in-memory database - TotalBlocks!");
421725 }

◆ FreeBlocks()

idx_t duckdb::InMemoryBlockManager::FreeBlocks ( )
inlineoverridevirtual

Returns the number of free blocks.

Implements duckdb::BlockManager.

421726 {
421727 throw InternalException("Cannot perform IO in in-memory database - FreeBlocks!");
421728 }

◆ BlockManager()

duckdb::BlockManager::BlockManager ( BufferManager & buffer_manager,
const optional_idx block_alloc_size_p,
const optional_idx block_header_size_p )
387029 : buffer_manager(buffer_manager), metadata_manager(make_uniq<MetadataManager>(*this, buffer_manager)),
387030 block_alloc_size(block_alloc_size_p), block_header_size(block_header_size_p) {
387031}
optional_idx block_alloc_size
The allocation size of blocks managed by this block manager. Defaults to DEFAULT_BLOCK_ALLOC_SIZE for...
Definition duckdb.hpp:45375
optional_idx block_header_size
The size of the block headers (including checksum) in this block manager. Defaults to DEFAULT_BLOCK_H...
Definition duckdb.hpp:45379
BufferManager & buffer_manager
The buffer manager.
Definition duckdb.hpp:45214
unique_ptr< MetadataManager > metadata_manager
The metadata manager.
Definition duckdb.hpp:45371

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