factor out to function

This commit is contained in:
Louis Dureuil
2025-12-08 17:37:28 +01:00
parent d92cc8afa5
commit d812b12be6

View File

@@ -226,6 +226,26 @@ impl IndexScheduler {
total_moved_documents += documents_to_delete.len(); total_moved_documents += documents_to_delete.len();
self.delete_documents_from_index(progress, must_stop_processing, &indexer_alloc, index_uid, index, &err, index_rtxn, documents_to_delete, fields_ids_map)
},
)?;
Ok(total_moved_documents)
}
#[allow(clippy::too_many_arguments)]
fn delete_documents_from_index(
&self,
progress: &Progress,
must_stop_processing: &super::MustStopProcessing,
indexer_alloc: &Bump,
index_uid: &str,
index: &milli::Index,
err: &impl Fn(milli::Error) -> Error,
index_rtxn: milli::heed::RoTxn<'_, milli::heed::WithoutTls>,
documents_to_delete: RoaringBitmap,
fields_ids_map: milli::FieldsIdsMap,
) -> std::result::Result<(), Error> {
let mut new_fields_ids_map = fields_ids_map.clone(); let mut new_fields_ids_map = fields_ids_map.clone();
// candidates not empty => index not empty => a primary key is set // candidates not empty => index not empty => a primary key is set
@@ -267,8 +287,7 @@ impl IndexScheduler {
// update stats // update stats
let mut mapper_wtxn = self.env.write_txn()?; let mut mapper_wtxn = self.env.write_txn()?;
let stats = let stats = crate::index_mapper::IndexStats::new(index, &index_wtxn).map_err(err)?;
crate::index_mapper::IndexStats::new(index, &index_wtxn).map_err(err)?;
self.index_mapper.store_stats_of(&mut mapper_wtxn, index_uid, &stats)?; self.index_mapper.store_stats_of(&mut mapper_wtxn, index_uid, &stats)?;
index_wtxn.commit()?; index_wtxn.commit()?;
@@ -276,9 +295,5 @@ impl IndexScheduler {
mapper_wtxn.commit()?; mapper_wtxn.commit()?;
Ok(()) Ok(())
},
)?;
Ok(total_moved_documents)
} }
} }