pub struct Config {
pub signature_size: usize,
pub num_bands: usize,
pub shingle_size: usize,
pub similarity_threshold: f64,
/* private fields */
}Fields§
§signature_size: usizeNumber of hash functions (signature size).
num_bands: usizeNumber of LSH bands.
shingle_size: usizeSize of shingles (k-grams).
similarity_threshold: f64Similarity threshold for duplicates (0.0-1.0).
Implementations§
Source§impl Config
impl Config
Sourcepub fn new(
signature_size: usize,
num_bands: usize,
shingle_size: usize,
similarity_threshold: f64,
) -> Result<Self>
pub fn new( signature_size: usize, num_bands: usize, shingle_size: usize, similarity_threshold: f64, ) -> Result<Self>
Create a new configuration with custom parameters.
§Errors
Returns an error if parameters are invalid:
signature_sizemust be divisible bynum_bandssimilarity_thresholdmust be in (0.0, 1.0]shingle_sizemust be at least 1
Sourcepub fn with_similarity_threshold(self, threshold: f64) -> Self
pub fn with_similarity_threshold(self, threshold: f64) -> Self
Set the similarity threshold.
Sourcepub fn with_num_bands(self, num_bands: usize) -> Self
pub fn with_num_bands(self, num_bands: usize) -> Self
Set the number of LSH bands.
The bands must tile the signature exactly (signature_size % num_bands == 0). Rather than silently dropping a requested count that does not
divide the current signature_size (the old behavior, which left the
caller believing their value took effect), this snaps to the divisor of
signature_size nearest the request, so the invariant always holds and
the change always takes effect. A request of 0 (no valid band count)
leaves the current value unchanged. Use Config::new for a fallible,
error-returning construction instead.
Sourcepub fn with_shingle_size(self, shingle_size: usize) -> Self
pub fn with_shingle_size(self, shingle_size: usize) -> Self
Set the shingle size (k-gram length).
Sourcepub fn with_signature_size(self, signature_size: usize) -> Self
pub fn with_signature_size(self, signature_size: usize) -> Self
Set the signature size (number of hash functions).
The signature must be an exact multiple of num_bands. Rather than
silently dropping a requested size that is not (the old behavior), this
rounds UP to the next multiple of the current num_bands, so the bands
always tile the signature and the change always takes effect. A request
of 0 leaves the current value unchanged. Use Config::new for a
fallible, error-returning construction instead.
Sourcepub fn with_max_document_size(self, max_bytes: usize) -> Self
pub fn with_max_document_size(self, max_bytes: usize) -> Self
Set the maximum document size in bytes.
Sourcepub fn with_memory_limit(self, memory_limit_in_mb: usize) -> Self
pub fn with_memory_limit(self, memory_limit_in_mb: usize) -> Self
Set the memory limit in MB.
Sourcepub fn with_store_documents(self, store: bool) -> Self
pub fn with_store_documents(self, store: bool) -> Self
Enable or disable storing document content.
Sourcepub const fn rows_per_band(&self) -> usize
pub const fn rows_per_band(&self) -> usize
Calculate rows per band.
Sourcepub fn estimated_memory_per_document(&self) -> usize
pub fn estimated_memory_per_document(&self) -> usize
Calculate the estimated memory usage per document in bytes.
Sourcepub fn max_documents_in_memory(&self) -> usize
pub fn max_documents_in_memory(&self) -> usize
Calculate the maximum number of documents that fit in memory.