Call spill_if_needed in for_each_document_change

This commit is contained in:
Louis Dureuil 2024-10-16 11:34:04 +02:00 committed by Clément Renault
parent 336c2816e3
commit f095477c0c
No known key found for this signature in database
GPG Key ID: F250A4C4E3AE5F5F

View File

@ -308,7 +308,7 @@ impl<
db_fields_ids_map,
new_fields_ids_map: fields_ids_map,
doc_alloc,
extractor_alloc,
extractor_alloc: &extractor_alloc.0,
data,
doc_allocs,
})
@ -327,6 +327,15 @@ pub trait Extractor<'extractor>: Sync {
context: &'doc DocumentChangeContext<Self::Data>,
) -> Result<()>;
/// Gives a chance to the data to spill itself on disk and reset the extractor allocator.
///
/// The Extractor and data implementations are responsible for checking that there are no live allocations before
/// attempting to reset the extractor allocator. Failure to uphold this invariant will result in a panic.
///
/// # Panics
///
/// - calls `extractor_alloc.borrow_mut()` while there are outstanding allocations referencing the `extractor_alloc`
#[inline]
fn spill_if_needed<'doc>(
&'doc self,
_data: &'doc Self::Data,
@ -423,6 +432,8 @@ where
// send back the doc_alloc in the pool
context.doc_allocs.get_or_default().0.set(std::mem::take(&mut context.doc_alloc));
extractor.spill_if_needed(&context.data, &context.extractor_alloc);
res
},
)