pub struct Comparator { /* private fields */ }Expand description
Pairwise record comparator with automatic GPU/CPU selection.
Wraps FieldComparator (CPU) or DeviceComparator (GPU) depending on the
Backend. Implements ComparatorTrait identically in both cases.
Implementations§
Source§impl Comparator
impl Comparator
Sourcepub fn from_cpu(fc: FieldComparator) -> Self
pub fn from_cpu(fc: FieldComparator) -> Self
Wrap an already-constructed zer_compare::FieldComparator directly.
Use this when you want to override default similarity functions via
zer_compare::FieldComparator::with_fns before creating the comparator.
Always uses the CPU path; GPU acceleration is not available this way.
Sourcepub fn new(schema: &Schema, backend: &Backend) -> Self
pub fn new(schema: &Schema, backend: &Backend) -> Self
Build a comparator from a schema and backend.
Sourcepub fn backend_name(&self) -> &'static str
pub fn backend_name(&self) -> &'static str
Name of the active backend, for diagnostics.
Sourcepub fn compare_batch_from_pool(
&self,
pool: &RecordPool,
pair_indices: &[(usize, usize)],
schema: &Schema,
) -> ComparisonBatch
pub fn compare_batch_from_pool( &self, pool: &RecordPool, pair_indices: &[(usize, usize)], schema: &Schema, ) -> ComparisonBatch
Primary hot-path: pool-native batch comparison.
pool is a RecordPool built from the candidate records; pair_indices
holds (i, j) pairs where i and j are indices into the pool.
Avoids all Record::clone() and HashMap lookups, the fastest path for
large BRP-style jobs where records are already loaded into a pool.
Sourcepub fn compare_batch_indexed(
&self,
records: &[Record],
pair_indices: &[(usize, usize)],
schema: &Schema,
) -> ComparisonBatch
pub fn compare_batch_indexed( &self, records: &[Record], pair_indices: &[(usize, usize)], schema: &Schema, ) -> ComparisonBatch
Convenience wrapper: builds a pool from a flat records slice and compares
the pair_indices pairs. No Record::clone().
Trait Implementations§
Source§impl Comparator for Comparator
impl Comparator for Comparator
Source§fn compare(&self, a: &Record, b: &Record, schema: &Schema) -> ComparisonVector
fn compare(&self, a: &Record, b: &Record, schema: &Schema) -> ComparisonVector
Source§fn compare_batch_from_pool(
&self,
pool: &RecordPool,
indices: &[(usize, usize)],
schema: &Schema,
) -> ComparisonBatch
fn compare_batch_from_pool( &self, pool: &RecordPool, indices: &[(usize, usize)], schema: &Schema, ) -> ComparisonBatch
Auto Trait Implementations§
impl Freeze for Comparator
impl !RefUnwindSafe for Comparator
impl Send for Comparator
impl Sync for Comparator
impl Unpin for Comparator
impl UnsafeUnpin for Comparator
impl !UnwindSafe for Comparator
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