@@ -32,6 +32,11 @@ use std::fmt::Debug;
3232use crate :: search:: assert_layer_invariants;
3333use crate :: { priority_queue:: PriorityQueue , search:: match_within_epsilon} ;
3434
35+ const PRIMES : [ usize ; 40 ] = [
36+ 2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 , 37 , 41 , 43 , 47 , 53 , 59 , 61 , 67 , 71 , 73 , 79 , 83 , 89 , 97 ,
37+ 101 , 103 , 107 , 109 , 113 , 127 , 131 , 137 , 139 , 149 , 151 , 157 , 163 , 167 , 173 ,
38+ ] ;
39+
3540pub enum WrappedBorrowable < ' a , T : ?Sized , Borrowable : Deref < Target = T > + ' a > {
3641 Left ( Borrowable ) ,
3742 Right ( & ' a T ) ,
@@ -158,12 +163,11 @@ impl<C> Layer<C> {
158163 }
159164
160165 pub fn routing_nodes ( & self , nodeid : NodeId , sp : SearchParameters ) -> Vec < NodeId > {
161- let primes = [ 1 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 , 37 ] ;
162166 // Calculate using the circulants
163167 let size = self . node_count ( ) ;
164- primes
168+ PRIMES
165169 . iter ( )
166- . take ( sp. grid_network_dimension )
170+ . take ( sp. circulant_parameter_count )
167171 . map ( |prime| NodeId ( ( nodeid. 0 + prime) % size) )
168172 . filter ( |i| * i != nodeid)
169173 . collect ( )
@@ -2251,7 +2255,9 @@ mod tests {
22512255 fn test_recall ( ) {
22522256 let size = 10_000 ;
22532257 let dimension = 1536 ;
2254- let bp = BuildParameters :: default ( ) ;
2258+ let mut bp = BuildParameters :: default ( ) ;
2259+ bp. initial_partition_search . circulant_parameter_count = 0 ;
2260+ bp. optimization . search . circulant_parameter_count = 0 ;
22552261 let mut hnsw: Hnsw < BigComparator > =
22562262 bigvec:: make_random_hnsw_with_build_parameters ( size, dimension, bp) ;
22572263 do_test_recall ( & hnsw, 0.9 ) ;
@@ -2487,7 +2493,8 @@ mod tests {
24872493 let cc = Comparator32 { data : vecs. into ( ) } ;
24882494 let vids: Vec < VectorId > = ( 0 ..size) . map ( VectorId ) . collect ( ) ;
24892495 let mut bp = BuildParameters :: default ( ) ;
2490- bp. optimization . search . grid_network_dimension = 0 ;
2496+ bp. initial_partition_search . circulant_parameter_count = 0 ;
2497+ bp. optimization . search . circulant_parameter_count = 0 ;
24912498 let mut hnsw: Hnsw < Comparator32 > = Hnsw :: generate ( cc, vids, bp, & mut ( ) ) ;
24922499 hnsw. improve_index ( bp, None , & mut ( ) ) ;
24932500 panic ! ( )
0 commit comments