Skip to main content

vortex_layout/flatbuffers/generated/
layout.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3//
4// Regenerate with `cargo run -p xtask -- generate-flatbuffers`.
5
6// automatically generated by the FlatBuffers compiler, do not modify
7// @generated
8extern crate alloc;
9
10
11pub enum LayoutOffset {}
12#[derive(Copy, Clone, PartialEq)]
13
14/// A `Layout` is a recursive data structure describing the physical layout of Vortex arrays in random access storage.
15/// As a starting, concrete example, the first three Layout encodings are defined as:
16///
17/// 1. encoding == 1, `Flat` -> one buffer, zero child Layouts
18/// 2. encoding == 2, `Chunked` -> zero buffers, one or more child Layouts (used for chunks of rows)
19/// 3. encoding == 3, `Columnar` -> zero buffers, one or more child Layouts (used for columns of structs)
20///
21/// The `row_count` represents the number of rows represented by this Layout. This is very useful for
22/// pruning the Layout tree based on row filters.
23///
24/// The `metadata` field is fully opaque at this layer, and allows the Layout implementation corresponding to
25/// `encoding` to embed additional information that may be useful for the reader. For example, the `ChunkedLayout`
26/// uses the first byte of the `metadata` array as a boolean to indicate whether the first child Layout represents
27/// the statistics table for the other chunks. 
28pub struct Layout<'a> {
29  pub _tab: ::flatbuffers::Table<'a>,
30}
31
32impl<'a> ::flatbuffers::Follow<'a> for Layout<'a> {
33  type Inner = Layout<'a>;
34  #[inline]
35  unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
36    Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
37  }
38}
39
40impl<'a> Layout<'a> {
41  pub const VT_ENCODING: ::flatbuffers::VOffsetT = 4;
42  pub const VT_ROW_COUNT: ::flatbuffers::VOffsetT = 6;
43  pub const VT_METADATA: ::flatbuffers::VOffsetT = 8;
44  pub const VT_CHILDREN: ::flatbuffers::VOffsetT = 10;
45  pub const VT_SEGMENTS: ::flatbuffers::VOffsetT = 12;
46
47  #[inline]
48  pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
49    Layout { _tab: table }
50  }
51  #[allow(unused_mut)]
52  pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
53    _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
54    args: &'args LayoutArgs<'args>
55  ) -> ::flatbuffers::WIPOffset<Layout<'bldr>> {
56    let mut builder = LayoutBuilder::new(_fbb);
57    builder.add_row_count(args.row_count);
58    if let Some(x) = args.segments { builder.add_segments(x); }
59    if let Some(x) = args.children { builder.add_children(x); }
60    if let Some(x) = args.metadata { builder.add_metadata(x); }
61    builder.add_encoding(args.encoding);
62    builder.finish()
63  }
64
65
66  /// The ID of the encoding used for this Layout.
67  #[inline]
68  pub fn encoding(&self) -> u16 {
69    // Safety:
70    // Created from valid Table for this object
71    // which contains a valid value in this slot
72    unsafe { self._tab.get::<u16>(Layout::VT_ENCODING, Some(0)).unwrap()}
73  }
74  /// The number of rows of data represented by this Layout.
75  #[inline]
76  pub fn row_count(&self) -> u64 {
77    // Safety:
78    // Created from valid Table for this object
79    // which contains a valid value in this slot
80    unsafe { self._tab.get::<u64>(Layout::VT_ROW_COUNT, Some(0)).unwrap()}
81  }
82  /// Any additional metadata this layout needs to interpret its children.
83  /// This does not include data-specific metadata, which the layout should store in a segment.
84  #[inline]
85  pub fn metadata(&self) -> Option<::flatbuffers::Vector<'a, u8>> {
86    // Safety:
87    // Created from valid Table for this object
88    // which contains a valid value in this slot
89    unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Layout::VT_METADATA, None)}
90  }
91  /// The children of this Layout.
92  #[inline]
93  pub fn children(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Layout<'a>>>> {
94    // Safety:
95    // Created from valid Table for this object
96    // which contains a valid value in this slot
97    unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Layout>>>>(Layout::VT_CHILDREN, None)}
98  }
99  /// Identifiers for each `SegmentSpec` of data required by this layout.
100  #[inline]
101  pub fn segments(&self) -> Option<::flatbuffers::Vector<'a, u32>> {
102    // Safety:
103    // Created from valid Table for this object
104    // which contains a valid value in this slot
105    unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u32>>>(Layout::VT_SEGMENTS, None)}
106  }
107}
108
109impl ::flatbuffers::Verifiable for Layout<'_> {
110  #[inline]
111  fn run_verifier(
112    v: &mut ::flatbuffers::Verifier, pos: usize
113  ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
114    v.visit_table(pos)?
115     .visit_field::<u16>("encoding", Self::VT_ENCODING, false)?
116     .visit_field::<u64>("row_count", Self::VT_ROW_COUNT, false)?
117     .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("metadata", Self::VT_METADATA, false)?
118     .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<Layout>>>>("children", Self::VT_CHILDREN, false)?
119     .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u32>>>("segments", Self::VT_SEGMENTS, false)?
120     .finish();
121    Ok(())
122  }
123}
124pub struct LayoutArgs<'a> {
125    pub encoding: u16,
126    pub row_count: u64,
127    pub metadata: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>,
128    pub children: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Layout<'a>>>>>,
129    pub segments: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u32>>>,
130}
131impl<'a> Default for LayoutArgs<'a> {
132  #[inline]
133  fn default() -> Self {
134    LayoutArgs {
135      encoding: 0,
136      row_count: 0,
137      metadata: None,
138      children: None,
139      segments: None,
140    }
141  }
142}
143
144pub struct LayoutBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
145  fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
146  start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
147}
148impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> LayoutBuilder<'a, 'b, A> {
149  #[inline]
150  pub fn add_encoding(&mut self, encoding: u16) {
151    self.fbb_.push_slot::<u16>(Layout::VT_ENCODING, encoding, 0);
152  }
153  #[inline]
154  pub fn add_row_count(&mut self, row_count: u64) {
155    self.fbb_.push_slot::<u64>(Layout::VT_ROW_COUNT, row_count, 0);
156  }
157  #[inline]
158  pub fn add_metadata(&mut self, metadata: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) {
159    self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Layout::VT_METADATA, metadata);
160  }
161  #[inline]
162  pub fn add_children(&mut self, children: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Layout<'b >>>>) {
163    self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Layout::VT_CHILDREN, children);
164  }
165  #[inline]
166  pub fn add_segments(&mut self, segments: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u32>>) {
167    self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Layout::VT_SEGMENTS, segments);
168  }
169  #[inline]
170  pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> LayoutBuilder<'a, 'b, A> {
171    let start = _fbb.start_table();
172    LayoutBuilder {
173      fbb_: _fbb,
174      start_: start,
175    }
176  }
177  #[inline]
178  pub fn finish(self) -> ::flatbuffers::WIPOffset<Layout<'a>> {
179    let o = self.fbb_.end_table(self.start_);
180    ::flatbuffers::WIPOffset::new(o.value())
181  }
182}
183
184impl ::core::fmt::Debug for Layout<'_> {
185  fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
186    let mut ds = f.debug_struct("Layout");
187      ds.field("encoding", &self.encoding());
188      ds.field("row_count", &self.row_count());
189      ds.field("metadata", &self.metadata());
190      ds.field("children", &self.children());
191      ds.field("segments", &self.segments());
192      ds.finish()
193  }
194}
195#[inline]
196/// Verifies that a buffer of bytes contains a `Layout`
197/// and returns it.
198/// Note that verification is still experimental and may not
199/// catch every error, or be maximally performant. For the
200/// previous, unchecked, behavior use
201/// `root_as_layout_unchecked`.
202pub fn root_as_layout(buf: &[u8]) -> Result<Layout<'_>, ::flatbuffers::InvalidFlatbuffer> {
203  ::flatbuffers::root::<Layout>(buf)
204}
205#[inline]
206/// Verifies that a buffer of bytes contains a size prefixed
207/// `Layout` and returns it.
208/// Note that verification is still experimental and may not
209/// catch every error, or be maximally performant. For the
210/// previous, unchecked, behavior use
211/// `size_prefixed_root_as_layout_unchecked`.
212pub fn size_prefixed_root_as_layout(buf: &[u8]) -> Result<Layout<'_>, ::flatbuffers::InvalidFlatbuffer> {
213  ::flatbuffers::size_prefixed_root::<Layout>(buf)
214}
215#[inline]
216/// Verifies, with the given options, that a buffer of bytes
217/// contains a `Layout` and returns it.
218/// Note that verification is still experimental and may not
219/// catch every error, or be maximally performant. For the
220/// previous, unchecked, behavior use
221/// `root_as_layout_unchecked`.
222pub fn root_as_layout_with_opts<'b, 'o>(
223  opts: &'o ::flatbuffers::VerifierOptions,
224  buf: &'b [u8],
225) -> Result<Layout<'b>, ::flatbuffers::InvalidFlatbuffer> {
226  ::flatbuffers::root_with_opts::<Layout<'b>>(opts, buf)
227}
228#[inline]
229/// Verifies, with the given verifier options, that a buffer of
230/// bytes contains a size prefixed `Layout` and returns
231/// it. Note that verification is still experimental and may not
232/// catch every error, or be maximally performant. For the
233/// previous, unchecked, behavior use
234/// `root_as_layout_unchecked`.
235pub fn size_prefixed_root_as_layout_with_opts<'b, 'o>(
236  opts: &'o ::flatbuffers::VerifierOptions,
237  buf: &'b [u8],
238) -> Result<Layout<'b>, ::flatbuffers::InvalidFlatbuffer> {
239  ::flatbuffers::size_prefixed_root_with_opts::<Layout<'b>>(opts, buf)
240}
241#[inline]
242/// Assumes, without verification, that a buffer of bytes contains a Layout and returns it.
243/// # Safety
244/// Callers must trust the given bytes do indeed contain a valid `Layout`.
245pub unsafe fn root_as_layout_unchecked(buf: &[u8]) -> Layout<'_> {
246  unsafe { ::flatbuffers::root_unchecked::<Layout>(buf) }
247}
248#[inline]
249/// Assumes, without verification, that a buffer of bytes contains a size prefixed Layout and returns it.
250/// # Safety
251/// Callers must trust the given bytes do indeed contain a valid size prefixed `Layout`.
252pub unsafe fn size_prefixed_root_as_layout_unchecked(buf: &[u8]) -> Layout<'_> {
253  unsafe { ::flatbuffers::size_prefixed_root_unchecked::<Layout>(buf) }
254}
255#[inline]
256pub fn finish_layout_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
257    fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
258    root: ::flatbuffers::WIPOffset<Layout<'a>>) {
259  fbb.finish(root, None);
260}
261
262#[inline]
263pub fn finish_size_prefixed_layout_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset<Layout<'a>>) {
264  fbb.finish_size_prefixed(root, None);
265}