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

source

pub fn max_doc(&self) -> DocId

Returns the highest document id ever attributed in this segment + 1.

source

pub fn num_docs(&self) -> DocId

Returns the number of alive documents. Deleted documents are not counted.

source

pub fn schema(&self) -> &Schema

Returns the schema of the index this segment belongs to.

source

pub fn num_deleted_docs(&self) -> DocId

Return the number of documents that have been deleted in the segment.

source

pub fn has_deletes(&self) -> bool

Returns true if some of the documents of the segment have been deleted.

source

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.

source

pub fn facet_reader(&self, field_name: &str) -> Result<FacetReader>

Accessor to the FacetReader associated with a given Field.

source

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.

source

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

source

pub fn open(segment: &Segment) -> Result<SegmentReader>

Open a new segment for reading.

source

pub fn open_with_custom_alive_set( segment: &Segment, custom_bitset: Option<AliveBitSet> ) -> Result<SegmentReader>

Open a new segment for reading.

source

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).

source

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.

source

pub fn segment_id(&self) -> SegmentId

Returns the segment id

source

pub fn delete_opstamp(&self) -> Option<Opstamp>

Returns the delete opstamp

source

pub fn alive_bitset(&self) -> Option<&AliveBitSet>

Returns the bitset representing the alive DocIds.

source

pub fn is_deleted(&self, doc: DocId) -> bool

Returns true if the doc is marked as deleted.

source

pub fn doc_ids_alive(&self) -> Box<dyn Iterator<Item = DocId> + '_>

Returns an iterator that will iterate over the alive document ids

source

pub fn space_usage(&self) -> Result<SegmentSpaceUsage>

Summarize total space usage of this segment.

Trait Implementations§

source§

impl Clone for SegmentReader

source§

fn clone(&self) -> SegmentReader

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for SegmentReader

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> Downcast for T
where T: Any,

source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> Fruit for T
where T: Send + Downcast,