@@ -17,15 +17,16 @@ use diskann_quantization::{
1717use diskann_vector:: PreprocessedDistanceFunction ;
1818
1919use super :: ConfigError ;
20- use crate :: TestCallCount ;
20+ use crate :: { bftree_insert , TestCallCount } ;
2121
2222pub struct QuantQueryComputer ( QueryComputer < GlobalAllocator > ) ;
2323
24- impl PreprocessedDistanceFunction < & [ u8 ] , f32 > for QuantQueryComputer {
25- fn evaluate_similarity ( & self , x : & [ u8 ] ) -> f32 {
26- self . 0
27- . evaluate_similarity ( Opaque :: new ( x) )
28- . expect ( "spherical query distance failed" )
24+ impl QuantQueryComputer {
25+ pub ( crate ) fn evaluate ( & self , x : & [ u8 ] ) -> ANNResult < f32 > {
26+ match self . 0 . evaluate_similarity ( Opaque :: new ( x) ) {
27+ Ok ( distance) => Ok ( distance) ,
28+ Err ( err) => Err ( ANNError :: new ( diskann:: ANNErrorKind :: IndexError , err) ) ,
29+ }
2930 }
3031}
3132
@@ -188,7 +189,7 @@ impl QuantVectorProvider {
188189 )
189190 . map_err ( |e| ANNError :: log_sq_error ( e) ) ?;
190191
191- self . quant_vector_index . insert ( key, quant_vector) ;
192+ bftree_insert ( & self . quant_vector_index , key, quant_vector) ? ;
192193
193194 Ok ( ( ) )
194195 }
@@ -209,7 +210,7 @@ impl QuantVectorProvider {
209210 // Update pq vector with id = i to v
210211 let key = bytemuck:: bytes_of ( & i) ;
211212
212- self . quant_vector_index . insert ( key, v) ;
213+ bftree_insert ( & self . quant_vector_index , key, v) ? ;
213214
214215 Ok ( ( ) )
215216 }
@@ -264,7 +265,7 @@ mod tests {
264265
265266 use diskann:: ANNErrorKind ;
266267 use diskann_quantization:: spherical:: iface:: Opaque ;
267- use diskann_vector:: { DistanceFunction , PreprocessedDistanceFunction } ;
268+ use diskann_vector:: DistanceFunction ;
268269 use tokio:: task:: JoinSet ;
269270
270271 use super :: * ;
@@ -331,7 +332,7 @@ mod tests {
331332
332333 // Query Computer — verify it returns finite distances.
333334 let c = provider. query_computer ( & [ -0.5f32 , -0.5 ] ) . unwrap ( ) ;
334- let dist = c. evaluate_similarity ( & provider. get_vector_sync ( 3 ) . unwrap ( ) ) ;
335+ let dist = c. evaluate ( & provider. get_vector_sync ( 3 ) . unwrap ( ) ) . unwrap ( ) ;
335336 assert ! ( dist. is_finite( ) , "query distance should be finite" ) ;
336337
337338 // Distance Computer — verify distances between compressed vectors are finite
0 commit comments