From b2e1469aa2fa30d42c20930822fb6309eb19b730 Mon Sep 17 00:00:00 2001 From: jean-pierreBoth Date: Fri, 20 Dec 2024 14:26:34 +0100 Subject: [PATCH] typos before pushing to crates.io --- README.md | 2 +- src/hnsw.rs | 8 ++++---- src/hnswio.rs | 7 +++++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 48d2d3d..f905b89 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ The nearest neighbour of the point is searched in lookup tables from the upper l The parameter of the exponential law to sample point levels is set to `ln(max_nb_connection)/scale`. By default *scale* is set to 1. It is possible to reduce the *scale* parameter and thus reduce the number of levels used (See Hnsw::modify_level_scale) without increasing max_nb_connection. -This often provide beter recalls without increasing *max_nb_connection* which increase memory usage. (See examples) +This often provide better recalls without increasing *max_nb_connection* and thus spare memory usage. (See examples) The main parameters occuring in constructing the graph or in searching are: diff --git a/src/hnsw.rs b/src/hnsw.rs index e03bb19..cc8277b 100644 --- a/src/hnsw.rs +++ b/src/hnsw.rs @@ -861,10 +861,10 @@ impl<'b, T: Clone + Send + Sync, D: Distance + Send + Sync> Hnsw<'b, T, D> { self.datamap_opt } - /// By default the levels are sampled using an exponential law of parameter ln(max_nb_conn) - /// so the probability of having more than l levels decrease as exp(-l * ln(max_nb_conn)) - /// Reducing the scale change the parameter of the exponential to ln(max_nb_conn)/scale. - /// This reduce the number of levels generated and can provide better precision, reduce memory but with some more cpu used + /// By default the levels are sampled using an exponential law of parameter **ln(max_nb_conn)** + /// so the probability of having more than l levels decrease as **exp(-l * ln(max_nb_conn))**. + /// Reducing the scale change the parameter of the exponential to **ln(max_nb_conn)/scale**. + /// This reduce the number of levels generated and can provide better precision, reduce memory with marginally more cpu used. /// The factor must between 0.2 and 1. pub fn modify_level_scale(&mut self, scale_modification: f64) { // diff --git a/src/hnswio.rs b/src/hnswio.rs index 331eb3a..ea845f5 100644 --- a/src/hnswio.rs +++ b/src/hnswio.rs @@ -326,10 +326,10 @@ impl HnswIo { } /// same as preceding, avoids the call to [set_options](Self::set_options()) - pub fn new_with_options(directory: &Path, basename: String, options: ReloadOptions) -> Self { + pub fn new_with_options(directory: &Path, basename: &str, options: ReloadOptions) -> Self { HnswIo { dir: directory.to_path_buf(), - basename, + basename: basename.to_string(), options, datamap: None, nb_point_loaded: Arc::new(AtomicUsize::new(0)), @@ -446,6 +446,7 @@ impl HnswIo { let data_in = &mut init.datafile; let graph_in = &mut init.graphfile; let description = init.descr; + info!("format version : {}", description.format_version); // In datafile , we must read MAGICDATAP and dimension and check let mut it_slice = [0u8; std::mem::size_of::()]; data_in.read_exact(&mut it_slice)?; @@ -495,6 +496,7 @@ impl HnswIo { if datamap_res.is_err() { error!("load_hnsw could not initialize mmap") } else { + info!("reload using mmap"); self.datamap = Some(datamap_res.unwrap()); } } @@ -981,6 +983,7 @@ pub fn load_description(io_in: &mut dyn Read) -> Result { let mut it_slice = [0u8; std::mem::size_of::()]; io_in.read_exact(&mut it_slice)?; descr.level_scale = f64::from_ne_bytes(it_slice); + info!(" level scale : {:.2e}", descr.level_scale); } // let mut it_slice = [0u8; std::mem::size_of::()];