Struct tantivy::SegmentReader
source · [−]pub struct SegmentReader { /* private fields */ }
Expand description
Entry point to access all of the datastructures of the Segment
- term dictionary
- postings
- store
- fast field readers
- field norm reader
The segment reader has a very low memory footprint, as close to all of the memory data is mmapped.
Implementations
sourceimpl SegmentReader
impl SegmentReader
sourcepub fn max_doc(&self) -> DocId
pub fn max_doc(&self) -> DocId
Returns the highest document id ever attributed in this segment + 1.
sourcepub fn num_docs(&self) -> DocId
pub fn num_docs(&self) -> DocId
Returns the number of alive documents. Deleted documents are not counted.
sourcepub fn num_deleted_docs(&self) -> DocId
pub fn num_deleted_docs(&self) -> DocId
Return the number of documents that have been deleted in the segment.
sourcepub fn has_deletes(&self) -> bool
pub fn has_deletes(&self) -> bool
Returns true if some of the documents of the segment have been deleted.
sourcepub fn fast_fields(&self) -> &FastFieldReaders
pub fn fast_fields(&self) -> &FastFieldReaders
Accessor to a segment’s fast field reader given a field.
Returns the u64 fast value reader if the field is a u64 field indexed as “fast”.
Return a FastFieldNotAvailableError if the field is not declared as a fast field in the schema.
Panics
May panic if the index is corrupted.
sourcepub fn facet_reader(&self, field: Field) -> Result<FacetReader>
pub fn facet_reader(&self, field: Field) -> Result<FacetReader>
Accessor to the FacetReader
associated with a given Field
.
sourcepub fn get_fieldnorms_reader(&self, field: Field) -> Result<FieldNormReader>
pub fn get_fieldnorms_reader(&self, field: Field) -> Result<FieldNormReader>
Accessor to the segment’s Field norms
’s reader.
Field norms are the length (in tokens) of the fields. It is used in the computation of the TfIdf.
They are simply stored as a fast field, serialized in
the .fieldnorm
file of the segment.
sourcepub fn get_store_reader(&self, cache_size: usize) -> Result<StoreReader>
pub fn get_store_reader(&self, cache_size: usize) -> Result<StoreReader>
Accessor to the segment’s StoreReader
.
sourcepub fn open(segment: &Segment) -> Result<SegmentReader>
pub fn open(segment: &Segment) -> Result<SegmentReader>
Open a new segment for reading.
sourcepub fn open_with_custom_alive_set(
segment: &Segment,
custom_bitset: Option<AliveBitSet>
) -> Result<SegmentReader>
pub fn open_with_custom_alive_set(
segment: &Segment,
custom_bitset: Option<AliveBitSet>
) -> Result<SegmentReader>
Open a new segment for reading.
sourcepub fn inverted_index(&self, field: Field) -> Result<Arc<InvertedIndexReader>>
pub fn inverted_index(&self, field: Field) -> Result<Arc<InvertedIndexReader>>
Returns a field reader associated with the field given in argument. If the field was not present in the index during indexing time, the InvertedIndexReader is empty.
The field reader is in charge of iterating through the term dictionary associated with a specific field, and opening the posting list associated with any term.
If the field is not marked as index, a warning is logged and an empty InvertedIndexReader
is returned.
Similarly, if the field is marked as indexed but no term has been indexed for the given
index, an empty InvertedIndexReader
is returned (but no warning is logged).
sourcepub fn segment_id(&self) -> SegmentId
pub fn segment_id(&self) -> SegmentId
Returns the segment id
sourcepub fn delete_opstamp(&self) -> Option<Opstamp>
pub fn delete_opstamp(&self) -> Option<Opstamp>
Returns the delete opstamp
sourcepub fn alive_bitset(&self) -> Option<&AliveBitSet>
pub fn alive_bitset(&self) -> Option<&AliveBitSet>
Returns the bitset representing the alive DocId
s.
sourcepub fn is_deleted(&self, doc: DocId) -> bool
pub fn is_deleted(&self, doc: DocId) -> bool
Returns true if the doc
is marked
as deleted.
sourcepub fn doc_ids_alive(&self) -> Box<dyn Iterator<Item = DocId> + '_>
pub fn doc_ids_alive(&self) -> Box<dyn Iterator<Item = DocId> + '_>
Returns an iterator that will iterate over the alive document ids
sourcepub fn space_usage(&self) -> Result<SegmentSpaceUsage>
pub fn space_usage(&self) -> Result<SegmentSpaceUsage>
Summarize total space usage of this segment.
Trait Implementations
sourceimpl Clone for SegmentReader
impl Clone for SegmentReader
sourcefn clone(&self) -> SegmentReader
fn clone(&self) -> SegmentReader
1.0.0const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for SegmentReader
impl Debug for SegmentReader
Auto Trait Implementations
impl !RefUnwindSafe for SegmentReader
impl Send for SegmentReader
impl Sync for SegmentReader
impl Unpin for SegmentReader
impl !UnwindSafe for SegmentReader
Blanket Implementations
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstablefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
sourcefn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read moresourcefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read moresourcefn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read moresourcefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read moresourceimpl<T> DowncastSync for Twhere
T: Any + Send + Sync,
impl<T> DowncastSync for Twhere
T: Any + Send + Sync,
sourcefn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send + 'static>
fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send + 'static>
Arc<Trait>
(where Trait: Downcast
) to Arc<Any>
. Arc<Any>
can then be
further downcast
into Arc<ConcreteType>
where ConcreteType
implements Trait
. Read more