1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/execution/index/art/leaf_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
13namespace duckdb {
14
15class LeafSegment {
16public:
17 //! The row IDs stored in this segment
18 row_t row_ids[Node::LEAF_SEGMENT_SIZE];
19 //! The pointer of the next segment, if the row IDs exceeds this segment
20 Node next;
21
22public:
23 //! Get a new leaf segment node, might cause a new buffer allocation, and initialize it
24 static LeafSegment &New(ART &art, Node &node);
25 //! Get a reference to the leaf segment
26 static inline LeafSegment &Get(const ART &art, const Node ptr) {
27 return *Node::GetAllocator(art, type: NType::LEAF_SEGMENT).Get<LeafSegment>(ptr);
28 }
29 //! Free the leaf segment and any subsequent ones
30 static void Free(ART &art, Node &node);
31
32 //! Append a row ID to the current segment, or create a new segment containing that row ID
33 LeafSegment &Append(ART &art, uint32_t &count, const row_t row_id);
34 //! Get the tail of a list of segments
35 LeafSegment &GetTail(const ART &art);
36};
37
38} // namespace duckdb
39