Skip to main content

HdtStorageStats

Struct HdtStorageStats 

Source
pub struct HdtStorageStats {
    pub vertex_count: usize,
    pub edge_count: usize,
    pub available_levels: usize,
    pub vector_capacity_bytes: usize,
    pub ordered_payload_bytes: usize,
    pub edge_arc_capacity_bytes: usize,
    pub level_capacity_bytes: usize,
    pub levels: Vec<HdtLevelStorage>,
}
Expand description

Structural storage snapshot of an crate::HdtGraph, from crate::HdtGraph::storage_stats, collected outside timed graph operations.

A stable interface of the experimental HDT engine (crate::EngineConfig::Hdt). The struct is exhaustive: its eight public fields are frozen for 1.x, and a new field requires a major release.

§Guaranteed

For a snapshot s of a graph g, computed at the call:

  • s.vertex_count == g.node_count() and s.edge_count == g.edge_count().
  • Every *_bytes field is in bytes; vertex_count, edge_count, available_levels and the per-level counts are plain counts.
  • s.vector_capacity_bytes is the sum of s.level_capacity_bytes, s.edge_arc_capacity_bytes and, for every level, its token_capacity_bytes, vertex_index_capacity_bytes, free_list_capacity_bytes, adjacency_capacity_bytes and mapping_capacity_bytes.
  • s.levels is empty exactly when s.vertex_count == 0, and s.levels[i].level == i for every index i (ascending, from level 0).
  • s.available_levels == 0 exactly when s.vertex_count == 0, and s.levels.len() <= s.available_levels. Since vertices are never removed, available_levels never decreases for one graph.
  • Level 0 holds a spanning forest of the whole graph: s.levels[0].tree_edges equals vertex_count minus the number of connected components, and tree_edges does not increase from one level to the next (each level’s forest contains the next one’s).
  • Each edge has exactly one level, where it is counted at both endpoints: the sum over all levels of tree_incidences + non_tree_incidences is 2 * s.edge_count, and the sum of tree_incidences is 2 * s.levels[0].tree_edges.

§Implementation-dependent

Every capacity and payload byte value, the number of materialized levels, the per-level vertices record slots, which edges are tree edges at which level, and the exact available_levels beyond the properties above depend on the implementation, the operation history and the standard library’s growth policy, and may change in any release. Capacities retain their peaks after removals. None of the values is total heap usage or RSS: allocator overhead, hash table and B-tree overhead and the snapshot itself are excluded.

§Examples

use knotrel_core::HdtGraph;

let mut graph = HdtGraph::new();
graph.link(1, 2)?;
graph.link(2, 3)?;
graph.link(3, 1)?;
graph.add_node(4);
let storage = graph.storage_stats();
assert_eq!(storage.vertex_count, 4);
assert_eq!(storage.edge_count, 3);
// Four vertices in two components: a spanning forest of two edges.
assert_eq!(storage.levels[0].tree_edges, 2);
let incidences: usize = storage
    .levels
    .iter()
    .map(|level| level.tree_incidences + level.non_tree_incidences)
    .sum();
assert_eq!(incidences, 2 * storage.edge_count);

Fields§

§vertex_count: usize

Registered graph vertices.

§edge_count: usize

Live graph edges.

§available_levels: usize

Number of levels allowed by the current vertex universe.

§vector_capacity_bytes: usize

Owned vector capacities in bytes, excluding this snapshot.

§ordered_payload_bytes: usize

Live key/value payload bytes of the graph’s ordered (B-tree) and hashed containers: the vertex-ID and edge hash maps, and for every level its B-tree adjacency sets and its mapping_payload_bytes. Despite the name, hashed containers are included; B-tree and hash table overhead are excluded.

§edge_arc_capacity_bytes: usize

Capacity bytes of per-edge tour handle vectors.

§level_capacity_bytes: usize

Capacity bytes of the level vector, including inline container headers.

§levels: Vec<HdtLevelStorage>

Materialized levels, in ascending order.

Trait Implementations§

Source§

impl Clone for HdtStorageStats

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 Debug for HdtStorageStats

Source§

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

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

impl Eq for HdtStorageStats

Source§

impl PartialEq for HdtStorageStats

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 HdtStorageStats

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.