Skip to main content

Snapshot

Struct Snapshot 

Source
pub struct Snapshot<'s> { /* private fields */ }
Expand description

A pinned, immutable read view of the store.

Implementations§

Source§

impl<'s> Snapshot<'s>

Source

pub fn query(&'s self, query: &str, opts: &QueryOpts) -> Vec<Hit<'s>>

Answer a plain-language query with ranked URL + anchor references.

Source

pub fn related(&'s self, key: UrlKey, k: usize) -> Vec<Hit<'s>>

Documents most related to key: outbound links and similarity edges, strongest first.

Source§

impl<'s> Snapshot<'s>

Source

pub fn generation(&self) -> u64

The base generation this snapshot pins.

Source

pub fn base_len(&self) -> usize

Node count in the base (including stubs/tombstones).

Source

pub fn node(&self, key: UrlKey) -> Option<NodeRef<'_>>

Look up a node by durable key, merging base and overlay state.

Source

pub fn len(&self) -> usize

Live (non-stub, non-tombstone, non-removed) document count.

Source

pub fn is_empty(&self) -> bool

True when no live documents exist.

Source

pub fn for_each_live<'a>(&'a self, f: impl FnMut(NodeRef<'a>))

Visit every live node (base then overlay-fresh, both in key order for determinism where it matters to callers).

Source

pub fn neighbors(&self, key: UrlKey) -> Neighbors<'_>

Outbound edges of key. Overlay whole-set replacements win over the base CSR run.

Source

pub fn in_edges(&self, key: UrlKey, f: impl FnMut(UrlKey, EdgeType, u8, u16))

Inbound edges of key, as (source, type, flags, weight): the sources whose edge sets point at it. Base runs come from the reverse index written at compaction; sources whose edges the overlay replaced or removed are skipped there and reported from the overlay instead.

Source

pub fn attr(&self, key: UrlKey, k: u8) -> Option<&str>

Value of attribute k of key (see crate::Writer::set_attrs).

Source

pub fn attrs<'a>(&'a self, key: UrlKey, f: impl FnMut(u8, &'a str))

Every attribute of key, in key order. An overlay whole-set replacement wins over the base.

Source

pub fn named_attrs<'a>(&'a self, key: UrlKey, f: impl FnMut(&'a str, &'a str))

Every named attribute of key (see crate::Writer::set_named_attrs) in name order, as (name, value) borrowed from the mmap or overlay. Records written without a name (crate::Writer::set_attrs) carry no NUL and are skipped.

Source

pub fn segments(&self, key: UrlKey) -> Vec<SegRef<'_>>

The node’s segments (anchors). Overlay whole-set replacement wins.

Source

pub fn due(&self, now_ms: u64, max: usize) -> Vec<DueItem<'_>>

Everything due for revalidation at now_ms, most important first.

Source§

impl Snapshot<'_>

Source

pub fn walk( &self, from: UrlKey, dir: Direction, max_depth: u32, follow: impl Fn(EdgeType) -> bool, w: &mut Walk, visit: impl FnMut(Hop) -> bool, )

Breadth-first walk from from along edges in dir whose type follow accepts, at most max_depth hops. visit sees every node reached once, nearest first, and returns whether to continue past it (so “the nearest described ancestor” is a walk that stops at described nodes).

Source

pub fn walk_both( &self, from: UrlKey, max_depth: u32, follow: impl Fn(EdgeType) -> bool, w: &mut Walk, visit: impl FnMut(Hop) -> bool, )

crate::Snapshot::walk along outbound and inbound edges at once: the lineage neighbourhood of a node (what it derives from and what derives from it, and so on outwards). Each node is reached once, at its shortest distance over either direction; a node’s outbound edges are offered before its inbound ones.

Trait Implementations§

Source§

impl Debug for Snapshot<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'s> !Freeze for Snapshot<'s>

§

impl<'s> !RefUnwindSafe for Snapshot<'s>

§

impl<'s> !Send for Snapshot<'s>

§

impl<'s> !Sync for Snapshot<'s>

§

impl<'s> Unpin for Snapshot<'s>

§

impl<'s> UnsafeUnpin for Snapshot<'s>

§

impl<'s> UnwindSafe for Snapshot<'s>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.