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::Node256 Class Reference

Node256 holds up to 256 children. They are indexed by their key byte. More...

Collaboration diagram for duckdb::Node256:

Public Member Functions

 Node256 (const Node256 &)=delete
Node256 & operator= (const Node256 &)=delete
void ReplaceChild (const uint8_t byte, const Node child)
 Replace the child at byte.
NodeChildren ExtractChildren (ArenaAllocator &arena)

Static Public Member Functions

static NodeHandle< Node256 > New (ART &art, Node &node)
 Get a new Node256 handle and initialize the Node256.
static void InsertChild (ART &art, Node &node, const uint8_t byte, const Node child)
 Insert a child at byte.
static void DeleteChild (ART &art, Node &node, const uint8_t byte)
 Delete the child at byte.
template<class F, class NODE>
static void Iterator (NODE &n, F &&lambda)
template<class NODE>
static unsafe_optional_ptr< Node > GetChild (NODE &n, const uint8_t byte, const bool unsafe=false)
template<class NODE>
static unsafe_optional_ptr< Node > GetNextChild (NODE &n, uint8_t &byte)

Static Public Attributes

static constexpr NType NODE_256 = NType::NODE_256
static constexpr uint16_t CAPACITY = 256
static constexpr uint8_t SHRINK_THRESHOLD = 36

Static Private Member Functions

static void GrowNode48 (ART &art, Node &node256, Node &node48)

Private Attributes

uint16_t count
Node children [CAPACITY]

Friends

class Node48

Detailed Description

Node256 holds up to 256 children. They are indexed by their key byte.

Member Function Documentation

◆ New()

NodeHandle< Node256 > duckdb::Node256::New ( ART & art,
Node & node )
inlinestatic

Get a new Node256 handle and initialize the Node256.

58137 {
58138 node = Node::GetAllocator(art, NODE_256).New();
58139 node.SetMetadata(static_cast<uint8_t>(NODE_256));
58140
58141 NodeHandle<Node256> handle(art, node);
58142 auto &n = handle.Get();
58143
58144 // Reset the node (count and children).
58145 n.count = 0;
58146 for (uint16_t i = 0; i < CAPACITY; i++) {
58147 n.children[i].Clear();
58148 }
58149
58150 return handle;
58151 }
IndexPointer New()
Get a new IndexPointer to a segment, might cause a new buffer allocation.
Definition duckdb.cpp:156189
void SetMetadata(const uint8_t metadata)
Set metadata (Bits 56-63).
Definition duckdb.hpp:22544
static FixedSizeAllocator & GetAllocator(const ART &art, const NType type)
Get a reference to the allocator.
Definition duckdb.cpp:154663
::uint8_t uint8_t
Here is the call graph for this function:
Here is the caller graph for this function:

◆ InsertChild()

void duckdb::Node256::InsertChild ( ART & art,
Node & node,
const uint8_t byte,
const Node child )
static

Insert a child at byte.

155181 {
155182 NodeHandle<Node256> handle(art, node);
155183 auto &n = handle.Get();
155184 n.count++;
155185 n.children[byte] = child;
155186}
Here is the caller graph for this function:

◆ DeleteChild()

void duckdb::Node256::DeleteChild ( ART & art,
Node & node,
const uint8_t byte )
static

Delete the child at byte.

155188 {
155189 {
155190 NodeHandle<Node256> handle(art, node);
155191 auto &n = handle.Get();
155192
155193 // Free the child and decrease the count.
155194 Node::FreeTree(art, n.children[byte]);
155195 n.count--;
155196
155197 if (n.count > SHRINK_THRESHOLD) {
155198 return;
155199 }
155200 }
155201
155202 // Shrink to Node48.
155203 auto node256 = node;
155204 Node48::ShrinkNode256(art, node, node256);
155205}
static void ShrinkNode256(ART &art, Node &node48, Node &node256)
We shrink at <= Node256::SHRINK_THRESHOLD.
Definition duckdb.cpp:155401
static void FreeTree(ART &art, Node &node)
Free the node and its children.
Definition duckdb.cpp:154628
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReplaceChild()

void duckdb::Node256::ReplaceChild ( const uint8_t byte,
const Node child )
inline

Replace the child at byte.

58158 {
58159 D_ASSERT(count > SHRINK_THRESHOLD);
58160 auto status = children[byte].GetGateStatus();
58161 children[byte] = child;
58162 if (status == GateStatus::GATE_SET && child.HasMetadata()) {
58163 children[byte].SetGateStatus(status);
58164 }
58165 }
Here is the call graph for this function:

◆ Iterator()

template<class F, class NODE>
void duckdb::Node256::Iterator ( NODE & n,
F && lambda )
inlinestatic
58169 {
58170 D_ASSERT(n.count);
58171 for (idx_t i = 0; i < CAPACITY; i++) {
58172 if (n.children[i].HasMetadata()) {
58173 lambda(n.children[i]);
58174 }
58175 }
58176 }
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ GetChild()

template<class NODE>
unsafe_optional_ptr< Node > duckdb::Node256::GetChild ( NODE & n,
const uint8_t byte,
const bool unsafe = false )
inlinestatic
58179 {
58180 if (unsafe) {
58181 return &n.children[byte];
58182 }
58183 if (n.children[byte].HasMetadata()) {
58184 return &n.children[byte];
58185 }
58186 return nullptr;
58187 }

◆ GetNextChild()

template<class NODE>
unsafe_optional_ptr< Node > duckdb::Node256::GetNextChild ( NODE & n,
uint8_t & byte )
inlinestatic
58190 {
58191 for (idx_t i = byte; i < CAPACITY; i++) {
58192 if (n.children[i].HasMetadata()) {
58193 byte = UnsafeNumericCast<uint8_t>(i);
58194 return &n.children[i];
58195 }
58196 }
58197 return nullptr;
58198 }

◆ ExtractChildren()

NodeChildren duckdb::Node256::ExtractChildren ( ArenaAllocator & arena)
inline

Extracts the bytes and their respective children. The return value is valid as long as the arena is valid. The node must be freed after calling into this function.

58203 {
58204 auto mem_bytes = arena.AllocateAligned(sizeof(uint8_t) * count);
58205 array_ptr<uint8_t> bytes(mem_bytes, count);
58206 auto mem_children = arena.AllocateAligned(sizeof(Node) * count);
58207 array_ptr<Node> children_ptr(reinterpret_cast<Node *>(mem_children), count);
58208
58209 uint16_t ptr_idx = 0;
58210 for (idx_t i = 0; i < CAPACITY; i++) {
58211 if (children[i].HasMetadata()) {
58212 bytes[ptr_idx] = UnsafeNumericCast<uint8_t>(i);
58213 children_ptr[ptr_idx] = children[i];
58214 ptr_idx++;
58215 }
58216 }
58217
58218 return NodeChildren(bytes, children_ptr);
58219 }
::uint16_t uint16_t

◆ GrowNode48()

void duckdb::Node256::GrowNode48 ( ART & art,
Node & node256,
Node & node48 )
staticprivate
155207 {
155208 {
155209 NodeHandle<Node48> n48_handle(art, node48);
155210 auto &n48 = n48_handle.Get();
155211
155212 auto n256_handle = New(art, node256);
155213 auto &n256 = n256_handle.Get();
155214 node256.SetGateStatus(node48.GetGateStatus());
155215
155216 n256.count = n48.count;
155217 for (uint16_t i = 0; i < CAPACITY; i++) {
155218 if (n48.child_index[i] != Node48::EMPTY_MARKER) {
155219 n256.children[i] = n48.children[n48.child_index[i]];
155220 }
155221 }
155222 }
155223 Node::FreeNode(art, node48);
155224}
static NodeHandle< Node256 > New(ART &art, Node &node)
Get a new Node256 handle and initialize the Node256.
Definition duckdb.cpp:58137
static void FreeNode(ART &art, Node &node)
Free the node.
Definition duckdb.cpp:154622

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