duckdb 0.7.2-dev2552.0 → 0.7.2-dev2675.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 +7 -7
- package/package.json +2 -2
- package/src/duckdb/extension/parquet/parquet_statistics.cpp +3 -0
- package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +2 -2
- package/src/duckdb/src/common/radix_partitioning.cpp +1 -1
- package/src/duckdb/src/execution/index/art/art.cpp +286 -269
- package/src/duckdb/src/execution/index/art/art_key.cpp +22 -32
- package/src/duckdb/src/execution/index/art/fixed_size_allocator.cpp +224 -0
- package/src/duckdb/src/execution/index/art/iterator.cpp +142 -123
- package/src/duckdb/src/execution/index/art/leaf.cpp +319 -170
- package/src/duckdb/src/execution/index/art/leaf_segment.cpp +42 -0
- package/src/duckdb/src/execution/index/art/node.cpp +444 -379
- package/src/duckdb/src/execution/index/art/node16.cpp +178 -114
- package/src/duckdb/src/execution/index/art/node256.cpp +117 -79
- package/src/duckdb/src/execution/index/art/node4.cpp +169 -114
- package/src/duckdb/src/execution/index/art/node48.cpp +175 -105
- package/src/duckdb/src/execution/index/art/prefix.cpp +405 -127
- package/src/duckdb/src/execution/index/art/prefix_segment.cpp +42 -0
- package/src/duckdb/src/execution/index/art/swizzleable_pointer.cpp +10 -85
- package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +2 -1
- package/src/duckdb/src/execution/operator/persistent/base_csv_reader.cpp +2 -2
- package/src/duckdb/src/execution/operator/persistent/csv_reader_options.cpp +2 -0
- package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +11 -12
- package/src/duckdb/src/function/table/read_csv.cpp +5 -1
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/common/queue.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +53 -45
- package/src/duckdb/src/include/duckdb/execution/index/art/art_key.hpp +29 -24
- package/src/duckdb/src/include/duckdb/execution/index/art/fixed_size_allocator.hpp +114 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/iterator.hpp +26 -20
- package/src/duckdb/src/include/duckdb/execution/index/art/leaf.hpp +63 -39
- package/src/duckdb/src/include/duckdb/execution/index/art/leaf_segment.hpp +36 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/node.hpp +98 -116
- package/src/duckdb/src/include/duckdb/execution/index/art/node16.hpp +48 -36
- package/src/duckdb/src/include/duckdb/execution/index/art/node256.hpp +52 -35
- package/src/duckdb/src/include/duckdb/execution/index/art/node4.hpp +46 -36
- package/src/duckdb/src/include/duckdb/execution/index/art/node48.hpp +57 -35
- package/src/duckdb/src/include/duckdb/execution/index/art/prefix.hpp +57 -50
- package/src/duckdb/src/include/duckdb/execution/index/art/prefix_segment.hpp +40 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/swizzleable_pointer.hpp +38 -31
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_file_handle.hpp +2 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/statement/insert_statement.hpp +4 -1
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/buffer_manager.hpp +0 -5
- package/src/duckdb/src/include/duckdb/storage/index.hpp +13 -28
- package/src/duckdb/src/include/duckdb/storage/standard_buffer_manager.hpp +0 -2
- package/src/duckdb/src/include/duckdb/transaction/cleanup_state.hpp +5 -0
- package/src/duckdb/src/include/duckdb.h +26 -0
- package/src/duckdb/src/main/capi/helper-c.cpp +7 -0
- package/src/duckdb/src/parser/statement/insert_statement.cpp +15 -6
- package/src/duckdb/src/parser/transform/constraint/transform_constraint.cpp +1 -1
- package/src/duckdb/src/parser/transform/expression/transform_function.cpp +18 -5
- package/src/duckdb/src/parser/transform/statement/transform_insert.cpp +5 -7
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +20 -7
- package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +14 -9
- package/src/duckdb/src/storage/checkpoint_manager.cpp +11 -9
- package/src/duckdb/src/storage/data_table.cpp +6 -3
- package/src/duckdb/src/storage/index.cpp +18 -6
- package/src/duckdb/src/storage/local_storage.cpp +8 -2
- package/src/duckdb/src/storage/standard_buffer_manager.cpp +0 -9
- package/src/duckdb/src/storage/wal_replay.cpp +1 -1
- package/src/duckdb/src/transaction/cleanup_state.cpp +6 -0
- package/src/duckdb/src/transaction/undo_buffer.cpp +8 -0
- package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +4 -4
- package/src/duckdb/ub_src_execution_index_art.cpp +7 -1
@@ -7,48 +7,65 @@
|
|
7
7
|
//===----------------------------------------------------------------------===//
|
8
8
|
|
9
9
|
#pragma once
|
10
|
+
|
11
|
+
#include "duckdb/execution/index/art/art.hpp"
|
12
|
+
#include "duckdb/execution/index/art/fixed_size_allocator.hpp"
|
10
13
|
#include "duckdb/execution/index/art/node.hpp"
|
11
|
-
#include "duckdb/execution/index/art/
|
14
|
+
#include "duckdb/execution/index/art/prefix.hpp"
|
12
15
|
|
13
16
|
namespace duckdb {
|
14
17
|
|
15
|
-
|
18
|
+
//! Node256 holds up to 256 ARTNode children which can be directly indexed by the key byte
|
19
|
+
class Node256 {
|
16
20
|
public:
|
17
|
-
//!
|
18
|
-
|
19
|
-
//!
|
20
|
-
|
21
|
+
//! Number of non-null children
|
22
|
+
uint16_t count;
|
23
|
+
//! Compressed path (prefix)
|
24
|
+
Prefix prefix;
|
25
|
+
//! ART node pointers to the child nodes
|
26
|
+
Node children[Node::NODE_256_CAPACITY];
|
21
27
|
|
22
28
|
public:
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
//!
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
//!
|
38
|
-
|
39
|
-
//!
|
40
|
-
void
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
static void InsertChild(ART &art, Node *&node, uint8_t key_byte, Node *new_child);
|
46
|
-
//! Erase the child at pos and (if necessary) shrink to Node48
|
47
|
-
static void EraseChild(ART &art, Node *&node, idx_t pos);
|
48
|
-
|
49
|
-
//! Returns the size (maximum capacity) of the Node256
|
50
|
-
static constexpr idx_t GetSize() {
|
51
|
-
return 256;
|
29
|
+
//! Get a new Node256 node, might cause a new buffer allocation, and initialize it
|
30
|
+
static Node256 &New(ART &art, Node &node);
|
31
|
+
//! Free the node (and its subtree)
|
32
|
+
static void Free(ART &art, Node &node);
|
33
|
+
//! Get a reference to the node
|
34
|
+
static inline Node256 &Get(const ART &art, const Node ptr) {
|
35
|
+
return *Node::GetAllocator(art, NType::NODE_256).Get<Node256>(ptr);
|
36
|
+
}
|
37
|
+
//! Initializes all the fields of the node while growing a Node48 to a Node256
|
38
|
+
static Node256 &GrowNode48(ART &art, Node &node256, Node &node48);
|
39
|
+
|
40
|
+
//! Initializes a merge by incrementing the buffer IDs of the node
|
41
|
+
void InitializeMerge(ART &art, const ARTFlags &flags);
|
42
|
+
|
43
|
+
//! Insert a child node at byte
|
44
|
+
static void InsertChild(ART &art, Node &node, const uint8_t byte, const Node child);
|
45
|
+
//! Delete the child node at the respective byte
|
46
|
+
static void DeleteChild(ART &art, Node &node, const uint8_t byte);
|
47
|
+
|
48
|
+
//! Replace the child node at the respective byte
|
49
|
+
inline void ReplaceChild(const uint8_t byte, const Node child) {
|
50
|
+
children[byte] = child;
|
52
51
|
}
|
52
|
+
|
53
|
+
//! Get the child for the respective byte in the node
|
54
|
+
inline optional_ptr<Node> GetChild(const uint8_t byte) {
|
55
|
+
if (children[byte].IsSet()) {
|
56
|
+
return &children[byte];
|
57
|
+
}
|
58
|
+
return nullptr;
|
59
|
+
}
|
60
|
+
//! Get the first child that is greater or equal to the specific byte
|
61
|
+
optional_ptr<Node> GetNextChild(uint8_t &byte);
|
62
|
+
|
63
|
+
//! Serialize an ART node
|
64
|
+
BlockPointer Serialize(ART &art, MetaBlockWriter &writer);
|
65
|
+
//! Deserialize this node
|
66
|
+
void Deserialize(ART &art, MetaBlockReader &reader);
|
67
|
+
|
68
|
+
//! Vacuum the children of the node
|
69
|
+
void Vacuum(ART &art, const ARTFlags &flags);
|
53
70
|
};
|
54
71
|
} // namespace duckdb
|
@@ -7,50 +7,60 @@
|
|
7
7
|
//===----------------------------------------------------------------------===//
|
8
8
|
|
9
9
|
#pragma once
|
10
|
+
|
11
|
+
#include "duckdb/execution/index/art/art.hpp"
|
12
|
+
#include "duckdb/execution/index/art/fixed_size_allocator.hpp"
|
10
13
|
#include "duckdb/execution/index/art/node.hpp"
|
11
|
-
#include "duckdb/execution/index/art/
|
14
|
+
#include "duckdb/execution/index/art/prefix.hpp"
|
12
15
|
|
13
16
|
namespace duckdb {
|
14
17
|
|
15
|
-
|
18
|
+
//! Node4 holds up to four ARTNode children sorted by their key byte
|
19
|
+
class Node4 {
|
16
20
|
public:
|
17
|
-
//!
|
18
|
-
|
21
|
+
//! Number of non-null children
|
22
|
+
uint8_t count;
|
23
|
+
//! Compressed path (prefix)
|
24
|
+
Prefix prefix;
|
19
25
|
//! Array containing all partial key bytes
|
20
|
-
uint8_t key[
|
21
|
-
//! ART pointers to the child nodes
|
22
|
-
|
26
|
+
uint8_t key[Node::NODE_4_CAPACITY];
|
27
|
+
//! ART node pointers to the child nodes
|
28
|
+
Node children[Node::NODE_4_CAPACITY];
|
23
29
|
|
24
30
|
public:
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
idx_t GetChildGreaterEqual(uint8_t k, bool &equal) override;
|
33
|
-
//! Get the position of the minimum element in the node
|
34
|
-
idx_t GetMin() override;
|
35
|
-
//! Get the next position in the node, or DConstants::INVALID_INDEX if there is no next position
|
36
|
-
idx_t GetNextPos(idx_t pos) override;
|
37
|
-
//! Get the next position in the node, or DConstants::INVALID_INDEX if there is no next position
|
38
|
-
idx_t GetNextPosAndByte(idx_t pos, uint8_t &byte) override;
|
39
|
-
//! Get Node4 child
|
40
|
-
Node *GetChild(ART &art, idx_t pos) override;
|
41
|
-
//! Replace child pointer
|
42
|
-
void ReplaceChildPointer(idx_t pos, Node *node) override;
|
43
|
-
//! Returns whether the child at pos is in memory
|
44
|
-
bool ChildIsInMemory(idx_t pos) override;
|
45
|
-
|
46
|
-
//! Insert a new child node at key_byte into the Node4
|
47
|
-
static void InsertChild(ART &art, Node *&node, uint8_t key_byte, Node *new_child);
|
48
|
-
//! Erase the child at pos and (if necessary) merge with last child
|
49
|
-
static void EraseChild(ART &art, Node *&node, idx_t pos);
|
50
|
-
|
51
|
-
//! Returns the size (maximum capacity) of the Node4
|
52
|
-
static constexpr idx_t GetSize() {
|
53
|
-
return 4;
|
31
|
+
//! Get a new Node4 node, might cause a new buffer allocation, and initialize it
|
32
|
+
static Node4 &New(ART &art, Node &node);
|
33
|
+
//! Free the node (and its subtree)
|
34
|
+
static void Free(ART &art, Node &node);
|
35
|
+
//! Get a reference to the node
|
36
|
+
static inline Node4 &Get(const ART &art, const Node ptr) {
|
37
|
+
return *Node::GetAllocator(art, NType::NODE_4).Get<Node4>(ptr);
|
54
38
|
}
|
39
|
+
//! Initializes all fields of the node while shrinking a Node16 to a Node4
|
40
|
+
static Node4 &ShrinkNode16(ART &art, Node &node4, Node &node16);
|
41
|
+
|
42
|
+
//! Initializes a merge by incrementing the buffer IDs of the node
|
43
|
+
void InitializeMerge(ART &art, const ARTFlags &flags);
|
44
|
+
|
45
|
+
//! Insert a child node at byte
|
46
|
+
static void InsertChild(ART &art, Node &node, const uint8_t byte, const Node child);
|
47
|
+
//! Delete the child node at the respective byte
|
48
|
+
static void DeleteChild(ART &art, Node &node, const uint8_t byte);
|
49
|
+
|
50
|
+
//! Replace the child node at the respective byte
|
51
|
+
void ReplaceChild(const uint8_t byte, const Node child);
|
52
|
+
|
53
|
+
//! Get the child for the respective byte in the node
|
54
|
+
optional_ptr<Node> GetChild(const uint8_t byte);
|
55
|
+
//! Get the first child that is greater or equal to the specific byte
|
56
|
+
optional_ptr<Node> GetNextChild(uint8_t &byte);
|
57
|
+
|
58
|
+
//! Serialize an ART node
|
59
|
+
BlockPointer Serialize(ART &art, MetaBlockWriter &writer);
|
60
|
+
//! Deserialize this node
|
61
|
+
void Deserialize(ART &art, MetaBlockReader &reader);
|
62
|
+
|
63
|
+
//! Vacuum the children of the node
|
64
|
+
void Vacuum(ART &art, const ARTFlags &flags);
|
55
65
|
};
|
56
66
|
} // namespace duckdb
|
@@ -7,49 +7,71 @@
|
|
7
7
|
//===----------------------------------------------------------------------===//
|
8
8
|
|
9
9
|
#pragma once
|
10
|
+
|
11
|
+
#include "duckdb/execution/index/art/art.hpp"
|
12
|
+
#include "duckdb/execution/index/art/fixed_size_allocator.hpp"
|
10
13
|
#include "duckdb/execution/index/art/node.hpp"
|
11
|
-
#include "duckdb/execution/index/art/
|
14
|
+
#include "duckdb/execution/index/art/prefix.hpp"
|
12
15
|
|
13
16
|
namespace duckdb {
|
14
17
|
|
15
|
-
|
18
|
+
//! Node48 holds up to 48 ARTNode children. It contains a child_index array which can be directly indexed by the key
|
19
|
+
//! byte, and which contains the position of the child node in the children array
|
20
|
+
class Node48 {
|
16
21
|
public:
|
17
|
-
//!
|
18
|
-
|
22
|
+
//! Number of non-null children
|
23
|
+
uint8_t count;
|
24
|
+
//! Compressed path (prefix)
|
25
|
+
Prefix prefix;
|
19
26
|
//! Array containing all possible partial key bytes, those not set have an EMPTY_MARKER
|
20
|
-
uint8_t child_index[
|
21
|
-
//! ART pointers to the child nodes
|
22
|
-
|
27
|
+
uint8_t child_index[Node::NODE_256_CAPACITY];
|
28
|
+
//! ART node pointers to the child nodes
|
29
|
+
Node children[Node::NODE_48_CAPACITY];
|
23
30
|
|
24
31
|
public:
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
//!
|
34
|
-
|
35
|
-
//!
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
//!
|
42
|
-
void
|
43
|
-
//!
|
44
|
-
|
45
|
-
|
46
|
-
//!
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
//! Returns the size (maximum capacity) of the Node48
|
51
|
-
static constexpr idx_t GetSize() {
|
52
|
-
return 48;
|
32
|
+
//! Get a new Node48 node, might cause a new buffer allocation, and initialize it
|
33
|
+
static Node48 &New(ART &art, Node &node);
|
34
|
+
//! Free the node (and its subtree)
|
35
|
+
static void Free(ART &art, Node &node);
|
36
|
+
//! Get a reference to the node
|
37
|
+
static inline Node48 &Get(const ART &art, const Node ptr) {
|
38
|
+
return *Node::GetAllocator(art, NType::NODE_48).Get<Node48>(ptr);
|
39
|
+
}
|
40
|
+
//! Initializes all the fields of the node while growing a Node16 to a Node48
|
41
|
+
static Node48 &GrowNode16(ART &art, Node &node48, Node &node16);
|
42
|
+
//! Initializes all fields of the node while shrinking a Node256 to a Node48
|
43
|
+
static Node48 &ShrinkNode256(ART &art, Node &node48, Node &node256);
|
44
|
+
|
45
|
+
//! Initializes a merge by incrementing the buffer IDs of the node
|
46
|
+
void InitializeMerge(ART &art, const ARTFlags &flags);
|
47
|
+
|
48
|
+
//! Insert a child node at byte
|
49
|
+
static void InsertChild(ART &art, Node &node, const uint8_t byte, const Node child);
|
50
|
+
//! Delete the child node at the respective byte
|
51
|
+
static void DeleteChild(ART &art, Node &node, const uint8_t byte);
|
52
|
+
|
53
|
+
//! Replace the child node at the respective byte
|
54
|
+
inline void ReplaceChild(const uint8_t byte, const Node child) {
|
55
|
+
D_ASSERT(child_index[byte] != Node::EMPTY_MARKER);
|
56
|
+
children[child_index[byte]] = child;
|
53
57
|
}
|
58
|
+
|
59
|
+
//! Get the child for the respective byte in the node
|
60
|
+
inline optional_ptr<Node> GetChild(const uint8_t byte) {
|
61
|
+
if (child_index[byte] != Node::EMPTY_MARKER) {
|
62
|
+
return &children[child_index[byte]];
|
63
|
+
}
|
64
|
+
return nullptr;
|
65
|
+
}
|
66
|
+
//! Get the first child that is greater or equal to the specific byte
|
67
|
+
optional_ptr<Node> GetNextChild(uint8_t &byte);
|
68
|
+
|
69
|
+
//! Serialize an ART node
|
70
|
+
BlockPointer Serialize(ART &art, MetaBlockWriter &writer);
|
71
|
+
//! Deserialize this node
|
72
|
+
void Deserialize(ART &art, MetaBlockReader &reader);
|
73
|
+
|
74
|
+
//! Vacuum the children of the node
|
75
|
+
void Vacuum(ART &art, const ARTFlags &flags);
|
54
76
|
};
|
55
77
|
} // namespace duckdb
|
@@ -7,71 +7,78 @@
|
|
7
7
|
//===----------------------------------------------------------------------===//
|
8
8
|
#pragma once
|
9
9
|
|
10
|
-
#include "duckdb/execution/index/art/
|
11
|
-
#include "duckdb/storage/meta_block_reader.hpp"
|
12
|
-
#include "duckdb/storage/meta_block_writer.hpp"
|
10
|
+
#include "duckdb/execution/index/art/node.hpp"
|
13
11
|
|
14
12
|
namespace duckdb {
|
15
|
-
class ART;
|
16
13
|
|
17
|
-
|
18
|
-
|
14
|
+
// classes
|
15
|
+
class ARTKey;
|
16
|
+
class PrefixSegment;
|
19
17
|
|
18
|
+
class Prefix {
|
20
19
|
public:
|
21
|
-
//!
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
//! Number of bytes in this prefix
|
21
|
+
uint32_t count;
|
22
|
+
union {
|
23
|
+
//! Pointer to the head of the list of prefix segments
|
24
|
+
Node ptr;
|
25
|
+
//! Inlined prefix bytes
|
26
|
+
uint8_t inlined[Node::PREFIX_INLINE_BYTES];
|
27
|
+
} data;
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
public:
|
30
|
+
//! Delete all prefix segments (if not inlined) and reset all fields
|
31
|
+
void Free(ART &art);
|
32
|
+
//! Initializes all the fields of an empty prefix
|
33
|
+
inline void Initialize() {
|
34
|
+
count = 0;
|
32
35
|
}
|
33
|
-
//!
|
34
|
-
|
35
|
-
//!
|
36
|
-
|
37
|
-
//! Returns a const pointer to the prefix data
|
38
|
-
const uint8_t *GetPrefixData() const;
|
36
|
+
//! Initialize a prefix from an ART key
|
37
|
+
void Initialize(ART &art, const ARTKey &key, const uint32_t depth, const uint32_t count_p);
|
38
|
+
//! Initialize a prefix from another prefix up to count
|
39
|
+
void Initialize(ART &art, const Prefix &other, const uint32_t count_p);
|
39
40
|
|
40
|
-
//!
|
41
|
-
|
42
|
-
//! Assign operator
|
43
|
-
Prefix &operator=(const Prefix &src);
|
44
|
-
//! Move operator
|
45
|
-
Prefix &operator=(Prefix &&other) noexcept;
|
41
|
+
//! Initializes a merge by incrementing the buffer IDs of the prefix segments
|
42
|
+
void InitializeMerge(ART &art, const idx_t buffer_count);
|
46
43
|
|
44
|
+
//! Move a prefix into this prefix
|
45
|
+
inline void Move(Prefix &other) {
|
46
|
+
count = other.count;
|
47
|
+
data = other.data;
|
48
|
+
other.Initialize();
|
49
|
+
}
|
50
|
+
//! Append a prefix to this prefix
|
51
|
+
void Append(ART &art, const Prefix &other);
|
47
52
|
//! Concatenate prefix with a partial key byte and another prefix: other.prefix + byte + this->prefix
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
uint8_t Reduce(ART &art, uint32_t n);
|
52
|
-
|
53
|
-
//! Serializes the prefix
|
54
|
-
void Serialize(duckdb::MetaBlockWriter &writer);
|
55
|
-
//! Deserializes the prefix
|
56
|
-
void Deserialize(duckdb::MetaBlockReader &reader);
|
53
|
+
void Concatenate(ART &art, const uint8_t byte, const Prefix &other);
|
54
|
+
//! Removes the first n bytes, and returns the new first byte
|
55
|
+
uint8_t Reduce(ART &art, const idx_t reduce_count);
|
57
56
|
|
57
|
+
//! Get the byte at position
|
58
|
+
uint8_t GetByte(const ART &art, const idx_t position) const;
|
58
59
|
//! Compare the key with the prefix of the node, return the position where they mismatch
|
59
|
-
uint32_t KeyMismatchPosition(
|
60
|
-
//! Compare this prefix to another prefix, return the position where they mismatch, or
|
61
|
-
uint32_t MismatchPosition(Prefix &other);
|
60
|
+
uint32_t KeyMismatchPosition(const ART &art, const ARTKey &key, const uint32_t depth) const;
|
61
|
+
//! Compare this prefix to another prefix, return the position where they mismatch, or count otherwise
|
62
|
+
uint32_t MismatchPosition(const ART &art, const Prefix &other) const;
|
62
63
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
64
|
+
//! Serialize this prefix
|
65
|
+
void Serialize(const ART &art, MetaBlockWriter &writer) const;
|
66
|
+
//! Deserialize this prefix
|
67
|
+
void Deserialize(ART &art, MetaBlockReader &reader);
|
68
|
+
|
69
|
+
//! Vacuum the prefix segments of a prefix, if not inlined
|
70
|
+
void Vacuum(ART &art);
|
69
71
|
|
70
72
|
private:
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
73
|
+
//! Returns whether this prefix is inlined
|
74
|
+
inline bool IsInlined() const {
|
75
|
+
return count <= Node::PREFIX_INLINE_BYTES;
|
76
|
+
}
|
77
|
+
//! Moves all inlined bytes onto a prefix segment, does not change the size
|
78
|
+
//! so this will be an (temporarily) invalid prefix
|
79
|
+
PrefixSegment &MoveInlinedToSegment(ART &art);
|
80
|
+
//! Inlines up to eight bytes on the first prefix segment
|
81
|
+
void MoveSegmentToInlined(ART &art);
|
75
82
|
};
|
76
83
|
|
77
84
|
} // namespace duckdb
|
@@ -0,0 +1,40 @@
|
|
1
|
+
//===----------------------------------------------------------------------===//
|
2
|
+
// DuckDB
|
3
|
+
//
|
4
|
+
// duckdb/execution/index/art/prefix_segment.hpp
|
5
|
+
//
|
6
|
+
//
|
7
|
+
//===----------------------------------------------------------------------===//
|
8
|
+
#pragma once
|
9
|
+
|
10
|
+
#include "duckdb/execution/index/art/art.hpp"
|
11
|
+
#include "duckdb/execution/index/art/node.hpp"
|
12
|
+
|
13
|
+
namespace duckdb {
|
14
|
+
|
15
|
+
class PrefixSegment {
|
16
|
+
public:
|
17
|
+
//! Constructor of an empty prefix segment containing bytes.
|
18
|
+
//! NOTE: only use this constructor for temporary prefix segments
|
19
|
+
PrefixSegment() {};
|
20
|
+
|
21
|
+
//! The prefix bytes stored in this segment
|
22
|
+
uint8_t bytes[Node::PREFIX_SEGMENT_SIZE];
|
23
|
+
//! The position of the next segment, if the prefix exceeds this segment
|
24
|
+
Node next;
|
25
|
+
|
26
|
+
public:
|
27
|
+
//! Get a new prefix segment node, might cause a new buffer allocation, and initialize it
|
28
|
+
static PrefixSegment &New(ART &art, Node &node);
|
29
|
+
//! Get a reference to the prefix segment
|
30
|
+
static inline PrefixSegment &Get(const ART &art, const Node ptr) {
|
31
|
+
return *Node::GetAllocator(art, NType::PREFIX_SEGMENT).Get<PrefixSegment>(ptr);
|
32
|
+
}
|
33
|
+
|
34
|
+
//! Append a byte to the current segment, or create a new segment containing that byte
|
35
|
+
PrefixSegment &Append(ART &art, uint32_t &count, const uint8_t byte);
|
36
|
+
//! Get the tail of a list of segments
|
37
|
+
PrefixSegment &GetTail(const ART &art);
|
38
|
+
};
|
39
|
+
|
40
|
+
} // namespace duckdb
|
@@ -7,45 +7,52 @@
|
|
7
7
|
//===----------------------------------------------------------------------===//
|
8
8
|
#pragma once
|
9
9
|
|
10
|
-
#include "duckdb/
|
10
|
+
#include "duckdb/common/constants.hpp"
|
11
11
|
|
12
12
|
namespace duckdb {
|
13
13
|
|
14
|
-
|
15
|
-
class
|
14
|
+
// classes
|
15
|
+
class MetaBlockReader;
|
16
16
|
|
17
|
-
//
|
18
|
-
|
17
|
+
// structs
|
18
|
+
struct BlockPointer;
|
19
|
+
|
20
|
+
//! SwizzleablePointer provides functions on a (possibly) swizzled pointer. If the swizzle flag is set, then the
|
21
|
+
//! pointer points to a storage address (and has no type), otherwise the pointer has a type and stores
|
22
|
+
//! other information (e.g., a buffer location)
|
19
23
|
class SwizzleablePointer {
|
20
24
|
public:
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
//! Constructs an empty SwizzleablePointer
|
26
|
+
SwizzleablePointer() : swizzle_flag(0), type(0), offset(0), buffer_id(0) {};
|
27
|
+
//! Constructs a swizzled pointer from a buffer ID and an offset
|
28
|
+
explicit SwizzleablePointer(MetaBlockReader &reader);
|
29
|
+
//! Constructs a non-swizzled pointer from a buffer ID and an offset
|
30
|
+
SwizzleablePointer(uint32_t offset, uint32_t buffer_id)
|
31
|
+
: swizzle_flag(0), type(0), offset(offset), buffer_id(buffer_id) {};
|
32
|
+
|
33
|
+
//! The swizzle flag, set if swizzled, not set otherwise
|
34
|
+
uint8_t swizzle_flag : 1;
|
35
|
+
//! The type of the pointer, zero if not set
|
36
|
+
uint8_t type : 7;
|
37
|
+
//! The offset of a memory location
|
38
|
+
uint32_t offset : 24;
|
39
|
+
//! The buffer ID of a memory location
|
40
|
+
uint32_t buffer_id : 32;
|
29
41
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
42
|
+
public:
|
43
|
+
//! Checks if the pointer is swizzled
|
44
|
+
inline bool IsSwizzled() const {
|
45
|
+
return swizzle_flag;
|
46
|
+
}
|
47
|
+
//! Returns true, if neither the swizzle flag nor the type is set, and false otherwise
|
48
|
+
inline bool IsSet() const {
|
49
|
+
return swizzle_flag || type;
|
50
|
+
}
|
51
|
+
//! Reset the pointer
|
52
|
+
inline void Reset() {
|
53
|
+
swizzle_flag = 0;
|
54
|
+
type = 0;
|
37
55
|
}
|
38
|
-
|
39
|
-
//! Deletes the underlying object (if necessary) and set the pointer to nullptr
|
40
|
-
void Reset();
|
41
|
-
|
42
|
-
private:
|
43
|
-
uint64_t pointer;
|
44
|
-
|
45
|
-
friend bool operator!=(const SwizzleablePointer &s_ptr, const uint64_t &ptr);
|
46
|
-
|
47
|
-
//! Extracts the block info from swizzled pointer
|
48
|
-
BlockPointer GetSwizzledBlockInfo();
|
49
56
|
};
|
50
57
|
|
51
58
|
} // namespace duckdb
|
@@ -16,7 +16,8 @@ namespace duckdb {
|
|
16
16
|
|
17
17
|
struct CSVFileHandle {
|
18
18
|
public:
|
19
|
-
explicit CSVFileHandle(unique_ptr<FileHandle> file_handle_p
|
19
|
+
explicit CSVFileHandle(unique_ptr<FileHandle> file_handle_p, bool enable_reset = true)
|
20
|
+
: file_handle(std::move(file_handle_p)), reset_enabled(enable_reset) {
|
20
21
|
can_seek = file_handle->CanSeek();
|
21
22
|
plain_file_source = file_handle->OnDiskFile() && can_seek;
|
22
23
|
file_size = file_handle->GetFileSize();
|
@@ -62,6 +62,8 @@ struct BufferedCSVReaderOptions {
|
|
62
62
|
//! Whether file is compressed or not, and if so which compression type
|
63
63
|
//! AUTO_DETECT (default; infer from file extension)
|
64
64
|
FileCompressionType compression = FileCompressionType::AUTO_DETECT;
|
65
|
+
//! Option to convert quoted values to NULL values
|
66
|
+
bool allow_quoted_nulls = true;
|
65
67
|
|
66
68
|
//===--------------------------------------------------------------------===//
|
67
69
|
// CSVAutoOptions
|
@@ -72,6 +72,9 @@ public:
|
|
72
72
|
//! CTEs
|
73
73
|
CommonTableExpressionMap cte_map;
|
74
74
|
|
75
|
+
//! Whether or not this a DEFAULT VALUES
|
76
|
+
bool default_values = false;
|
77
|
+
|
75
78
|
protected:
|
76
79
|
InsertStatement(const InsertStatement &other);
|
77
80
|
|
@@ -82,7 +85,7 @@ public:
|
|
82
85
|
|
83
86
|
//! If the INSERT statement is inserted DIRECTLY from a values list (i.e. INSERT INTO tbl VALUES (...)) this returns
|
84
87
|
//! the expression list Otherwise, this returns NULL
|
85
|
-
ExpressionListRef
|
88
|
+
optional_ptr<ExpressionListRef> GetValuesList() const;
|
86
89
|
};
|
87
90
|
|
88
91
|
} // namespace duckdb
|
@@ -312,7 +312,8 @@ private:
|
|
312
312
|
void TransformExpressionList(duckdb_libpgquery::PGList &list, vector<unique_ptr<ParsedExpression>> &result);
|
313
313
|
|
314
314
|
//! Transform a Postgres PARTITION BY/ORDER BY specification into lists of expressions
|
315
|
-
void TransformWindowDef(duckdb_libpgquery::PGWindowDef *window_spec, WindowExpression *expr
|
315
|
+
void TransformWindowDef(duckdb_libpgquery::PGWindowDef *window_spec, WindowExpression *expr,
|
316
|
+
const char *window_name = nullptr);
|
316
317
|
//! Transform a Postgres window frame specification into frame expressions
|
317
318
|
void TransformWindowFrame(duckdb_libpgquery::PGWindowDef *window_spec, WindowExpression *expr);
|
318
319
|
|
@@ -58,15 +58,10 @@ public:
|
|
58
58
|
//! Construct a managed buffer.
|
59
59
|
virtual unique_ptr<FileBuffer> ConstructManagedBuffer(idx_t size, unique_ptr<FileBuffer> &&source,
|
60
60
|
FileBufferType type = FileBufferType::MANAGED_BUFFER);
|
61
|
-
//! Increases the currently allocated memory, but the actual allocation does not go through the buffer manager
|
62
|
-
virtual void IncreaseUsedMemory(idx_t size, bool unsafe = false) = 0;
|
63
|
-
//! Decrease the currently allocated memory, but the actual deallocation does not go through the buffer manager
|
64
|
-
virtual void DecreaseUsedMemory(idx_t size) = 0;
|
65
61
|
//! Get the underlying buffer pool responsible for managing the buffers
|
66
62
|
virtual BufferPool &GetBufferPool();
|
67
63
|
|
68
64
|
// Static methods
|
69
|
-
|
70
65
|
DUCKDB_API static BufferManager &GetBufferManager(DatabaseInstance &db);
|
71
66
|
DUCKDB_API static BufferManager &GetBufferManager(ClientContext &context);
|
72
67
|
DUCKDB_API static BufferManager &GetBufferManager(AttachedDatabase &db);
|