From 8933d870312fd6733625477e9ff092d36bd97e0d Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Mon, 1 Sep 2025 12:10:36 +0200 Subject: [PATCH] Make backend change cancelable --- crates/milli/src/vector/store.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/milli/src/vector/store.rs b/crates/milli/src/vector/store.rs index c39596da2..a93ae3043 100644 --- a/crates/milli/src/vector/store.rs +++ b/crates/milli/src/vector/store.rs @@ -104,7 +104,15 @@ impl VectorStore { } } - pub fn change_backend(&mut self, wtxn: &mut RwTxn, progress: Progress) -> crate::Result<()> { + pub fn change_backend( + &mut self, + wtxn: &mut RwTxn, + progress: Progress, + must_stop_processing: MSP, + ) -> crate::Result<()> + where + MSP: Fn() -> bool + Sync + Send, + { if self.backend == VectorStoreBackend::Arroy { self.backend = VectorStoreBackend::Hannoy; if self.quantized { @@ -139,6 +147,7 @@ impl VectorStore { let mut rng = rand::rngs::StdRng::from_entropy(); let writer = hannoy::Writer::new(self._hannoy_angular_db(), index, dimensions); let mut builder = writer.builder(&mut rng).progress(progress.clone()); + builder.cancel(must_stop_processing); builder.prepare_arroy_conversion(wtxn)?; builder.build::(wtxn)?; }