pub struct PQScratch {
pub aligned_pqtable_dist_scratch: AlignedSlice<f32>,
pub aligned_dist_scratch: AlignedSlice<f32>,
pub aligned_pq_coord_scratch: AlignedSlice<u8>,
pub rotated_query: Vec<f32>,
}Expand description
PQ scratch
Fields§
§aligned_pqtable_dist_scratch: AlignedSlice<f32>Aligned pq table distance scratch, the length must be at least [256 * NCHUNKS]. 256 is the number of PQ centroids. This is used to store the distance between each chunk in the query vector to each centroid, which is why the length is num of centroids * num of chunks
aligned_dist_scratch: AlignedSlice<f32>Aligned dist scratch, must be at least diskann MAX_DEGREE This is used to temporarily save the pq distance between query vector to the candidate vectors.
aligned_pq_coord_scratch: AlignedSlice<u8>Aligned pq coord scratch, must be at least [N_CHUNKS * MAX_DEGREE] This is used to store the pq coordinates of the candidate vectors.
rotated_query: Vec<f32>Query scratch buffer stored as f32. set initializes it by copying/converting the
raw query values; PQTable.PreprocessQuery can then rotate or otherwise preprocess it.
Implementations§
Source§impl PQScratch
impl PQScratch
Sourcepub fn new(
graph_degree: usize,
dim: usize,
num_pq_chunks: usize,
num_centers: usize,
) -> ANNResult<Self>
pub fn new( graph_degree: usize, dim: usize, num_pq_chunks: usize, num_centers: usize, ) -> ANNResult<Self>
Create a new pq scratch
Sourcepub fn set<T: VectorRepr>(&mut self, dim: usize, query: &[T]) -> ANNResult<()>
pub fn set<T: VectorRepr>(&mut self, dim: usize, query: &[T]) -> ANNResult<()>
Copy query into rotated_query, converting to f32.
dim is the element count in the T representation. The decompressed
f32 length returned by T::as_f32 may differ (e.g. MinMaxElement
expands to more f32s than its raw element count), so the destination
slice is sized by that actual length.
Returns DimensionMismatchError if dim > query.len() or the
decompressed vector does not fit in rotated_query.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PQScratch
impl RefUnwindSafe for PQScratch
impl Send for PQScratch
impl Sync for PQScratch
impl Unpin for PQScratch
impl UnsafeUnpin for PQScratch
impl UnwindSafe for PQScratch
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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