pub struct Reader { /* private fields */ }Expand description
Read transaction over a pinned snapshot.
A read transaction owns its own Arc<Snapshot> and never borrows the
Db, so it stays valid across a later begin_write/checkpoint on
the same handle (it cloned the snapshot before the write borrowed &mut). It
is Send + Sync (asserted below).
§Performance
Creating and cloning a read transaction is O(1): it shares the pinned
snapshot through an Arc, not by copying.
Implementations§
Source§impl Reader
impl Reader
Sourcepub fn element_count(&self) -> usize
pub fn element_count(&self) -> usize
Sourcepub fn relation_count(&self) -> usize
pub fn relation_count(&self) -> usize
Sourcepub fn incidence_count(&self) -> usize
pub fn incidence_count(&self) -> usize
Sourcepub fn element_ids(&self) -> Vec<ElementId>
pub fn element_ids(&self) -> Vec<ElementId>
Sourcepub fn relation_ids(&self) -> Vec<RelationId>
pub fn relation_ids(&self) -> Vec<RelationId>
Sourcepub fn contains_element(&self, id: ElementId) -> bool
pub fn contains_element(&self, id: ElementId) -> bool
Sourcepub fn contains_relation(&self, id: RelationId) -> bool
pub fn contains_relation(&self, id: RelationId) -> bool
Sourcepub fn contains_incidence(&self, id: IncidenceId) -> bool
pub fn contains_incidence(&self, id: IncidenceId) -> bool
Sourcepub fn element(&self, id: ElementId) -> Option<Element>
pub fn element(&self, id: ElementId) -> Option<Element>
Returns an owned element view — id, labels, and all properties read in one call.
§Performance
This method is O(log n + label count + property count).
Sourcepub fn relation(&self, id: RelationId) -> Option<Relation>
pub fn relation(&self, id: RelationId) -> Option<Relation>
Returns an owned relation view — id, type, labels, and all properties read in one call.
§Performance
This method is O(log n + label count + property count).
Sourcepub fn incidence(&self, id: IncidenceId) -> Option<IncidenceRecord>
pub fn incidence(&self, id: IncidenceId) -> Option<IncidenceRecord>
Sourcepub fn element_incidences(&self, id: ElementId) -> Vec<IncidenceRecord>
pub fn element_incidences(&self, id: ElementId) -> Vec<IncidenceRecord>
Returns every visible incidence attached to an element, in ascending incidence-id order.
The merged set mixes overlay-owned and base-borrowed records, so this
returns an owned Vec (IncidenceRecord is Copy, so the copy is
cheap).
§Performance
This method is O(base incidences + overlay incidence change).
Sourcepub fn endpoints(&self, relation: RelationId) -> Option<(ElementId, ElementId)>
pub fn endpoints(&self, relation: RelationId) -> Option<(ElementId, ElementId)>
Returns a binary relation’s two endpoint elements, ordered by ascending incidence id.
Reads the relation’s incidences from the reverse-adjacency index and
returns the elements carried by its first two incidences in id order. A
relation with fewer than two visible incidences returns None. This
reports endpoints structurally, without consulting any projection’s
source/target roles — use Self::neighbors when role direction matters.
§Performance
This method is O(degree) over the relation’s incidences.
Sourcepub fn neighbors(
&self,
element: ElementId,
relation_type: RelationTypeId,
direction: Direction,
) -> Vec<ElementId>
pub fn neighbors( &self, element: ElementId, relation_type: RelationTypeId, direction: Direction, ) -> Vec<ElementId>
Returns the elements reachable from element along relations of
relation_type, in ascending element-id order.
Direction selects the role element must play on each relation. Endpoint
roles are encoded by incidence-creation order: a binary relation’s source
is its lower incidence id and its target the higher (see
Self::endpoints). Outgoing requires element to be the source (and
yields the target), Incoming requires it to be the target (and yields
the source), and Both yields the opposite endpoint either way. Resolved
over the reverse-adjacency index — each incidence of element whose
relation has the requested type contributes that relation’s other
endpoint — so this works for any binary relation without a materialized
projection.
§Performance
This method is O(degree of element + sum of touched relation degrees).
Sourcepub fn property(
&self,
subject: PropertySubject,
key: PropertyKeyId,
) -> Option<PropertyValue>
pub fn property( &self, subject: PropertySubject, key: PropertyKeyId, ) -> Option<PropertyValue>
Sourcepub fn element_by_key<T: ValueType>(
&self,
index: EqualityIndex<T>,
value: impl Assignable<T>,
) -> Result<Option<Element>, DbError>
pub fn element_by_key<T: ValueType>( &self, index: EqualityIndex<T>, value: impl Assignable<T>, ) -> Result<Option<Element>, DbError>
Sourcepub fn lookup_property_equal(
&self,
key: PropertyKeyId,
value: &PropertyValue,
) -> Result<Vec<PropertySubject>, DbError>
pub fn lookup_property_equal( &self, key: PropertyKeyId, value: &PropertyValue, ) -> Result<Vec<PropertySubject>, DbError>
Sourcepub fn lookup_property_range(
&self,
key: PropertyKeyId,
min: &PropertyValue,
max: &PropertyValue,
) -> Result<Vec<PropertySubject>, DbError>
pub fn lookup_property_range( &self, key: PropertyKeyId, min: &PropertyValue, max: &PropertyValue, ) -> Result<Vec<PropertySubject>, DbError>
Sourcepub fn lookup(
&self,
index: IndexId,
lookup: Match<'_>,
) -> Result<Vec<PropertySubject>, DbError>
pub fn lookup( &self, index: IndexId, lookup: Match<'_>, ) -> Result<Vec<PropertySubject>, DbError>
Sourcepub fn graph_projection(
&self,
id: ProjectionId,
) -> Result<GraphProjection, DbError>
pub fn graph_projection( &self, id: ProjectionId, ) -> Result<GraphProjection, DbError>
Sourcepub fn graph_projection_by_name(
&self,
name: &str,
) -> Result<GraphProjection, DbError>
pub fn graph_projection_by_name( &self, name: &str, ) -> Result<GraphProjection, DbError>
Sourcepub fn walk(
&self,
projection: ProjectionId,
seeds: &[ElementId],
walk: Walk,
) -> Result<Subgraph, DbError>
pub fn walk( &self, projection: ProjectionId, seeds: &[ElementId], walk: Walk, ) -> Result<Subgraph, DbError>
Walks a cataloged graph projection from canonical seed elements, returning the discovered nodes AND the projection edges among them.
Nodes are unique canonical elements in BFS first-discovery order; depth is
the shortest discovered hop count from any seed. Edges connect two
discovered nodes, ordered deterministically and unique by relation, so the
Subgraph never references a node it omitted.
§Errors
Returns DbError when the projection is unknown, is not a graph,
cannot be materialized, or a seed element is not part of the projection.
§Performance
This method is O(relation count * incidence count + visited edges).
Sourcepub fn personalized_pagerank(
&self,
projection: ProjectionId,
seeds: &[ElementId],
config: PageRankConfig<f64>,
) -> Result<Vec<(ElementId, f64)>, DbError>
pub fn personalized_pagerank( &self, projection: ProjectionId, seeds: &[ElementId], config: PageRankConfig<f64>, ) -> Result<Vec<(ElementId, f64)>, DbError>
Ranks a cataloged graph projection by personalized PageRank, returning
every projection element paired with its rank, ordered highest first.
seeds are the restart (teleport) set: rank mass returns to them on each
damping step, biasing the stationary distribution toward elements
reachable from the seeds (random walk with restart). The seed weights are
normalized internally, so passing the seed elements is sufficient. With no
seeds this is the uniform-teleport PageRank over the projection.
§Errors
Returns DbError when the projection is unknown, is not a graph, cannot
be materialized, or PageRank rejects the configuration (the
PageRankConfig was invalid or the power iteration did not converge).
Seeds absent from the projection are ignored rather than erroring; with no
resolvable seed this is the uniform-teleport rank.
§Performance
This method is O(relation count * incidence count + iterations * (visible elements + visible edges) + visible elements * log(visible elements)) — the trailing term is the final rank sort.
Sourcepub fn longest_path(
&self,
projection: ProjectionId,
elements: &[ElementId],
) -> Result<Vec<ElementId>, DbError>
pub fn longest_path( &self, projection: ProjectionId, elements: &[ElementId], ) -> Result<Vec<ElementId>, DbError>
Returns the longest chain of canonical elements along the projection’s
outgoing edges within the subgraph induced by elements.
Only edges whose endpoints are both in elements participate. The path
lists each element once from start to end; its length in edges is
path.len() - 1. An empty elements slice yields an empty path.
§Errors
Returns DbError when the projection is unknown, is not a graph, cannot
be materialized, or the induced subgraph contains a cycle. Elements absent
from the projection are ignored, so the chain is computed over the present
subset.
§Performance
This method is O(relation count * incidence count + visible elements + visible edges).