pub struct BlockPostingList { /* private fields */ }Implementations§
Source§impl BlockPostingList
impl BlockPostingList
Sourcepub fn from_posting_list(list: &PostingList) -> Result<Self>
pub fn from_posting_list(list: &PostingList) -> Result<Self>
Build from a posting list.
Block format (8-byte header + packed arrays):
[count: u16][first_doc: u32][doc_id_bits: u8][tf_bits: u8]
[packed doc_id deltas: (count-1) × bytes_per_value(doc_id_bits)]
[packed tfs: count × bytes_per_value(tf_bits)]Sourcepub fn serialize<W: Write>(&self, writer: &mut W) -> Result<()>
pub fn serialize<W: Write>(&self, writer: &mut W) -> Result<()>
Serialize the block posting list (footer-based: stream first).
Format:
[stream: block data]
[L0 entries: l0_count × 16 bytes (first_doc, last_doc, offset, max_weight)]
[L1 entries: l1_count × 4 bytes (last_doc)]
[footer: stream_len(8) + l0_count(4) + l1_count(4) + doc_count(4) + max_tf(4) = 24 bytes]Sourcepub fn deserialize(raw: &[u8]) -> Result<Self>
pub fn deserialize(raw: &[u8]) -> Result<Self>
Deserialize from a byte slice (footer-based format).
Sourcepub fn deserialize_zero_copy(raw: OwnedBytes) -> Result<Self>
pub fn deserialize_zero_copy(raw: OwnedBytes) -> Result<Self>
Zero-copy deserialization from OwnedBytes.
Stream and L0 are sliced from the source without copying.
L1 is extracted into a Vec<u32> for SIMD-friendly access (tiny: ≤ N/8 entries).
pub fn doc_count(&self) -> u32
Sourcepub fn num_blocks(&self) -> usize
pub fn num_blocks(&self) -> usize
Get number of blocks
Sourcepub fn block_max_tf(&self, block_idx: usize) -> Option<u32>
pub fn block_max_tf(&self, block_idx: usize) -> Option<u32>
Get block’s max term frequency for block-max pruning
Sourcepub fn concatenate_blocks(sources: &[(BlockPostingList, u32)]) -> Result<Self>
pub fn concatenate_blocks(sources: &[(BlockPostingList, u32)]) -> Result<Self>
Concatenate blocks from multiple posting lists with doc_id remapping. This is O(num_blocks) instead of O(num_postings).
Sourcepub fn concatenate_streaming<W: Write>(
sources: &[(&[u8], u32)],
writer: &mut W,
) -> Result<(u32, usize)>
pub fn concatenate_streaming<W: Write>( sources: &[(&[u8], u32)], writer: &mut W, ) -> Result<(u32, usize)>
Streaming merge: write blocks directly to output writer (bounded memory).
Zero-materializing: reads L0 entries directly from source bytes (mmap or &u8) without parsing into Vecs. Block sizes computed from the 8-byte header (deterministic with packed encoding).
Output L0 + L1 are buffered (bounded O(total_blocks × 16 + total_blocks/8 × 4)). Block data flows source → output writer without intermediate buffering.
Returns (doc_count, bytes_written).
Sourcepub fn decode_block_into(
&self,
block_idx: usize,
doc_ids: &mut Vec<u32>,
tfs: &mut Vec<u32>,
) -> bool
pub fn decode_block_into( &self, block_idx: usize, doc_ids: &mut Vec<u32>, tfs: &mut Vec<u32>, ) -> bool
Decode a specific block into caller-provided buffers.
Returns true if the block was decoded, false if block_idx is out of range.
Reuses doc_ids and tfs buffers (cleared before filling).
Uses SIMD-accelerated unpack for 8/16/32-bit packed arrays.
Sourcepub fn block_first_doc(&self, block_idx: usize) -> Option<DocId>
pub fn block_first_doc(&self, block_idx: usize) -> Option<DocId>
First doc_id of a block (from L0 skip entry). Returns None if out of range.
Sourcepub fn block_last_doc(&self, block_idx: usize) -> Option<DocId>
pub fn block_last_doc(&self, block_idx: usize) -> Option<DocId>
Last doc_id of a block (from L0 skip entry). Returns None if out of range.
Sourcepub fn seek_block(&self, target: DocId, from_block: usize) -> Option<usize>
pub fn seek_block(&self, target: DocId, from_block: usize) -> Option<usize>
Find the first block whose last_doc >= target, starting from from_block.
Uses SIMD-accelerated linear scan:
find_first_ge_u32on the contiguous L1last_docarray- Extract ≤
L1_INTERVALL0last_docvalues into a stack buffer →find_first_ge_u32
Returns None if no block contains target.
Sourcepub fn iterator(&self) -> BlockPostingIterator<'_>
pub fn iterator(&self) -> BlockPostingIterator<'_>
Create an iterator with skip support
Sourcepub fn into_iterator(self) -> BlockPostingIterator<'static>
pub fn into_iterator(self) -> BlockPostingIterator<'static>
Create an owned iterator that doesn’t borrow self
Trait Implementations§
Source§impl Clone for BlockPostingList
impl Clone for BlockPostingList
Source§fn clone(&self) -> BlockPostingList
fn clone(&self) -> BlockPostingList
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for BlockPostingList
impl RefUnwindSafe for BlockPostingList
impl Send for BlockPostingList
impl Sync for BlockPostingList
impl Unpin for BlockPostingList
impl UnwindSafe for BlockPostingList
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.