pub struct AsyncSegmentReader { /* private fields */ }Expand description
Async segment reader with lazy loading
- Term dictionary: only index loaded, blocks loaded on-demand
- Postings: loaded on-demand per term via HTTP range requests
- Document store: only index loaded, blocks loaded on-demand via HTTP range requests
Implementations§
Source§impl AsyncSegmentReader
impl AsyncSegmentReader
Sourcepub async fn open<D: Directory>(
dir: &D,
segment_id: SegmentId,
schema: Arc<Schema>,
doc_id_offset: DocId,
cache_blocks: usize,
) -> Result<Self>
pub async fn open<D: Directory>( dir: &D, segment_id: SegmentId, schema: Arc<Schema>, doc_id_offset: DocId, cache_blocks: usize, ) -> Result<Self>
Open a segment with lazy loading
pub fn meta(&self) -> &SegmentMeta
pub fn num_docs(&self) -> u32
Sourcepub fn avg_field_len(&self, field: Field) -> f32
pub fn avg_field_len(&self, field: Field) -> f32
Get average field length for BM25F scoring
pub fn doc_id_offset(&self) -> DocId
pub fn schema(&self) -> &Schema
Sourcepub fn term_dict_stats(&self) -> SSTableStats
pub fn term_dict_stats(&self) -> SSTableStats
Get term dictionary stats for debugging
Sourcepub async fn get_postings(
&self,
field: Field,
term: &[u8],
) -> Result<Option<BlockPostingList>>
pub async fn get_postings( &self, field: Field, term: &[u8], ) -> Result<Option<BlockPostingList>>
Get posting list for a term (async - loads on demand)
For small posting lists (1-3 docs), the data is inlined in the term dictionary and no additional I/O is needed. For larger lists, reads from .post file.
Sourcepub async fn doc(&self, local_doc_id: DocId) -> Result<Option<Document>>
pub async fn doc(&self, local_doc_id: DocId) -> Result<Option<Document>>
Get document by local doc_id (async - loads on demand)
Sourcepub async fn prefetch_terms(
&self,
field: Field,
start_term: &[u8],
end_term: &[u8],
) -> Result<()>
pub async fn prefetch_terms( &self, field: Field, start_term: &[u8], end_term: &[u8], ) -> Result<()>
Prefetch term dictionary blocks for a key range
Sourcepub fn store_has_dict(&self) -> bool
pub fn store_has_dict(&self) -> bool
Check if store uses dictionary compression (incompatible with raw merging)
Sourcepub fn store_raw_blocks(&self) -> Vec<RawStoreBlock>
pub fn store_raw_blocks(&self) -> Vec<RawStoreBlock>
Get raw store blocks for optimized merging
Sourcepub fn store_data_slice(&self) -> &LazyFileSlice
pub fn store_data_slice(&self) -> &LazyFileSlice
Get store data slice for raw block access
Sourcepub async fn all_terms(&self) -> Result<Vec<(Vec<u8>, TermInfo)>>
pub async fn all_terms(&self) -> Result<Vec<(Vec<u8>, TermInfo)>>
Get all terms from this segment (for merge)
Sourcepub async fn read_postings(&self, offset: u64, len: u32) -> Result<Vec<u8>>
pub async fn read_postings(&self, offset: u64, len: u32) -> Result<Vec<u8>>
Read raw posting bytes at offset
Sourcepub fn search_dense_vector(
&self,
field: Field,
query: &[f32],
k: usize,
rerank_factor: usize,
) -> Result<Vec<(DocId, f32)>>
pub fn search_dense_vector( &self, field: Field, query: &[f32], k: usize, rerank_factor: usize, ) -> Result<Vec<(DocId, f32)>>
Search dense vectors using RaBitQ
Returns (doc_id, distance) pairs sorted by distance (ascending). The doc_ids are adjusted by doc_id_offset for this segment. If mrl_dim is configured, the query vector is automatically trimmed.
Sourcepub fn has_dense_vector_index(&self, field: Field) -> bool
pub fn has_dense_vector_index(&self, field: Field) -> bool
Check if this segment has a dense vector index for the given field
Sourcepub fn get_dense_vector_index(&self, field: Field) -> Option<Arc<RaBitQIndex>>
pub fn get_dense_vector_index(&self, field: Field) -> Option<Arc<RaBitQIndex>>
Get the dense vector index for a field (if available)
Sourcepub fn get_ivf_vector_index(&self, field: Field) -> Option<Arc<IVFRaBitQIndex>>
pub fn get_ivf_vector_index(&self, field: Field) -> Option<Arc<IVFRaBitQIndex>>
Get the IVF vector index for a field (if available)
Sourcepub fn get_scann_vector_index(
&self,
field: Field,
) -> Option<(Arc<IVFPQIndex>, Arc<PQCodebook>)>
pub fn get_scann_vector_index( &self, field: Field, ) -> Option<(Arc<IVFPQIndex>, Arc<PQCodebook>)>
Get the ScaNN vector index for a field (if available)
Sourcepub fn get_vector_index(&self, field: Field) -> Option<&VectorIndex>
pub fn get_vector_index(&self, field: Field) -> Option<&VectorIndex>
Get the vector index type for a field
Sourcepub async fn search_sparse_vector(
&self,
field: Field,
indices: &[u32],
weights: &[f32],
k: usize,
) -> Result<Vec<(u32, f32)>>
pub async fn search_sparse_vector( &self, field: Field, indices: &[u32], weights: &[f32], k: usize, ) -> Result<Vec<(u32, f32)>>
Search for similar sparse vectors using inverted index
Sparse vectors are indexed as terms “dim_{index}” with the weight stored. This method accumulates dot product scores across all non-zero dimensions.
Returns (doc_id, score) pairs sorted by score descending.
Auto Trait Implementations§
impl Freeze for AsyncSegmentReader
impl !RefUnwindSafe for AsyncSegmentReader
impl Send for AsyncSegmentReader
impl Sync for AsyncSegmentReader
impl Unpin for AsyncSegmentReader
impl !UnwindSafe for AsyncSegmentReader
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.