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
impl SegmentReader
Sourcepub fn open(data: Vec<u8>) -> Result<Self>
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.
pub fn segment_id(&self) -> SegmentId
pub fn doc_count(&self) -> u32
pub fn max_doc(&self) -> u32
pub fn header(&self) -> &SegmentHeader
Sourcepub fn doc_store(&self) -> DocStoreReader<'_>
pub fn doc_store(&self) -> DocStoreReader<'_>
Get the document store reader.
Sourcepub fn postings(
&self,
field_id: FieldId,
term: &str,
) -> Option<PostingListReader<'_>>
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).
Sourcepub fn postings_block_max(
&self,
field_id: FieldId,
term: &str,
) -> Option<BlockMaxPostingListReader<'_>>
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.
Sourcepub fn postings_with_positions(
&self,
field_id: FieldId,
term: &str,
) -> Option<PositionPostingListReader<'_>>
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.
Sourcepub fn terms_with_prefix(
&self,
field_id: FieldId,
prefix: &str,
) -> Vec<(String, u32)>
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.
Sourcepub fn automaton_search<A: Automaton>(
&self,
field_id: FieldId,
aut: A,
) -> Vec<(String, u32)>
pub fn automaton_search<A: Automaton>( &self, field_id: FieldId, aut: A, ) -> Vec<(String, u32)>
Search terms using an FST automaton. Returns matching (term, doc_count) pairs. The automaton prunes non-matching FST subtrees for O(matching) complexity.
Sourcepub fn doc_freq(&self, field_id: FieldId, term: &str) -> u32
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).
Sourcepub fn parent_bitset(&self) -> Option<&[bool]>
pub fn parent_bitset(&self) -> Option<&[bool]>
Get the parent bitset (if this segment has nested documents).
Sourcepub fn geo_points(&self, field_id: FieldId) -> Option<GeoPointStore>
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.
Sourcepub fn geo_shapes(&self, field_id: FieldId) -> Option<GeoShapeStore>
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.
Sourcepub fn column(&self, field_id: FieldId) -> Option<ColumnReader<'_>>
pub fn column(&self, field_id: FieldId) -> Option<ColumnReader<'_>>
Get a column reader for a doc_values field.
Sourcepub fn norms(&self, field_id: FieldId) -> Option<FieldNormsReader<'_>>
pub fn norms(&self, field_id: FieldId) -> Option<FieldNormsReader<'_>>
Get the field norms reader for a field.
Sourcepub fn avg_field_length(&self, field_id: FieldId) -> f32
pub fn avg_field_length(&self, field_id: FieldId) -> f32
Compute the average field length for a field (for BM25).
Auto Trait Implementations§
impl !Freeze for SegmentReader
impl RefUnwindSafe for SegmentReader
impl Send for SegmentReader
impl Sync for SegmentReader
impl Unpin for SegmentReader
impl UnsafeUnpin 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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