Skip to main content

BasicTableBase

Struct BasicTableBase 

Source
pub struct BasicTableBase<T, U>
where T: DenseData<Elem = f32>, U: DenseData<Elem = usize>,
{ /* private fields */ }
Expand description

A basic PQ table that stores the pivot table in the following dense, row-major form:

          | -- chunk 0 -- | -- chunk 1 -- | -- chunk 2 -- | .... | -- chunk N-1 -- |
          +------------------------------------------------------------------------+
 pivot 0  | c000 c001 ... | c010 c011 ... | c020 c021 ... | .... |       ...       |
 pivot 1  | c100 c101 ... | c110 c111 ... | c120 c121 ... | .... |       ...       |
   ...    |      ...      |      ...      |      ...      | .... |       ...       |
 pivot K  | cK00 cK01 ... | cK10 cK11 ... | cK20 cK21 ... | .... |       ...       |

The member offsets describes the number of dimensions of each chunk.

§Invariants

  • offsets.dim() == pivots.nrows(): The dimensionality of the two must agree.

Implementations§

Source§

impl<T, U> BasicTableBase<T, U>
where T: DenseData<Elem = f32>, U: DenseData<Elem = usize>,

Source

pub fn new( pivots: MatrixBase<T>, offsets: ChunkOffsetsBase<U>, ) -> Result<Self, BasicTableError>

Construct a new BasicTableBase over the pivot table and offsets.

§Error

Returns an error if pivots.ncols() != offsets.dim() or if pivots.nrows() == 0.

Source

pub fn view_pivots(&self) -> MatrixView<'_, f32>

Return a view over the pivot table.

Source

pub fn view_offsets(&self) -> ChunkOffsetsView<'_>

Return a view over the schema offsets.

Source

pub fn ncenters(&self) -> usize

Return the number of pivots in each PQ chunk.

Source

pub fn nchunks(&self) -> usize

Return the number of PQ chunks.

Source

pub fn dim(&self) -> usize

Return the dimensionality of the full-precision vectors associated with this table.

Trait Implementations§

Source§

impl<T, U> Clone for BasicTableBase<T, U>
where T: DenseData<Elem = f32> + Clone, U: DenseData<Elem = usize> + Clone,

Source§

fn clone(&self) -> BasicTableBase<T, U>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T, U> CompressInto<&[f32], &mut [u8]> for BasicTableBase<T, U>
where T: DenseData<Elem = f32>, U: DenseData<Elem = usize>,

Source§

fn compress_into(&self, from: &[f32], to: &mut [u8]) -> Result<(), Self::Error>

Compress the full-precision vector from into the PQ byte buffer to.

Compression is performed by partitioning from into chunks according to the offsets schema in the table and then finding the closest pivot according to the L2 distance.

The final compressed value is the index of the closest pivot.

§Errors

Returns errors under the following conditions:

  • self.ncenters() > 256: If the number of centers exceeds 256, then it cannot be guaranteed that the index of the closest pivot for a chunk will fit losslessly in an 8-bit integer.

  • from.len() != self.dim(): The full precision vector must have the dimensionality expected by the compression.

  • to.len() != self.nchunks(): The PQ buffer must be sized appropriately.

  • If any chunk is sufficiently far from all centers that its distance becomes infinity to all centers.

§Allocates

This function should not allocate when successful.

§Parallelism

This function is single-threaded.

Source§

type Error = TableCompressionError

Errors that may occur during compression.
Source§

type Output = ()

An output type resulting from compression.
Source§

impl<T, U> Debug for BasicTableBase<T, U>
where T: DenseData<Elem = f32> + Debug, U: DenseData<Elem = usize> + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T, U> Freeze for BasicTableBase<T, U>
where T: Freeze, U: Freeze,

§

impl<T, U> RefUnwindSafe for BasicTableBase<T, U>

§

impl<T, U> Send for BasicTableBase<T, U>
where T: Send, U: Send,

§

impl<T, U> Sync for BasicTableBase<T, U>
where T: Sync, U: Sync,

§

impl<T, U> Unpin for BasicTableBase<T, U>
where T: Unpin, U: Unpin,

§

impl<T, U> UnwindSafe for BasicTableBase<T, U>
where T: UnwindSafe, U: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Generator<T> for T
where T: Clone,

Source§

fn generate(&mut self) -> T

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> AsyncFriendly for T
where T: Send + Sync + 'static,