pub struct GraphIndex<'a> { /* private fields */ }Expand description
A borrowed, per-traversal accelerator for SchemaGraph::lookup.
SchemaGraph::lookup is a linear scan over defs. When a single
traversal (value validation, rendering, ref resolution) resolves many
SchemaType::Refs against a wide graph, those repeated scans dominate.
GraphIndex borrows a graph once and, for graphs above a small size
threshold, builds a one-shot hash index so each subsequent lookup is O(1).
Small graphs keep the plain linear scan, because building and hashing an
index is a net loss there (and would otherwise regress narrow inputs such
as a typical agent method parameter record).
It only borrows the graph and never mutates it, so SchemaGraph stays a
pure data/wire model (no embedded lazy cache that would travel through
serde / desert / protobuf / poem derives).
Implementations§
Source§impl<'a> GraphIndex<'a>
impl<'a> GraphIndex<'a>
Sourcepub fn new(graph: &'a SchemaGraph) -> GraphIndex<'a>
pub fn new(graph: &'a SchemaGraph) -> GraphIndex<'a>
Borrow graph and prepare a lookup accelerator for it.
Sourcepub fn lookup(&self, id: &TypeId) -> Option<&'a SchemaTypeDef>
pub fn lookup(&self, id: &TypeId) -> Option<&'a SchemaTypeDef>
Look up a named definition by its TypeId, with the same semantics as
SchemaGraph::lookup.