pub(crate) fn advance_deletes(
    mut segment: Segment,
    segment_entry: &mut SegmentEntry,
    target_opstamp: Opstamp,
) -> Result<()> {
    {
        if segment_entry.meta().delete_opstamp() == Some(target_opstamp) {
            // We are already up-to-date here.
            return Ok(());
        }

        let segment_reader = SegmentReader::open(&segment)?;

        let max_doc = segment_reader.max_doc();
        let mut delete_bitset: BitSet = match segment_entry.delete_bitset() {
            Some(previous_delete_bitset) => (*previous_delete_bitset).clone(),
            None => BitSet::with_capacity(max_doc as usize),
        };

        let delete_cursor = segment_entry.delete_cursor();

        compute_deleted_bitset(
            &mut delete_bitset,
            &segment_reader,
            delete_cursor,
            &DocToOpstampMapping::None,
            target_opstamp,
        )?;

        // TODO optimize
        for doc in 0u32..max_doc {
            if segment_reader.is_deleted(doc) {
                delete_bitset.insert(doc as usize);
            }
        }

        let num_deleted_docs = delete_bitset.len();
        if num_deleted_docs > 0 {
            segment = segment.with_delete_meta(num_deleted_docs as u32, target_opstamp);
            let mut delete_file = segment.open_write(SegmentComponent::DELETE)?;
            write_delete_bitset(&delete_bitset, &mut delete_file)?;
            delete_file.terminate()?;
        }
    }
    segment_entry.set_meta(segment.meta().clone());
    Ok(())
}
/// Advance delete for the given segment up
/// to the target opstamp.
Advance delete for the given segment up
to the target opstamp.
Advance delete for the given segment up to the target opstamp .
pub(crate) fn advance_deletes(
    mut segment: Segment,
    segment_entry: &mut SegmentEntry,
    target_opstamp: Opstamp,
) -> Result<()> {
    {
        if segment_entry.meta().delete_opstamp() == Some(target_opstamp) {
            // We are already up-to-date here.
            return Ok(());
        }
        let segment_reader = SegmentReader::open(&segment)?;
        let max_doc = segment_reader.max_doc();
        let mut delete_bitset: BitSet = match segment_entry.delete_bitset() {
            Some(previous_delete_bitset) => (*previous_delete_bitset).clone(),
            None => BitSet::with_capacity(max_doc as usize),
        };
        let delete_cursor = segment_entry.delete_cursor();
        compute_deleted_bitset(
            &mut delete_bitset,
            &segment_reader,
            delete_cursor,
            &DocToOpstampMapping::None,
            target_opstamp,
        )?;
        // TODO optimize
        for doc in 0u32..max_doc {
            if segment_reader.is_deleted(doc) {
                delete_bitset.insert(doc as usize);
            }
        }
        let num_deleted_docs = delete_bitset.len();
        if num_deleted_docs > 0 {
            segment = segment.with_delete_meta(num_deleted_docs as u32, target_opstamp);
            let mut delete_file = segment.open_write(SegmentComponent::DELETE)?;
            write_delete_bitset(&delete_bitset, &mut delete_file)?;
            delete_file.terminate()?;
        }
    }
    segment_entry.set_meta(segment.meta().clone());
    Ok(())
}
pub ( crate ) fn advance_deletes ( mut segment : Segment , segment_entry : & mut SegmentEntry , target_opstamp : Opstamp , ) -> Result < ( ) > { { if segment_entry . meta ( ) . delete_opstamp ( ) == Some ( target_opstamp ) { // We are already up-to-date here. return Ok ( ( ) ) ; } let segment_reader = SegmentReader :: open ( & segment ) ? ; let max_doc = segment_reader . max_doc ( ) ; let mut delete_bitset : BitSet = match segment_entry . delete_bitset ( ) { Some ( previous_delete_bitset ) => ( * previous_delete_bitset ) . clone ( ) , None => BitSet :: with_capacity ( max_doc as usize ) , } ; let delete_cursor = segment_entry . delete_cursor ( ) ; compute_deleted_bitset ( & mut delete_bitset , & segment_reader , delete_cursor , & DocToOpstampMapping :: None , target_opstamp , ) ? ; // TODO optimize for doc in 0u32 .. max_doc { if segment_reader . is_deleted ( doc ) { delete_bitset . insert ( doc as usize ) ; } } let num_deleted_docs = delete_bitset . len ( ) ; if num_deleted_docs > 0 { segment = segment . with_delete_meta ( num_deleted_docs as u32 , target_opstamp ) ; let mut delete_file = segment . open_write ( SegmentComponent :: DELETE ) ? ; write_delete_bitset ( & delete_bitset , & mut delete_file ) ? ; delete_file . terminate ( ) ? ; } } segment_entry . set_meta ( segment . meta ( ) . clone ( ) ) ; Ok ( ( ) ) }
Advance delete for the given segment up
to the target opstamp.
Advance delete for the given segment up to the target opstamp .
segment
Segment
segment_entry
&mut SegmentEntry
target_opstamp
Opstamp
segment
Segment
segment_entry
&mut SegmentEntry
target_opstamp
Opstamp