Skip to main content

VersionsSeen

Struct VersionsSeen 

Source
pub struct VersionsSeen { /* private fields */ }
Expand description

Version tracking for node activation

Tracks which versions each node has seen to determine when it should be activated based on its trigger fields.

Implementations§

Source§

impl VersionsSeen

Source

pub fn new(node_names: &[String], num_fields: usize) -> Self

Create a new version tracker for the given nodes and fields

§Examples
use juncture_core::pregel::scheduler::VersionsSeen;

let node_names = vec!["node_a".to_string(), "node_b".to_string()];
let seen = VersionsSeen::new(&node_names, 3);
assert_eq!(seen.get_seen("node_a"), &[0, 0, 0]);
Source

pub fn should_activate( &self, node_name: &str, trigger_fields: &[usize], current: &[u64], ) -> bool

Check if a node should be activated based on its trigger fields

Returns true if any of the node’s trigger fields have new versions that the node hasn’t seen yet.

§Examples
use juncture_core::pregel::scheduler::VersionsSeen;

let node_names = vec!["node_a".to_string()];
let mut seen = VersionsSeen::new(&node_names, 3);

// Node should activate if field 0 has version > what it has seen
let trigger_fields = vec![0]; // triggers on field 0
let current = vec![1, 0, 0]; // field 0 is at version 1
assert!(seen.should_activate("node_a", &trigger_fields, &current));
Source

pub fn mark_consumed(&mut self, node_name: &str, current: &[u64])

Mark that a node has consumed the current field versions

§Examples
use juncture_core::pregel::scheduler::VersionsSeen;

let node_names = vec!["node_a".to_string()];
let mut seen = VersionsSeen::new(&node_names, 3);

let current = vec![1, 0, 0];
seen.mark_consumed("node_a", &current);

// Now node shouldn't activate for same versions
assert!(!seen.should_activate("node_a", &[0], &current));
Source

pub fn get_seen(&self, node_name: &str) -> &[u64]

Get the versions a node has seen

Returns an empty slice if the node is not tracked.

Source

pub fn get_versions(&self, node_name: &str) -> &[u64]

Get the versions a node has seen (alias for get_seen)

Returns an empty slice if the node is not tracked.

Source

pub fn compute_triggered_fields( &self, node_name: &str, trigger_fields: &[usize], current_versions: &[u64], ) -> Vec<usize>

Compute which fields triggered a node to activate

Compares the node’s seen versions with current field versions to determine which specific fields had updates that caused the node to be scheduled.

§Arguments
  • node_name - Name of the node to check
  • trigger_fields - Field indices that the node subscribes to
  • current_versions - Current field versions
§Returns

Vector of field indices that triggered this node (subset of trigger_fields)

§Examples
use juncture_core::pregel::scheduler::VersionsSeen;

let node_names = vec!["node_a".to_string()];
let mut seen = VersionsSeen::new(&node_names, 3);

let trigger_fields = vec![0, 2]; // node subscribes to fields 0 and 2
let current = vec![1, 0, 1]; // fields 0 and 2 have new versions
let triggered = seen.compute_triggered_fields("node_a", &trigger_fields, &current);
assert_eq!(triggered, vec![0, 2]); // both fields triggered

Trait Implementations§

Source§

impl Clone for VersionsSeen

Source§

fn clone(&self) -> VersionsSeen

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 VersionsSeen

Source§

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

Formats the value using the given formatter. Read more

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more