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

Public Member Functions

 UndoBufferAllocator (BufferManager &buffer_manager)
UndoBufferReference Allocate (idx_t alloc_len)

Public Attributes

mutex lock
BufferManager & buffer_manager
unique_ptr< UndoBufferEntry > head
optional_ptr< UndoBufferEntry > tail

Constructor & Destructor Documentation

◆ UndoBufferAllocator()

duckdb::UndoBufferAllocator::UndoBufferAllocator ( BufferManager & buffer_manager)
explicit
447877 : buffer_manager(buffer_manager) {
447878}

Member Function Documentation

◆ Allocate()

UndoBufferReference duckdb::UndoBufferAllocator::Allocate ( idx_t alloc_len)
447880 {
447881 lock_guard<mutex> guard(lock);
447882 D_ASSERT(!head || head->position <= head->capacity);
447883 BufferHandle handle;
447884 if (!head || head->position + alloc_len > head->capacity) {
447885 // no space in current head - allocate a new block
447886 auto block_size = buffer_manager.GetBlockSize();
447887 ;
447888 idx_t capacity;
447889 if (!head && alloc_len <= 4096) {
447890 capacity = 4096;
447891 } else {
447892 capacity = block_size;
447893 }
447894 if (capacity < alloc_len) {
447895 capacity = NextPowerOfTwo(alloc_len);
447896 }
447897 auto entry = make_uniq<UndoBufferEntry>(buffer_manager);
447898 if (capacity < block_size) {
447899 entry->block = buffer_manager.RegisterSmallMemory(MemoryTag::TRANSACTION, capacity);
447900 handle = buffer_manager.Pin(entry->block);
447901 } else {
447902 handle = buffer_manager.Allocate(MemoryTag::TRANSACTION, capacity, false);
447903 entry->block = handle.GetBlockHandle();
447904 }
447905 entry->capacity = capacity;
447906 entry->position = 0;
447907 // add block to the chain
447908 if (head) {
447909 head->prev = entry.get();
447910 entry->next = std::move(head);
447911 } else {
447912 tail = entry.get();
447913 }
447914 head = std::move(entry);
447915 } else {
447916 handle = buffer_manager.Pin(head->block);
447917 }
447918 idx_t current_position = head->position;
447919 head->position += alloc_len;
447920 return UndoBufferReference(*head, std::move(handle), current_position);
447921}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

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