152660 {
152661 while (!
s.empty()) {
152662
152663 auto entry =
s.top();
152665
152666 D_ASSERT(entry.start <
keys.size());
152667 D_ASSERT(entry.end <
keys.size());
152668 D_ASSERT(entry.start <= entry.end);
152669
152670 auto &start =
keys[entry.start];
152671 auto &end =
keys[entry.end];
152672 D_ASSERT(start.len != 0);
152673
152674
152675 auto prefix_depth = entry.depth;
152676 while (start.len != entry.depth && start.ByteMatches(end, entry.depth)) {
152677 entry.depth++;
152678 }
152679
152680
152681 if (start.len == entry.depth) {
152682
152683 auto row_id_count = entry.end - entry.start + 1;
152684 if (
art.IsUnique() && row_id_count != 1) {
152685 return ARTConflictType::CONSTRAINT;
152686 }
152687
152688 reference<Node> ref(entry.node);
152689 auto count = UnsafeNumericCast<idx_t>(start.len - prefix_depth);
152691
152692
152693 if (row_id_count == 1) {
152695 continue;
152696 }
152697
152698
152699
152700
152701 for (
idx_t i = entry.start; i < entry.start + row_id_count; i++) {
152703 IndexAppendMode::DEFAULT);
152704 }
152705 ref.get().SetGateStatus(GateStatus::GATE_SET);
152706 continue;
152707 }
152708
152709
152710 reference<Node> ref(entry.node);
152711 auto prefix_length = entry.depth - prefix_depth;
152713
152714 vector<idx_t> child_offsets;
152715 child_offsets.emplace_back(entry.start);
152716 for (
idx_t i = entry.start + 1; i <= entry.end; i++) {
152717 if (
keys[i - 1].data[entry.depth] !=
keys[i].data[entry.depth]) {
152718 child_offsets.emplace_back(i);
152719 }
152720 }
152721
152722
152724 auto start_offset = child_offsets[0];
152725 for (
idx_t i = 1; i <= child_offsets.size(); i++) {
152726 auto child_byte =
keys[start_offset].data[entry.depth];
152727
152728
152730 auto child = ref.get().Node::GetChildMutable(
art, child_byte,
true);
152731 auto end_offset = i != child_offsets.size() ? child_offsets[i] - 1 : entry.end;
152732 s.emplace(*child, start_offset, end_offset, entry.depth + 1);
152733 start_offset = end_offset + 1;
152734 }
152735 }
152736
152737
152738 return ARTConflictType::NO_CONFLICT;
152739}
static ARTConflictType Insert(ArenaAllocator &arena, ART &art, Node &node, const ARTKey &key, idx_t depth, const ARTKey &row_id, GateStatus status, DeleteIndexInfo delete_index_info, const IndexAppendMode append_mode)
Definition duckdb.cpp:150573
static void New(Node &node, const row_t row_id)
Inline a row ID into a node pointer.
Definition duckdb.cpp:154285
static void New(ART &art, Node &node, const NType type)
Get a new pointer to a node and initialize it.
Definition duckdb.cpp:154594
static NType GetNodeType(const idx_t count)
Returns the node type for a count.
Definition duckdb.cpp:154879
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
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237