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

Public Member Functions

 Node48 (const Node48 &)=delete
Node48 & operator= (const Node48 &)=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< Node48 > New (ART &art, Node &node)
 Get a new Node48 handle and initialize the Node48.
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_48 = NType::NODE_48
static constexpr uint8_t CAPACITY = 48
static constexpr uint8_t EMPTY_MARKER = 48
static constexpr uint8_t SHRINK_THRESHOLD = 12

Static Private Member Functions

static void GrowNode16 (ART &art, Node &node48, Node &node16)
static void ShrinkNode256 (ART &art, Node &node48, Node &node256)
 We shrink at <= Node256::SHRINK_THRESHOLD.

Private Attributes

uint8_t count
uint8_t child_index [Node256::CAPACITY]
Node children [CAPACITY]

Friends

class Node16
class Node256

Detailed Description

Node48 holds up to 48 children. The child_index array is indexed by the key byte. It contains the position of the child node in the children array.

Member Function Documentation

◆ New()

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

Get a new Node48 handle and initialize the Node48.

58254 {
58255 node = Node::GetAllocator(art, NODE_48).New();
58256 node.SetMetadata(static_cast<uint8_t>(NODE_48));
58257
58258 NodeHandle<Node48> handle(art, node);
58259 auto &n = handle.Get();
58260
58261 // Reset the node (count and child_index).
58262 n.count = 0;
58263 for (uint16_t i = 0; i < Node256::CAPACITY; i++) {
58264 n.child_index[i] = EMPTY_MARKER;
58265 }
58266 // Zero-initialize the node.
58267 for (uint8_t i = 0; i < CAPACITY; i++) {
58268 n.children[i].Clear();
58269 }
58270
58271 return handle;
58272 }
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::Node48::InsertChild ( ART & art,
Node & node,
const uint8_t byte,
const Node child )
static

Insert a child at byte.

155333 {
155334 {
155335 NodeHandle<Node48> handle(art, node);
155336 auto &n = handle.Get();
155337
155338 if (n.count != CAPACITY) {
155339 // Still space. Insert the child.
155340 // Find an empty position in the node list.
155341 auto child_pos = n.count;
155342 if (n.children[child_pos].HasMetadata()) {
155343 child_pos = 0;
155344 while (n.children[child_pos].HasMetadata()) {
155345 child_pos++;
155346 }
155347 }
155348
155349 n.children[child_pos] = child;
155350 n.child_index[byte] = child_pos;
155351 n.count++;
155352 return;
155353 }
155354 }
155355
155356 // The node is full.
155357 // Grow to Node256.
155358 auto node48 = node;
155359 Node256::GrowNode48(art, node, node48);
155360 Node256::InsertChild(art, node, byte, child);
155361}
static void InsertChild(ART &art, Node &node, const uint8_t byte, const Node child)
Insert a child at byte.
Definition duckdb.cpp:155181
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DeleteChild()

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

Delete the child at byte.

155363 {
155364 {
155365 NodeHandle<Node48> handle(art, node);
155366 auto &n = handle.Get();
155367
155368 // Free the child and decrease the count.
155369 Node::FreeTree(art, n.children[n.child_index[byte]]);
155370 n.child_index[byte] = EMPTY_MARKER;
155371 n.count--;
155372
155373 if (n.count >= SHRINK_THRESHOLD) {
155374 return;
155375 }
155376 }
155377
155378 // Shrink to Node16.
155379 auto node48 = node;
155380 Node16::ShrinkNode48(art, node, node48);
155381}
static void ShrinkNode48(ART &art, Node &node16, Node &node48)
We shrink at < Node48::SHRINK_THRESHOLD.
Definition duckdb.cpp:153792
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::Node48::ReplaceChild ( const uint8_t byte,
const Node child )
inline

Replace the child at byte.

58279 {
58280 D_ASSERT(count >= SHRINK_THRESHOLD);
58281 auto status = children[child_index[byte]].GetGateStatus();
58282 children[child_index[byte]] = child;
58283 if (status == GateStatus::GATE_SET && child.HasMetadata()) {
58284 children[child_index[byte]].SetGateStatus(status);
58285 }
58286 }
Here is the call graph for this function:

◆ Iterator()

template<class F, class NODE>
void duckdb::Node48::Iterator ( NODE & n,
F && lambda )
inlinestatic
58290 {
58291 D_ASSERT(n.count);
58292 for (idx_t i = 0; i < Node256::CAPACITY; i++) {
58293 if (n.child_index[i] != EMPTY_MARKER) {
58294 lambda(n.children[n.child_index[i]]);
58295 }
58296 }
58297 }
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::Node48::GetChild ( NODE & n,
const uint8_t byte,
const bool unsafe = false )
inlinestatic
58300 {
58301 if (n.child_index[byte] != Node48::EMPTY_MARKER) {
58302 if (!unsafe && !n.children[n.child_index[byte]].HasMetadata()) {
58303 throw InternalException("empty child for byte %d in Node48::GetChild", byte);
58304 }
58305 return &n.children[n.child_index[byte]];
58306 }
58307 return nullptr;
58308 }

◆ GetNextChild()

template<class NODE>
unsafe_optional_ptr< Node > duckdb::Node48::GetNextChild ( NODE & n,
uint8_t & byte )
inlinestatic
58311 {
58312 for (idx_t i = byte; i < Node256::CAPACITY; i++) {
58313 if (n.child_index[i] != EMPTY_MARKER) {
58314 byte = UnsafeNumericCast<uint8_t>(i);
58315 return &n.children[n.child_index[i]];
58316 }
58317 }
58318 return nullptr;
58319 }

◆ ExtractChildren()

NodeChildren duckdb::Node48::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.

58324 {
58325 auto mem_bytes = arena.AllocateAligned(sizeof(uint8_t) * count);
58326 array_ptr<uint8_t> bytes(mem_bytes, count);
58327 auto mem_children = arena.AllocateAligned(sizeof(Node) * count);
58328 array_ptr<Node> children_ptr(reinterpret_cast<Node *>(mem_children), count);
58329
58330 uint16_t ptr_idx = 0;
58331 for (idx_t i = 0; i < Node256::CAPACITY; i++) {
58332 if (child_index[i] != EMPTY_MARKER) {
58333 bytes[ptr_idx] = UnsafeNumericCast<uint8_t>(i);
58334 children_ptr[ptr_idx] = children[child_index[i]];
58335 ptr_idx++;
58336 }
58337 }
58338
58339 return NodeChildren(bytes, children_ptr);
58340 }
::uint16_t uint16_t

◆ GrowNode16()

void duckdb::Node48::GrowNode16 ( ART & art,
Node & node48,
Node & node16 )
staticprivate
155383 {
155384 {
155385 NodeHandle<Node16> n16_handle(art, node16);
155386 auto &n16 = n16_handle.Get();
155387
155388 auto n48_handle = New(art, node48);
155389 auto &n48 = n48_handle.Get();
155390 node48.SetGateStatus(node16.GetGateStatus());
155391
155392 n48.count = n16.count;
155393 for (uint8_t i = 0; i < n16.count; i++) {
155394 n48.child_index[n16.key[i]] = i;
155395 n48.children[i] = n16.children[i];
155396 }
155397 }
155398 Node::FreeNode(art, node16);
155399}
static NodeHandle< Node48 > New(ART &art, Node &node)
Get a new Node48 handle and initialize the Node48.
Definition duckdb.cpp:58254
static void FreeNode(ART &art, Node &node)
Free the node.
Definition duckdb.cpp:154622

◆ ShrinkNode256()

void duckdb::Node48::ShrinkNode256 ( ART & art,
Node & node48,
Node & node256 )
staticprivate

We shrink at <= Node256::SHRINK_THRESHOLD.

155401 {
155402 {
155403 auto n48_handle = New(art, node48);
155404 auto &n48 = n48_handle.Get();
155405 node48.SetGateStatus(node256.GetGateStatus());
155406
155407 NodeHandle<Node256> n256_handle(art, node256);
155408 auto &n256 = n256_handle.Get();
155409
155410 n48.count = 0;
155411 for (uint16_t i = 0; i < Node256::CAPACITY; i++) {
155412 if (!n256.children[i].HasMetadata()) {
155413 continue;
155414 }
155415 n48.child_index[i] = n48.count;
155416 n48.children[n48.count] = n256.children[i];
155417 n48.count++;
155418 }
155419 }
155420 Node::FreeNode(art, node256);
155421}
Here is the call graph for this function:
Here is the caller graph for this function:

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