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

Public Member Functions

void ReplaceChild (const ART &art, const uint8_t byte, const Node child=Node()) const
 Replace the child at byte.
const unsafe_optional_ptr< Node > GetChild (ART &art, const uint8_t byte) const
 Get the immutable child at byte.
unsafe_optional_ptr< Node > GetChildMutable (ART &art, const uint8_t byte, const bool unsafe=false) const
 Get the child at byte.
const unsafe_optional_ptr< Node > GetNextChild (ART &art, uint8_t &byte) const
 Get the first immutable child greater than or equal to the byte.
bool HasByte (ART &art, const uint8_t byte) const
 Returns true, if the byte exists, else false.
bool GetNextByte (ART &art, uint8_t &byte) const
 Get the first byte greater than or equal to the byte.
void Verify (ART &art) const
 Traverses and verifies the node.
void VerifyAllocations (ART &art, unordered_map< uint8_t, idx_t > &node_counts) const
 Counts each node type.
string ToString (ART &art, const ToStringOptions &options) const
NType GetType () const
 Returns the node type.
bool IsNode () const
 True, if the node is a Node4, Node16, Node48, or Node256.
bool IsLeafNode () const
 True, if the node is a Node7Leaf, Node15Leaf, or Node256Leaf.
bool IsAnyLeaf () const
 True, if the node is any leaf.
row_t GetRowId () const
 Get the row ID (8th to 63rd bit).
void SetRowId (const row_t row_id)
 Set the row ID (8th to 63rd bit).
GateStatus GetGateStatus () const
 Returns the gate status of a node.
void SetGateStatus (const GateStatus status)
 Sets the gate status of a node.
void operator= (const IndexPointer &ptr)
 Assign operator.
Public Member Functions inherited from duckdb::IndexPointer
 IndexPointer ()
 Constructs an empty IndexPointer.
 IndexPointer (const uint32_t buffer_id, const uint32_t offset)
 Constructs an in-memory IndexPointer with a buffer ID and an offset.
idx_t Get () const
 Get data (all 64 bits).
void Set (const idx_t data_p)
 Set data (all 64 bits).
bool HasMetadata () const
 Returns false, if the metadata is empty.
uint8_t GetMetadata () const
 Get metadata (Bits 56-63).
void SetMetadata (const uint8_t metadata)
 Set metadata (Bits 56-63).
idx_t GetOffset () const
 Get the offset (Bits 32-55).
idx_t GetBufferId () const
 Get the buffer ID (Bits 0-31).
void Clear ()
 Resets the IndexPointer.
void IncreaseBufferId (const idx_t summand)
 Adds an idx_t to a buffer ID, the rightmost 32 bits of data (Bits 0-31) contain the buffer ID.
bool operator== (const IndexPointer &ptr) const
 Comparison operator.

Static Public Member Functions

static void New (ART &art, Node &node, const NType type)
 Get a new pointer to a node and initialize it.
static void FreeNode (ART &art, Node &node)
 Free the node.
static void FreeTree (ART &art, Node &node)
 Free the node and its children.
static FixedSizeAllocator & GetAllocator (const ART &art, const NType type)
 Get a reference to the allocator.
static uint8_t GetAllocatorIdx (const NType type)
 Get the index of a node type's allocator.
template<class NODE>
static NODE & Ref (const ART &art, const Node ptr, const NType type)
 Get a reference to a node.
template<class NODE>
static unsafe_optional_ptr< NODE > InMemoryRef (const ART &art, const Node ptr, const NType type)
 Get a node pointer, if the node is in memory, else nullptr.
static void InsertChild (ART &art, Node &node, const uint8_t byte, const Node child=Node())
 Insert the child at byte.
static void DeleteChild (ART &art, Node &node, Node &prefix, const uint8_t byte, const GateStatus status, const ARTKey &row_id)
 Delete the child at byte.
static NType GetNodeType (const idx_t count)
 Returns the node type for a count.
static void TransformToDeprecated (ART &art, Node &node, TransformToDeprecatedState &state)
 Transform the node storage to deprecated storage.

Static Public Attributes

static constexpr uint8_t AND_GATE = 0x80
 A gate sets the leftmost bit of the metadata, binary: 1000-0000.
static constexpr idx_t AND_ROW_ID = 0x00FFFFFFFFFFFFFF
Static Public Attributes inherited from duckdb::IndexPointer
static constexpr idx_t SHIFT_OFFSET = 32
 Bit-shifting.
static constexpr idx_t SHIFT_METADATA = 56
static constexpr idx_t AND_OFFSET = 0x0000000000FFFFFF
 AND operations.
static constexpr idx_t AND_BUFFER_ID = 0x00000000FFFFFFFF
static constexpr idx_t AND_METADATA = 0xFF00000000000000

Friends

class Prefix

Detailed Description

The Node is the pointer class of the ART index. It inherits from the IndexPointer, and adds ART-specific functionality.

Member Function Documentation

◆ New()

void duckdb::Node::New ( ART & art,
Node & node,
const NType type )
static

Get a new pointer to a node and initialize it.

154594 {
154595 switch (type) {
154596 case NType::NODE_7_LEAF:
154597 Node7Leaf::New(art, node);
154598 break;
154599 case NType::NODE_15_LEAF:
154600 Node15Leaf::New(art, node);
154601 break;
154602 case NType::NODE_256_LEAF:
154603 Node256Leaf::New(art, node);
154604 break;
154605 case NType::NODE_4:
154606 Node4::New(art, node);
154607 break;
154608 case NType::NODE_16:
154609 Node16::New(art, node);
154610 break;
154611 case NType::NODE_48:
154612 Node48::New(art, node);
154613 break;
154614 case NType::NODE_256:
154615 Node256::New(art, node);
154616 break;
154617 default:
154618 throw InternalException("Invalid node type for New: %d.", type);
154619 }
154620}
static NodeHandle< BaseLeaf > New(ART &art, Node &node)
Definition duckdb.cpp:150900
static NodeHandle< BaseNode > New(ART &art, Node &node)
Definition duckdb.cpp:57961
static NodeHandle< Node256Leaf > New(ART &art, Node &node)
Get a new Node256Leaf handle and initialize the leaf.
Definition duckdb.cpp:155234
static NodeHandle< Node256 > New(ART &art, Node &node)
Get a new Node256 handle and initialize the Node256.
Definition duckdb.cpp:58137
static NodeHandle< Node48 > New(ART &art, Node &node)
Get a new Node48 handle and initialize the Node48.
Definition duckdb.cpp:58254
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FreeNode()

void duckdb::Node::FreeNode ( ART & art,
Node & node )
static

Free the node.

154622 {
154623 D_ASSERT(node.HasMetadata());
154624 GetAllocator(art, node.GetType()).Free(node);
154625 node.Clear();
154626}
void Free(const IndexPointer ptr)
Free the segment of the IndexPointer.
Definition duckdb.cpp:156230
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:
Here is the caller graph for this function:

◆ FreeTree()

void duckdb::Node::FreeTree ( ART & art,
Node & node )
static

Free the node and its children.

154628 {
154629 auto handler = [&art](Node &node) {
154630 const auto type = node.GetType();
154631 switch (type) {
154632 case NType::LEAF_INLINED:
154633 node.Clear();
154634 return ARTHandlingResult::NONE;
154635 case NType::LEAF:
154636 Leaf::DeprecatedFree(art, node);
154637 return ARTHandlingResult::NONE;
154638 case NType::NODE_7_LEAF:
154639 case NType::NODE_15_LEAF:
154640 case NType::NODE_256_LEAF:
154641 case NType::PREFIX:
154642 case NType::NODE_4:
154643 case NType::NODE_16:
154644 case NType::NODE_48:
154645 case NType::NODE_256:
154646 break;
154647 default:
154648 throw InternalException("invalid node type for Free: %d", type);
154649 }
154650
154651 FreeNode(art, node);
154652 return ARTHandlingResult::NONE;
154653 };
154654
154655 ARTScanner<ARTScanHandling::POP, Node> scanner(art, handler, node);
154656 scanner.Scan(handler);
154657}
static void DeprecatedFree(ART &art, Node &node)
Frees the linked list of leaves.
Definition duckdb.cpp:154420
static void FreeNode(ART &art, Node &node)
Free the node.
Definition duckdb.cpp:154622
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAllocator()

FixedSizeAllocator & duckdb::Node::GetAllocator ( const ART & art,
const NType type )
static

Get a reference to the allocator.

154663 {
154664 return *(*art.allocators)[GetAllocatorIdx(type)];
154665}
static uint8_t GetAllocatorIdx(const NType type)
Get the index of a node type's allocator.
Definition duckdb.cpp:154667
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAllocatorIdx()

uint8_t duckdb::Node::GetAllocatorIdx ( const NType type)
static

Get the index of a node type's allocator.

154667 {
154668 switch (type) {
154669 case NType::PREFIX:
154670 return 0;
154671 case NType::LEAF:
154672 return 1;
154673 case NType::NODE_4:
154674 return 2;
154675 case NType::NODE_16:
154676 return 3;
154677 case NType::NODE_48:
154678 return 4;
154679 case NType::NODE_256:
154680 return 5;
154681 case NType::NODE_7_LEAF:
154682 return 6;
154683 case NType::NODE_15_LEAF:
154684 return 7;
154685 case NType::NODE_256_LEAF:
154686 return 8;
154687 default:
154688 throw InternalException("Invalid node type for GetAllocatorIdx: %d.", type);
154689 }
154690}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Ref()

template<class NODE>
NODE & duckdb::Node::Ref ( const ART & art,
const Node ptr,
const NType type )
inlinestatic

Get a reference to a node.

11976 {
11977 D_ASSERT(ptr.GetType() != NType::PREFIX);
11978 return *(GetAllocator(art, type).Get<NODE>(ptr, !std::is_const<NODE>::value));
11979 }
unsafe_optional_ptr< T > Get(const IndexPointer ptr, const bool dirty=true)
Definition duckdb.cpp:11710
Here is the call graph for this function:
Here is the caller graph for this function:

◆ InMemoryRef()

template<class NODE>
unsafe_optional_ptr< NODE > duckdb::Node::InMemoryRef ( const ART & art,
const Node ptr,
const NType type )
inlinestatic

Get a node pointer, if the node is in memory, else nullptr.

11982 {
11983 D_ASSERT(ptr.GetType() != NType::PREFIX);
11984 return GetAllocator(art, type).GetIfLoaded<NODE>(ptr);
11985 }
unsafe_optional_ptr< T > GetIfLoaded(const IndexPointer ptr)
Definition duckdb.cpp:11742
Here is the call graph for this function:

◆ ReplaceChild()

void duckdb::Node::ReplaceChild ( const ART & art,
const uint8_t byte,
const Node child = Node() ) const

Replace the child at byte.

154696 {
154697 D_ASSERT(HasMetadata());
154698
154699 auto type = GetType();
154700 switch (type) {
154701 case NType::NODE_4:
154702 return Node4::ReplaceChild(Ref<Node4>(art, *this, type), byte, child);
154703 case NType::NODE_16:
154704 return Node16::ReplaceChild(Ref<Node16>(art, *this, type), byte, child);
154705 case NType::NODE_48:
154706 return Ref<Node48>(art, *this, type).ReplaceChild(byte, child);
154707 case NType::NODE_256:
154708 return Ref<Node256>(art, *this, type).ReplaceChild(byte, child);
154709 default:
154710 throw InternalException("Invalid node type for ReplaceChild: %d.", type);
154711 }
154712}
static void ReplaceChild(BaseNode &n, const uint8_t byte, const Node child)
Definition duckdb.cpp:57980
bool HasMetadata() const
Returns false, if the metadata is empty.
Definition duckdb.hpp:22536
NType GetType() const
Returns the node type.
Definition duckdb.cpp:12025
static NODE & Ref(const ART &art, const Node ptr, const NType type)
Get a reference to a node.
Definition duckdb.cpp:11976
Here is the call graph for this function:
Here is the caller graph for this function:

◆ InsertChild()

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

Insert the child at byte.

154714 {
154715 D_ASSERT(node.HasMetadata());
154716
154717 auto type = node.GetType();
154718 switch (type) {
154719 case NType::NODE_4:
154720 return Node4::InsertChild(art, node, byte, child);
154721 case NType::NODE_16:
154722 return Node16::InsertChild(art, node, byte, child);
154723 case NType::NODE_48:
154724 return Node48::InsertChild(art, node, byte, child);
154725 case NType::NODE_256:
154726 return Node256::InsertChild(art, node, byte, child);
154727 case NType::NODE_7_LEAF:
154728 return Node7Leaf::InsertByte(art, node, byte);
154729 case NType::NODE_15_LEAF:
154730 return Node15Leaf::InsertByte(art, node, byte);
154731 case NType::NODE_256_LEAF:
154732 return Node256Leaf::InsertByte(art, node, byte);
154733 default:
154734 throw InternalException("Invalid node type for InsertChild: %d.", type);
154735 }
154736}
static void InsertByte(ART &art, Node &node, const uint8_t byte)
Insert a byte.
Definition duckdb.cpp:153556
static void InsertChild(ART &art, Node &node, const uint8_t byte, const Node child)
Insert a child at byte.
Definition duckdb.cpp:153745
static void InsertByte(ART &art, Node &node, const uint8_t byte)
Insert a byte.
Definition duckdb.cpp:155248
static void InsertChild(ART &art, Node &node, const uint8_t byte, const Node child)
Insert a child at byte.
Definition duckdb.cpp:155181
static void InsertChild(ART &art, Node &node, const uint8_t byte, const Node child)
Insert a child at byte.
Definition duckdb.cpp:155333
static void InsertChild(ART &art, Node &node, const uint8_t byte, const Node child)
Insert a child at byte.
Definition duckdb.cpp:153682
static void InsertByte(ART &art, Node &node, const uint8_t byte)
Insert a byte.
Definition duckdb.cpp:153489
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DeleteChild()

void duckdb::Node::DeleteChild ( ART & art,
Node & node,
Node & prefix,
const uint8_t byte,
const GateStatus status,
const ARTKey & row_id )
static

Delete the child at byte.

154743 {
154744 D_ASSERT(node.HasMetadata());
154745
154746 auto type = node.GetType();
154747 switch (type) {
154748 case NType::NODE_4:
154749 return Node4::DeleteChild(art, node, prefix, byte, status);
154750 case NType::NODE_16:
154751 return Node16::DeleteChild(art, node, byte);
154752 case NType::NODE_48:
154753 return Node48::DeleteChild(art, node, byte);
154754 case NType::NODE_256:
154755 return Node256::DeleteChild(art, node, byte);
154756 case NType::NODE_7_LEAF:
154757 return Node7Leaf::DeleteByte(art, node, prefix, byte, row_id);
154758 case NType::NODE_15_LEAF:
154759 return Node15Leaf::DeleteByte(art, node, byte);
154760 case NType::NODE_256_LEAF:
154761 return Node256Leaf::DeleteByte(art, node, byte);
154762 default:
154763 throw InternalException("Invalid node type for DeleteChild: %d.", type);
154764 }
154765}
static void DeleteByte(ART &art, Node &node, const uint8_t byte)
Delete a byte.
Definition duckdb.cpp:153570
static void DeleteChild(ART &art, Node &node, const uint8_t byte)
Delete the child at byte.
Definition duckdb.cpp:153761
static void DeleteByte(ART &art, Node &node, const uint8_t byte)
Delete a byte.
Definition duckdb.cpp:155257
static void DeleteChild(ART &art, Node &node, const uint8_t byte)
Delete the child at byte.
Definition duckdb.cpp:155188
static void DeleteChild(ART &art, Node &node, const uint8_t byte)
Delete the child at byte.
Definition duckdb.cpp:155363
static void DeleteChild(ART &art, Node &node, Node &prefix, const uint8_t byte, const GateStatus status)
Delete the child at byte.
Definition duckdb.cpp:153699
static void DeleteByte(ART &art, Node &node, Node &prefix, const uint8_t byte, const ARTKey &row_id)
Delete a byte.
Definition duckdb.cpp:153505
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetChild()

const unsafe_optional_ptr< Node > duckdb::Node::GetChild ( ART & art,
const uint8_t byte ) const

Get the immutable child at byte.

154791 {
154792 return GetChildInternal(art, *this, byte, false);
154793}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetChildMutable()

unsafe_optional_ptr< Node > duckdb::Node::GetChildMutable ( ART & art,
const uint8_t byte,
const bool unsafe = false ) const

Get the child at byte.

154795 {
154796 return GetChildInternal(art, *this, byte, unsafe);
154797}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetNextChild()

const unsafe_optional_ptr< Node > duckdb::Node::GetNextChild ( ART & art,
uint8_t & byte ) const

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

154818 {
154819 return GetNextChildInternal(art, *this, byte);
154820}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HasByte()

bool duckdb::Node::HasByte ( ART & art,
const uint8_t byte ) const

Returns true, if the byte exists, else false.

154822 {
154823 D_ASSERT(HasMetadata());
154824
154825 auto type = GetType();
154826 switch (type) {
154827 case NType::NODE_7_LEAF:
154828 return Ref<const Node7Leaf>(art, *this, NType::NODE_7_LEAF).HasByte(byte);
154829 case NType::NODE_15_LEAF:
154830 return Ref<const Node15Leaf>(art, *this, NType::NODE_15_LEAF).HasByte(byte);
154831 case NType::NODE_256_LEAF:
154832 return Ref<Node256Leaf>(art, *this, NType::NODE_256_LEAF).HasByte(byte);
154833 default:
154834 throw InternalException("Invalid node type for GetNextByte: %d.", type);
154835 }
154836}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetNextByte()

bool duckdb::Node::GetNextByte ( ART & art,
uint8_t & byte ) const

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

154838 {
154839 D_ASSERT(HasMetadata());
154840
154841 auto type = GetType();
154842 switch (type) {
154843 case NType::NODE_7_LEAF:
154844 return Ref<const Node7Leaf>(art, *this, NType::NODE_7_LEAF).GetNextByte(byte);
154845 case NType::NODE_15_LEAF:
154846 return Ref<const Node15Leaf>(art, *this, NType::NODE_15_LEAF).GetNextByte(byte);
154847 case NType::NODE_256_LEAF:
154848 return Ref<Node256Leaf>(art, *this, NType::NODE_256_LEAF).GetNextByte(byte);
154849 default:
154850 throw InternalException("Invalid node type for GetNextByte: %d.", type);
154851 }
154852}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Verify()

void duckdb::Node::Verify ( ART & art) const

Traverses and verifies the node.

154989 {
154990 D_ASSERT(HasMetadata());
154991
154992 auto type = GetType();
154993 switch (type) {
154994 case NType::LEAF_INLINED:
154995 return;
154996 case NType::LEAF:
154997 Leaf::DeprecatedVerify(art, *this);
154998 return;
154999 case NType::PREFIX: {
155000 ConstPrefixHandle::Verify(art, *this);
155001 return;
155002 }
155003 default:
155004 break;
155005 }
155006
155007 if (!IsLeafNode()) {
155008 uint8_t byte = 0;
155009 auto child = GetNextChild(art, byte);
155010 while (child) {
155011 child->Verify(art);
155012 if (byte == NumericLimits<uint8_t>::Maximum()) {
155013 break;
155014 }
155015 byte++;
155016 child = GetNextChild(art, byte);
155017 }
155018 }
155019}
static void Verify(ART &art, const Node &node)
Traverses and verifies the node and its subtree.
Definition duckdb.cpp:153926
static void DeprecatedVerify(ART &art, const Node &node)
Traverses and verifies the linked list of leaves.
Definition duckdb.cpp:154492
const unsafe_optional_ptr< Node > GetNextChild(ART &art, uint8_t &byte) const
Get the first immutable child greater than or equal to the byte.
Definition duckdb.cpp:154818
bool IsLeafNode() const
True, if the node is a Node7Leaf, Node15Leaf, or Node256Leaf.
Definition duckdb.cpp:154902
::uint8_t uint8_t
Here is the call graph for this function:
Here is the caller graph for this function:

◆ VerifyAllocations()

void duckdb::Node::VerifyAllocations ( ART & art,
unordered_map< uint8_t, idx_t > & node_counts ) const

Counts each node type.

155021 {
155022 D_ASSERT(HasMetadata());
155023
155024 auto handler = [&art, &node_counts](const Node &node) {
155025 ARTHandlingResult result;
155026 const auto type = node.GetType();
155027 switch (type) {
155028 case NType::LEAF_INLINED:
155029 return ARTHandlingResult::SKIP;
155030 case NType::LEAF: {
155031 auto &leaf = Ref<Leaf>(art, node, type);
155032 leaf.DeprecatedVerifyAllocations(art, node_counts);
155033 return ARTHandlingResult::SKIP;
155034 }
155035 case NType::NODE_7_LEAF:
155036 case NType::NODE_15_LEAF:
155037 case NType::NODE_256_LEAF: {
155038 result = ARTHandlingResult::SKIP;
155039 break;
155040 }
155041 case NType::PREFIX:
155042 case NType::NODE_4:
155043 case NType::NODE_16:
155044 case NType::NODE_48:
155045 case NType::NODE_256: {
155046 result = ARTHandlingResult::CONTINUE;
155047 break;
155048 }
155049 default:
155050 throw InternalException("invalid node type for VerifyAllocations: %d", type);
155051 }
155052 node_counts[GetAllocatorIdx(type)]++;
155053 return result;
155054 };
155055
155056 ARTScanner<ARTScanHandling::EMPLACE, const Node> scanner(art, handler, *this);
155057 scanner.Scan(handler);
155058}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetNodeType()

NType duckdb::Node::GetNodeType ( const idx_t count)
static

Returns the node type for a count.

154879 {
154880 if (count <= Node4::CAPACITY) {
154881 return NType::NODE_4;
154882 } else if (count <= Node16::CAPACITY) {
154883 return NType::NODE_16;
154884 } else if (count <= Node48::CAPACITY) {
154885 return NType::NODE_48;
154886 }
154887 return NType::NODE_256;
154888}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TransformToDeprecated()

void duckdb::Node::TransformToDeprecated ( ART & art,
Node & node,
TransformToDeprecatedState & state )
static

Transform the node storage to deprecated storage.

154939 {
154940 vector<reference<Node>> stack;
154941 stack.emplace_back(node);
154942
154943 while (!stack.empty()) {
154944 Node &current = stack.back().get();
154945 stack.pop_back();
154946
154947 D_ASSERT(current.HasMetadata());
154948
154949 if (current.GetGateStatus() == GateStatus::GATE_SET) {
154950 D_ASSERT(current.GetType() != NType::LEAF_INLINED);
154951 Leaf::TransformToDeprecated(art, current);
154952 continue;
154953 }
154954
154955 auto type = current.GetType();
154956 switch (type) {
154957 case NType::PREFIX: {
154958 auto child = PrefixHandle::TransformToDeprecated(art, current, state);
154959 if (child) {
154960 stack.emplace_back(*child);
154961 }
154962 break;
154963 }
154964 case NType::LEAF_INLINED:
154965 case NType::LEAF:
154966 break;
154967 case NType::NODE_4:
154968 TransformToDeprecatedPushChildren<Node4>(art, current, type, stack);
154969 break;
154970 case NType::NODE_16:
154971 TransformToDeprecatedPushChildren<Node16>(art, current, type, stack);
154972 break;
154973 case NType::NODE_48:
154974 TransformToDeprecatedPushChildren<Node48>(art, current, type, stack);
154975 break;
154976 case NType::NODE_256:
154977 TransformToDeprecatedPushChildren<Node256>(art, current, type, stack);
154978 break;
154979 default:
154980 throw InternalException("invalid node type for TransformToDeprecated: %d", type);
154981 }
154982 }
154983}
static void TransformToDeprecated(ART &art, Node &node)
Transforms a nested leaf to a deprecated leaf.
Definition duckdb.cpp:154375
static optional_ptr< Node > TransformToDeprecated(ART &art, Node &node, TransformToDeprecatedState &state)
Definition duckdb.cpp:155818
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ToString()

string duckdb::Node::ToString ( ART & art,
const ToStringOptions & options ) const

Returns the string representation of the node at indentation level.

Parameters:

  • art: root node of tree being printed.
  • options: Printing options (see ToStringOptions struct for details).
155064 {
155065 auto indent = [](string &str, const idx_t n) {
155066 str.append(n, ' ');
155067 };
155068 // if inside gate, print byte values not ascii.
155069 auto format_byte = [&](uint8_t byte) {
155070 if (!options.inside_gate && options.display_ascii && byte >= 32 && byte <= 126) {
155071 return string(1, static_cast<char>(byte));
155072 }
155073 return to_string(byte);
155074 };
155075 auto type = GetType();
155076 bool is_gate = GetGateStatus() == GateStatus::GATE_SET;
155077 bool propagate_gate = options.inside_gate || is_gate;
155078
155079 bool print_full_tree = propagate_gate || !options.key_path || options.depth_remaining == 0;
155080
155081 switch (type) {
155082 case NType::LEAF_INLINED: {
155083 string str = "";
155084 indent(str, options.indent_level);
155085 return str + "Inlined Leaf [row ID: " + to_string(GetRowId()) + "]\n";
155086 }
155087 case NType::LEAF: {
155088 ToStringOptions leaf_options = options;
155089 return Leaf::DeprecatedToString(art, *this, leaf_options);
155090 }
155091 case NType::PREFIX: {
155092 ToStringOptions prefix_options = options;
155093 prefix_options.inside_gate = propagate_gate;
155094 string str = ConstPrefixHandle::ToString(art, *this, prefix_options);
155095 if (is_gate) {
155096 string s = "";
155097 indent(s, options.indent_level);
155098 s += "Gate\n";
155099 return s + str;
155100 }
155101 string s = "";
155102 return s + str;
155103 }
155104 default:
155105 break;
155106 }
155107 string str = "";
155108 indent(str, options.indent_level);
155109 str = str + "Node" + to_string(GetCapacity(type)) += "\n";
155110 uint8_t byte = 0;
155111
155112 if (IsLeafNode()) {
155113 indent(str, options.indent_level);
155114 str += "Leaf |";
155115 auto has_byte = GetNextByte(art, byte);
155116 while (has_byte) {
155117 str += format_byte(byte) + "|";
155118 if (byte == NumericLimits<uint8_t>::Maximum()) {
155119 break;
155120 }
155121 byte++;
155122 has_byte = GetNextByte(art, byte);
155123 }
155124 str += "\n";
155125 } else {
155126 uint8_t expected_byte = 0;
155127 bool has_expected_byte = false;
155128 if (options.key_path && !print_full_tree && options.key_depth < options.key_path->len) {
155129 expected_byte = (*options.key_path)[options.key_depth];
155130 has_expected_byte = true;
155131 }
155132
155133 uint8_t byte = 0;
155134 auto child = GetNextChild(art, byte);
155135 while (child) {
155136 // Determine if this child is on the path to the key_path
155137 // If we have an expected byte, only traverse the matching child
155138 // If we don't have an expected byte, we're printing the full tree, so all children are on_path.
155139 bool on_path = !has_expected_byte || (has_expected_byte && byte == expected_byte);
155140 if (on_path) {
155141 ToStringOptions child_options = options;
155142 child_options.indent_level = options.indent_level + options.indent_amount;
155143 child_options.inside_gate = propagate_gate;
155144 child_options.key_depth = has_expected_byte ? options.key_depth + 1 : options.key_depth;
155145 child_options.depth_remaining = (options.depth_remaining > 0) ? options.depth_remaining - 1 : 0;
155146 string c = child->ToString(art, child_options);
155147 indent(str, options.indent_level);
155148 str = str + format_byte(byte) + ",\n" + c;
155149 } else {
155150 // If we have an expected byte, but the current byte is not the expected byte.
155151 // In this case we check if we are only printing the structure, in which case we skip printing the
155152 // child byte.
155153 if (!options.structure_only) {
155154 indent(str, options.indent_level);
155155 str = str + format_byte(byte) + ", [not printed]\n";
155156 }
155157 }
155158 byte++;
155159 child = GetNextChild(art, byte);
155160 if (byte == NumericLimits<uint8_t>::Maximum()) {
155161 break;
155162 }
155163 }
155164 }
155165
155166 if (is_gate) {
155167 string s = "";
155168 indent(s, options.indent_level + options.indent_amount);
155169 str = "Gate\n" + s + str;
155170 }
155171 return str;
155172}
static string ToString(ART &art, const Node &node, const ToStringOptions &options)
Returns the string representation of the node using ToStringOptions.
Definition duckdb.cpp:153897
static string DeprecatedToString(ART &art, const Node &node, const ToStringOptions &options)
Definition duckdb.cpp:154464
bool GetNextByte(ART &art, uint8_t &byte) const
Get the first byte greater than or equal to the byte.
Definition duckdb.cpp:154838
row_t GetRowId() const
Get the row ID (8th to 63rd bit).
Definition duckdb.cpp:12037
GateStatus GetGateStatus() const
Returns the gate status of a node.
Definition duckdb.cpp:12046
std::string to_string(const T &value)
Definition duckdb.cpp:19425
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:

◆ GetType()

NType duckdb::Node::GetType ( ) const
inline

Returns the node type.

12025 {
12026 return NType(GetMetadata() & ~AND_GATE);
12027 }
uint8_t GetMetadata() const
Get metadata (Bits 56-63).
Definition duckdb.hpp:22540
static constexpr uint8_t AND_GATE
A gate sets the leftmost bit of the metadata, binary: 1000-0000.
Definition duckdb.cpp:11958
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsNode()

bool duckdb::Node::IsNode ( ) const

True, if the node is a Node4, Node16, Node48, or Node256.

154890 {
154891 switch (GetType()) {
154892 case NType::NODE_4:
154893 case NType::NODE_16:
154894 case NType::NODE_48:
154895 case NType::NODE_256:
154896 return true;
154897 default:
154898 return false;
154899 }
154900}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsLeafNode()

bool duckdb::Node::IsLeafNode ( ) const

True, if the node is a Node7Leaf, Node15Leaf, or Node256Leaf.

154902 {
154903 switch (GetType()) {
154904 case NType::NODE_7_LEAF:
154905 case NType::NODE_15_LEAF:
154906 case NType::NODE_256_LEAF:
154907 return true;
154908 default:
154909 return false;
154910 }
154911}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsAnyLeaf()

bool duckdb::Node::IsAnyLeaf ( ) const

True, if the node is any leaf.

154913 {
154914 if (IsLeafNode()) {
154915 return true;
154916 }
154917
154918 switch (GetType()) {
154919 case NType::LEAF_INLINED:
154920 case NType::LEAF:
154921 return true;
154922 default:
154923 return false;
154924 }
154925}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetRowId()

row_t duckdb::Node::GetRowId ( ) const
inline

Get the row ID (8th to 63rd bit).

12037 {
12038 return UnsafeNumericCast<row_t>(Get() & AND_ROW_ID);
12039 }
idx_t Get() const
Get data (all 64 bits).
Definition duckdb.hpp:22527
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetRowId()

void duckdb::Node::SetRowId ( const row_t row_id)
inline

Set the row ID (8th to 63rd bit).

12041 {
12042 Set((Get() & AND_METADATA) | UnsafeNumericCast<idx_t>(row_id));
12043 }
void Set(const idx_t data_p)
Set data (all 64 bits).
Definition duckdb.hpp:22531
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetGateStatus()

GateStatus duckdb::Node::GetGateStatus ( ) const
inline

Returns the gate status of a node.

12046 {
12047 return (GetMetadata() & AND_GATE) == 0 ? GateStatus::GATE_NOT_SET : GateStatus::GATE_SET;
12048 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetGateStatus()

void duckdb::Node::SetGateStatus ( const GateStatus status)
inline

Sets the gate status of a node.

12050 {
12051 switch (status) {
12052 case GateStatus::GATE_SET:
12053 D_ASSERT(GetType() != NType::LEAF_INLINED);
12055 break;
12056 case GateStatus::GATE_NOT_SET:
12058 break;
12059 }
12060 }
void SetMetadata(const uint8_t metadata)
Set metadata (Bits 56-63).
Definition duckdb.hpp:22544
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

void duckdb::Node::operator= ( const IndexPointer & ptr)
inline

Assign operator.

12063 {
12064 Set(ptr.Get());
12065 }
Here is the call graph for this function:

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