Skip to main content

CchEngine

Struct CchEngine 

Source
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>

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl<P: Clone + ProfileId> Clone for CchEngine<P>

Source§

fn clone(&self) -> CchEngine<P>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.