diskann-quantization 0.51.0

DiskANN is a fast approximate nearest neighbor search library for high dimensional data
Documentation
/*
 * Copyright (c) Microsoft Corporation.
 * Licensed under the MIT license.
 */

// automatically generated by the FlatBuffers compiler, do not modify
// @generated
extern crate alloc;
extern crate flatbuffers;
use alloc::boxed::Box;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use core::mem;
use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum RandomRotationOffset {}
#[derive(Copy, Clone, PartialEq)]

pub struct RandomRotation<'a> {
  pub _tab: flatbuffers::Table<'a>,
}

impl<'a> flatbuffers::Follow<'a> for RandomRotation<'a> {
  type Inner = RandomRotation<'a>;
  #[inline]
  unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
    Self { _tab: flatbuffers::Table::new(buf, loc) }
  }
}

impl<'a> RandomRotation<'a> {
  pub const VT_DATA: flatbuffers::VOffsetT = 4;
  pub const VT_NROWS: flatbuffers::VOffsetT = 6;
  pub const VT_NCOLS: flatbuffers::VOffsetT = 8;

  #[inline]
  pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
    RandomRotation { _tab: table }
  }
  #[allow(unused_mut)]
  pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
    _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
    args: &'args RandomRotationArgs<'args>
  ) -> flatbuffers::WIPOffset<RandomRotation<'bldr>> {
    let mut builder = RandomRotationBuilder::new(_fbb);
    builder.add_ncols(args.ncols);
    builder.add_nrows(args.nrows);
    if let Some(x) = args.data { builder.add_data(x); }
    builder.finish()
  }


  #[inline]
  pub fn data(&self) -> flatbuffers::Vector<'a, f32> {
    // Safety:
    // Created from valid Table for this object
    // which contains a valid value in this slot
    unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, f32>>>(RandomRotation::VT_DATA, None).unwrap()}
  }
  #[inline]
  pub fn nrows(&self) -> u32 {
    // Safety:
    // Created from valid Table for this object
    // which contains a valid value in this slot
    unsafe { self._tab.get::<u32>(RandomRotation::VT_NROWS, Some(0)).unwrap()}
  }
  #[inline]
  pub fn ncols(&self) -> u32 {
    // Safety:
    // Created from valid Table for this object
    // which contains a valid value in this slot
    unsafe { self._tab.get::<u32>(RandomRotation::VT_NCOLS, Some(0)).unwrap()}
  }
}

impl flatbuffers::Verifiable for RandomRotation<'_> {
  #[inline]
  fn run_verifier(
    v: &mut flatbuffers::Verifier, pos: usize
  ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
    use self::flatbuffers::Verifiable;
    v.visit_table(pos)?
     .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, f32>>>("data", Self::VT_DATA, true)?
     .visit_field::<u32>("nrows", Self::VT_NROWS, false)?
     .visit_field::<u32>("ncols", Self::VT_NCOLS, false)?
     .finish();
    Ok(())
  }
}
pub struct RandomRotationArgs<'a> {
    pub data: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, f32>>>,
    pub nrows: u32,
    pub ncols: u32,
}
impl<'a> Default for RandomRotationArgs<'a> {
  #[inline]
  fn default() -> Self {
    RandomRotationArgs {
      data: None, // required field
      nrows: 0,
      ncols: 0,
    }
  }
}

pub struct RandomRotationBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
  fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
  start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> RandomRotationBuilder<'a, 'b, A> {
  #[inline]
  pub fn add_data(&mut self, data: flatbuffers::WIPOffset<flatbuffers::Vector<'b , f32>>) {
    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(RandomRotation::VT_DATA, data);
  }
  #[inline]
  pub fn add_nrows(&mut self, nrows: u32) {
    self.fbb_.push_slot::<u32>(RandomRotation::VT_NROWS, nrows, 0);
  }
  #[inline]
  pub fn add_ncols(&mut self, ncols: u32) {
    self.fbb_.push_slot::<u32>(RandomRotation::VT_NCOLS, ncols, 0);
  }
  #[inline]
  pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> RandomRotationBuilder<'a, 'b, A> {
    let start = _fbb.start_table();
    RandomRotationBuilder {
      fbb_: _fbb,
      start_: start,
    }
  }
  #[inline]
  pub fn finish(self) -> flatbuffers::WIPOffset<RandomRotation<'a>> {
    let o = self.fbb_.end_table(self.start_);
    self.fbb_.required(o, RandomRotation::VT_DATA,"data");
    flatbuffers::WIPOffset::new(o.value())
  }
}

impl core::fmt::Debug for RandomRotation<'_> {
  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    let mut ds = f.debug_struct("RandomRotation");
      ds.field("data", &self.data());
      ds.field("nrows", &self.nrows());
      ds.field("ncols", &self.ncols());
      ds.finish()
  }
}