duckdb 0.8.2-dev4025.0 → 0.8.2-dev4142.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.gyp +1 -0
- package/package.json +1 -1
- package/src/duckdb/extension/json/buffered_json_reader.cpp +76 -74
- package/src/duckdb/extension/json/include/buffered_json_reader.hpp +35 -32
- package/src/duckdb/extension/json/include/json_scan.hpp +9 -6
- package/src/duckdb/extension/json/json_scan.cpp +124 -121
- package/src/duckdb/src/catalog/catalog.cpp +20 -0
- package/src/duckdb/src/catalog/catalog_entry/duck_index_entry.cpp +5 -0
- package/src/duckdb/src/common/arrow/arrow_converter.cpp +3 -0
- package/src/duckdb/src/common/radix_partitioning.cpp +1 -1
- package/src/duckdb/src/common/sort/partition_state.cpp +5 -1
- package/src/duckdb/src/core_functions/aggregate/holistic/mode.cpp +1 -1
- package/src/duckdb/src/core_functions/function_list.cpp +7 -0
- package/src/duckdb/src/core_functions/scalar/list/list_cosine_similarity.cpp +78 -0
- package/src/duckdb/src/core_functions/scalar/list/list_distance.cpp +72 -0
- package/src/duckdb/src/core_functions/scalar/list/list_inner_product.cpp +70 -0
- package/src/duckdb/src/execution/index/art/art.cpp +111 -92
- package/src/duckdb/src/execution/index/art/iterator.cpp +21 -27
- package/src/duckdb/src/execution/index/art/leaf.cpp +72 -153
- package/src/duckdb/src/execution/index/art/node.cpp +109 -203
- package/src/duckdb/src/execution/index/art/node16.cpp +32 -64
- package/src/duckdb/src/execution/index/art/node256.cpp +38 -53
- package/src/duckdb/src/execution/index/art/node4.cpp +31 -62
- package/src/duckdb/src/execution/index/art/node48.cpp +43 -65
- package/src/duckdb/src/execution/index/art/prefix.cpp +70 -141
- package/src/duckdb/src/execution/index/fixed_size_allocator.cpp +345 -0
- package/src/duckdb/src/execution/index/fixed_size_buffer.cpp +74 -0
- package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_art_index.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_columns.cpp +3 -1
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +1 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_index_entry.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/optional_idx.hpp +1 -1
- package/src/duckdb/src/include/duckdb/core_functions/scalar/list_functions.hpp +51 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +17 -7
- package/src/duckdb/src/include/duckdb/execution/index/art/iterator.hpp +5 -5
- package/src/duckdb/src/include/duckdb/execution/index/art/leaf.hpp +10 -16
- package/src/duckdb/src/include/duckdb/execution/index/art/node.hpp +38 -116
- package/src/duckdb/src/include/duckdb/execution/index/art/node16.hpp +17 -18
- package/src/duckdb/src/include/duckdb/execution/index/art/node256.hpp +17 -23
- package/src/duckdb/src/include/duckdb/execution/index/art/node4.hpp +17 -18
- package/src/duckdb/src/include/duckdb/execution/index/art/node48.hpp +17 -24
- package/src/duckdb/src/include/duckdb/execution/index/art/prefix.hpp +16 -22
- package/src/duckdb/src/include/duckdb/execution/index/fixed_size_allocator.hpp +126 -0
- package/src/duckdb/src/include/duckdb/execution/index/fixed_size_buffer.hpp +79 -0
- package/src/duckdb/src/include/duckdb/execution/index/index_pointer.hpp +96 -0
- package/src/duckdb/src/include/duckdb/main/extension_entries.hpp +1 -0
- package/src/duckdb/src/include/duckdb/main/extension_helper.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parallel/task_scheduler.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/block.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/index.hpp +10 -8
- package/src/duckdb/src/include/duckdb/storage/metadata/metadata_writer.hpp +3 -0
- package/src/duckdb/src/main/extension/extension_helper.cpp +17 -0
- package/src/duckdb/src/main/extension/extension_install.cpp +5 -3
- package/src/duckdb/src/main/extension/extension_load.cpp +3 -3
- package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +14 -5
- package/src/duckdb/src/storage/checkpoint/table_data_writer.cpp +2 -3
- package/src/duckdb/src/storage/checkpoint_manager.cpp +16 -21
- package/src/duckdb/src/storage/data_table.cpp +3 -3
- package/src/duckdb/src/storage/index.cpp +7 -1
- package/src/duckdb/src/storage/metadata/metadata_manager.cpp +21 -21
- package/src/duckdb/src/storage/standard_buffer_manager.cpp +0 -8
- package/src/duckdb/src/storage/storage_info.cpp +1 -1
- package/src/duckdb/src/storage/table_index_list.cpp +1 -1
- package/src/duckdb/src/transaction/commit_state.cpp +5 -1
- package/src/duckdb/ub_src_core_functions_scalar_list.cpp +6 -0
- package/src/duckdb/ub_src_execution_index.cpp +4 -0
- package/src/duckdb/ub_src_execution_index_art.cpp +0 -2
- package/src/duckdb/src/execution/index/art/fixed_size_allocator.cpp +0 -238
- package/src/duckdb/src/include/duckdb/execution/index/art/fixed_size_allocator.hpp +0 -115
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
#pragma once
|
10
10
|
|
11
|
-
#include "duckdb/execution/index/
|
11
|
+
#include "duckdb/execution/index/fixed_size_allocator.hpp"
|
12
12
|
#include "duckdb/execution/index/art/art.hpp"
|
13
13
|
#include "duckdb/execution/index/art/node.hpp"
|
14
14
|
|
@@ -28,6 +28,10 @@ struct BlockPointer;
|
|
28
28
|
//! row ID directly in the node pointer.
|
29
29
|
class Leaf {
|
30
30
|
public:
|
31
|
+
//! Delete copy constructors, as any Leaf can never own its memory
|
32
|
+
Leaf(const Leaf &) = delete;
|
33
|
+
Leaf &operator=(const Leaf &) = delete;
|
34
|
+
|
31
35
|
//! The number of row IDs in this leaf
|
32
36
|
uint8_t count;
|
33
37
|
//! Up to LEAF_SIZE row IDs
|
@@ -43,15 +47,10 @@ public:
|
|
43
47
|
static void New(ART &art, reference<Node> &node, const row_t *row_ids, idx_t count);
|
44
48
|
//! Free the leaf (chain)
|
45
49
|
static void Free(ART &art, Node &node);
|
46
|
-
//! Get a reference to the leaf
|
47
|
-
static inline Leaf &Get(const ART &art, const Node ptr) {
|
48
|
-
D_ASSERT(!ptr.IsSerialized());
|
49
|
-
return *Node::GetAllocator(art, NType::LEAF).Get<Leaf>(ptr);
|
50
|
-
}
|
51
50
|
|
52
51
|
//! Initializes a merge by incrementing the buffer IDs of the leaf (chain)
|
53
52
|
static void InitializeMerge(ART &art, Node &node, const ARTFlags &flags);
|
54
|
-
//! Merge
|
53
|
+
//! Merge leaf (chains) and free all copied leaf nodes
|
55
54
|
static void Merge(ART &art, Node &l_node, Node &r_node);
|
56
55
|
|
57
56
|
//! Insert a row ID into a leaf
|
@@ -60,19 +59,14 @@ public:
|
|
60
59
|
static bool Remove(ART &art, reference<Node> &node, const row_t row_id);
|
61
60
|
|
62
61
|
//! Get the total count of row IDs in the chain of leaves
|
63
|
-
static idx_t TotalCount(ART &art, Node &node);
|
62
|
+
static idx_t TotalCount(ART &art, const Node &node);
|
64
63
|
//! Fill the result_ids vector with the row IDs of this leaf chain, if the total count does not exceed max_count
|
65
|
-
static bool GetRowIds(ART &art, Node &node, vector<row_t> &result_ids, idx_t max_count);
|
64
|
+
static bool GetRowIds(ART &art, const Node &node, vector<row_t> &result_ids, const idx_t max_count);
|
66
65
|
//! Returns whether the leaf contains the row ID
|
67
|
-
static bool ContainsRowId(ART &art, Node &node, const row_t row_id);
|
66
|
+
static bool ContainsRowId(ART &art, const Node &node, const row_t row_id);
|
68
67
|
|
69
68
|
//! Returns the string representation of the leaf (chain), or only traverses and verifies the leaf (chain)
|
70
|
-
static string VerifyAndToString(ART &art, Node &node);
|
71
|
-
|
72
|
-
//! Serialize the leaf (chain)
|
73
|
-
static BlockPointer Serialize(ART &art, Node &node, MetadataWriter &writer);
|
74
|
-
//! Deserialize the leaf (chain)
|
75
|
-
static void Deserialize(ART &art, Node &node, MetadataReader &reader);
|
69
|
+
static string VerifyAndToString(ART &art, const Node &node, const bool only_verify);
|
76
70
|
|
77
71
|
//! Vacuum the leaf (chain)
|
78
72
|
static void Vacuum(ART &art, Node &node);
|
@@ -13,6 +13,8 @@
|
|
13
13
|
#include "duckdb/common/to_string.hpp"
|
14
14
|
#include "duckdb/common/typedefs.hpp"
|
15
15
|
#include "duckdb/common/limits.hpp"
|
16
|
+
#include "duckdb/execution/index/index_pointer.hpp"
|
17
|
+
#include "duckdb/execution/index/fixed_size_allocator.hpp"
|
16
18
|
|
17
19
|
namespace duckdb {
|
18
20
|
|
@@ -26,7 +28,7 @@ enum class NType : uint8_t {
|
|
26
28
|
NODE_256 = 6,
|
27
29
|
LEAF_INLINED = 7,
|
28
30
|
};
|
29
|
-
|
31
|
+
|
30
32
|
class ART;
|
31
33
|
class Prefix;
|
32
34
|
class MetadataReader;
|
@@ -38,9 +40,8 @@ struct ARTFlags;
|
|
38
40
|
struct MetaBlockPointer;
|
39
41
|
|
40
42
|
//! The Node is the pointer class of the ART index.
|
41
|
-
//!
|
42
|
-
|
43
|
-
class Node {
|
43
|
+
//! It inherits from the IndexPointer, and adds ART-specific functionality
|
44
|
+
class Node : public IndexPointer {
|
44
45
|
public:
|
45
46
|
//! Node thresholds
|
46
47
|
static constexpr uint8_t NODE_48_SHRINK_THRESHOLD = 12;
|
@@ -50,33 +51,11 @@ public:
|
|
50
51
|
static constexpr uint8_t NODE_16_CAPACITY = 16;
|
51
52
|
static constexpr uint8_t NODE_48_CAPACITY = 48;
|
52
53
|
static constexpr uint16_t NODE_256_CAPACITY = 256;
|
53
|
-
//! Bit-shifting
|
54
|
-
static constexpr uint64_t SHIFT_OFFSET = 32;
|
55
|
-
static constexpr uint64_t SHIFT_TYPE = 56;
|
56
|
-
static constexpr uint64_t SHIFT_SERIALIZED_FLAG = 63;
|
57
|
-
//! AND operations
|
58
|
-
static constexpr uint64_t AND_OFFSET = 0x0000000000FFFFFF;
|
59
|
-
static constexpr uint64_t AND_BUFFER_ID = 0x00000000FFFFFFFF;
|
60
|
-
static constexpr uint64_t AND_IS_SET = 0xFF00000000000000;
|
61
|
-
static constexpr uint64_t AND_RESET = 0x00FFFFFFFFFFFFFF;
|
62
|
-
//! OR operations
|
63
|
-
static constexpr uint64_t SET_SERIALIZED_FLAG = 0x8000000000000000;
|
64
54
|
//! Other constants
|
65
55
|
static constexpr uint8_t EMPTY_MARKER = 48;
|
66
56
|
static constexpr uint8_t LEAF_SIZE = 4;
|
67
57
|
static constexpr uint8_t PREFIX_SIZE = 15;
|
68
|
-
|
69
|
-
public:
|
70
|
-
//! Constructors
|
71
|
-
|
72
|
-
//! Constructs an empty Node
|
73
|
-
Node() : data(0) {};
|
74
|
-
//! Constructs a serialized Node pointer from a block ID and an offset
|
75
|
-
explicit Node(MetadataReader &reader);
|
76
|
-
//! Constructs an in-memory Node from a buffer ID and an offset
|
77
|
-
Node(const uint32_t buffer_id, const uint32_t offset) : data(0) {
|
78
|
-
SetPtr(buffer_id, offset);
|
79
|
-
};
|
58
|
+
static constexpr idx_t AND_ROW_ID = 0x00FFFFFFFFFFFFFF;
|
80
59
|
|
81
60
|
public:
|
82
61
|
//! Get a new pointer to a node, might cause a new buffer allocation, and initialize it
|
@@ -84,33 +63,43 @@ public:
|
|
84
63
|
//! Free the node (and its subtree)
|
85
64
|
static void Free(ART &art, Node &node);
|
86
65
|
|
87
|
-
//!
|
88
|
-
|
66
|
+
//! Get references to the allocator
|
67
|
+
static FixedSizeAllocator &GetAllocator(const ART &art, const NType type);
|
68
|
+
//! Get a (immutable) reference to the node. If dirty is false, then T should be a const class
|
69
|
+
template <class NODE>
|
70
|
+
static inline const NODE &Ref(const ART &art, const Node ptr, const NType type) {
|
71
|
+
return *(GetAllocator(art, type).Get<const NODE>(ptr, false));
|
72
|
+
}
|
73
|
+
//! Get a (const) reference to the node. If dirty is false, then T should be a const class
|
74
|
+
template <class NODE>
|
75
|
+
static inline NODE &RefMutable(const ART &art, const Node ptr, const NType type) {
|
76
|
+
return *(GetAllocator(art, type).Get<NODE>(ptr));
|
77
|
+
}
|
78
|
+
|
79
|
+
//! Replace the child node at byte
|
80
|
+
void ReplaceChild(const ART &art, const uint8_t byte, const Node child) const;
|
89
81
|
//! Insert the child node at byte
|
90
82
|
static void InsertChild(ART &art, Node &node, const uint8_t byte, const Node child);
|
91
|
-
//! Delete the child node at
|
83
|
+
//! Delete the child node at byte
|
92
84
|
static void DeleteChild(ART &art, Node &node, Node &prefix, const uint8_t byte);
|
93
85
|
|
86
|
+
//! Get the child (immutable) for the respective byte in the node
|
87
|
+
optional_ptr<const Node> GetChild(ART &art, const uint8_t byte) const;
|
94
88
|
//! Get the child for the respective byte in the node
|
95
|
-
optional_ptr<Node>
|
89
|
+
optional_ptr<Node> GetChildMutable(ART &art, const uint8_t byte) const;
|
90
|
+
//! Get the first child (immutable) that is greater or equal to the specific byte
|
91
|
+
optional_ptr<const Node> GetNextChild(ART &art, uint8_t &byte) const;
|
96
92
|
//! Get the first child that is greater or equal to the specific byte
|
97
|
-
optional_ptr<Node>
|
98
|
-
|
99
|
-
//! Serialize the node
|
100
|
-
BlockPointer Serialize(ART &art, MetadataWriter &writer);
|
101
|
-
//! Deserialize the node
|
102
|
-
void Deserialize(ART &art);
|
93
|
+
optional_ptr<Node> GetNextChildMutable(ART &art, uint8_t &byte) const;
|
103
94
|
|
104
95
|
//! Returns the string representation of the node, or only traverses and verifies the node and its subtree
|
105
|
-
string VerifyAndToString(ART &art, const bool only_verify);
|
96
|
+
string VerifyAndToString(ART &art, const bool only_verify) const;
|
106
97
|
//! Returns the capacity of the node
|
107
98
|
idx_t GetCapacity() const;
|
108
99
|
//! Returns the matching node type for a given count
|
109
100
|
static NType GetARTNodeTypeByCount(const idx_t count);
|
110
|
-
//! Get references to the different allocators
|
111
|
-
static FixedSizeAllocator &GetAllocator(const ART &art, NType type);
|
112
101
|
|
113
|
-
//! Initializes a merge by
|
102
|
+
//! Initializes a merge by incrementing the buffer IDs of a node and its subtree
|
114
103
|
void InitializeMerge(ART &art, const ARTFlags &flags);
|
115
104
|
//! Merge another node into this node
|
116
105
|
bool Merge(ART &art, Node &other);
|
@@ -122,90 +111,23 @@ public:
|
|
122
111
|
//! Vacuum all nodes that exceed their respective vacuum thresholds
|
123
112
|
void Vacuum(ART &art, const ARTFlags &flags);
|
124
113
|
|
125
|
-
// Getters and Setters
|
126
|
-
|
127
|
-
//! Returns whether the node is serialized or not (zero bit)
|
128
|
-
inline bool IsSerialized() const {
|
129
|
-
return data >> Node::SHIFT_SERIALIZED_FLAG;
|
130
|
-
}
|
131
|
-
//! Get the type (1st to 7th bit)
|
132
|
-
inline NType GetType() const {
|
133
|
-
D_ASSERT(!IsSerialized());
|
134
|
-
auto type = data >> Node::SHIFT_TYPE;
|
135
|
-
D_ASSERT(type >= (uint8_t)NType::PREFIX);
|
136
|
-
D_ASSERT(type <= (uint8_t)NType::LEAF_INLINED);
|
137
|
-
return NType(type);
|
138
|
-
}
|
139
|
-
//! Get the offset (8th to 23rd bit)
|
140
|
-
inline idx_t GetOffset() const {
|
141
|
-
auto offset = data >> Node::SHIFT_OFFSET;
|
142
|
-
return offset & Node::AND_OFFSET;
|
143
|
-
}
|
144
|
-
//! Get the block/buffer ID (24th to 63rd bit)
|
145
|
-
inline idx_t GetBufferId() const {
|
146
|
-
return data & Node::AND_BUFFER_ID;
|
147
|
-
}
|
148
114
|
//! Get the row ID (8th to 63rd bit)
|
149
115
|
inline row_t GetRowId() const {
|
150
|
-
return
|
151
|
-
}
|
152
|
-
|
153
|
-
//! Set the serialized flag (zero bit)
|
154
|
-
inline void SetSerialized() {
|
155
|
-
data &= Node::AND_RESET;
|
156
|
-
data |= Node::SET_SERIALIZED_FLAG;
|
157
|
-
}
|
158
|
-
//! Set the type (1st to 7th bit)
|
159
|
-
inline void SetType(const uint8_t type) {
|
160
|
-
D_ASSERT(!IsSerialized());
|
161
|
-
data += (uint64_t)type << Node::SHIFT_TYPE;
|
162
|
-
}
|
163
|
-
//! Set the block/buffer ID (24th to 63rd bit) and offset (8th to 23rd bit)
|
164
|
-
inline void SetPtr(const uint32_t buffer_id, const uint32_t offset) {
|
165
|
-
D_ASSERT(!(data & Node::AND_RESET));
|
166
|
-
auto shifted_offset = ((uint64_t)offset) << Node::SHIFT_OFFSET;
|
167
|
-
data += shifted_offset;
|
168
|
-
data += buffer_id;
|
116
|
+
return Get() & AND_ROW_ID;
|
169
117
|
}
|
170
118
|
//! Set the row ID (8th to 63rd bit)
|
171
119
|
inline void SetRowId(const row_t row_id) {
|
172
|
-
|
173
|
-
data += row_id;
|
174
|
-
}
|
175
|
-
|
176
|
-
//! Returns true, if neither the serialized flag is set nor the type
|
177
|
-
inline bool IsSet() const {
|
178
|
-
return data & Node::AND_IS_SET;
|
179
|
-
}
|
180
|
-
//! Reset the Node pointer by setting the node info to zero
|
181
|
-
inline void Reset() {
|
182
|
-
data = 0;
|
120
|
+
Set((Get() & AND_METADATA) | row_id);
|
183
121
|
}
|
184
122
|
|
185
|
-
//!
|
186
|
-
inline
|
187
|
-
|
188
|
-
data += summand;
|
123
|
+
//! Returns the type of the node, which is held in the metadata
|
124
|
+
inline NType GetType() const {
|
125
|
+
return NType(GetMetadata());
|
189
126
|
}
|
190
127
|
|
191
|
-
//!
|
192
|
-
inline
|
193
|
-
|
128
|
+
//! Assign operator
|
129
|
+
inline void operator=(const IndexPointer &ptr) {
|
130
|
+
Set(ptr.Get());
|
194
131
|
}
|
195
|
-
|
196
|
-
private:
|
197
|
-
//! Data holds all the information contained in a Node pointer
|
198
|
-
//! [0: serialized flag, 1 - 7: type,
|
199
|
-
//! 8 - 23: offset, 24 - 63: buffer/block ID OR
|
200
|
-
//! 8 - 63: row ID]
|
201
|
-
//! NOTE: a Node pointer can be either serialized OR have a type
|
202
|
-
//! NOTE: we do not use bit fields because when using bit fields Windows compiles
|
203
|
-
//! the Node class into 16 bytes instead of the intended 8 bytes, doubling the
|
204
|
-
//! space requirements
|
205
|
-
//! https://learn.microsoft.com/en-us/cpp/cpp/cpp-bit-fields?view=msvc-170
|
206
|
-
uint64_t data;
|
207
132
|
};
|
208
|
-
|
209
|
-
static_assert(sizeof(Node) == sizeof(uint64_t), "Invalid size for Node type.");
|
210
|
-
|
211
133
|
} // namespace duckdb
|
@@ -8,32 +8,32 @@
|
|
8
8
|
|
9
9
|
#pragma once
|
10
10
|
|
11
|
-
#include "duckdb/execution/index/
|
11
|
+
#include "duckdb/execution/index/fixed_size_allocator.hpp"
|
12
12
|
#include "duckdb/execution/index/art/art.hpp"
|
13
13
|
#include "duckdb/execution/index/art/node.hpp"
|
14
14
|
|
15
15
|
namespace duckdb {
|
16
16
|
|
17
|
-
//! Node16 holds up to 16
|
17
|
+
//! Node16 holds up to 16 Node children sorted by their key byte
|
18
18
|
class Node16 {
|
19
19
|
public:
|
20
|
+
//! Delete copy constructors, as any Node16 can never own its memory
|
21
|
+
Node16(const Node16 &) = delete;
|
22
|
+
Node16 &operator=(const Node16 &) = delete;
|
23
|
+
|
20
24
|
//! Number of non-null children
|
21
25
|
uint8_t count;
|
22
26
|
//! Array containing all partial key bytes
|
23
27
|
uint8_t key[Node::NODE_16_CAPACITY];
|
24
|
-
//!
|
28
|
+
//! Node pointers to the child nodes
|
25
29
|
Node children[Node::NODE_16_CAPACITY];
|
26
30
|
|
27
31
|
public:
|
28
|
-
//! Get a new Node16
|
32
|
+
//! Get a new Node16, might cause a new buffer allocation, and initialize it
|
29
33
|
static Node16 &New(ART &art, Node &node);
|
30
34
|
//! Free the node (and its subtree)
|
31
35
|
static void Free(ART &art, Node &node);
|
32
|
-
|
33
|
-
static inline Node16 &Get(const ART &art, const Node ptr) {
|
34
|
-
D_ASSERT(!ptr.IsSerialized());
|
35
|
-
return *Node::GetAllocator(art, NType::NODE_16).Get<Node16>(ptr);
|
36
|
-
}
|
36
|
+
|
37
37
|
//! Initializes all the fields of the node while growing a Node4 to a Node16
|
38
38
|
static Node16 &GrowNode4(ART &art, Node &node16, Node &node4);
|
39
39
|
//! Initializes all fields of the node while shrinking a Node48 to a Node16
|
@@ -44,21 +44,20 @@ public:
|
|
44
44
|
|
45
45
|
//! Insert a child node at byte
|
46
46
|
static void InsertChild(ART &art, Node &node, const uint8_t byte, const Node child);
|
47
|
-
//! Delete the child node at
|
47
|
+
//! Delete the child node at byte
|
48
48
|
static void DeleteChild(ART &art, Node &node, const uint8_t byte);
|
49
49
|
|
50
|
-
//! Replace the child node at
|
50
|
+
//! Replace the child node at byte
|
51
51
|
void ReplaceChild(const uint8_t byte, const Node child);
|
52
52
|
|
53
|
+
//! Get the (immutable) child for the respective byte in the node
|
54
|
+
optional_ptr<const Node> GetChild(const uint8_t byte) const;
|
53
55
|
//! Get the child for the respective byte in the node
|
54
|
-
optional_ptr<Node>
|
56
|
+
optional_ptr<Node> GetChildMutable(const uint8_t byte);
|
57
|
+
//! Get the first (immutable) child that is greater or equal to the specific byte
|
58
|
+
optional_ptr<const Node> GetNextChild(uint8_t &byte) const;
|
55
59
|
//! Get the first child that is greater or equal to the specific byte
|
56
|
-
optional_ptr<Node>
|
57
|
-
|
58
|
-
//! Serialize this node
|
59
|
-
BlockPointer Serialize(ART &art, MetadataWriter &writer);
|
60
|
-
//! Deserialize this node
|
61
|
-
void Deserialize(MetadataReader &reader);
|
60
|
+
optional_ptr<Node> GetNextChildMutable(uint8_t &byte);
|
62
61
|
|
63
62
|
//! Vacuum the children of the node
|
64
63
|
void Vacuum(ART &art, const ARTFlags &flags);
|
@@ -8,30 +8,30 @@
|
|
8
8
|
|
9
9
|
#pragma once
|
10
10
|
|
11
|
-
#include "duckdb/execution/index/
|
11
|
+
#include "duckdb/execution/index/fixed_size_allocator.hpp"
|
12
12
|
#include "duckdb/execution/index/art/art.hpp"
|
13
13
|
#include "duckdb/execution/index/art/node.hpp"
|
14
14
|
|
15
15
|
namespace duckdb {
|
16
16
|
|
17
|
-
//! Node256 holds up to 256
|
17
|
+
//! Node256 holds up to 256 Node children which can be directly indexed by the key byte
|
18
18
|
class Node256 {
|
19
19
|
public:
|
20
|
+
//! Delete copy constructors, as any Node256 can never own its memory
|
21
|
+
Node256(const Node256 &) = delete;
|
22
|
+
Node256 &operator=(const Node256 &) = delete;
|
23
|
+
|
20
24
|
//! Number of non-null children
|
21
25
|
uint16_t count;
|
22
|
-
//!
|
26
|
+
//! Node pointers to the child nodes
|
23
27
|
Node children[Node::NODE_256_CAPACITY];
|
24
28
|
|
25
29
|
public:
|
26
|
-
//! Get a new Node256
|
30
|
+
//! Get a new Node256, might cause a new buffer allocation, and initialize it
|
27
31
|
static Node256 &New(ART &art, Node &node);
|
28
32
|
//! Free the node (and its subtree)
|
29
33
|
static void Free(ART &art, Node &node);
|
30
|
-
|
31
|
-
static inline Node256 &Get(const ART &art, const Node ptr) {
|
32
|
-
D_ASSERT(!ptr.IsSerialized());
|
33
|
-
return *Node::GetAllocator(art, NType::NODE_256).Get<Node256>(ptr);
|
34
|
-
}
|
34
|
+
|
35
35
|
//! Initializes all the fields of the node while growing a Node48 to a Node256
|
36
36
|
static Node256 &GrowNode48(ART &art, Node &node256, Node &node48);
|
37
37
|
|
@@ -40,28 +40,22 @@ public:
|
|
40
40
|
|
41
41
|
//! Insert a child node at byte
|
42
42
|
static void InsertChild(ART &art, Node &node, const uint8_t byte, const Node child);
|
43
|
-
//! Delete the child node at
|
43
|
+
//! Delete the child node at byte
|
44
44
|
static void DeleteChild(ART &art, Node &node, const uint8_t byte);
|
45
45
|
|
46
|
-
//! Replace the child node at
|
46
|
+
//! Replace the child node at byte
|
47
47
|
inline void ReplaceChild(const uint8_t byte, const Node child) {
|
48
48
|
children[byte] = child;
|
49
49
|
}
|
50
50
|
|
51
|
+
//! Get the (immutable) child for the respective byte in the node
|
52
|
+
optional_ptr<const Node> GetChild(const uint8_t byte) const;
|
51
53
|
//! Get the child for the respective byte in the node
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
}
|
56
|
-
return nullptr;
|
57
|
-
}
|
54
|
+
optional_ptr<Node> GetChildMutable(const uint8_t byte);
|
55
|
+
//! Get the first (immutable) child that is greater or equal to the specific byte
|
56
|
+
optional_ptr<const Node> GetNextChild(uint8_t &byte) const;
|
58
57
|
//! Get the first child that is greater or equal to the specific byte
|
59
|
-
optional_ptr<Node>
|
60
|
-
|
61
|
-
//! Serialize this node
|
62
|
-
BlockPointer Serialize(ART &art, MetadataWriter &writer);
|
63
|
-
//! Deserialize this node
|
64
|
-
void Deserialize(MetadataReader &reader);
|
58
|
+
optional_ptr<Node> GetNextChildMutable(uint8_t &byte);
|
65
59
|
|
66
60
|
//! Vacuum the children of the node
|
67
61
|
void Vacuum(ART &art, const ARTFlags &flags);
|
@@ -8,32 +8,32 @@
|
|
8
8
|
|
9
9
|
#pragma once
|
10
10
|
|
11
|
-
#include "duckdb/execution/index/
|
11
|
+
#include "duckdb/execution/index/fixed_size_allocator.hpp"
|
12
12
|
#include "duckdb/execution/index/art/art.hpp"
|
13
13
|
#include "duckdb/execution/index/art/node.hpp"
|
14
14
|
|
15
15
|
namespace duckdb {
|
16
16
|
|
17
|
-
//! Node4 holds up to four
|
17
|
+
//! Node4 holds up to four Node children sorted by their key byte
|
18
18
|
class Node4 {
|
19
19
|
public:
|
20
|
+
//! Delete copy constructors, as any Node4 can never own its memory
|
21
|
+
Node4(const Node4 &) = delete;
|
22
|
+
Node4 &operator=(const Node4 &) = delete;
|
23
|
+
|
20
24
|
//! Number of non-null children
|
21
25
|
uint8_t count;
|
22
26
|
//! Array containing all partial key bytes
|
23
27
|
uint8_t key[Node::NODE_4_CAPACITY];
|
24
|
-
//!
|
28
|
+
//! Node pointers to the child nodes
|
25
29
|
Node children[Node::NODE_4_CAPACITY];
|
26
30
|
|
27
31
|
public:
|
28
|
-
//! Get a new Node4
|
32
|
+
//! Get a new Node4, might cause a new buffer allocation, and initialize it
|
29
33
|
static Node4 &New(ART &art, Node &node);
|
30
34
|
//! Free the node (and its subtree)
|
31
35
|
static void Free(ART &art, Node &node);
|
32
|
-
|
33
|
-
static inline Node4 &Get(const ART &art, const Node ptr) {
|
34
|
-
D_ASSERT(!ptr.IsSerialized());
|
35
|
-
return *Node::GetAllocator(art, NType::NODE_4).Get<Node4>(ptr);
|
36
|
-
}
|
36
|
+
|
37
37
|
//! Initializes all fields of the node while shrinking a Node16 to a Node4
|
38
38
|
static Node4 &ShrinkNode16(ART &art, Node &node4, Node &node16);
|
39
39
|
|
@@ -42,21 +42,20 @@ public:
|
|
42
42
|
|
43
43
|
//! Insert a child node at byte
|
44
44
|
static void InsertChild(ART &art, Node &node, const uint8_t byte, const Node child);
|
45
|
-
//! Delete the child node at
|
45
|
+
//! Delete the child node at byte
|
46
46
|
static void DeleteChild(ART &art, Node &node, Node &prefix, const uint8_t byte);
|
47
47
|
|
48
|
-
//! Replace the child node at
|
48
|
+
//! Replace the child node at byte
|
49
49
|
void ReplaceChild(const uint8_t byte, const Node child);
|
50
50
|
|
51
|
+
//! Get the (immutable) child for the respective byte in the node
|
52
|
+
optional_ptr<const Node> GetChild(const uint8_t byte) const;
|
51
53
|
//! Get the child for the respective byte in the node
|
52
|
-
optional_ptr<Node>
|
54
|
+
optional_ptr<Node> GetChildMutable(const uint8_t byte);
|
55
|
+
//! Get the first (immutable) child that is greater or equal to the specific byte
|
56
|
+
optional_ptr<const Node> GetNextChild(uint8_t &byte) const;
|
53
57
|
//! Get the first child that is greater or equal to the specific byte
|
54
|
-
optional_ptr<Node>
|
55
|
-
|
56
|
-
//! Serialize this node
|
57
|
-
BlockPointer Serialize(ART &art, MetadataWriter &writer);
|
58
|
-
//! Deserialize this node
|
59
|
-
void Deserialize(MetadataReader &reader);
|
58
|
+
optional_ptr<Node> GetNextChildMutable(uint8_t &byte);
|
60
59
|
|
61
60
|
//! Vacuum the children of the node
|
62
61
|
void Vacuum(ART &art, const ARTFlags &flags);
|
@@ -8,33 +8,33 @@
|
|
8
8
|
|
9
9
|
#pragma once
|
10
10
|
|
11
|
-
#include "duckdb/execution/index/
|
11
|
+
#include "duckdb/execution/index/fixed_size_allocator.hpp"
|
12
12
|
#include "duckdb/execution/index/art/art.hpp"
|
13
13
|
#include "duckdb/execution/index/art/node.hpp"
|
14
14
|
|
15
15
|
namespace duckdb {
|
16
16
|
|
17
|
-
//! Node48 holds up to 48
|
17
|
+
//! Node48 holds up to 48 Node children. It contains a child_index array which can be directly indexed by the key
|
18
18
|
//! byte, and which contains the position of the child node in the children array
|
19
19
|
class Node48 {
|
20
20
|
public:
|
21
|
+
//! Delete copy constructors, as any Node48 can never own its memory
|
22
|
+
Node48(const Node48 &) = delete;
|
23
|
+
Node48 &operator=(const Node48 &) = delete;
|
24
|
+
|
21
25
|
//! Number of non-null children
|
22
26
|
uint8_t count;
|
23
27
|
//! Array containing all possible partial key bytes, those not set have an EMPTY_MARKER
|
24
28
|
uint8_t child_index[Node::NODE_256_CAPACITY];
|
25
|
-
//!
|
29
|
+
//! Node pointers to the child nodes
|
26
30
|
Node children[Node::NODE_48_CAPACITY];
|
27
31
|
|
28
32
|
public:
|
29
|
-
//! Get a new Node48
|
33
|
+
//! Get a new Node48, might cause a new buffer allocation, and initialize it
|
30
34
|
static Node48 &New(ART &art, Node &node);
|
31
35
|
//! Free the node (and its subtree)
|
32
36
|
static void Free(ART &art, Node &node);
|
33
|
-
|
34
|
-
static inline Node48 &Get(const ART &art, const Node ptr) {
|
35
|
-
D_ASSERT(!ptr.IsSerialized());
|
36
|
-
return *Node::GetAllocator(art, NType::NODE_48).Get<Node48>(ptr);
|
37
|
-
}
|
37
|
+
|
38
38
|
//! Initializes all the fields of the node while growing a Node16 to a Node48
|
39
39
|
static Node48 &GrowNode16(ART &art, Node &node48, Node &node16);
|
40
40
|
//! Initializes all fields of the node while shrinking a Node256 to a Node48
|
@@ -45,30 +45,23 @@ public:
|
|
45
45
|
|
46
46
|
//! Insert a child node at byte
|
47
47
|
static void InsertChild(ART &art, Node &node, const uint8_t byte, const Node child);
|
48
|
-
//! Delete the child node at
|
48
|
+
//! Delete the child node at byte
|
49
49
|
static void DeleteChild(ART &art, Node &node, const uint8_t byte);
|
50
50
|
|
51
|
-
//! Replace the child node at
|
51
|
+
//! Replace the child node at byte
|
52
52
|
inline void ReplaceChild(const uint8_t byte, const Node child) {
|
53
53
|
D_ASSERT(child_index[byte] != Node::EMPTY_MARKER);
|
54
54
|
children[child_index[byte]] = child;
|
55
55
|
}
|
56
56
|
|
57
|
+
//! Get the (immutable) child for the respective byte in the node
|
58
|
+
optional_ptr<const Node> GetChild(const uint8_t byte) const;
|
57
59
|
//! Get the child for the respective byte in the node
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
return &children[child_index[byte]];
|
62
|
-
}
|
63
|
-
return nullptr;
|
64
|
-
}
|
60
|
+
optional_ptr<Node> GetChildMutable(const uint8_t byte);
|
61
|
+
//! Get the first (immutable) child that is greater or equal to the specific byte
|
62
|
+
optional_ptr<const Node> GetNextChild(uint8_t &byte) const;
|
65
63
|
//! Get the first child that is greater or equal to the specific byte
|
66
|
-
optional_ptr<Node>
|
67
|
-
|
68
|
-
//! Serialize this node
|
69
|
-
BlockPointer Serialize(ART &art, MetadataWriter &writer);
|
70
|
-
//! Deserialize this node
|
71
|
-
void Deserialize(MetadataReader &reader);
|
64
|
+
optional_ptr<Node> GetNextChildMutable(uint8_t &byte);
|
72
65
|
|
73
66
|
//! Vacuum the children of the node
|
74
67
|
void Vacuum(ART &art, const ARTFlags &flags);
|