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

Public Member Functions

 BlockHandle (BlockManager &block_manager, block_id_t block_id, MemoryTag tag)
 BlockHandle (BlockManager &block_manager, block_id_t block_id, MemoryTag tag, unique_ptr< FileBuffer > buffer, DestroyBufferUpon destroy_buffer_upon, idx_t size, BufferPoolReservation &&reservation)
BlockManager & GetBlockManager () const
 Returns a reference to the block manager.
block_id_t BlockId () const
 Returns the block id.
idx_t GetBlockAllocSize () const
 Returns the block allocation size of this block.
idx_t GetBlockHeaderSize () const
 Returns the block header size including the 8-byte checksum.
idx_t GetBlockSize () const
 Returns the size of the block that is available for usage, as determined by the block manager that created the block. The block_alloc_size can differ from the memory_usage for blocks managed by the temporary block manager, thus, this should only be called for persistent blocks.
const BlockMemory & GetMemory () const
 Returns a const reference to the memory of a block.
BlockMemory & GetMemory ()
 Returns a reference to the memory of a block.
weak_ptr< BlockMemory > GetMemoryWeak () const
 Returns a weak pointer to the memory of a block.
BufferHandle LoadFromBuffer (BlockLock &l, data_ptr_t data, unique_ptr< FileBuffer > reusable_buffer, BufferPoolReservation reservation)
BufferHandle Load (QueryContext context, unique_ptr< FileBuffer > buffer=nullptr)
Public Member Functions inherited from duckdb::enable_shared_from_this< BlockHandle >
shared_ptr< BlockHandle > shared_from_this ()

Private Attributes

BlockManager & block_manager
 The block manager, which loads the block.
idx_t block_alloc_size
 The block allocation size, which is determined by the block manager creating the block. For non-temporary block managers the block_alloc_size corresponds to the memory_usage. If we are pinning/loading an unloaded block, then we know how much memory to reserve. This is NOT the actual memory available on a block.
idx_t block_header_size
 The size of the block header, including the checksum.
const block_id_t block_id
 The block id of the block.
const shared_ptr< BlockMemory > memory_p
 Pointer to the underlying memory of the block.
BlockMemory & memory
 Memory for fast access to the block memory.

Additional Inherited Members

Protected Member Functions inherited from duckdb::enable_shared_from_this< BlockHandle >
enable_shared_from_this & operator= (enable_shared_from_this const &) noexcept

Constructor & Destructor Documentation

◆ BlockHandle() [1/2]

duckdb::BlockHandle::BlockHandle ( BlockManager & block_manager,
block_id_t block_id,
MemoryTag tag )
386928 block_header_size(block_manager.GetBlockHeaderSize()), block_id(block_id_p),
386929 memory_p(make_shared_ptr<BlockMemory>(block_manager.GetBufferManager(), block_id_p, tag_p, block_alloc_size)),
386930 memory(*memory_p) {
386931}
idx_t block_header_size
The size of the block header, including the checksum.
Definition duckdb.hpp:45910
idx_t block_alloc_size
The block allocation size, which is determined by the block manager creating the block....
Definition duckdb.hpp:45908
const block_id_t block_id
The block id of the block.
Definition duckdb.hpp:45912
BlockManager & block_manager
The block manager, which loads the block.
Definition duckdb.hpp:45902
BlockMemory & memory
Memory for fast access to the block memory.
Definition duckdb.hpp:45917
const shared_ptr< BlockMemory > memory_p
Pointer to the underlying memory of the block.
Definition duckdb.hpp:45915

◆ BlockHandle() [2/2]

duckdb::BlockHandle::BlockHandle ( BlockManager & block_manager,
block_id_t block_id,
MemoryTag tag,
unique_ptr< FileBuffer > buffer,
DestroyBufferUpon destroy_buffer_upon,
idx_t size,
BufferPoolReservation && reservation )
386937 block_header_size(block_manager.GetBlockHeaderSize()), block_id(block_id_p),
386938 memory_p(make_shared_ptr<BlockMemory>(block_manager.GetBufferManager(), block_id_p, tag_p, std::move(buffer_p),
386939 destroy_buffer_upon_p, size_p, std::move(reservation))),
386940 memory(*memory_p) {
386941}

◆ ~BlockHandle()

duckdb::BlockHandle::~BlockHandle ( )
386943 { // NOLINT: allow internal exceptions
386944 // Early-out for temporary blocks.
386945 if (block_id >= MAXIMUM_BLOCK) {
386946 return;
386947 }
386948 try {
386949 block_manager.UnregisterPersistentBlock(*this);
386950 } catch (...) { // NOLINT
386951 // FIXME: log silent exceptions.
386952 }
386953}

Member Function Documentation

◆ GetBlockManager()

BlockManager & duckdb::BlockHandle::GetBlockManager ( ) const
inline

Returns a reference to the block manager.

45861 {
45862 return block_manager;
45863 }

◆ BlockId()

block_id_t duckdb::BlockHandle::BlockId ( ) const
inline

Returns the block id.

45865 {
45866 return block_id;
45867 }
Here is the caller graph for this function:

◆ GetBlockAllocSize()

idx_t duckdb::BlockHandle::GetBlockAllocSize ( ) const
inline

Returns the block allocation size of this block.

45869 {
45870 return block_alloc_size;
45871 }

◆ GetBlockHeaderSize()

idx_t duckdb::BlockHandle::GetBlockHeaderSize ( ) const
inline

Returns the block header size including the 8-byte checksum.

45873 {
45874 return block_header_size;
45875 }

◆ GetBlockSize()

idx_t duckdb::BlockHandle::GetBlockSize ( ) const
inline

Returns the size of the block that is available for usage, as determined by the block manager that created the block. The block_alloc_size can differ from the memory_usage for blocks managed by the temporary block manager, thus, this should only be called for persistent blocks.

45879 {
45881 }

◆ GetMemory() [1/2]

const BlockMemory & duckdb::BlockHandle::GetMemory ( ) const
inline

Returns a const reference to the memory of a block.

45883 {
45884 return memory;
45885 }
Here is the caller graph for this function:

◆ GetMemory() [2/2]

BlockMemory & duckdb::BlockHandle::GetMemory ( )
inline

Returns a reference to the memory of a block.

45887 {
45888 return memory;
45889 }

◆ GetMemoryWeak()

weak_ptr< BlockMemory > duckdb::BlockHandle::GetMemoryWeak ( ) const
inline

Returns a weak pointer to the memory of a block.

45891 {
45892 return weak_ptr<BlockMemory>(memory_p);
45893 }

◆ LoadFromBuffer()

BufferHandle duckdb::BlockHandle::LoadFromBuffer ( BlockLock & l,
data_ptr_t data,
unique_ptr< FileBuffer > reusable_buffer,
BufferPoolReservation reservation )
386975 {
386976 memory.VerifyMutex(l);
386977 // Copy the data of the file buffer into the block.
386978 D_ASSERT(memory.GetState() != BlockState::BLOCK_LOADED);
386979 D_ASSERT(memory.GetReaders() == 0);
386980 auto block = AllocateBlock(block_manager, std::move(reusable_buffer), block_id);
386981 memcpy(block->InternalBuffer(), data, block->AllocSize());
386982 memory.GetBuffer() = std::move(block);
386983 memory.SetState(BlockState::BLOCK_LOADED);
386984 memory.SetReaders(1);
386985 memory.GetMemoryCharge() = std::move(reservation);
386986 return BufferHandle(shared_from_this(), memory.GetBuffer());
386987}

◆ Load()

BufferHandle duckdb::BlockHandle::Load ( QueryContext context,
unique_ptr< FileBuffer > buffer = nullptr )
386989 {
386990 if (memory.GetState() == BlockState::BLOCK_LOADED) {
386991 // The block has already been loaded.
386992 D_ASSERT(memory.GetBuffer());
386993 memory.IncrementReaders();
386994 return BufferHandle(shared_from_this(), memory.GetBuffer());
386995 }
386996
386997 if (BlockId() < MAXIMUM_BLOCK) {
386998 auto block = AllocateBlock(block_manager, std::move(reusable_buffer), block_id);
386999 block_manager.Read(context, *block);
387000 memory.GetBuffer() = std::move(block);
387001 } else {
387002 if (!memory.MustWriteToTemporaryFile()) {
387003 // The buffer was destroyed upon unpin/evict, so there is no temporary buffer to read.
387004 return BufferHandle();
387005 }
387006 auto &buffer_manager = memory.GetBufferManager();
387007 auto &buffer = memory.GetBuffer();
387008 buffer = buffer_manager.ReadTemporaryBuffer(QueryContext(), memory.GetMemoryTag(), *this,
387009 std::move(reusable_buffer));
387010 }
387011 memory.SetState(BlockState::BLOCK_LOADED);
387012 memory.SetReaders(1);
387013 return BufferHandle(shared_from_this(), memory.GetBuffer());
387014}
block_id_t BlockId() const
Returns the block id.
Definition duckdb.hpp:45865

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