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::PartialBlockForCheckpoint Struct Reference
Inheritance diagram for duckdb::PartialBlockForCheckpoint:
Collaboration diagram for duckdb::PartialBlockForCheckpoint:

Classes

struct  PartialColumnSegment

Public Member Functions

 PartialBlockForCheckpoint (ColumnData &data, ColumnSegment &segment, PartialBlockState state, BlockManager &block_manager)
bool IsFlushed ()
void Flush (QueryContext context, const idx_t free_space_left) override
 Flush the block to disk and zero-initialize any free space and uninitialized regions.
void Merge (PartialBlock &other, idx_t offset, idx_t other_size) override
void AddSegmentToTail (ColumnData &data, ColumnSegment &segment, uint32_t offset_in_block) override
void Clear () override
Public Member Functions inherited from duckdb::PartialBlock
 PartialBlock (PartialBlockState state, BlockManager &block_manager, const shared_ptr< BlockHandle > &block_handle)
void AddUninitializedRegion (const idx_t start, const idx_t end)
 Add regions that need zero-initialization to avoid leaking memory.
void FlushInternal (const idx_t free_space_left)
template<class TARGET>
TARGET & Cast ()

Public Attributes

vector< PartialColumnSegment > segments
Public Attributes inherited from duckdb::PartialBlock
PartialBlockState state
 The current state of a partial block.
vector< UninitializedRegion > uninitialized_regions
 All uninitialized regions on this block, we need to zero-initialize them when flushing.
BlockManager & block_manager
 The block manager of the partial block manager.
shared_ptr< BlockHandle > block_handle
 The block handle of the underlying block that this partial block writes to.

Constructor & Destructor Documentation

◆ PartialBlockForCheckpoint()

duckdb::PartialBlockForCheckpoint::PartialBlockForCheckpoint ( ColumnData & data,
ColumnSegment & segment,
PartialBlockState state,
BlockManager & block_manager )
428129 : PartialBlock(state, block_manager, segment.block) {
428130 PartialBlockForCheckpoint::AddSegmentToTail(data, segment, 0);
428131}
PartialBlockState state
The current state of a partial block.
Definition duckdb.cpp:11360
BlockManager & block_manager
The block manager of the partial block manager.
Definition duckdb.cpp:11364

◆ ~PartialBlockForCheckpoint()

duckdb::PartialBlockForCheckpoint::~PartialBlockForCheckpoint ( )
override
428133 {
428134}

Member Function Documentation

◆ IsFlushed()

bool duckdb::PartialBlockForCheckpoint::IsFlushed ( )
428136 {
428137 // segments are cleared on Flush
428138 return segments.empty();
428139}

◆ Flush()

void duckdb::PartialBlockForCheckpoint::Flush ( QueryContext context,
const idx_t free_space_left )
overridevirtual

Flush the block to disk and zero-initialize any free space and uninitialized regions.

Implements duckdb::PartialBlock.

428141 {
428142 if (IsFlushed()) {
428143 throw InternalException("Flush called on partial block that was already flushed");
428144 }
428145
428146 // zero-initialize unused memory
428147 FlushInternal(free_space_left);
428148
428149 // At this point, we've already copied all data from tail_segments
428150 // into the page owned by first_segment. We flush all segment data to
428151 // disk with the following call.
428152 // persist the first segment to disk and point the remaining segments to the same block
428153 bool fetch_new_block = state.block_id == INVALID_BLOCK;
428154 if (fetch_new_block) {
428155 state.block_id = block_manager.GetFreeBlockId();
428156 }
428157
428158 for (idx_t i = 0; i < segments.size(); i++) {
428159 auto &segment = segments[i];
428160 if (i == 0) {
428161 // the first segment is converted to persistent - this writes the data for ALL segments to disk
428162 D_ASSERT(segment.offset_in_block == 0);
428163 segment.segment.ConvertToPersistent(context, &block_manager, state.block_id);
428164 // update the block after it has been converted to a persistent segment
428165 block_handle = segment.segment.block;
428166 } else {
428167 // subsequent segments are MARKED as persistent - they don't need to be rewritten
428168 segment.segment.MarkAsPersistent(block_handle, segment.offset_in_block);
428169 if (fetch_new_block) {
428170 // if we fetched a new block we need to increase the reference count to the block
428171 block_manager.IncreaseBlockReferenceCount(state.block_id);
428172 }
428173 }
428174 }
428175 Clear();
428176}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
shared_ptr< BlockHandle > block_handle
The block handle of the underlying block that this partial block writes to.
Definition duckdb.cpp:11366

◆ Merge()

void duckdb::PartialBlockForCheckpoint::Merge ( PartialBlock & other,
idx_t offset,
idx_t other_size )
overridevirtual

Implements duckdb::PartialBlock.

428178 {
428179 auto &other = other_p.Cast<PartialBlockForCheckpoint>();
428180
428181 auto &buffer_manager = block_manager.buffer_manager;
428182 // pin the source block
428183 auto old_handle = buffer_manager.Pin(other.block_handle);
428184 // pin the target block
428185 auto new_handle = buffer_manager.Pin(block_handle);
428186 // memcpy the contents of the old block to the new block
428187 memcpy(new_handle.Ptr() + offset, old_handle.Ptr(), other_size);
428188
428189 // now copy over all segments to the new block
428190 // move over the uninitialized regions
428191 for (auto &region : other.uninitialized_regions) {
428192 region.start += offset;
428193 region.end += offset;
428194 uninitialized_regions.push_back(region);
428195 }
428196
428197 // move over the segments
428198 for (auto &segment : other.segments) {
428199 AddSegmentToTail(segment.data, segment.segment, NumericCast<uint32_t>(segment.offset_in_block + offset));
428200 }
428201
428202 other.Clear();
428203}
vector< UninitializedRegion > uninitialized_regions
All uninitialized regions on this block, we need to zero-initialize them when flushing.
Definition duckdb.cpp:11362

◆ AddSegmentToTail()

void duckdb::PartialBlockForCheckpoint::AddSegmentToTail ( ColumnData & data,
ColumnSegment & segment,
uint32_t offset_in_block )
overridevirtual

Reimplemented from duckdb::PartialBlock.

428205 {
428206 segments.emplace_back(data, segment, offset_in_block);
428207}

◆ Clear()

void duckdb::PartialBlockForCheckpoint::Clear ( )
overridevirtual

Implements duckdb::PartialBlock.

428209 {
428210 uninitialized_regions.clear();
428211 block_handle.reset();
428212 segments.clear();
428213}

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