pub struct Segment {
pub id: u64,
/* private fields */
}Expand description
A read-only, mmap-backed view of a segment: shared immutable data plus this open’s snapshot of the live bitmap (the only part that changes on disk).
Fields§
§id: u64Implementations§
Source§impl Segment
impl Segment
pub fn open(paths: &Paths, seg_id: u64) -> Result<Segment>
Sourcepub fn reopen(&self, paths: &Paths) -> Result<Segment>
pub fn reopen(&self, paths: &Paths) -> Result<Segment>
Re-open this segment cheaply: share the immutable data and reload only the live bitmap (the single mutable file). Sound because segment ids are never reused — the same id always names the same immutable content.
pub fn is_live(&self, doc_id: u32) -> bool
Sourcepub fn subtract_live(&mut self, doc_ids: &[u32])
pub fn subtract_live(&mut self, doc_ids: &[u32])
Subtract pending tombstones from this open’s live snapshot. Readers use
this to honor deletes that are already published in the manifest but
not yet applied to the on-disk live bitmap (see
crate::meta::Meta::pending_tombstones).
pub fn live_count(&self) -> u64
Sourcepub fn all_live(&self) -> RoaringBitmap
pub fn all_live(&self) -> RoaringBitmap
All live doc ids in this segment.
Sourcepub fn candidates(&self, query: &TrigramQuery) -> Result<RoaringBitmap>
pub fn candidates(&self, query: &TrigramQuery) -> Result<RoaringBitmap>
Compute candidate doc ids satisfying the trigram query, intersected with the live set. An unconstrained query yields all live docs.
Methods from Deref<Target = SegmentData>§
pub fn doc(&self, doc_id: u32) -> Option<&DocMeta>
Sourcepub fn doc_path_score(&self, doc_id: u32) -> f32
pub fn doc_path_score(&self, doc_id: u32) -> f32
Path ranking adjustment for doc_id, or 0.0 if there is no such doc.
Computed on demand: [crate::search::path_score] allocates nothing, so
precomputing a column of these at open cost more (one pass over every
path in the repository, on the critical path of every cold query) than
the per-hit calls it saved.
Sourcepub fn sym(&self, i: u32) -> Option<SymbolEntry>
pub fn sym(&self, i: u32) -> Option<SymbolEntry>
Decode symbol row i. None for out-of-range ids or a corrupt row.
Sourcepub fn doc_syms(&self, doc_id: u32) -> impl Iterator<Item = SymbolEntry> + '_
pub fn doc_syms(&self, doc_id: u32) -> impl Iterator<Item = SymbolEntry> + '_
The symbols defined in doc_id, in storage order. O(1) range lookup.
Sourcepub fn doc_sym_count(&self, doc_id: u32) -> u32
pub fn doc_sym_count(&self, doc_id: u32) -> u32
Number of symbols defined in doc_id, without decoding any row.
Sourcepub fn doc_refs(&self, doc_id: u32) -> impl Iterator<Item = RefEntry> + '_
pub fn doc_refs(&self, doc_id: u32) -> impl Iterator<Item = RefEntry> + '_
The references (calls + imports) originating in doc_id.
Sourcepub fn refs_named<'s>(
&'s self,
name: &'s str,
) -> impl Iterator<Item = RefEntry> + 's
pub fn refs_named<'s>( &'s self, name: &'s str, ) -> impl Iterator<Item = RefEntry> + 's
References (calls and imports) whose name is exactly name, via the
persisted name index (O(results), no full scan). Liveness is not
filtered here; callers that care should check Segment::is_live.
Sourcepub fn calls_to<'s>(
&'s self,
name: &'s str,
) -> impl Iterator<Item = RefEntry> + 's
pub fn calls_to<'s>( &'s self, name: &'s str, ) -> impl Iterator<Item = RefEntry> + 's
Call sites whose callee is exactly name (see Self::refs_named).
Sourcepub fn syms_by_lower<'s>(
&'s self,
lower: &'s str,
) -> impl Iterator<Item = u32> + 's
pub fn syms_by_lower<'s>( &'s self, lower: &'s str, ) -> impl Iterator<Item = u32> + 's
Symbol row ids whose lowercased name is exactly lower. O(results)
via the persisted name FST.
Sourcepub fn sym_name_lower(&self, i: u32) -> &str
pub fn sym_name_lower(&self, i: u32) -> &str
Lowercased name of symbol row i (borrowed from the name column).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Segment
impl RefUnwindSafe for Segment
impl Send for Segment
impl Sync for Segment
impl Unpin for Segment
impl UnsafeUnpin for Segment
impl UnwindSafe for Segment
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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