uqa_storage_sqlite/mvcc/native/
family.rs1use super::layout::{NativeRecordLayout, LAYOUTS};
10
11#[derive(Clone, Copy, Debug, PartialEq, Eq)]
12#[repr(u16)]
13pub enum NativeRecordFamily {
14 Analyzers = 1,
15 BtreeIndexEntries = 2,
16 BtreeIndexRepairs = 3,
17 BtreeIndexes = 4,
18 CacheRevisions = 5,
19 CatalogIndexes = 6,
20 ColumnStats = 7,
21 DocLengths = 8,
22 DocumentBlobs = 9,
23 Documents = 10,
24 FieldStats = 11,
25 ForeignServers = 12,
26 ForeignTables = 13,
27 GraphEdges = 14,
28 GraphMembership = 15,
29 GraphPathIndexState = 16,
30 GraphPathPairs = 17,
31 GraphVertices = 18,
32 HNSWEdges = 19,
33 HNSWIndexes = 20,
34 HNSWNodes = 21,
35 IVFAssignments = 22,
36 IVFCentroids = 23,
37 IVFIndexes = 24,
38 Metadata = 25,
39 Models = 26,
40 NamedGraphs = 27,
41 OccurrenceClusters = 28,
42 OccurrenceDocuments = 29,
43 OccurrenceFields = 30,
44 OccurrenceFormats = 31,
45 OccurrenceLengths = 32,
46 PathIndexes = 33,
47 PostingClusters = 34,
48 PostingDocuments = 35,
49 Relations = 36,
50 Schemas = 37,
51 ScoringParams = 38,
52 Sequences = 39,
53 TableFieldAnalyzers = 40,
54 Tables = 41,
55 Vectors = 42,
56 Views = 43,
57 TableOwners = 44,
58 GraphLookups = 45,
59 OccurrenceSkips = 46,
60 OccurrenceBlockMax = 47,
61 OccurrenceGuards = 48,
62 VectorGuards = 49,
63 StandaloneGraphScopes = 50,
64 StandaloneGraphMetadata = 51,
65 StandaloneGraphCatalog = 52,
66 StandaloneGraphVertices = 53,
67 StandaloneGraphEdges = 54,
68 StandaloneGraphMembership = 55,
69 StandaloneGraphLookups = 56,
70 DiskANNRecords = 57,
71 VectorOrigins = 58,
72 VectorChanges = 59,
73 VectorPopulations = 60,
74 VectorPopulationWitnesses = 61,
75}
76
77impl NativeRecordFamily {
78 pub const fn id(self) -> u16 {
79 self as u16
80 }
81
82 pub fn from_id(id: u16) -> Option<Self> {
83 if id == Self::VectorPopulationWitnesses.id() {
84 return Some(Self::VectorPopulationWitnesses);
85 }
86 if id == Self::VectorPopulations.id() {
87 return Some(Self::VectorPopulations);
88 }
89 if id == Self::VectorChanges.id() {
90 return Some(Self::VectorChanges);
91 }
92 if id == Self::VectorOrigins.id() {
93 return Some(Self::VectorOrigins);
94 }
95 if id == Self::DiskANNRecords.id() {
96 return Some(Self::DiskANNRecords);
97 }
98 usize::from(id)
99 .checked_sub(1)
100 .and_then(|index| {
101 LAYOUTS.get(index).or_else(|| {
102 index
103 .checked_sub(LAYOUTS.len())
104 .and_then(|index| super::standalone_graph::schema::LAYOUTS.get(index))
105 })
106 })
107 .map(|layout| layout.family)
108 }
109
110 pub fn layout(self) -> &'static NativeRecordLayout {
111 if self == Self::VectorPopulationWitnesses {
112 return &super::populations::schema::WITNESS;
113 }
114 if self == Self::VectorPopulations {
115 return &super::populations::schema::HEADER;
116 }
117 if self == Self::VectorChanges {
118 return &super::diskann::CHANGES_LAYOUT;
119 }
120 if self == Self::VectorOrigins {
121 return &super::diskann::ORIGINS_LAYOUT;
122 }
123 if self == Self::DiskANNRecords {
124 return &super::diskann::LAYOUT;
125 }
126 let index = usize::from(self.id()) - 1;
127 if index < LAYOUTS.len() {
128 &LAYOUTS[index]
129 } else {
130 &super::standalone_graph::schema::LAYOUTS[index - LAYOUTS.len()]
131 }
132 }
133
134 pub(crate) fn is_standalone_graph(self) -> bool {
135 (Self::StandaloneGraphScopes.id()..=Self::StandaloneGraphLookups.id()).contains(&self.id())
136 }
137
138 pub fn all() -> impl ExactSizeIterator<Item = Self> {
139 (1..=Self::VectorPopulationWitnesses.id())
140 .map(|id| Self::from_id(id).expect("assigned native family"))
141 }
142}