pub struct MinHasher { /* private fields */ }Expand description
MinHasher computes MinHash signatures from documents.
This struct maintains the hash function coefficients and provides methods to compute signatures from raw bytes or strings.
Implementations§
Source§impl MinHasher
impl MinHasher
Sourcepub fn new(config: &Config) -> Result<Self>
pub fn new(config: &Config) -> Result<Self>
Create a new MinHasher from a configuration.
§Errors
Returns an error if the configuration is invalid.
Sourcepub fn compute(&self, data: &[u8], doc_id: usize) -> Result<MinHashSignature>
pub fn compute(&self, data: &[u8], doc_id: usize) -> Result<MinHashSignature>
Compute MinHash signature for a byte sequence.
§Errors
Returns an error if the document is empty or too large.
Sourcepub fn compute_str(&self, text: &str, doc_id: usize) -> Result<MinHashSignature>
pub fn compute_str(&self, text: &str, doc_id: usize) -> Result<MinHashSignature>
Sourcepub fn compute_batch(
&self,
documents: &[&[u8]],
start_id: usize,
) -> Vec<Result<MinHashSignature>> ⓘ
pub fn compute_batch( &self, documents: &[&[u8]], start_id: usize, ) -> Vec<Result<MinHashSignature>> ⓘ
Compute signatures for multiple documents in batch.
This is more efficient than calling compute repeatedly
due to better cache utilization.
Sourcepub fn compute_from_hashed_shingles(
&self,
shingle_hashes: &[u64],
doc_id: usize,
) -> MinHashSignature
pub fn compute_from_hashed_shingles( &self, shingle_hashes: &[u64], doc_id: usize, ) -> MinHashSignature
Compute signature from pre-hashed shingles.
Useful when shingles are computed elsewhere or cached.
Sourcepub const fn signature_size(&self) -> usize
pub const fn signature_size(&self) -> usize
Get the signature size.
Sourcepub const fn shingle_size(&self) -> usize
pub const fn shingle_size(&self) -> usize
Get the shingle size.
Auto Trait Implementations§
impl Freeze for MinHasher
impl RefUnwindSafe for MinHasher
impl Send for MinHasher
impl Sync for MinHasher
impl Unpin for MinHasher
impl UnsafeUnpin for MinHasher
impl UnwindSafe for MinHasher
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