Skip to content

Commit c277bf5

Browse files
committed
reverted signature
1 parent 3f431c2 commit c277bf5

File tree

3 files changed

+20
-26
lines changed

3 files changed

+20
-26
lines changed

Diff for: src/flatten.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use std::cmp::Ordering;
1111

1212
use crate::hnsw;
1313
use anndists::dist::distances::Distance;
14-
use log::error;
1514
use hnsw::*;
15+
use log::error;
1616

1717
// an ordering of Neighbour of a Point
1818

Diff for: src/hnsw.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ use std::collections::binary_heap::BinaryHeap;
2222
#[allow(unused)]
2323
use std::collections::HashSet;
2424

25-
use log::{debug, info};
2625
use log::trace;
26+
use log::{debug, info};
2727

2828
pub use crate::filter::FilterT;
2929
use anndists::dist::distances::Distance;

Diff for: src/hnswio.rs

+18-24
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ struct LoadInit {
264264
///
265265
/// See example in tests::reload_with_mmap
266266
/// ```text
267-
/// let directory = PathBuf::from(".");
268-
/// let mut reloader = HnswIo::new(directory.clone(), String::from("mmapreloadtest"));
267+
/// let directory = Path::new(".");
268+
/// let mut reloader = HnswIo::new(directory, "mmapreloadtest");
269269
/// let options = ReloadOptions::default().set_mmap(true);
270270
/// reloader.set_options(options);
271271
/// let hnsw_loaded : Hnsw<f32,DistL1>= reloader.load_hnsw::<f32, DistL1>().unwrap();
@@ -321,9 +321,9 @@ impl HnswIo {
321321
}
322322

323323
/// same as preceding, avoids the call to [set_options](Self::set_options())
324-
pub fn new_with_options(directory: PathBuf, basename: String, options: ReloadOptions) -> Self {
324+
pub fn new_with_options(directory: &Path, basename: String, options: ReloadOptions) -> Self {
325325
HnswIo {
326-
dir: directory,
326+
dir: directory.to_path_buf(),
327327
basename,
328328
options,
329329
datamap: None,
@@ -336,15 +336,15 @@ impl HnswIo {
336336
/// It is an error to call set_values on an already defined Hswnio by any function other than [default](Self::default())
337337
pub fn set_values(
338338
&mut self,
339-
directory: PathBuf,
339+
directory: &Path,
340340
basename: String,
341341
options: ReloadOptions,
342-
) -> anyhow::Result<()> {
342+
) -> Result<()> {
343343
if self.initialized {
344344
return Err(anyhow!("Hnswio already initialized"));
345345
};
346346
//
347-
self.dir = directory;
347+
self.dir = directory.to_path_buf();
348348
self.basename = basename;
349349
self.options = options;
350350
self.datamap = None;
@@ -355,7 +355,7 @@ impl HnswIo {
355355
} // end of set_values
356356

357357
//
358-
fn init(&self) -> anyhow::Result<LoadInit> {
358+
fn init(&self) -> Result<LoadInit> {
359359
//
360360
info!("reloading from basename : {}", &self.basename);
361361
//
@@ -418,11 +418,12 @@ impl HnswIo {
418418
self.options = options;
419419
}
420420

421-
/// reload a previously dumped hnsw stucture
422-
pub fn load_hnsw<T, D>(&mut self) -> Result<Hnsw<T, D>>
423-
where
424-
T: 'static + Serialize + DeserializeOwned + Clone + Sized + Send + Sync + std::fmt::Debug,
425-
D: Distance<T> + Default + Send + Sync,
421+
/// reload a previously dumped hnsw structure
422+
pub fn load_hnsw<'b, 'a, T, D>(&'a mut self) -> Result<Hnsw<'b, T, D>>
423+
where
424+
T: 'static + Serialize + DeserializeOwned + Clone + Sized + Send + Sync + std::fmt::Debug,
425+
D: Distance<T> + Default + Send + Sync,
426+
'a: 'b,
426427
{
427428
//
428429
debug!("HnswIo::load_hnsw ");
@@ -745,9 +746,7 @@ impl HnswIo {
745746
//
746747
info!(
747748
"found entry point, origin_id {:?} , layer {:?}, rank in layer {:?} ",
748-
origin_id,
749-
layer,
750-
rank_in_l
749+
origin_id, layer, rank_in_l
751750
);
752751
let entry_point = Arc::clone(&points_by_layer[layer as usize][rank_in_l as usize]);
753752
info!(
@@ -970,8 +969,7 @@ pub fn load_description(io_in: &mut dyn Read) -> Result<Description> {
970969
descr.dimension = usize::from_ne_bytes(it_slice);
971970
info!(
972971
"nb_point {:?} dimension {:?} ",
973-
descr.nb_point,
974-
descr.dimension
972+
descr.nb_point, descr.dimension
975973
);
976974
// distance name
977975
let mut it_slice = [0u8; std::mem::size_of::<usize>()];
@@ -1184,10 +1182,7 @@ type PointGraphInfo = (usize, PointId, Vec<Vec<Neighbour>>);
11841182

11851183
// This function reads neighbourhood info and returns neighbourhood info.
11861184
// It suppose and requires that the file graph_in is just at beginning of info related to origin_id
1187-
fn load_point_graph(
1188-
graph_in: &mut dyn Read,
1189-
descr: &Description,
1190-
) -> Result<PointGraphInfo> {
1185+
fn load_point_graph(graph_in: &mut dyn Read, descr: &Description) -> Result<PointGraphInfo> {
11911186
//
11921187
trace!("in load_point_graph");
11931188
// read and check magic
@@ -1213,8 +1208,7 @@ fn load_point_graph(
12131208
let p_id = PointId(layer, rank_in_l);
12141209
debug!(
12151210
"in load_point_graph, got origin_id : {}, p_id : {:?}",
1216-
origin_id,
1217-
p_id
1211+
origin_id, p_id
12181212
);
12191213
//
12201214
// Now for each layer , read neighbours

0 commit comments

Comments
 (0)