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

Public Member Functions

 WriteOverflowStringsToDisk (PartialBlockManager &partial_block_manager)
void WriteString (UncompressedStringSegmentState &state, string_t string, block_id_t &result_block, int32_t &result_offset) override
void Flush () override

Public Attributes

PartialBlockManager & partial_block_manager
 The block manager.
BufferHandle handle
 Temporary buffer.
block_id_t block_id
 The block on-disk to which we are writing.
idx_t offset
 The offset within the current block.

Private Member Functions

void AllocateNewBlock (UncompressedStringSegmentState &state, block_id_t new_block_id)
idx_t GetStringSpace () const

Constructor & Destructor Documentation

◆ WriteOverflowStringsToDisk()

duckdb::WriteOverflowStringsToDisk::WriteOverflowStringsToDisk ( PartialBlockManager & partial_block_manager)
explicit
389569}
block_id_t block_id
The block on-disk to which we are writing.
Definition duckdb.cpp:389545
PartialBlockManager & partial_block_manager
The block manager.
Definition duckdb.cpp:389540
idx_t offset
The offset within the current block.
Definition duckdb.cpp:389547

◆ ~WriteOverflowStringsToDisk()

duckdb::WriteOverflowStringsToDisk::~WriteOverflowStringsToDisk ( )
override
389571 {
389572 // verify that the overflow writer has been flushed
389573 D_ASSERT(Exception::UncaughtException() || offset == 0);
389574}

Member Function Documentation

◆ WriteString()

void duckdb::WriteOverflowStringsToDisk::WriteString ( UncompressedStringSegmentState & state,
string_t string,
block_id_t & result_block,
int32_t & result_offset )
overridevirtual

Implements duckdb::OverflowStringWriter.

389623 {
389624 auto &block_manager = partial_block_manager.GetBlockManager();
389625 auto &buffer_manager = block_manager.buffer_manager;
389626 if (!handle.IsValid()) {
389627 handle = buffer_manager.Allocate(MemoryTag::OVERFLOW_STRINGS, &block_manager);
389628 }
389629 // first write the length of the string
389630 if (block_id == INVALID_BLOCK || offset + 2 * sizeof(uint32_t) >= GetStringSpace()) {
389631 AllocateNewBlock(state, partial_block_manager.GetFreeBlockId());
389632 }
389633 result_block = block_id;
389634 result_offset = UnsafeNumericCast<int32_t>(offset);
389635
389636 // write the length field
389637 auto data_ptr = handle.Ptr();
389638 auto string_length = string.GetSize();
389639 Store<uint32_t>(UnsafeNumericCast<uint32_t>(string_length), data_ptr + offset);
389640 offset += sizeof(uint32_t);
389641
389642 // now write the remainder of the string
389643 auto strptr = string.GetData();
389644 auto remaining = UnsafeNumericCast<uint32_t>(string_length);
389645 while (remaining > 0) {
389646 uint32_t to_write = MinValue<uint32_t>(remaining, UnsafeNumericCast<uint32_t>(GetStringSpace() - offset));
389647 if (to_write > 0) {
389648 memcpy(data_ptr + offset, strptr, to_write);
389649
389650 remaining -= to_write;
389651 offset += to_write;
389652 strptr += to_write;
389653 }
389654 if (remaining > 0) {
389655 D_ASSERT(offset == GetStringSpace());
389656 // there is still remaining stuff to write
389657 // now write the current block to disk and allocate a new block
389658 AllocateNewBlock(state, partial_block_manager.GetFreeBlockId());
389659 }
389660 }
389661}
BufferHandle handle
Temporary buffer.
Definition duckdb.cpp:389543
::uint32_t uint32_t

◆ Flush()

void duckdb::WriteOverflowStringsToDisk::Flush ( )
overridevirtual

Implements duckdb::OverflowStringWriter.

389663 {
389664 if (block_id != INVALID_BLOCK && offset > 0) {
389665 // zero-initialize the empty part of the overflow string buffer (if any)
389666 if (offset < GetStringSpace()) {
389667 memset(handle.Ptr() + offset, 0, GetStringSpace() - offset);
389668 }
389669 // write to disk
389670 auto &block_manager = partial_block_manager.GetBlockManager();
389671 block_manager.Write(QueryContext(), handle.GetFileBuffer(), block_id);
389672 }
389673 block_id = INVALID_BLOCK;
389674 offset = 0;
389675}

◆ AllocateNewBlock()

void duckdb::WriteOverflowStringsToDisk::AllocateNewBlock ( UncompressedStringSegmentState & state,
block_id_t new_block_id )
private
389677 {
389678 if (block_id != INVALID_BLOCK) {
389679 // there is an old block, write it first
389680 // write the new block id at the end of the previous block
389681 Store<block_id_t>(new_block_id, handle.Ptr() + GetStringSpace());
389682 Flush();
389683 }
389684 offset = 0;
389685 block_id = new_block_id;
389686 auto &block_manager = partial_block_manager.GetBlockManager();
389687 state.RegisterBlock(block_manager, new_block_id);
389688}

◆ GetStringSpace()

idx_t duckdb::WriteOverflowStringsToDisk::GetStringSpace ( ) const
private
389690 {
389691 auto &block_manager = partial_block_manager.GetBlockManager();
389692 return block_manager.GetBlockSize() - sizeof(block_id_t);
389693}

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