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, type: 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 |
41 | |