pub struct CchEngine<P: ProfileId> {
pub data: Arc<ArcSwap<EngineData<P>>>,
}Expand description
The thread-safe, high-performance CCH routing engine.
This is the primary entry point for issuing queries and updating graph state.
By utilizing ArcSwap, topology updates are atomically swapped in. Metric updates mutate
the affected profile in place behind a read-write lock, so queries to that profile may wait briefly.
Fields§
§data: Arc<ArcSwap<EngineData<P>>>Lock-free pointer to the current active routing state.
Implementations§
Source§impl<P: ProfileId> CchEngine<P>
impl<P: ProfileId> CchEngine<P>
Sourcepub fn new<'a, G: CchGraph + Sync>(
graph: &G,
profile_weights: impl IntoIterator<Item = (&'a P, &'a Vec<f32>)>,
) -> Self
pub fn new<'a, G: CchGraph + Sync>( graph: &G, profile_weights: impl IntoIterator<Item = (&'a P, &'a Vec<f32>)>, ) -> Self
Bootstraps a new routing engine from a base graph and a set of initial profiles.
This performs the initial Nested Dissection ordering, topology contraction, and heavily parallelized metric customization for all provided profiles.
Sourcepub fn update_weights(&self, profile_id: P, new_weights: &[f32])
pub fn update_weights(&self, profile_id: P, new_weights: &[f32])
Performs a zero-downtime update of the edge weights for a specific profile (e.g., live traffic).
This triggers the parallel Customization phase for the new weights and updates the profile in place. Queries to the same profile will wait on the profile lock.
Sourcepub fn update_weights_partial(&self, profile_id: P, updates: &[(usize, f32)])
pub fn update_weights_partial(&self, profile_id: P, updates: &[(usize, f32)])
Performs an incremental metric update for an existing profile.
updates contains (original_edge_index, new_weight) pairs in the base graph’s CSR edge order.
The engine only recomputes the affected hierarchy arcs and their dependents.
Sourcepub fn update_topology<G: CchGraph + Sync>(
&self,
graph: &G,
modified_old_nodes: &[u32],
new_nodes: &[u32],
profile_weights: &FxHashMap<P, Vec<f32>>,
)
pub fn update_topology<G: CchGraph + Sync>( &self, graph: &G, modified_old_nodes: &[u32], new_nodes: &[u32], profile_weights: &FxHashMap<P, Vec<f32>>, )
Performs a partial structural update to the elimination tree (e.g., minor road closures).
Instead of rebuilding the entire graph from scratch, this identifies the affected branches of the elimination tree and only recontracts the modified segments. It then re-customizes the metrics and hot-swaps the active state.
Sourcepub fn rebuild_topology<G: CchGraph + Sync>(
&self,
graph: &G,
profile_weights: &FxHashMap<P, Vec<f32>>,
)
pub fn rebuild_topology<G: CchGraph + Sync>( &self, graph: &G, profile_weights: &FxHashMap<P, Vec<f32>>, )
Triggers a complete rebuild of the underlying topology and metric data.
This behaves exactly like new(), but atomically swaps the newly built engine state
into the current instance.
Sourcepub fn query_path(&self, profile: P, from: u32, to: u32) -> Option<PathResult>
pub fn query_path(&self, profile: P, from: u32, to: u32) -> Option<PathResult>
Executes a shortest-path query between a source and target node for the given profile.
This method leverages thread-local storage to ensure zero dynamic memory allocation during the query. It evaluates a bidirectional Dijkstra search over the shortcut hierarchy.
Returns None if the profile doesn’t exist or if no path can be found.
Trait Implementations§
Auto Trait Implementations§
impl<P> Freeze for CchEngine<P>
impl<P> !RefUnwindSafe for CchEngine<P>
impl<P> Send for CchEngine<P>
impl<P> Sync for CchEngine<P>
impl<P> Unpin for CchEngine<P>
impl<P> UnsafeUnpin for CchEngine<P>
impl<P> !UnwindSafe for CchEngine<P>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more