pub struct PostingsReader<'bytes> { /* private fields */ }Expand description
A validated view over an encoded posting list.
Implementations§
Source§impl<'bytes> PostingsReader<'bytes>
impl<'bytes> PostingsReader<'bytes>
Sourcepub fn positions(
&self,
row: u32,
) -> Result<Option<RowPositions<'bytes>>, PostingsError>
pub fn positions( &self, row: u32, ) -> Result<Option<RowPositions<'bytes>>, PostingsError>
Locates only one row’s position deltas. Other rows’ positions are not decoded; their frequencies establish the offset within this block.
§Errors
Returns a typed posting error for malformed frequencies or geometry.
Sourcepub fn open(bytes: &'bytes [u8]) -> Result<Self, PostingsError>
pub fn open(bytes: &'bytes [u8]) -> Result<Self, PostingsError>
Validates and opens an encoded posting list.
Every structural claim the bytes make is checked here, so the iteration methods below cannot fail on a reader that exists. Corrupt bytes produce a typed error and never a panic.
§Errors
Returns PostingsError for bad magic, an unreadable version, a
zero block size, an oversized bit width, an inconsistent posting
count, or truncation anywhere.
Sourcepub const fn version(&self) -> u16
pub const fn version(&self) -> u16
Returns the format version the stream declared.
A caller that needs impact pairs checks this rather than inferring their presence from a zero pair, so a v1 stream is refused loudly instead of silently bounding nothing.
Sourcepub const fn postings_per_block(&self) -> u16
pub const fn postings_per_block(&self) -> u16
Returns the postings-per-block geometry recorded in the header.
Sourcepub const fn document_frequency(&self) -> u32
pub const fn document_frequency(&self) -> u32
Returns the total posting count.
Sourcepub fn decode_block(&self, index: usize) -> Result<Vec<Posting>, PostingsError>
pub fn decode_block(&self, index: usize) -> Result<Vec<Posting>, PostingsError>
Decodes one block into document ids, frequencies, and positions.
§Errors
Returns PostingsError::Truncated when a stream is short. Bounds
were validated at PostingsReader::open, so a well-formed reader
decodes every block successfully.