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()ands.edge_count == g.edge_count().- Every
*_bytesfield is in bytes;vertex_count,edge_count,available_levelsand the per-level counts are plain counts. s.vector_capacity_bytesis the sum ofs.level_capacity_bytes,s.edge_arc_capacity_bytesand, for every level, itstoken_capacity_bytes,vertex_index_capacity_bytes,free_list_capacity_bytes,adjacency_capacity_bytesandmapping_capacity_bytes.s.levelsis empty exactly whens.vertex_count == 0, ands.levels[i].level == ifor every indexi(ascending, from level 0).s.available_levels == 0exactly whens.vertex_count == 0, ands.levels.len() <= s.available_levels. Since vertices are never removed,available_levelsnever decreases for one graph.- Level 0 holds a spanning forest of the whole graph:
s.levels[0].tree_edgesequalsvertex_countminus the number of connected components, andtree_edgesdoes 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_incidencesis2 * s.edge_count, and the sum oftree_incidencesis2 * 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: usizeRegistered graph vertices.
edge_count: usizeLive graph edges.
available_levels: usizeNumber of levels allowed by the current vertex universe.
vector_capacity_bytes: usizeOwned vector capacities in bytes, excluding this snapshot.
ordered_payload_bytes: usizeLive 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: usizeCapacity bytes of per-edge tour handle vectors.
level_capacity_bytes: usizeCapacity bytes of the level vector, including inline container headers.
levels: Vec<HdtLevelStorage>Materialized levels, in ascending order.