pub fn open(segment: &Segment) -> crate::Result<SegmentReader> {
        let termdict_source = segment.open_read(SegmentComponent::TERMS)?;
        let termdict_composite = CompositeFile::open(&termdict_source)?;

        let store_source = segment.open_read(SegmentComponent::STORE)?;

        fail_point!("SegmentReader::open#middle");

        let postings_source = segment.open_read(SegmentComponent::POSTINGS)?;
        let postings_composite = CompositeFile::open(&postings_source)?;

        let positions_composite = {
            if let Ok(source) = segment.open_read(SegmentComponent::POSITIONS) {
                CompositeFile::open(&source)?
            } else {
                CompositeFile::empty()
            }
        };

        let positions_idx_composite = {
            if let Ok(source) = segment.open_read(SegmentComponent::POSITIONSSKIP) {
                CompositeFile::open(&source)?
            } else {
                CompositeFile::empty()
            }
        };

        let schema = segment.schema();

        let fast_fields_data = segment.open_read(SegmentComponent::FASTFIELDS)?;
        let fast_fields_composite = CompositeFile::open(&fast_fields_data)?;
        let fast_field_readers =
            Arc::new(FastFieldReaders::load_all(&schema, &fast_fields_composite)?);

        let fieldnorm_data = segment.open_read(SegmentComponent::FIELDNORMS)?;
        let fieldnorm_readers = FieldNormReaders::open(fieldnorm_data)?;

        let delete_bitset_opt = if segment.meta().has_deletes() {
            let delete_data = segment.open_read(SegmentComponent::DELETE)?;
            Some(DeleteBitSet::open(delete_data))
        } else {
            None
        };

        Ok(SegmentReader {
            inv_idx_reader_cache: Arc::new(RwLock::new(HashMap::new())),
            max_doc: segment.meta().max_doc(),
            num_docs: segment.meta().num_docs(),
            termdict_composite,
            postings_composite,
            fast_fields_readers: fast_field_readers,
            fieldnorm_readers,
            segment_id: segment.id(),
            store_source,
            delete_bitset_opt,
            positions_composite,
            positions_idx_composite,
            schema,
        })
    }
/// Open a new segment for reading.
Open a new segment for reading.
Open a new segment for reading .
pub fn open(segment: &Segment) -> crate::Result<SegmentReader> {
        let termdict_source = segment.open_read(SegmentComponent::TERMS)?;
        let termdict_composite = CompositeFile::open(&termdict_source)?;
        let store_source = segment.open_read(SegmentComponent::STORE)?;
        fail_point!("SegmentReader::open#middle");
        let postings_source = segment.open_read(SegmentComponent::POSTINGS)?;
        let postings_composite = CompositeFile::open(&postings_source)?;
        let positions_composite = {
            if let Ok(source) = segment.open_read(SegmentComponent::POSITIONS) {
                CompositeFile::open(&source)?
            } else {
                CompositeFile::empty()
            }
        };
        let positions_idx_composite = {
            if let Ok(source) = segment.open_read(SegmentComponent::POSITIONSSKIP) {
                CompositeFile::open(&source)?
            } else {
                CompositeFile::empty()
            }
        };
        let schema = segment.schema();
        let fast_fields_data = segment.open_read(SegmentComponent::FASTFIELDS)?;
        let fast_fields_composite = CompositeFile::open(&fast_fields_data)?;
        let fast_field_readers =
            Arc::new(FastFieldReaders::load_all(&schema, &fast_fields_composite)?);
        let fieldnorm_data = segment.open_read(SegmentComponent::FIELDNORMS)?;
        let fieldnorm_readers = FieldNormReaders::open(fieldnorm_data)?;
        let delete_bitset_opt = if segment.meta().has_deletes() {
            let delete_data = segment.open_read(SegmentComponent::DELETE)?;
            Some(DeleteBitSet::open(delete_data))
        } else {
            None
        };
        Ok(SegmentReader {
            inv_idx_reader_cache: Arc::new(RwLock::new(HashMap::new())),
            max_doc: segment.meta().max_doc(),
            num_docs: segment.meta().num_docs(),
            termdict_composite,
            postings_composite,
            fast_fields_readers: fast_field_readers,
            fieldnorm_readers,
            segment_id: segment.id(),
            store_source,
            delete_bitset_opt,
            positions_composite,
            positions_idx_composite,
            schema,
        })
    }
pub fn open ( segment : & Segment ) -> crate :: Result < SegmentReader > { let termdict_source = segment . open_read ( SegmentComponent :: TERMS ) ? ; let termdict_composite = CompositeFile :: open ( & termdict_source ) ? ; let store_source = segment . open_read ( SegmentComponent :: STORE ) ? ; fail_point ! ( " " ) ; let postings_source = segment . open_read ( SegmentComponent :: POSTINGS ) ? ; let postings_composite = CompositeFile :: open ( & postings_source ) ? ; let positions_composite = { if let Ok ( source ) = segment . open_read ( SegmentComponent :: POSITIONS ) { CompositeFile :: open ( & source ) ? } else { CompositeFile :: empty ( ) } } ; let positions_idx_composite = { if let Ok ( source ) = segment . open_read ( SegmentComponent :: POSITIONSSKIP ) { CompositeFile :: open ( & source ) ? } else { CompositeFile :: empty ( ) } } ; let schema = segment . schema ( ) ; let fast_fields_data = segment . open_read ( SegmentComponent :: FASTFIELDS ) ? ; let fast_fields_composite = CompositeFile :: open ( & fast_fields_data ) ? ; let fast_field_readers = Arc :: new ( FastFieldReaders :: load_all ( & schema , & fast_fields_composite ) ? ) ; let fieldnorm_data = segment . open_read ( SegmentComponent :: FIELDNORMS ) ? ; let fieldnorm_readers = FieldNormReaders :: open ( fieldnorm_data ) ? ; let delete_bitset_opt = if segment . meta ( ) . has_deletes ( ) { let delete_data = segment . open_read ( SegmentComponent :: DELETE ) ? ; Some ( DeleteBitSet :: open ( delete_data ) ) } else { None } ; Ok ( SegmentReader { inv_idx_reader_cache : Arc :: new ( RwLock :: new ( HashMap :: new ( ) ) ) , max_doc : segment . meta ( ) . max_doc ( ) , num_docs : segment . meta ( ) . num_docs ( ) , termdict_composite , postings_composite , fast_fields_readers : fast_field_readers , fieldnorm_readers , segment_id : segment . id ( ) , store_source , delete_bitset_opt , positions_composite , positions_idx_composite , schema , } ) }
Open a new segment for reading.
Open a new segment for reading .
segment
&Segment
segment
&Segment