pub struct Impl<const NBITS: usize, A = GlobalAllocator>where
A: Allocator,{ /* private fields */ }Expand description
Implementation for Quantizer specializing on the number of bits used for data
compression.
Implementations§
Source§impl<const NBITS: usize, A: Allocator> Impl<NBITS, A>
impl<const NBITS: usize, A: Allocator> Impl<NBITS, A>
Sourcepub fn new(quantizer: SphericalQuantizer<A>) -> Result<Self, AllocatorError>where
Self: Constructible<A>,
pub fn new(quantizer: SphericalQuantizer<A>) -> Result<Self, AllocatorError>where
Self: Constructible<A>,
Construct a new plan around quantizer providing distance computers for metric.
Sourcepub fn quantizer(&self) -> &SphericalQuantizer<A>
pub fn quantizer(&self) -> &SphericalQuantizer<A>
Return the underlying SphericalQuantizer.
Sourcepub fn supports(layout: QueryLayout) -> bool
pub fn supports(layout: QueryLayout) -> bool
Return true if this plan supports layout for query computers.
Otherwise, return false.
Trait Implementations§
Source§impl<const NBITS: usize, A> Constructible<A> for Impl<NBITS, A>where
A: Allocator,
AsData<NBITS>: FromOpaque,
SphericalQuantizer<A>: Dispatchable<AsData<NBITS>, NBITS>,
impl<const NBITS: usize, A> Constructible<A> for Impl<NBITS, A>where
A: Allocator,
AsData<NBITS>: FromOpaque,
SphericalQuantizer<A>: Dispatchable<AsData<NBITS>, NBITS>,
fn dispatch_distance( quantizer: &SphericalQuantizer<A>, ) -> Result<Poly<dyn DynDistanceComputer, A>, AllocatorError>
Source§impl<A, B> Quantizer<B> for Impl<1, A>where
A: Allocator + RefUnwindSafe + Send + Sync + 'static,
B: Allocator + UnwindSafe + Send + Sync + 'static,
impl<A, B> Quantizer<B> for Impl<1, A>where
A: Allocator + RefUnwindSafe + Send + Sync + 'static,
B: Allocator + UnwindSafe + Send + Sync + 'static,
Source§fn distance_computer(
&self,
allocator: B,
) -> Result<DistanceComputer<B>, AllocatorError>
fn distance_computer( &self, allocator: B, ) -> Result<DistanceComputer<B>, AllocatorError>
Return a distance computer capable on operating on validly initialized
Opaque
slices of length Self::bytes. Read moreSource§fn distance_computer_ref(&self) -> &dyn DynDistanceComputer
fn distance_computer_ref(&self) -> &dyn DynDistanceComputer
Return a scoped distance computer capable on operating on validly initialized
Opaque slices of length Self::bytes. Read moreSource§fn query_computer(
&self,
layout: QueryLayout,
allocator: B,
) -> Result<DistanceComputer<B>, DistanceComputerError>
fn query_computer( &self, layout: QueryLayout, allocator: B, ) -> Result<DistanceComputer<B>, DistanceComputerError>
A stand alone distance computer specialized for the specified query layout. Read more
Source§fn query_buffer_description(
&self,
layout: QueryLayout,
) -> Result<QueryBufferDescription, UnsupportedQueryLayout>
fn query_buffer_description( &self, layout: QueryLayout, ) -> Result<QueryBufferDescription, UnsupportedQueryLayout>
Return the number of bytes and alignment of a buffer used to contain a compressed
query with the provided layout. Read more
Source§fn compress_query(
&self,
x: &[f32],
layout: QueryLayout,
allow_rescale: bool,
buffer: OpaqueMut<'_>,
scratch: ScopedAllocator<'_>,
) -> Result<(), QueryCompressionError>
fn compress_query( &self, x: &[f32], layout: QueryLayout, allow_rescale: bool, buffer: OpaqueMut<'_>, scratch: ScopedAllocator<'_>, ) -> Result<(), QueryCompressionError>
Compress the query using the specified layout into
buffer. Read moreSource§fn fused_query_computer(
&self,
x: &[f32],
layout: QueryLayout,
allow_rescale: bool,
allocator: B,
scratch: ScopedAllocator<'_>,
) -> Result<QueryComputer<B>, QueryComputerError>
fn fused_query_computer( &self, x: &[f32], layout: QueryLayout, allow_rescale: bool, allocator: B, scratch: ScopedAllocator<'_>, ) -> Result<QueryComputer<B>, QueryComputerError>
Return a query for the argument
x capable on operating on validly initialized
Opaque slices of length Self::bytes. Read moreSource§fn is_supported(&self, layout: QueryLayout) -> bool
fn is_supported(&self, layout: QueryLayout) -> bool
Return whether or not this plan supports the given
QueryLayout.Source§fn compress(
&self,
x: &[f32],
into: OpaqueMut<'_>,
scratch: ScopedAllocator<'_>,
) -> Result<(), CompressionError>
fn compress( &self, x: &[f32], into: OpaqueMut<'_>, scratch: ScopedAllocator<'_>, ) -> Result<(), CompressionError>
Compress the vector
x into the opaque slice. Read moreSource§fn metric(&self) -> SupportedMetric
fn metric(&self) -> SupportedMetric
Return the metric this plan was created with.
Source§fn try_clone_into(
&self,
allocator: B,
) -> Result<Poly<dyn Quantizer<B>, B>, AllocatorError>
fn try_clone_into( &self, allocator: B, ) -> Result<Poly<dyn Quantizer<B>, B>, AllocatorError>
Clone the backing object.
Source§fn serialize(&self, allocator: B) -> Result<Poly<[u8], B>, AllocatorError>
fn serialize(&self, allocator: B) -> Result<Poly<[u8], B>, AllocatorError>
Available on crate feature
flatbuffers only.Serialize
self into a flatbuffer, returning the flatbuffer. The function
try_deserialize should undo this operation.Source§impl<A, B> Quantizer<B> for Impl<2, A>where
A: Allocator + RefUnwindSafe + Send + Sync + 'static,
B: Allocator + UnwindSafe + Send + Sync + 'static,
impl<A, B> Quantizer<B> for Impl<2, A>where
A: Allocator + RefUnwindSafe + Send + Sync + 'static,
B: Allocator + UnwindSafe + Send + Sync + 'static,
Source§fn distance_computer(
&self,
allocator: B,
) -> Result<DistanceComputer<B>, AllocatorError>
fn distance_computer( &self, allocator: B, ) -> Result<DistanceComputer<B>, AllocatorError>
Return a distance computer capable on operating on validly initialized
Opaque
slices of length Self::bytes. Read moreSource§fn distance_computer_ref(&self) -> &dyn DynDistanceComputer
fn distance_computer_ref(&self) -> &dyn DynDistanceComputer
Return a scoped distance computer capable on operating on validly initialized
Opaque slices of length Self::bytes. Read moreSource§fn query_computer(
&self,
layout: QueryLayout,
allocator: B,
) -> Result<DistanceComputer<B>, DistanceComputerError>
fn query_computer( &self, layout: QueryLayout, allocator: B, ) -> Result<DistanceComputer<B>, DistanceComputerError>
A stand alone distance computer specialized for the specified query layout. Read more
Source§fn query_buffer_description(
&self,
layout: QueryLayout,
) -> Result<QueryBufferDescription, UnsupportedQueryLayout>
fn query_buffer_description( &self, layout: QueryLayout, ) -> Result<QueryBufferDescription, UnsupportedQueryLayout>
Return the number of bytes and alignment of a buffer used to contain a compressed
query with the provided layout. Read more
Source§fn compress_query(
&self,
x: &[f32],
layout: QueryLayout,
allow_rescale: bool,
buffer: OpaqueMut<'_>,
scratch: ScopedAllocator<'_>,
) -> Result<(), QueryCompressionError>
fn compress_query( &self, x: &[f32], layout: QueryLayout, allow_rescale: bool, buffer: OpaqueMut<'_>, scratch: ScopedAllocator<'_>, ) -> Result<(), QueryCompressionError>
Compress the query using the specified layout into
buffer. Read moreSource§fn fused_query_computer(
&self,
x: &[f32],
layout: QueryLayout,
allow_rescale: bool,
allocator: B,
scratch: ScopedAllocator<'_>,
) -> Result<QueryComputer<B>, QueryComputerError>
fn fused_query_computer( &self, x: &[f32], layout: QueryLayout, allow_rescale: bool, allocator: B, scratch: ScopedAllocator<'_>, ) -> Result<QueryComputer<B>, QueryComputerError>
Return a query for the argument
x capable on operating on validly initialized
Opaque slices of length Self::bytes. Read moreSource§fn is_supported(&self, layout: QueryLayout) -> bool
fn is_supported(&self, layout: QueryLayout) -> bool
Return whether or not this plan supports the given
QueryLayout.Source§fn compress(
&self,
x: &[f32],
into: OpaqueMut<'_>,
scratch: ScopedAllocator<'_>,
) -> Result<(), CompressionError>
fn compress( &self, x: &[f32], into: OpaqueMut<'_>, scratch: ScopedAllocator<'_>, ) -> Result<(), CompressionError>
Compress the vector
x into the opaque slice. Read moreSource§fn metric(&self) -> SupportedMetric
fn metric(&self) -> SupportedMetric
Return the metric this plan was created with.
Source§fn try_clone_into(
&self,
allocator: B,
) -> Result<Poly<dyn Quantizer<B>, B>, AllocatorError>
fn try_clone_into( &self, allocator: B, ) -> Result<Poly<dyn Quantizer<B>, B>, AllocatorError>
Clone the backing object.
Source§fn serialize(&self, allocator: B) -> Result<Poly<[u8], B>, AllocatorError>
fn serialize(&self, allocator: B) -> Result<Poly<[u8], B>, AllocatorError>
Available on crate feature
flatbuffers only.Serialize
self into a flatbuffer, returning the flatbuffer. The function
try_deserialize should undo this operation.Source§impl<A, B> Quantizer<B> for Impl<4, A>where
A: Allocator + RefUnwindSafe + Send + Sync + 'static,
B: Allocator + UnwindSafe + Send + Sync + 'static,
impl<A, B> Quantizer<B> for Impl<4, A>where
A: Allocator + RefUnwindSafe + Send + Sync + 'static,
B: Allocator + UnwindSafe + Send + Sync + 'static,
Source§fn distance_computer(
&self,
allocator: B,
) -> Result<DistanceComputer<B>, AllocatorError>
fn distance_computer( &self, allocator: B, ) -> Result<DistanceComputer<B>, AllocatorError>
Return a distance computer capable on operating on validly initialized
Opaque
slices of length Self::bytes. Read moreSource§fn distance_computer_ref(&self) -> &dyn DynDistanceComputer
fn distance_computer_ref(&self) -> &dyn DynDistanceComputer
Return a scoped distance computer capable on operating on validly initialized
Opaque slices of length Self::bytes. Read moreSource§fn query_computer(
&self,
layout: QueryLayout,
allocator: B,
) -> Result<DistanceComputer<B>, DistanceComputerError>
fn query_computer( &self, layout: QueryLayout, allocator: B, ) -> Result<DistanceComputer<B>, DistanceComputerError>
A stand alone distance computer specialized for the specified query layout. Read more
Source§fn query_buffer_description(
&self,
layout: QueryLayout,
) -> Result<QueryBufferDescription, UnsupportedQueryLayout>
fn query_buffer_description( &self, layout: QueryLayout, ) -> Result<QueryBufferDescription, UnsupportedQueryLayout>
Return the number of bytes and alignment of a buffer used to contain a compressed
query with the provided layout. Read more
Source§fn compress_query(
&self,
x: &[f32],
layout: QueryLayout,
allow_rescale: bool,
buffer: OpaqueMut<'_>,
scratch: ScopedAllocator<'_>,
) -> Result<(), QueryCompressionError>
fn compress_query( &self, x: &[f32], layout: QueryLayout, allow_rescale: bool, buffer: OpaqueMut<'_>, scratch: ScopedAllocator<'_>, ) -> Result<(), QueryCompressionError>
Compress the query using the specified layout into
buffer. Read moreSource§fn fused_query_computer(
&self,
x: &[f32],
layout: QueryLayout,
allow_rescale: bool,
allocator: B,
scratch: ScopedAllocator<'_>,
) -> Result<QueryComputer<B>, QueryComputerError>
fn fused_query_computer( &self, x: &[f32], layout: QueryLayout, allow_rescale: bool, allocator: B, scratch: ScopedAllocator<'_>, ) -> Result<QueryComputer<B>, QueryComputerError>
Return a query for the argument
x capable on operating on validly initialized
Opaque slices of length Self::bytes. Read moreSource§fn is_supported(&self, layout: QueryLayout) -> bool
fn is_supported(&self, layout: QueryLayout) -> bool
Return whether or not this plan supports the given
QueryLayout.Source§fn compress(
&self,
x: &[f32],
into: OpaqueMut<'_>,
scratch: ScopedAllocator<'_>,
) -> Result<(), CompressionError>
fn compress( &self, x: &[f32], into: OpaqueMut<'_>, scratch: ScopedAllocator<'_>, ) -> Result<(), CompressionError>
Compress the vector
x into the opaque slice. Read moreSource§fn metric(&self) -> SupportedMetric
fn metric(&self) -> SupportedMetric
Return the metric this plan was created with.
Source§fn try_clone_into(
&self,
allocator: B,
) -> Result<Poly<dyn Quantizer<B>, B>, AllocatorError>
fn try_clone_into( &self, allocator: B, ) -> Result<Poly<dyn Quantizer<B>, B>, AllocatorError>
Clone the backing object.
Source§fn serialize(&self, allocator: B) -> Result<Poly<[u8], B>, AllocatorError>
fn serialize(&self, allocator: B) -> Result<Poly<[u8], B>, AllocatorError>
Available on crate feature
flatbuffers only.Serialize
self into a flatbuffer, returning the flatbuffer. The function
try_deserialize should undo this operation.Source§impl<A, B> Quantizer<B> for Impl<8, A>where
A: Allocator + RefUnwindSafe + Send + Sync + 'static,
B: Allocator + UnwindSafe + Send + Sync + 'static,
impl<A, B> Quantizer<B> for Impl<8, A>where
A: Allocator + RefUnwindSafe + Send + Sync + 'static,
B: Allocator + UnwindSafe + Send + Sync + 'static,
Source§fn distance_computer(
&self,
allocator: B,
) -> Result<DistanceComputer<B>, AllocatorError>
fn distance_computer( &self, allocator: B, ) -> Result<DistanceComputer<B>, AllocatorError>
Return a distance computer capable on operating on validly initialized
Opaque
slices of length Self::bytes. Read moreSource§fn distance_computer_ref(&self) -> &dyn DynDistanceComputer
fn distance_computer_ref(&self) -> &dyn DynDistanceComputer
Return a scoped distance computer capable on operating on validly initialized
Opaque slices of length Self::bytes. Read moreSource§fn query_computer(
&self,
layout: QueryLayout,
allocator: B,
) -> Result<DistanceComputer<B>, DistanceComputerError>
fn query_computer( &self, layout: QueryLayout, allocator: B, ) -> Result<DistanceComputer<B>, DistanceComputerError>
A stand alone distance computer specialized for the specified query layout. Read more
Source§fn query_buffer_description(
&self,
layout: QueryLayout,
) -> Result<QueryBufferDescription, UnsupportedQueryLayout>
fn query_buffer_description( &self, layout: QueryLayout, ) -> Result<QueryBufferDescription, UnsupportedQueryLayout>
Return the number of bytes and alignment of a buffer used to contain a compressed
query with the provided layout. Read more
Source§fn compress_query(
&self,
x: &[f32],
layout: QueryLayout,
allow_rescale: bool,
buffer: OpaqueMut<'_>,
scratch: ScopedAllocator<'_>,
) -> Result<(), QueryCompressionError>
fn compress_query( &self, x: &[f32], layout: QueryLayout, allow_rescale: bool, buffer: OpaqueMut<'_>, scratch: ScopedAllocator<'_>, ) -> Result<(), QueryCompressionError>
Compress the query using the specified layout into
buffer. Read moreSource§fn fused_query_computer(
&self,
x: &[f32],
layout: QueryLayout,
allow_rescale: bool,
allocator: B,
scratch: ScopedAllocator<'_>,
) -> Result<QueryComputer<B>, QueryComputerError>
fn fused_query_computer( &self, x: &[f32], layout: QueryLayout, allow_rescale: bool, allocator: B, scratch: ScopedAllocator<'_>, ) -> Result<QueryComputer<B>, QueryComputerError>
Return a query for the argument
x capable on operating on validly initialized
Opaque slices of length Self::bytes. Read moreSource§fn is_supported(&self, layout: QueryLayout) -> bool
fn is_supported(&self, layout: QueryLayout) -> bool
Return whether or not this plan supports the given
QueryLayout.Source§fn compress(
&self,
x: &[f32],
into: OpaqueMut<'_>,
scratch: ScopedAllocator<'_>,
) -> Result<(), CompressionError>
fn compress( &self, x: &[f32], into: OpaqueMut<'_>, scratch: ScopedAllocator<'_>, ) -> Result<(), CompressionError>
Compress the vector
x into the opaque slice. Read moreSource§fn metric(&self) -> SupportedMetric
fn metric(&self) -> SupportedMetric
Return the metric this plan was created with.
Source§fn try_clone_into(
&self,
allocator: B,
) -> Result<Poly<dyn Quantizer<B>, B>, AllocatorError>
fn try_clone_into( &self, allocator: B, ) -> Result<Poly<dyn Quantizer<B>, B>, AllocatorError>
Clone the backing object.
Source§fn serialize(&self, allocator: B) -> Result<Poly<[u8], B>, AllocatorError>
fn serialize(&self, allocator: B) -> Result<Poly<[u8], B>, AllocatorError>
Available on crate feature
flatbuffers only.Serialize
self into a flatbuffer, returning the flatbuffer. The function
try_deserialize should undo this operation.Auto Trait Implementations§
impl<const NBITS: usize, A> Freeze for Impl<NBITS, A>where
A: Freeze,
impl<const NBITS: usize, A = GlobalAllocator> !RefUnwindSafe for Impl<NBITS, A>
impl<const NBITS: usize, A> Send for Impl<NBITS, A>where
A: Send,
impl<const NBITS: usize, A> Sync for Impl<NBITS, A>where
A: Sync,
impl<const NBITS: usize, A> Unpin for Impl<NBITS, A>where
A: Unpin,
impl<const NBITS: usize, A> UnsafeUnpin for Impl<NBITS, A>where
A: UnsafeUnpin,
impl<const NBITS: usize, A = GlobalAllocator> !UnwindSafe for Impl<NBITS, A>
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
Mutably borrows from an owned value. Read more
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>
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 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>
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