@@ -32,6 +32,11 @@ use std::fmt::Debug;
32
32
use crate :: search:: assert_layer_invariants;
33
33
use crate :: { priority_queue:: PriorityQueue , search:: match_within_epsilon} ;
34
34
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
+
35
40
pub enum WrappedBorrowable < ' a , T : ?Sized , Borrowable : Deref < Target = T > + ' a > {
36
41
Left ( Borrowable ) ,
37
42
Right ( & ' a T ) ,
@@ -158,12 +163,11 @@ impl<C> Layer<C> {
158
163
}
159
164
160
165
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 ] ;
162
166
// Calculate using the circulants
163
167
let size = self . node_count ( ) ;
164
- primes
168
+ PRIMES
165
169
. iter ( )
166
- . take ( sp. grid_network_dimension )
170
+ . take ( sp. circulant_parameter_count )
167
171
. map ( |prime| NodeId ( ( nodeid. 0 + prime) % size) )
168
172
. filter ( |i| * i != nodeid)
169
173
. collect ( )
@@ -2251,7 +2255,9 @@ mod tests {
2251
2255
fn test_recall ( ) {
2252
2256
let size = 10_000 ;
2253
2257
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 ;
2255
2261
let mut hnsw: Hnsw < BigComparator > =
2256
2262
bigvec:: make_random_hnsw_with_build_parameters ( size, dimension, bp) ;
2257
2263
do_test_recall ( & hnsw, 0.9 ) ;
@@ -2487,7 +2493,8 @@ mod tests {
2487
2493
let cc = Comparator32 { data : vecs. into ( ) } ;
2488
2494
let vids: Vec < VectorId > = ( 0 ..size) . map ( VectorId ) . collect ( ) ;
2489
2495
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 ;
2491
2498
let mut hnsw: Hnsw < Comparator32 > = Hnsw :: generate ( cc, vids, bp, & mut ( ) ) ;
2492
2499
hnsw. improve_index ( bp, None , & mut ( ) ) ;
2493
2500
panic ! ( )
0 commit comments