153352 {
153353 D_ASSERT(entry.left.GetType() == NType::PREFIX);
153354 D_ASSERT(entry.right.GetType() == NType::PREFIX);
153355
153356
153357
153358
153359
153360
153361
153362
153363
153364
153365
153366
153367 Prefix l_prefix(
art, entry.left,
true);
153368 Prefix r_prefix(
art, entry.right,
true);
153369 const auto count =
art.PrefixCount();
153370
153371
153372
153373 const auto max_count = MinValue(l_prefix.data[count], r_prefix.data[count]);
153374 optional_idx pos;
153375 for (
idx_t i = 0; i < max_count; i++) {
153376 if (l_prefix.data[i] != r_prefix.data[i]) {
153377 pos = i;
153378 break;
153379 }
153380 }
153381
153382 if (pos.IsValid()) {
153383
153384
153385
153386
153387 const auto cast_pos = UnsafeNumericCast<uint8_t>(pos.GetIndex());
153388 const auto l_byte = Prefix::GetByte(
art, entry.left, cast_pos);
153389 const auto r_byte = Prefix::GetByte(
art, entry.right, cast_pos);
153390
153391
153392 reference<Node> ref(entry.left);
153393 Node l_child;
153396
153398 ref.get().SetGateStatus(status);
153399
153402 entry.right.Clear();
153403 return;
153404 }
153405
153406 if (l_prefix.data[count] == r_prefix.data[count]) {
153407
153408
153409
153410 auto r_child = *r_prefix.ptr;
153412 entry.right = r_child;
153413
153414 auto depth = entry.depth + l_prefix.data[count];
153415 Emplace(*l_prefix.ptr, entry.right, entry.status, depth);
153416 return;
153417 }
153418
153419
153420 if (r_prefix.data[count] == max_count) {
153421
153422
153423 swap(entry.left, entry.right);
153424 MergeNodeAndPrefix(*r_prefix.ptr, entry.right, entry.status, entry.depth + max_count, max_count);
153425 return;
153426 }
153427
153428
153429 MergeNodeAndPrefix(*l_prefix.ptr, entry.right, entry.status, entry.depth + max_count, max_count);
153430}
static NodeHandle< BaseNode > New(ART &art, Node &node)
Definition duckdb.cpp:57961
static void InsertChild(ART &art, Node &node, const uint8_t byte, const Node child)
Insert a child at byte.
Definition duckdb.cpp:153682
static GateStatus Split(ART &art, reference< Node > &node, Node &child, const uint8_t pos)
Definition duckdb.cpp:155544
double depth(InputArray R, InputArray t, InputArray X)