diff --git a/src/api.rs b/src/api.rs index abfbfe6..5d75fbc 100644 --- a/src/api.rs +++ b/src/api.rs @@ -36,7 +36,7 @@ pub trait AnnT { fn file_dump(&self, path: &Path, file_basename: &str) -> anyhow::Result; } -impl<'b, T, D> AnnT for Hnsw<'b, T, D> +impl AnnT for Hnsw<'_, T, D> where T: Serialize + DeserializeOwned + Clone + Send + Sync, D: Distance + Send + Sync, @@ -63,12 +63,9 @@ where self.parallel_search(data, knbn, ef_s) } - /// The main entry point to do a dump. - /// It will generate two files one for the graph part of the data. The other for the real data points of the structure. - /// The names of file are $filename.hnsw.graph for the graph and $filename.hnsw.data. - /// - - /// + // The main entry point to do a dump. + // It will generate two files one for the graph part of the data. The other for the real data points of the structure. + // The names of file are $filename.hnsw.graph for the graph and $filename.hnsw.data. fn file_dump(&self, path: &Path, file_basename: &str) -> anyhow::Result { info!("In Hnsw::file_dump"); // diff --git a/src/datamap.rs b/src/datamap.rs index 833e182..3bce7c3 100644 --- a/src/datamap.rs +++ b/src/datamap.rs @@ -295,7 +295,7 @@ impl DataMap { /// returns Keys in order they are in the file, thus optimizing file/memory access. /// Note that in case of parallel insertion this can be different from insertion odrer. pub fn get_dataid_iter(&self) -> indexmap::map::Keys { - return self.hmap.keys(); + self.hmap.keys() } /// returns full data type name diff --git a/src/flatten.rs b/src/flatten.rs index 2298306..d204e0c 100644 --- a/src/flatten.rs +++ b/src/flatten.rs @@ -107,7 +107,7 @@ impl FlatNeighborhood { } } // end impl block for FlatNeighborhood -impl<'b, T: Clone + Send + Sync, D: Distance + Send + Sync> From<&Hnsw<'b, T, D>> +impl + Send + Sync> From<&Hnsw<'_, T, D>> for FlatNeighborhood { /// extract from the Hnsw strucure a hashtable mapping original DataId into a FlatPoint structure gathering its neighbourhood information. diff --git a/src/hnsw.rs b/src/hnsw.rs index e8d61a8..e03bb19 100644 --- a/src/hnsw.rs +++ b/src/hnsw.rs @@ -75,7 +75,7 @@ impl PartialOrd for PointIdWithOrder { } // end cmp } // end impl PartialOrd -impl<'b, T: Send + Sync + Clone + Copy> From<&PointWithOrder<'b, T>> for PointIdWithOrder { +impl From<&PointWithOrder<'_, T>> for PointIdWithOrder { fn from(point: &PointWithOrder) -> PointIdWithOrder { PointIdWithOrder::new(point.point_ref.p_id, point.dist_to_ref) } @@ -270,23 +270,23 @@ pub(crate) struct PointWithOrder<'b, T: Clone + Send + Sync> { dist_to_ref: f32, } -impl<'b, T: Clone + Send + Sync> PartialEq for PointWithOrder<'b, T> { +impl PartialEq for PointWithOrder<'_, T> { fn eq(&self, other: &PointWithOrder) -> bool { self.dist_to_ref == other.dist_to_ref } // end eq } -impl<'b, T: Clone + Send + Sync> Eq for PointWithOrder<'b, T> {} +impl Eq for PointWithOrder<'_, T> {} // order points by distance to self. #[allow(clippy::non_canonical_partial_ord_impl)] -impl<'b, T: Clone + Send + Sync> PartialOrd for PointWithOrder<'b, T> { +impl PartialOrd for PointWithOrder<'_, T> { fn partial_cmp(&self, other: &PointWithOrder) -> Option { self.dist_to_ref.partial_cmp(&other.dist_to_ref) } // end cmp } // end impl PartialOrd -impl<'b, T: Clone + Send + Sync> Ord for PointWithOrder<'b, T> { +impl Ord for PointWithOrder<'_, T> { fn cmp(&self, other: &PointWithOrder) -> Ordering { if !self.dist_to_ref.is_nan() && !other.dist_to_ref.is_nan() { self.dist_to_ref.partial_cmp(&other.dist_to_ref).unwrap() @@ -375,7 +375,7 @@ impl LayerGenerator { log::info!("using scale for sampling levels : {:.2e}", self.scale); } - /// + // fn get_level_scale(&self) -> f64 { self.scale } @@ -406,7 +406,7 @@ pub struct PointIndexation<'b, T: Clone + Send + Sync> { // A point indexation may contain circular references. To deallocate these after a point indexation goes out of scope, // implement the Drop trait. -impl<'b, T: Clone + Send + Sync> Drop for PointIndexation<'b, T> { +impl Drop for PointIndexation<'_, T> { fn drop(&mut self) { let cpu_start = ProcessTime::now(); let sys_now = SystemTime::now(); @@ -643,7 +643,7 @@ impl<'a, 'b, T: Clone + Send + Sync> IterPoint<'a, 'b, T> { } // end of block impl IterPoint /// iterator for layer 0 to upper layer. -impl<'a, 'b, T: Clone + Send + Sync> Iterator for IterPoint<'a, 'b, T> { +impl<'b, T: Clone + Send + Sync> Iterator for IterPoint<'_, 'b, T> { type Item = Arc>; // fn next(&mut self) -> Option { @@ -711,7 +711,7 @@ impl<'a, 'b, T: Clone + Send + Sync> IterPointLayer<'a, 'b, T> { } // end of block impl IterPointLayer /// iterator for layer 0 to upper layer. -impl<'a, 'b, T: Clone + Send + Sync + 'b> Iterator for IterPointLayer<'a, 'b, T> { +impl<'b, T: Clone + Send + Sync + 'b> Iterator for IterPointLayer<'_, 'b, T> { type Item = Arc>; // fn next(&mut self) -> Option { diff --git a/src/hnswio.rs b/src/hnswio.rs index b777b11..331eb3a 100644 --- a/src/hnswio.rs +++ b/src/hnswio.rs @@ -312,6 +312,7 @@ pub struct HnswIo { impl HnswIo { /// - directory is directory containing the dumped files, /// - basename is used to build $basename.hnsw.data and $basename.hnsw.graph + /// /// default is to use default ReloadOptions. pub fn new(directory: &Path, basename: &str) -> Self { HnswIo { @@ -1055,7 +1056,7 @@ pub fn load_description(io_in: &mut dyn Read) -> Result { /// 1. The value MAGICDATAP (u32) /// 2. origin_id as a u64 /// 3. The vector of data (the length is known from Description) - +/// fn dump_point( point: &Point, mode: DumpMode, @@ -1295,7 +1296,7 @@ fn load_point_graph(graph_in: &mut dyn Read, descr: &Description) -> Result HnswIoT for PointIndexation<'b, T> { +impl HnswIoT for PointIndexation<'_, T> { fn dump(&self, mode: DumpMode, dumpinit: &mut DumpInit) -> Result { let graphout = &mut dumpinit.graph_out; let dataout = &mut dumpinit.data_out; @@ -1343,10 +1344,9 @@ impl<'b, T: Serialize + DeserializeOwned + Clone + Send + Sync> HnswIoT for Poin // impl< - 'b, T: Serialize + DeserializeOwned + Clone + Sized + Send + Sync, D: Distance + Send + Sync, - > HnswIoT for Hnsw<'b, T, D> + > HnswIoT for Hnsw<'_, T, D> { /// The dump method for hnsw. /// - graphout is a BufWriter dedicated to the dump of the graph part of Hnsw diff --git a/src/libext.rs b/src/libext.rs index c3a369b..76bfd62 100644 --- a/src/libext.rs +++ b/src/libext.rs @@ -22,6 +22,8 @@ use crate::hnswio::*; /// returns a pointer to a Hnswio /// args corresponds to string giving base filename of dump, supposed to be in current directory +/// # Safety +/// pointer must be char* pointer to the string #[no_mangle] pub unsafe extern "C" fn get_hnswio(flen: u64, name: *const u8) -> *const HnswIo { let slice = unsafe { std::slice::from_raw_parts(name, flen as usize) }; @@ -101,7 +103,6 @@ super::declare_myapi_type!(HnswApif64, f64); //=================================================================================================== // These are the macros to generate trait implementation for useful numeric types #[allow(unused_macros)] - macro_rules! generate_insert( ($function_name:ident, $api_name:ty, $type_val:ty) => ( /// # Safety @@ -281,7 +282,7 @@ macro_rules! generate_loadhnsw( /// function to reload from a previous dump (knowing data type and distance used). /// This function takes as argument a pointer to Hnswio_api that drives the reloading. /// The pointer is provided by the function [get_hnswio()](get_hnswio). - /// + /// # Safety /// The function is unsafe because it dereferences a raw pointer /// #[no_mangle]