@@ -19,7 +19,10 @@ use diskann_benchmark_runner::{
1919 Benchmark , Checkpoint ,
2020} ;
2121use diskann_bftree:: { quant:: QuantVectorProvider , BfTreeProvider } ;
22- use diskann_providers:: model:: graph:: provider:: async_:: common:: Quantized ;
22+ use diskann_providers:: {
23+ model:: graph:: provider:: async_:: common:: Quantized ,
24+ storage:: { FileStorageProvider , SaveWith } ,
25+ } ;
2326use diskann_quantization:: alloc:: { AllocatorError , GlobalAllocator , Poly } ;
2427use diskann_quantization:: spherical:: {
2528 iface:: { self as spherical_iface, Quantizer } ,
@@ -204,18 +207,36 @@ impl Benchmark for StreamingSpherical {
204207 ) -> anyhow:: Result < Self :: Output > {
205208 writeln ! ( output, "{}" , input) ?;
206209
207- super :: streaming_utils:: run_streaming :: < f32 , _ > (
210+ let mut index_for_save: Option < BfTreeSQIndex > = None ;
211+
212+ let results = super :: streaming_utils:: run_streaming :: < f32 , _ > (
208213 input. runbook_params ( ) ,
209- |max_points| bftree_sq_streaming_impl ( input, max_points) ,
214+ |max_points| {
215+ let ( streamer, index) = bftree_sq_streaming_impl ( input, max_points) ?;
216+ index_for_save = Some ( index) ;
217+ Ok ( streamer)
218+ } ,
210219 output,
211- )
220+ ) ?;
221+
222+ // save the index if requested
223+ if let Some ( save_path) = input. build ( ) . save_path ( ) {
224+ let index = index_for_save. expect ( "index should have been set by make_streamer" ) ;
225+ crate :: utils:: tokio:: block_on (
226+ index
227+ . provider ( )
228+ . save_with ( & FileStorageProvider , & save_path. to_string ( ) ) ,
229+ ) ?;
230+ }
231+
232+ Ok ( results)
212233 }
213234}
214235
215236fn bftree_sq_streaming_impl (
216237 input : & BfTreeSphericalDynamicRun ,
217238 max_points : usize ,
218- ) -> anyhow:: Result < bigann:: WithData < f32 , u32 , Managed < f32 , StreamStats > > > {
239+ ) -> anyhow:: Result < ( bigann:: WithData < f32 , u32 , Managed < f32 , StreamStats > > , BfTreeSQIndex ) > {
219240 let topk = match input. search_phase ( ) {
220241 SearchPhase :: Topk ( topk) => topk,
221242 _ => anyhow:: bail!( "Only TopK is currently supported by the streaming index" ) ,
@@ -257,6 +278,7 @@ fn bftree_sq_streaming_impl(
257278 . compute ( data. as_view ( ) ) ?;
258279 let provider = BfTreeProvider :: new ( params, start_points. as_view ( ) , quantizer_poly) ?;
259280 let index = Arc :: new ( DiskANNIndex :: new ( config, provider, None ) ) ;
281+ let index_handle = index. clone ( ) ;
260282
261283 let num_threads_and_tasks = NonZeroUsize :: new ( input. build ( ) . num_threads ( ) ) . unwrap ( ) ;
262284 let managed_stream = BfTreeSQStream {
@@ -283,5 +305,5 @@ fn bftree_sq_streaming_impl(
283305 ) ?) )
284306 } ) ;
285307
286- Ok ( layered)
308+ Ok ( ( layered, index_handle ) )
287309}
0 commit comments