Skip to main content

SegmentReader

Struct SegmentReader 

Source
pub struct SegmentReader { /* private fields */ }
Expand description

Reads a segment produced by super::builder::SegmentBuilder.

Owns the segment data and provides typed accessors for all components.

Implementations§

Source§

impl SegmentReader

Source

pub fn open(data: Vec<u8>) -> Result<Self>

Open a segment from its raw bytes.

Validates the header magic and checksum. Component checksums are validated lazily on access.

Source

pub fn segment_id(&self) -> SegmentId

Source

pub fn doc_count(&self) -> u32

Source

pub fn max_doc(&self) -> u32

Source

pub fn header(&self) -> &SegmentHeader

Source

pub fn doc_store(&self) -> DocStoreReader<'_>

Get the document store reader.

Source

pub fn postings( &self, field_id: FieldId, term: &str, ) -> Option<PostingListReader<'_>>

Look up a term in a field’s inverted index and return a posting list reader.

Works for both position-aware and non-position formats. Positions are skipped — only doc_id and tf are returned. Use postings_with_positions for position-aware reading (phrase queries).

Source

pub fn postings_block_max( &self, field_id: FieldId, term: &str, ) -> Option<BlockMaxPostingListReader<'_>>

Look up a term and return a block-max posting list reader (if the posting list uses the block-max format). Returns None for old-format postings.

Source

pub fn postings_with_positions( &self, field_id: FieldId, term: &str, ) -> Option<PositionPostingListReader<'_>>

Look up a term and return a position-aware posting list reader.

Returns None if the field/term doesn’t exist or the postings don’t have positions encoded.

Source

pub fn terms_with_prefix( &self, field_id: FieldId, prefix: &str, ) -> Vec<(String, u32)>

Get all terms with a given prefix and their doc frequencies.

Search terms using an FST automaton. Returns matching (term, doc_count) pairs. The automaton prunes non-matching FST subtrees for O(matching) complexity.

Source

pub fn doc_freq(&self, field_id: FieldId, term: &str) -> u32

Get the term count for a specific term in a field (number of docs containing it).

Source

pub fn parent_bitset(&self) -> Option<&[bool]>

Get the parent bitset (if this segment has nested documents).

Source

pub fn geo_points(&self, field_id: FieldId) -> Option<GeoPointStore>

Get geo point store for a geo_point field.

The store is deserialized and lat-sorted on first access, then cached for subsequent queries on the same segment.

Source

pub fn geo_shapes(&self, field_id: FieldId) -> Option<GeoShapeStore>

Get geo shape store for a geo_shape field.

The store is deserialized on first access, then cached.

Source

pub fn column(&self, field_id: FieldId) -> Option<ColumnReader<'_>>

Get a column reader for a doc_values field.

Source

pub fn norms(&self, field_id: FieldId) -> Option<FieldNormsReader<'_>>

Get the field norms reader for a field.

Source

pub fn avg_field_length(&self, field_id: FieldId) -> f32

Compute the average field length for a field (for BM25).

Source

pub fn terms(&self, field_id: FieldId) -> Vec<String>

Get all terms in a field (useful for testing/debugging).

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool