pub struct BasicTableBase<T, U>{ /* 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>
impl<T, U> BasicTableBase<T, U>
Sourcepub fn new(
pivots: MatrixBase<T>,
offsets: ChunkOffsetsBase<U>,
) -> Result<Self, BasicTableError>
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.
Sourcepub fn view_pivots(&self) -> MatrixView<'_, f32>
pub fn view_pivots(&self) -> MatrixView<'_, f32>
Return a view over the pivot table.
Sourcepub fn view_offsets(&self) -> ChunkOffsetsView<'_>
pub fn view_offsets(&self) -> ChunkOffsetsView<'_>
Return a view over the schema offsets.
Trait Implementations§
Source§impl<T, U> Clone for BasicTableBase<T, U>
impl<T, U> Clone for BasicTableBase<T, U>
Source§fn clone(&self) -> BasicTableBase<T, U>
fn clone(&self) -> BasicTableBase<T, U>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T, U> CompressInto<&[f32], &mut [u8]> for BasicTableBase<T, U>
impl<T, U> CompressInto<&[f32], &mut [u8]> for BasicTableBase<T, U>
Source§fn compress_into(&self, from: &[f32], to: &mut [u8]) -> Result<(), Self::Error>
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
type Error = TableCompressionError
Auto Trait Implementations§
impl<T, U> Freeze for BasicTableBase<T, U>
impl<T, U> RefUnwindSafe for BasicTableBase<T, U>where
T: RefUnwindSafe,
U: RefUnwindSafe,
impl<T, U> Send for BasicTableBase<T, U>
impl<T, U> Sync for BasicTableBase<T, U>
impl<T, U> Unpin for BasicTableBase<T, U>
impl<T, U> UnsafeUnpin for BasicTableBase<T, U>where
T: UnsafeUnpin,
U: UnsafeUnpin,
impl<T, U> UnwindSafe for BasicTableBase<T, U>where
T: UnwindSafe,
U: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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