Node256 holds up to 256 children. They are indexed by their key byte.
More...
|
| 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 constexpr NType | NODE_256 = NType::NODE_256 |
|
static constexpr uint16_t | CAPACITY = 256 |
|
static constexpr uint8_t | SHRINK_THRESHOLD = 36 |
Node256 holds up to 256 children. They are indexed by their key byte.
◆ New()
Get a new Node256 handle and initialize the Node256.
58137 {
58140
58141 NodeHandle<Node256> handle(art, node);
58142 auto &n = handle.Get();
58143
58144
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
◆ 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}
◆ 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
155195 n.count--;
155196
155197 if (n.count > SHRINK_THRESHOLD) {
155198 return;
155199 }
155200 }
155201
155202
155203 auto node256 = node;
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
◆ 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 }
◆ 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()
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
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 }
◆ 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 }
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: