Skip to main content

LifecycleStorage

Struct LifecycleStorage 

Source
#[non_exhaustive]
pub struct LifecycleStorage { pub engine_vertices: usize, pub retired_vertices: usize, pub catalog_nodes: usize, pub catalog_node_capacity: usize, pub incident_entries: usize, pub incident_capacity: usize, }
Expand description

Storage diagnostics of a LifecycleGraph, from LifecycleGraph::storage_stats.

Logical sizes and retained capacities are reported separately: vectors and hash maps keep capacity after removals, so capacity can exceed the logical size. Capacities count elements, not bytes, and exclude allocator overhead and the inner engine’s own capacities.

The type, its six fields and its trait implementations are stable. It is #[non_exhaustive]: a minor release may add fields, but none of these is removed or changes meaning or unit in 1.x.

§Guaranteed

For a value s returned by g.storage_stats():

  • Every field is a count of elements (entries, vertices or slots), never bytes.
  • The values are computed at the call; s is a copy that does not follow later mutations of g.
  • s.catalog_nodes == g.node_count(), s.engine_vertices == g.engine_vertex_count(), s.engine_vertices == s.catalog_nodes + s.retired_vertices and s.incident_entries == 2 * g.edge_count() (registered edges, enabled or not, counted at both endpoints).
  • s.catalog_node_capacity >= s.catalog_nodes and s.incident_capacity >= s.incident_entries.
  • s.engine_vertices <= 2 * s.catalog_nodes + 1024, the bound of LifecycleGraph::engine_vertex_count.
  • On a graph with no registered node and no removal (for example a new one), engine_vertices, retired_vertices, catalog_nodes and incident_entries are 0.

§Implementation-dependent

The capacities (initial values, growth, what is retained after removals and catalog rebuilds), and how many retired slots exist below the bound above, that is when retired slots are compacted, depend on the implementation, the operation history and the standard library’s growth policy, and may change in any release. None of the values measures heap usage or RSS.

§Examples

use knotrel_core::{EngineConfig, LifecycleGraph};

let mut graph = LifecycleGraph::new(EngineConfig::CompactBfs)?;
graph.link(1, 2)?;
graph.link(2, 3)?;
assert!(graph.remove_node(3));
let storage = graph.storage_stats();
assert_eq!(storage.catalog_nodes, graph.node_count());
assert_eq!(storage.incident_entries, 2 * graph.edge_count());
assert_eq!(
    storage.engine_vertices,
    storage.catalog_nodes + storage.retired_vertices
);
assert!(storage.incident_capacity >= storage.incident_entries);

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§engine_vertices: usize

Vertices held by the inner engine, including retired slots.

§retired_vertices: usize

Retired engine slots of removed nodes not yet compacted.

§catalog_nodes: usize

Registered nodes in the catalog.

§catalog_node_capacity: usize

Capacity of the catalog’s node map (elements).

§incident_entries: usize

Incidence entries in the catalog: two per registered edge.

§incident_capacity: usize

Sum of the incident vectors’ capacities (elements).

Trait Implementations§

Source§

impl Clone for LifecycleStorage

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for LifecycleStorage

Source§

impl Debug for LifecycleStorage

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for LifecycleStorage

Source§

impl PartialEq for LifecycleStorage

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for LifecycleStorage

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.