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
 
Node48operator= (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< Node48New (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< NodeGetChild (NODE &n, const uint8_t byte, const bool unsafe=false)
 
template<class NODE >
static unsafe_optional_ptr< NodeGetNextChild (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()

static 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 }
static FixedSizeAllocator & GetAllocator(const ART &art, const NType type)
Get a reference to the allocator.
::uint8_t uint8_t
::uint16_t uint16_t
Here is the call 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 }
GateStatus GetGateStatus() const
Returns the gate status of a node.
Definition duckdb.cpp:12046
void SetGateStatus(const GateStatus status)
Sets the gate status of a node.
Definition duckdb.cpp:12050
Here is the call graph for this function:

◆ Iterator()

template<class F , class NODE >
static 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 }

◆ GetChild()

template<class NODE >
static 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 >
static 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 }

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