Struct tantivy::index::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§
source§impl 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_name: &str) -> Result<FacetReader>
pub fn facet_reader(&self, field_name: &str) -> 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_num_blocks: usize) -> Result<StoreReader>
pub fn get_store_reader(&self, cache_num_blocks: usize) -> Result<StoreReader>
Accessor to the segment’s StoreReader
.
cache_num_blocks
sets the number of decompressed blocks to be cached in an LRU.
The size of blocks is configurable, this should be reflexted in the
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 fields_metadata(&self) -> Result<Vec<FieldMetadata>>
pub fn fields_metadata(&self) -> Result<Vec<FieldMetadata>>
Returns the list of fields that have been indexed in the segment. The field list includes the field defined in the schema as well as the fields that have been indexed as a part of a JSON field. The returned field name is the full field name, including the name of the JSON field.
The returned field names can be used in queries.
Notice: If your data contains JSON fields this is very expensive, as it requires browsing through the inverted index term dictionary and the columnar field dictionary.
Disclaimer: Some fields may not be listed here. For instance, if the schema contains a json field that is not indexed nor a fast field but is stored, it is possible for the field to not be listed.
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§
source§impl Clone for SegmentReader
impl Clone for SegmentReader
source§fn clone(&self) -> SegmentReader
fn clone(&self) -> SegmentReader
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for SegmentReader
impl !RefUnwindSafe for SegmentReader
impl Send for SegmentReader
impl Sync for SegmentReader
impl Unpin for SegmentReader
impl !UnwindSafe for SegmentReader
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn 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.source§fn 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.