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::BaseNode< CAPACITY, TYPE > Class Template Reference
Collaboration diagram for duckdb::BaseNode< CAPACITY, TYPE >:

Public Member Functions

 BaseNode (const BaseNode &)=delete
BaseNode & operator= (const BaseNode &)=delete
NodeChildren ExtractChildren (ArenaAllocator &arena)

Static Public Member Functions

static NodeHandle< BaseNode > New (ART &art, Node &node)
 Get a new BaseNode handle and initialize the base node.
static void ReplaceChild (BaseNode &n, const uint8_t byte, const Node child)
 Replace the child at byte.
static unsafe_optional_ptr< Node > GetChild (BaseNode &n, const uint8_t byte, const bool unsafe=false)
 Get the child at byte.
static unsafe_optional_ptr< Node > GetNextChild (BaseNode &n, uint8_t &byte)
 Get the first child greater than or equal to the byte.
template<class F>
static void Iterator (BaseNode< CAPACITY, TYPE > &n, F &&lambda)

Static Private Member Functions

static void InsertChildInternal (BaseNode &n, const uint8_t byte, const Node child)
static NodeHandle< BaseNode > DeleteChildInternal (ART &art, Node &node, const uint8_t byte)

Private Attributes

uint8_t count
uint8_t key [CAPACITY]
Node children [CAPACITY]

Friends

class Node4
class Node16
class Node48

Member Function Documentation

◆ New()

template<uint8_t CAPACITY, NType TYPE>
NodeHandle< BaseNode > duckdb::BaseNode< CAPACITY, TYPE >::New ( ART & art,
Node & node )
inlinestatic

Get a new BaseNode handle and initialize the base node.

57961 {
57963 node.SetMetadata(static_cast<uint8_t>(TYPE));
57964
57966 auto &n = handle.Get();
57967
57968 // Reset the node (count).
57969 n.count = 0;
57970 // Zero-initialize the node.
57971 for (uint8_t i = 0; i < CAPACITY; i++) {
57972 n.key[i] = 0;
57973 n.children[i].Clear();
57974 }
57975
57976 return handle;
57977 }
Definition duckdb.cpp:57944
IndexPointer New()
Get a new IndexPointer to a segment, might cause a new buffer allocation.
Definition duckdb.cpp:156189
void Clear()
Resets the IndexPointer.
Definition duckdb.hpp:22560
static FixedSizeAllocator & GetAllocator(const ART &art, const NType type)
Get a reference to the allocator.
Definition duckdb.cpp:154663
Here is the call graph for this function:

◆ ReplaceChild()

template<uint8_t CAPACITY, NType TYPE>
void duckdb::BaseNode< CAPACITY, TYPE >::ReplaceChild ( BaseNode< CAPACITY, TYPE > & n,
const uint8_t byte,
const Node child )
inlinestatic

Replace the child at byte.

57980 {
57981 D_ASSERT(n.count != 0);
57982 for (uint8_t i = 0; i < n.count; i++) {
57983 if (n.key[i] == byte) {
57984 auto status = n.children[i].GetGateStatus();
57985 n.children[i] = child;
57986
57987 if (status == GateStatus::GATE_SET && child.HasMetadata()) {
57988 n.children[i].SetGateStatus(status);
57989 }
57990 return;
57991 }
57992 }
57993 }
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:

◆ GetChild()

template<uint8_t CAPACITY, NType TYPE>
unsafe_optional_ptr< Node > duckdb::BaseNode< CAPACITY, TYPE >::GetChild ( BaseNode< CAPACITY, TYPE > & n,
const uint8_t byte,
const bool unsafe = false )
inlinestatic

Get the child at byte.

57996 {
57997 for (uint8_t i = 0; i < n.count; i++) {
57998 if (n.key[i] == byte) {
57999 if (!unsafe && !n.children[i].HasMetadata()) {
58000 throw InternalException("empty child i = %d for byte %d in BaseNode::GetChild", i, byte);
58001 }
58002 return &n.children[i];
58003 }
58004 }
58005 return nullptr;
58006 }
bool HasMetadata() const
Returns false, if the metadata is empty.
Definition duckdb.hpp:22536
Here is the call graph for this function:

◆ GetNextChild()

template<uint8_t CAPACITY, NType TYPE>
unsafe_optional_ptr< Node > duckdb::BaseNode< CAPACITY, TYPE >::GetNextChild ( BaseNode< CAPACITY, TYPE > & n,
uint8_t & byte )
inlinestatic

Get the first child greater than or equal to the byte.

58009 {
58010 for (uint8_t i = 0; i < n.count; i++) {
58011 if (n.key[i] >= byte) {
58012 byte = n.key[i];
58013 return &n.children[i];
58014 }
58015 }
58016 return nullptr;
58017 }

◆ ExtractChildren()

template<uint8_t CAPACITY, NType TYPE>
NodeChildren duckdb::BaseNode< CAPACITY, TYPE >::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.

58022 {
58023 auto mem_bytes = arena.AllocateAligned(sizeof(uint8_t) * count);
58025 auto mem_children = arena.AllocateAligned(sizeof(Node) * count);
58026 array_ptr<Node> children_ptr(reinterpret_cast<Node *>(mem_children), count);
58027
58028 for (uint8_t i = 0; i < count; i++) {
58029 bytes[i] = key[i];
58030 children_ptr[i] = children[i];
58031 }
58032
58034 }

◆ Iterator()

template<uint8_t CAPACITY, NType TYPE>
template<class F>
void duckdb::BaseNode< CAPACITY, TYPE >::Iterator ( BaseNode< CAPACITY, TYPE > & n,
F && lambda )
inlinestatic
58038 {
58039 for (uint8_t i = 0; i < n.count; i++) {
58040 lambda(n.children[i]);
58041 }
58042 }

◆ InsertChildInternal()

template<uint8_t CAPACITY, NType TYPE>
void duckdb::BaseNode< CAPACITY, TYPE >::InsertChildInternal ( BaseNode< CAPACITY, TYPE > & n,
const uint8_t byte,
const Node child )
staticprivate
153634 {
153635 // Still space. Insert the child.
153636 uint8_t child_pos = 0;
153637 while (child_pos < n.count && n.key[child_pos] < byte) {
153638 child_pos++;
153639 }
153640
153641 // Move children backwards to make space.
153642 for (uint8_t i = n.count; i > child_pos; i--) {
153643 n.key[i] = n.key[i - 1];
153644 n.children[i] = n.children[i - 1];
153645 }
153646
153647 n.key[child_pos] = byte;
153648 n.children[child_pos] = child;
153649 n.count++;
153650}

◆ DeleteChildInternal()

template<uint8_t CAPACITY, NType TYPE>
NodeHandle< BaseNode< CAPACITY, TYPE > > duckdb::BaseNode< CAPACITY, TYPE >::DeleteChildInternal ( ART & art,
Node & node,
const uint8_t byte )
staticprivate
153654 {
153656 auto &n = handle.Get();
153657
153658 uint8_t child_pos = 0;
153659 for (; child_pos < n.count; child_pos++) {
153660 if (n.key[child_pos] == byte) {
153661 break;
153662 }
153663 }
153664
153665 // Free the child and decrease the count.
153666 Node::FreeTree(art, n.children[child_pos]);
153667 n.count--;
153668
153669 // Possibly move children backwards.
153670 for (uint8_t i = child_pos; i < n.count; i++) {
153671 n.key[i] = n.key[i + 1];
153672 n.children[i] = n.children[i + 1];
153673 }
153674
153675 return handle;
153676}
static void FreeTree(ART &art, Node &node)
Free the node and its children.
Definition duckdb.cpp:154628

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