@@ -55,8 +55,14 @@ impl<S: G> IvfNaive<S> {
5555 self . mmap . raw . payload ( i)
5656 }
5757
58- pub fn search ( & self , k : usize , vector : & [ S :: Scalar ] , filter : & mut impl Filter ) -> Heap {
59- search ( & self . mmap , k, vector, filter)
58+ pub fn search (
59+ & self ,
60+ k : usize ,
61+ vector : & [ S :: Scalar ] ,
62+ nprobe : u32 ,
63+ filter : & mut impl Filter ,
64+ ) -> Heap {
65+ search ( & self . mmap , k, vector, nprobe, filter)
6066 }
6167}
6268
@@ -70,7 +76,6 @@ pub struct IvfRam<S: G> {
7076 dims : u16 ,
7177 // ----------------------
7278 nlist : u32 ,
73- nprobe : u32 ,
7479 // ----------------------
7580 centroids : Vec2 < S > ,
7681 heads : Vec < AtomicU32 > ,
@@ -87,7 +92,6 @@ pub struct IvfMmap<S: G> {
8792 dims : u16 ,
8893 // ----------------------
8994 nlist : u32 ,
90- nprobe : u32 ,
9195 // ----------------------
9296 centroids : MmapArray < S :: Scalar > ,
9397 heads : MmapArray < u32 > ,
@@ -116,7 +120,6 @@ pub fn make<S: G>(
116120 least_iterations,
117121 iterations,
118122 nlist,
119- nprobe,
120123 nsample,
121124 quantization : quantization_opts,
122125 } = options. indexing . clone ( ) . unwrap_ivf ( ) ;
@@ -186,7 +189,6 @@ pub fn make<S: G>(
186189 centroids,
187190 heads,
188191 nexts,
189- nprobe,
190192 nlist,
191193 dims,
192194 }
@@ -212,7 +214,6 @@ pub fn save<S: G>(mut ram: IvfRam<S>, path: PathBuf) -> IvfMmap<S> {
212214 quantization : ram. quantization ,
213215 dims : ram. dims ,
214216 nlist : ram. nlist ,
215- nprobe : ram. nprobe ,
216217 centroids,
217218 heads,
218219 nexts,
@@ -230,13 +231,12 @@ pub fn load<S: G>(path: PathBuf, options: IndexOptions) -> IvfMmap<S> {
230231 let centroids = MmapArray :: open ( path. join ( "centroids" ) ) ;
231232 let heads = MmapArray :: open ( path. join ( "heads" ) ) ;
232233 let nexts = MmapArray :: open ( path. join ( "nexts" ) ) ;
233- let IvfIndexingOptions { nlist, nprobe , .. } = options. indexing . unwrap_ivf ( ) ;
234+ let IvfIndexingOptions { nlist, .. } = options. indexing . unwrap_ivf ( ) ;
234235 IvfMmap {
235236 raw,
236237 quantization,
237238 dims : options. vector . dims ,
238239 nlist,
239- nprobe,
240240 centroids,
241241 heads,
242242 nexts,
@@ -247,11 +247,12 @@ pub fn search<S: G>(
247247 mmap : & IvfMmap < S > ,
248248 k : usize ,
249249 vector : & [ S :: Scalar ] ,
250+ nprobe : u32 ,
250251 filter : & mut impl Filter ,
251252) -> Heap {
252253 let mut target = vector. to_vec ( ) ;
253254 S :: elkan_k_means_normalize ( & mut target) ;
254- let mut lists = Heap :: new ( mmap . nprobe as usize ) ;
255+ let mut lists = Heap :: new ( nprobe as usize ) ;
255256 for i in 0 ..mmap. nlist {
256257 let centroid = mmap. centroids ( i) ;
257258 let distance = S :: elkan_k_means_distance ( & target, centroid) ;
0 commit comments