Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2007cec
Update vendored DuckDB sources to 5657cbdc0b
duckdblabs-bot Oct 4, 2025
6a14da4
Update vendored DuckDB sources to b3c8acdc0e
duckdblabs-bot Oct 7, 2025
0b478d3
Update vendored DuckDB sources to f793ea27c6
duckdblabs-bot Oct 8, 2025
45e0299
Update vendored DuckDB sources to 353406bd7f
duckdblabs-bot Oct 9, 2025
0eda34b
Update vendored DuckDB sources to 9d77bcf518
duckdblabs-bot Oct 11, 2025
f10aea5
Update vendored DuckDB sources to 2762f1aa72
duckdblabs-bot Oct 12, 2025
2088ae4
Update vendored DuckDB sources to 7621d1bad9
duckdblabs-bot Oct 14, 2025
855724b
Update vendored DuckDB sources to 746404c6aa
duckdblabs-bot Oct 15, 2025
81d6e16
Update vendored DuckDB sources to 5d422e423e
duckdblabs-bot Oct 16, 2025
b3f1929
Update vendored DuckDB sources to f256271bbc
duckdblabs-bot Oct 17, 2025
498da86
Update vendored DuckDB sources to 50acc16a8d
duckdblabs-bot Oct 18, 2025
457acae
Update vendored DuckDB sources to d921f4d6ba
duckdblabs-bot Oct 19, 2025
f24aa46
Update vendored DuckDB sources to c8906e701e
duckdblabs-bot Oct 22, 2025
7565c88
Update vendored DuckDB sources to bfc1fc8800
duckdblabs-bot Oct 25, 2025
80341dc
Update vendored DuckDB sources to ee49c5b308
duckdblabs-bot Oct 28, 2025
a0eaba7
Update vendored DuckDB sources to 4ff549de0d
duckdblabs-bot Oct 29, 2025
d1c6fb9
Update vendored DuckDB sources to c8906e701e
duckdblabs-bot Oct 29, 2025
a476351
Update vendored DuckDB sources to 620e685c6d
duckdblabs-bot Nov 5, 2025
f320879
Update vendored DuckDB sources to 963000678a
duckdblabs-bot Nov 6, 2025
bdbfad9
Update vendored DuckDB sources to d573b275ce
duckdblabs-bot Nov 7, 2025
9989217
Update vendored DuckDB sources to 44b706b2b7
duckdblabs-bot Nov 8, 2025
b762a52
Update vendored DuckDB sources to 5511fb39ac
duckdblabs-bot Nov 11, 2025
4e7f155
Update vendored DuckDB sources to 39f5583f99
duckdblabs-bot Nov 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update vendored DuckDB sources to 7621d1bad9
  • Loading branch information
duckdblabs-bot committed Nov 11, 2025
commit 2088ae4734863a3b1aaf995b7c578f63d2cce654
145 changes: 86 additions & 59 deletions src/duckdb/src/execution/index/art/base_leaf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ void BaseLeaf<CAPACITY, TYPE>::InsertByteInternal(BaseLeaf &n, const uint8_t byt
}

template <uint8_t CAPACITY, NType TYPE>
BaseLeaf<CAPACITY, TYPE> &BaseLeaf<CAPACITY, TYPE>::DeleteByteInternal(ART &art, Node &node, const uint8_t byte) {
auto &n = Node::Ref<BaseLeaf>(art, node, node.GetType());
NodeHandle<BaseLeaf<CAPACITY, TYPE>> BaseLeaf<CAPACITY, TYPE>::DeleteByteInternal(ART &art, Node &node,
const uint8_t byte) {
NodeHandle<BaseLeaf<CAPACITY, TYPE>> handle(art, node);
auto &n = handle.Get();
uint8_t child_pos = 0;

for (; child_pos < n.count; child_pos++) {
Expand All @@ -45,35 +47,44 @@ BaseLeaf<CAPACITY, TYPE> &BaseLeaf<CAPACITY, TYPE>::DeleteByteInternal(ART &art,
for (uint8_t i = child_pos; i < n.count; i++) {
n.key[i] = n.key[i + 1];
}
return n;
return handle;
}

//===--------------------------------------------------------------------===//
// Node7Leaf
//===--------------------------------------------------------------------===//

void Node7Leaf::InsertByte(ART &art, Node &node, const uint8_t byte) {
// The node is full. Grow to Node15.
auto &n7 = Node::Ref<Node7Leaf>(art, node, NODE_7_LEAF);
if (n7.count == CAPACITY) {
auto node7 = node;
Node15Leaf::GrowNode7Leaf(art, node, node7);
Node15Leaf::InsertByte(art, node, byte);
return;
}
{
NodeHandle<Node7Leaf> handle(art, node);
auto &n7 = handle.Get();

InsertByteInternal(n7, byte);
if (n7.count != CAPACITY) {
InsertByteInternal(n7, byte);
return;
}
}
// The node is full. Grow to Node15.
auto node7 = node;
Node15Leaf::GrowNode7Leaf(art, node, node7);
Node15Leaf::InsertByte(art, node, byte);
}

void Node7Leaf::DeleteByte(ART &art, Node &node, Node &prefix, const uint8_t byte, const ARTKey &row_id) {
auto &n7 = DeleteByteInternal(art, node, byte);
idx_t remainder;
{
auto n7_handle = DeleteByteInternal(art, node, byte);
auto &n7 = n7_handle.Get();

if (n7.count != 1) {
return;
}

// Compress one-way nodes.
if (n7.count == 1) {
// Compress one-way nodes.
D_ASSERT(node.GetGateStatus() == GateStatus::GATE_NOT_SET);

// Get the remaining row ID.
auto remainder = UnsafeNumericCast<idx_t>(row_id.GetRowId()) & AND_LAST_BYTE;
remainder = UnsafeNumericCast<idx_t>(row_id.GetRowId()) & AND_LAST_BYTE;
remainder |= UnsafeNumericCast<idx_t>(n7.key[0]);

// Free the prefix (nodes) and inline the remainder.
Expand All @@ -82,23 +93,27 @@ void Node7Leaf::DeleteByte(ART &art, Node &node, Node &prefix, const uint8_t byt
Leaf::New(prefix, UnsafeNumericCast<row_t>(remainder));
return;
}

// Free the Node7Leaf and inline the remainder.
Node::FreeNode(art, node);
Leaf::New(node, UnsafeNumericCast<row_t>(remainder));
}
// Free the Node7Leaf and inline the remainder.
Node::FreeNode(art, node);
Leaf::New(node, UnsafeNumericCast<row_t>(remainder));
}

void Node7Leaf::ShrinkNode15Leaf(ART &art, Node &node7_leaf, Node &node15_leaf) {
auto &n7 = New(art, node7_leaf);
auto &n15 = Node::Ref<Node15Leaf>(art, node15_leaf, NType::NODE_15_LEAF);
node7_leaf.SetGateStatus(node15_leaf.GetGateStatus());
{
auto n7_handle = New(art, node7_leaf);
auto &n7 = n7_handle.Get();

n7.count = n15.count;
for (uint8_t i = 0; i < n15.count; i++) {
n7.key[i] = n15.key[i];
}
NodeHandle<Node15Leaf> n15_handle(art, node15_leaf);
auto &n15 = n15_handle.Get();

node7_leaf.SetGateStatus(node15_leaf.GetGateStatus());

n7.count = n15.count;
for (uint8_t i = 0; i < n15.count; i++) {
n7.key[i] = n15.key[i];
}
}
Node::FreeNode(art, node15_leaf);
}

Expand All @@ -107,54 +122,66 @@ void Node7Leaf::ShrinkNode15Leaf(ART &art, Node &node7_leaf, Node &node15_leaf)
//===--------------------------------------------------------------------===//

void Node15Leaf::InsertByte(ART &art, Node &node, const uint8_t byte) {
// The node is full. Grow to Node256Leaf.
auto &n15 = Node::Ref<Node15Leaf>(art, node, NODE_15_LEAF);
if (n15.count == CAPACITY) {
auto node15 = node;
Node256Leaf::GrowNode15Leaf(art, node, node15);
Node256Leaf::InsertByte(art, node, byte);
return;
{
NodeHandle<Node15Leaf> n15_handle(art, node);
auto &n15 = n15_handle.Get();
if (n15.count != CAPACITY) {
InsertByteInternal(n15, byte);
return;
}
}

InsertByteInternal(n15, byte);
auto node15 = node;
Node256Leaf::GrowNode15Leaf(art, node, node15);
Node256Leaf::InsertByte(art, node, byte);
}

void Node15Leaf::DeleteByte(ART &art, Node &node, const uint8_t byte) {
auto &n15 = DeleteByteInternal(art, node, byte);

// Shrink node to Node7.
if (n15.count < Node7Leaf::CAPACITY) {
auto node15 = node;
Node7Leaf::ShrinkNode15Leaf(art, node, node15);
{
auto n15_handle = DeleteByteInternal(art, node, byte);
auto &n15 = n15_handle.Get();
if (n15.count >= Node7Leaf::CAPACITY) {
return;
}
}
auto node15 = node;
Node7Leaf::ShrinkNode15Leaf(art, node, node15);
}

void Node15Leaf::GrowNode7Leaf(ART &art, Node &node15_leaf, Node &node7_leaf) {
auto &n7 = Node::Ref<Node7Leaf>(art, node7_leaf, NType::NODE_7_LEAF);
auto &n15 = New(art, node15_leaf);
node15_leaf.SetGateStatus(node7_leaf.GetGateStatus());
{
NodeHandle<Node7Leaf> n7_handle(art, node7_leaf);
auto &n7 = n7_handle.Get();

n15.count = n7.count;
for (uint8_t i = 0; i < n7.count; i++) {
n15.key[i] = n7.key[i];
}
auto n15_handle = New(art, node15_leaf);
auto &n15 = n15_handle.Get();
node15_leaf.SetGateStatus(node7_leaf.GetGateStatus());

n15.count = n7.count;
for (uint8_t i = 0; i < n7.count; i++) {
n15.key[i] = n7.key[i];
}
}
Node::FreeNode(art, node7_leaf);
}

void Node15Leaf::ShrinkNode256Leaf(ART &art, Node &node15_leaf, Node &node256_leaf) {
auto &n15 = New(art, node15_leaf);
auto &n256 = Node::Ref<Node256Leaf>(art, node256_leaf, NType::NODE_256_LEAF);
node15_leaf.SetGateStatus(node256_leaf.GetGateStatus());

ValidityMask mask(&n256.mask[0], Node256::CAPACITY);
for (uint16_t i = 0; i < Node256::CAPACITY; i++) {
if (mask.RowIsValid(i)) {
n15.key[n15.count] = UnsafeNumericCast<uint8_t>(i);
n15.count++;
{
auto n15_handle = New(art, node15_leaf);
auto &n15 = n15_handle.Get();

NodeHandle<Node256Leaf> n256_handle(art, node256_leaf);
auto &n256 = n256_handle.Get();

node15_leaf.SetGateStatus(node256_leaf.GetGateStatus());

ValidityMask mask(&n256.mask[0], Node256::CAPACITY);
for (uint16_t i = 0; i < Node256::CAPACITY; i++) {
if (mask.RowIsValid(i)) {
n15.key[n15.count] = UnsafeNumericCast<uint8_t>(i);
n15.count++;
}
}
}

Node::FreeNode(art, node256_leaf);
}

Expand Down
Loading