From e73e07f3f48adec60c1305ae6f9861f55d9a70f9 Mon Sep 17 00:00:00 2001 From: Eduardo Pinho Date: Sun, 24 Mar 2024 14:06:18 +0000 Subject: [PATCH 1/3] Reorganize imports --- src/index/autotune.rs | 4 ---- src/index/flat.rs | 5 ----- src/index/ivf_flat.rs | 4 ---- src/index/pretransform.rs | 4 ---- src/index/refine_flat.rs | 4 ---- src/index/scalar_quantizer.rs | 4 ---- 6 files changed, 25 deletions(-) diff --git a/src/index/autotune.rs b/src/index/autotune.rs index 131f8fa..37628a3 100644 --- a/src/index/autotune.rs +++ b/src/index/autotune.rs @@ -1,11 +1,7 @@ use std::ffi; -use std::ptr; use super::*; -use crate::error::{Error, Result}; -use crate::faiss_try; - /// Uses a-priori knowledge on the Faiss indexes to extract tunable parameters. pub struct ParameterSpace { inner: *mut FaissParameterSpace, diff --git a/src/index/flat.rs b/src/index/flat.rs index 99a4573..29af56a 100644 --- a/src/index/flat.rs +++ b/src/index/flat.rs @@ -2,11 +2,6 @@ use super::*; -use crate::error::{Error, Result}; -use crate::faiss_try; -use std::mem; -use std::ptr; - /// Alias for the native implementation of a flat index. pub type FlatIndex = FlatIndexImpl; diff --git a/src/index/ivf_flat.rs b/src/index/ivf_flat.rs index 8aff588..f8f71ec 100644 --- a/src/index/ivf_flat.rs +++ b/src/index/ivf_flat.rs @@ -2,11 +2,7 @@ use super::*; -use crate::error::Result; -use crate::faiss_try; -use std::mem; use std::os::raw::{c_char, c_int}; -use std::ptr; /// Alias for the native implementation of a flat index. pub type IVFFlatIndex = IVFFlatIndexImpl; diff --git a/src/index/pretransform.rs b/src/index/pretransform.rs index e71d5ad..69780e8 100644 --- a/src/index/pretransform.rs +++ b/src/index/pretransform.rs @@ -2,13 +2,9 @@ use super::*; -use crate::error::{Error, Result}; -use crate::faiss_try; use crate::vector_transform::NativeVectorTransform; use std::marker::PhantomData; -use std::mem; use std::os::raw::c_int; -use std::ptr; /// Alias for the native implementation of a PreTransform index. pub type PreTransformIndex = PreTransformIndexImpl; diff --git a/src/index/refine_flat.rs b/src/index/refine_flat.rs index f0dd519..b87a65a 100644 --- a/src/index/refine_flat.rs +++ b/src/index/refine_flat.rs @@ -2,12 +2,8 @@ use super::*; -use crate::error::Result; -use crate::faiss_try; use std::marker::PhantomData; -use std::mem; use std::os::raw::c_int; -use std::ptr; /// Alias for the native implementation of a index. pub type RefineFlatIndex = RefineFlatIndexImpl; diff --git a/src/index/scalar_quantizer.rs b/src/index/scalar_quantizer.rs index 2056aac..468dfdd 100644 --- a/src/index/scalar_quantizer.rs +++ b/src/index/scalar_quantizer.rs @@ -2,12 +2,8 @@ use super::*; -use crate::error::Result; -use crate::faiss_try; use std::marker::PhantomData; -use std::mem; use std::os::raw::c_int; -use std::ptr; /// Alias for the native implementation of a scalar quantizer index. pub type ScalarQuantizerIndex = ScalarQuantizerIndexImpl; From 5560746ac4e415bfa4bfdf929416725d53d9cd9f Mon Sep 17 00:00:00 2001 From: Eduardo Pinho Date: Sun, 24 Mar 2024 14:06:40 +0000 Subject: [PATCH 2/3] Clippy lint fix: multiple_bound_locations --- src/cluster.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cluster.rs b/src/cluster.rs index e2526af..722d1a9 100644 --- a/src/cluster.rs +++ b/src/cluster.rs @@ -227,9 +227,9 @@ impl Clustering { * Perform the clustering algorithm with the given data and index. * The index is used during the assignment stage. */ - pub fn train(&mut self, x: &[f32], index: &mut I) -> Result<()> + pub fn train(&mut self, x: &[f32], index: &mut I) -> Result<()> where - I: NativeIndex, + I: ?Sized + NativeIndex, { unsafe { let n = x.len() / self.d() as usize; From bbd63f9a74a0a7008c0c586cdfccf34c2cfbb992 Mon Sep 17 00:00:00 2001 From: Eduardo Pinho Date: Wed, 27 Mar 2024 11:41:18 +0000 Subject: [PATCH 3/3] Reorganize imports in tests --- src/index/autotune.rs | 2 +- src/index/pretransform.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/index/autotune.rs b/src/index/autotune.rs index 37628a3..307048e 100644 --- a/src/index/autotune.rs +++ b/src/index/autotune.rs @@ -63,7 +63,7 @@ impl Drop for ParameterSpace { #[cfg(test)] mod tests { - use super::*; + use crate::index::autotune::ParameterSpace; use crate::index::index_factory; use crate::metric::MetricType; diff --git a/src/index/pretransform.rs b/src/index/pretransform.rs index 69780e8..7ec7741 100644 --- a/src/index/pretransform.rs +++ b/src/index/pretransform.rs @@ -294,7 +294,8 @@ where #[cfg(test)] mod tests { - use super::*; + use crate::index::pretransform::PreTransformIndexImpl; + use crate::index::UpcastIndex as _; use crate::metric::MetricType; use crate::{ index::{index_factory, ConcurrentIndex, Idx, Index},