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

Public Member Functions

 PrefixHandle (const ART &art, const Node node)
 PrefixHandle (FixedSizeAllocator &allocator, const Node node, const uint8_t count)
 PrefixHandle (const PrefixHandle &)=delete
 PrefixHandle (PrefixHandle &&other) noexcept
PrefixHandle & operator= (PrefixHandle &&other) noexcept

Static Public Member Functions

static PrefixHandle NewDeprecated (FixedSizeAllocator &allocator, Node &node)
 Create a new deprecated prefix node and return a handle to it.
static optional_ptr< Node > TransformToDeprecated (ART &art, Node &node, TransformToDeprecatedState &state)

Public Attributes

data_ptr_t data
Node * child

Static Public Attributes

static constexpr NType PREFIX = NType::PREFIX
static constexpr uint8_t DEPRECATED_COUNT = 15

Private Member Functions

PrefixHandle TransformToDeprecatedAppend (ART &art, FixedSizeAllocator &allocator, const uint8_t byte)

Private Attributes

SegmentHandle segment_handle

Detailed Description

PrefixHandle is a mutable wrapper to access and modify a prefix node. The prefix contains up to the ART's prefix size bytes, an additional byte for the count, and a Node pointer to a child node. PrefixHandle uses SegmentHandle for memory management and marks memory as modified. For read-only access, use ConstPrefixHandle instead.

Constructor & Destructor Documentation

◆ PrefixHandle() [1/3]

duckdb::PrefixHandle::PrefixHandle ( const ART & art,
const Node node )
155776 : segment_handle(Node::GetAllocator(art, PREFIX).GetHandle(node)) {
155777 data = segment_handle.GetPtr();
155778 child = reinterpret_cast<Node *>(data + art.PrefixCount() + 1);
155779 segment_handle.MarkModified();
155780}
static FixedSizeAllocator & GetAllocator(const ART &art, const NType type)
Get a reference to the allocator.
Definition duckdb.cpp:154663

◆ PrefixHandle() [2/3]

duckdb::PrefixHandle::PrefixHandle ( FixedSizeAllocator & allocator,
const Node node,
const uint8_t count )
155783 : segment_handle(allocator.GetHandle(node)) {
155784 data = segment_handle.GetPtr();
155785 child = reinterpret_cast<Node *>(data + count + 1);
155786 segment_handle.MarkModified();
155787}

◆ PrefixHandle() [3/3]

duckdb::PrefixHandle::PrefixHandle ( PrefixHandle && other)
noexcept
155790 : data(other.data), child(other.child), segment_handle(std::move(other.segment_handle)) {
155791 other.data = nullptr;
155792 other.child = nullptr;
155793}

Member Function Documentation

◆ operator=()

PrefixHandle & duckdb::PrefixHandle::operator= ( PrefixHandle && other)
noexcept
155795 {
155796 if (this != &other) {
155797 // old segment handle reader count gets decremented on this move.
155798 segment_handle = std::move(other.segment_handle);
155799
155800 data = other.data;
155801 child = other.child;
155802
155803 other.data = nullptr;
155804 other.child = nullptr;
155805 }
155806 return *this;
155807}

◆ NewDeprecated()

PrefixHandle duckdb::PrefixHandle::NewDeprecated ( FixedSizeAllocator & allocator,
Node & node )
static

Create a new deprecated prefix node and return a handle to it.

155809 {
155810 node = allocator.New();
155811 node.SetMetadata(static_cast<uint8_t>(PREFIX));
155812
155813 PrefixHandle handle(allocator, node, DEPRECATED_COUNT);
155814 handle.data[DEPRECATED_COUNT] = 0;
155815 return handle;
155816}
::uint8_t uint8_t
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TransformToDeprecated()

optional_ptr< Node > duckdb::PrefixHandle::TransformToDeprecated ( ART & art,
Node & node,
TransformToDeprecatedState & state )
static

Transform prefix chain to deprecated format. nullptr denotes an early out optimization (the prefix has not been loaded from storage, hence we do not need to transform it. Otherwise, we get a pointer to the child node at the end of the prefix chain.

155818 {
155819 // Early-out, if we do not need any transformations.
155820 if (!state.HasAllocator()) {
155821 reference<Node> ref(node);
155822 auto &allocator = Node::GetAllocator(art, PREFIX);
155823 while (ref.get().GetType() == PREFIX && ref.get().GetGateStatus() == GateStatus::GATE_NOT_SET) {
155824 if (!allocator.LoadedFromStorage(ref)) {
155825 return nullptr;
155826 }
155827 PrefixHandle handle(art, ref);
155828 ref = *handle.child;
155829 }
155830 return ref.get();
155831 }
155832
155833 // We need to create a new prefix (chain) in the deprecated format.
155834 auto &deprecated_allocator = state.GetAllocator();
155835 Node new_node;
155836 auto new_handle = NewDeprecated(deprecated_allocator, new_node);
155837
155838 auto &allocator = Node::GetAllocator(art, PREFIX);
155839 Node current_node = node;
155840 while (current_node.GetType() == PREFIX && current_node.GetGateStatus() == GateStatus::GATE_NOT_SET) {
155841 if (!allocator.LoadedFromStorage(current_node)) {
155842 return nullptr;
155843 }
155844 {
155845 // Decrease the readers on current_handle after moving all data over.
155846 PrefixHandle current_handle(art, current_node);
155847 for (idx_t i = 0; i < current_handle.data[art.PrefixCount()]; i++) {
155848 new_handle = new_handle.TransformToDeprecatedAppend(art, deprecated_allocator, current_handle.data[i]);
155849 }
155850 *new_handle.child = *current_handle.child;
155851 }
155852
155853 // Freeing the node here can trigger a buffer removal (last segment on the buffer).
155854 // In that case, there cannot be any readers left on the buffer.
155855 Node::FreeNode(art, current_node);
155856 current_node = *new_handle.child;
155857 }
155858
155859 node = new_node;
155860 return new_handle.child;
155861}
static void FreeNode(ART &art, Node &node)
Free the node.
Definition duckdb.cpp:154622
static PrefixHandle NewDeprecated(FixedSizeAllocator &allocator, Node &node)
Create a new deprecated prefix node and return a handle to it.
Definition duckdb.cpp:155809
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TransformToDeprecatedAppend()

PrefixHandle duckdb::PrefixHandle::TransformToDeprecatedAppend ( ART & art,
FixedSizeAllocator & allocator,
const uint8_t byte )
private
155863 {
155864 if (data[DEPRECATED_COUNT] != DEPRECATED_COUNT) {
155865 data[data[DEPRECATED_COUNT]] = byte;
155866 data[DEPRECATED_COUNT]++;
155867 return std::move(*this);
155868 }
155869
155870 auto new_prefix = NewDeprecated(allocator, *child);
155871 return new_prefix.TransformToDeprecatedAppend(art, allocator, byte);
155872}

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