Insert a key and its row ID into the node. Starts at depth (in the key). status indicates if the insert happens inside a gate or not.
150575 {
150576 reference<Node> active_node_ref(node);
150577 reference<const ARTKey> active_key_ref(key);
150578
150579
150580 if (!node.HasMetadata()) {
150581 D_ASSERT(depth == 0);
150582 if (status == GateStatus::GATE_SET) {
150584 return ARTConflictType::NO_CONFLICT;
150585 }
150586
150587 Prefix::New(art, active_node_ref, active_key_ref.get(), depth, active_key_ref.get().len);
150588 Leaf::New(active_node_ref, row_id.GetRowId());
150589 return ARTConflictType::NO_CONFLICT;
150590 }
150591
150592 while (active_node_ref.get().HasMetadata()) {
150593 auto &active_node = active_node_ref.get();
150594 auto &active_key = active_key_ref.get();
150595
150596
150597
150598 if (status == GateStatus::GATE_NOT_SET && active_node.GetGateStatus() == GateStatus::GATE_SET) {
150599 if (!art.IsUnique()) {
150600
150601 active_key_ref = row_id;
150603 status = GateStatus::GATE_SET;
150604 continue;
150605 }
150606
150607
150608
150609
150610
150611
150612 return ARTConflictType::TRANSACTION;
150613 }
150614
150615 const auto type = active_node.GetType();
150616 switch (type) {
150617 case NType::LEAF_INLINED: {
150618 return InsertIntoInlined(arena, art, active_node, key, row_id, depth, status, delete_index_info,
150619 append_mode);
150620 }
150621 case NType::LEAF: {
150623 continue;
150624 }
150625 case NType::NODE_7_LEAF:
150626 case NType::NODE_15_LEAF:
150627 case NType::NODE_256_LEAF: {
150628
150629 auto byte = active_key[Prefix::ROW_ID_COUNT];
150631 return ARTConflictType::NO_CONFLICT;
150632 }
150633 case NType::NODE_4:
150634 case NType::NODE_16:
150635 case NType::NODE_48:
150636 case NType::NODE_256: {
150637 D_ASSERT(depth < active_key.len);
150638 auto child = active_node.GetChildMutable(art, active_key[depth]);
150639 if (child) {
150640
150641 active_node_ref = *child;
150643 D_ASSERT(active_node_ref.get().HasMetadata());
150644 continue;
150645 }
150646 InsertIntoNode(art, active_node, key, row_id, depth, status);
150647 return ARTConflictType::NO_CONFLICT;
150648 }
150649 case NType::PREFIX: {
150650 Prefix prefix(art, active_node, true);
150651 for (
idx_t i = 0; i < prefix.data[art.PrefixCount()]; i++) {
150652 if (prefix.data[i] != active_key[depth]) {
150653
150654 InsertIntoPrefix(art, active_node_ref, active_key, row_id, i, depth, status);
150655 return ARTConflictType::NO_CONFLICT;
150656 }
150658 }
150659 active_node_ref = *prefix.ptr;
150660 D_ASSERT(active_node_ref.get().HasMetadata());
150661 continue;
150662 }
150663 default:
150664 throw InternalException("Invalid node type for ARTOperator::Insert.");
150665 }
150666 }
150667 throw InternalException("node without metadata in ARTOperator::Insert");
150668 }
static void New(Node &node, const row_t row_id)
Inline a row ID into a node pointer.
Definition duckdb.cpp:154285
static void TransformToNested(ART &art, Node &node)
Transforms a deprecated leaf to a nested leaf.
Definition duckdb.cpp:154349
static void InsertChild(ART &art, Node &node, const uint8_t byte, const Node child=Node())
Insert the child at byte.
Definition duckdb.cpp:154714
static void New(ART &art, reference< Node > &ref, const ARTKey &key, const idx_t depth, idx_t count)
Get a new list of prefix nodes. The node reference holds the child of the last prefix node.
Definition duckdb.cpp:155477