pub struct CosineJoiner { /* private fields */ }Expand description
A reusable cosine-join handle that owns the corpus and — under feature = "gpu" on macOS — the
Metal device, compiled batch_cosine kernel, and the corpus CSR uploaded to unified memory, all
acquired once at construction. Repeated joins at different thresholds
then skip the per-call kernel compile + CSR upload that cosine_join_with pays (only the
t-specific inverted index is rebuilt each call, on the CPU). Always constructible; degrades to
the pure-CPU join when the gpu feature is off or no Metal device is available — mirroring
Rationer. This is the right entry point for sweeping thresholds or joining repeatedly.
Implementations§
Source§impl CosineJoiner
impl CosineJoiner
Sourcepub fn new(corpus: Corpus) -> Self
pub fn new(corpus: Corpus) -> Self
Build a joiner over corpus, acquiring the GPU device + uploading the corpus CSR once if the
gpu feature is on and a Metal device is present.
Sourcepub fn corpus(&self) -> &Corpus
pub fn corpus(&self) -> &Corpus
The owned corpus (e.g. for len() or to run other queries against it).
Sourcepub fn has_gpu(&self) -> bool
pub fn has_gpu(&self) -> bool
Whether a Metal GPU backend was acquired. Always false without feature = "gpu" on macOS;
when false, every join runs on the CPU regardless of mode.
Sourcepub fn join(&self, t: f64, mode: Concurrency) -> Vec<(usize, usize, f64)>
pub fn join(&self, t: f64, mode: Concurrency) -> Vec<(usize, usize, f64)>
Run the join at threshold t under mode, reusing the handle’s GPU resources. Returns the
same results as cosine_join_with (Cpu/GpuPlusCpu exact, Gpu f32→f64); falls back to the
CPU join when the GPU is unavailable.
Auto Trait Implementations§
impl Freeze for CosineJoiner
impl RefUnwindSafe for CosineJoiner
impl Send for CosineJoiner
impl Sync for CosineJoiner
impl Unpin for CosineJoiner
impl UnsafeUnpin for CosineJoiner
impl UnwindSafe for CosineJoiner
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> 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