Skip to main content

vortex_flatbuffers/generated/
layout.rs

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