Skip to main content

Dictionary

Struct Dictionary 

Source
pub struct Dictionary { /* private fields */ }
Expand description

A read-only dictionary mapping terms ↔ role-specific IDs.

Holds the four sections as [ChunkedSection]s — local files keep each section as one resident chunk; a lazily-opened remote file faults individual chunks in on first touch. Lookups never re-parse a header.

Implementations§

Source§

impl Dictionary

Source

pub fn from_sections(sections: [Vec<u8>; 4]) -> Dictionary

Rebuild from four serialized sections (shared, subjects, objects, predicates), e.g. when reading a .rete file.

Source

pub fn from_chunked_sections(sections: [ChunkedSection; 4]) -> Dictionary

Rebuild from four already-chunked sections (the remote lazy-open path).

Source

pub fn term_count(&self) -> u32

Total number of distinct terms across all four sections.

Source

pub fn has_quoted_triples(&self) -> bool

Does this dataset contain RDF-star quoted triples? Meaningful only for a freshly built dictionary (a read-back one carries the truth in the file header’s FLAG_HAS_QUOTED_TRIPLES, not here).

Source

pub fn load_incomplete(&self) -> bool

Did any lazy chunk fetch fail since this dictionary was opened — or since the last reset_load_failure?

Source

pub fn reset_load_failure(&self)

Forget recorded fetch failures across every section (see GraphIndex::reset_load_failure — the per-query reset for resident sessions). Failed chunks were never cached, so they simply retry.

Source

pub fn prefetch_all(&self)

Batch-fault every unloaded chunk of every section (no-op for local dictionaries). Callers about to resolve every term — export, dump — call this once so the sweep coalesces into a few range reads instead of one fetch per chunk.

Source

pub fn prefetch_terms(&self, node_ids: &[u32], predicate_ids: &[u32])

Batch-fault just the chunks needed to resolve a bounded result set: node_ids are unified-node ids (the Val::Id(id) with id >= 0), predicate_ids are predicate-space ids. Groups them by (section, chunk) and coalesces each section’s faults into a few range reads — turning “one request per distinct output term” into “a handful per query”. No-op for a local dictionary (every chunk is already resident).

Source

pub fn shared_count(&self) -> u32

Number of shared terms S.

Source

pub fn subject_only_count(&self) -> u32

Number of subject-only terms Su.

Source

pub fn object_only_count(&self) -> u32

Number of object-only terms Oo.

Source

pub fn node_count(&self) -> u32

Total distinct graph nodes N = S + Su + Oo.

Source

pub fn subject_node(&self, sid: u32) -> u32

Unified node ID for a subject-role ID. Shared and subject-only IDs are already contiguous (1..=S+Su), so this is just sid - 1.

Source

pub fn object_node(&self, oid: u32) -> u32

Unified node ID for an object-role ID: shared stay at oid-1, object-only IDs are shifted past the subject-only block.

Source

pub fn node_term(&self, node: u32) -> Option<String>

Resolve a unified node ID back to its term.

Source

pub fn prefetch_subject_terms(&self, ids: &[u32])

Batch-fault the dictionary chunks that decoding these subject-role ids will touch — one coalesced read per section instead of a blocking round trip per id. Purely a cache warmer (resident sections no-op).

Source

pub fn prefetch_node_terms(&self, nodes: &[u32])

prefetch_subject_terms for unified node ids — the id space solution rows carry. Warms every chunk a batch of row decodes (a FILTER’s string ops, the projection) is about to fault, using node_term’s exact routing.

Source

pub fn node_of_term(&self, term: &str) -> Option<u32>

Unified node ID for a term, resolving via subject role then object role.

Source

pub fn node_as_subject_id(&self, node: u32) -> Option<u32>

Subject-role ID of a node, or None if the node never appears as a subject (an object-only term).

Source

pub fn node_as_object_id(&self, node: u32) -> Option<u32>

Object-role ID of a node, or None if the node never appears as an object (a subject-only term).

Source

pub fn subject_id(&self, term: &str) -> Option<u32>

Subject-role ID for term: shared 1..=S, else subject-only S+1...

Source

pub fn object_id(&self, term: &str) -> Option<u32>

Object-role ID for term: shared 1..=S, else object-only S+1...

Source

pub fn predicate_id(&self, term: &str) -> Option<u32>

Predicate ID for term (independent space).

Source

pub fn subject_term(&self, id: u32) -> Option<String>

Source

pub fn object_term(&self, id: u32) -> Option<String>

Source

pub fn predicate_term(&self, id: u32) -> Option<String>

Source

pub fn encode(&self, s: &str, p: &str, o: &str) -> Option<(u32, u32, u32)>

Encode a (s, p, o) term triple to its (subject_id, predicate_id, object_id). None if any term is unknown.

Source

pub fn sections(&self) -> [Vec<u8>; 4]

The four serialized sections (header + body each), for the file writer.

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V