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
impl VersionsSeen
Sourcepub fn should_activate(
&self,
node_name: &str,
trigger_fields: &[usize],
current: &[u64],
) -> bool
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, ¤t));Sourcepub fn mark_consumed(&mut self, node_name: &str, current: &[u64])
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", ¤t);
// Now node shouldn't activate for same versions
assert!(!seen.should_activate("node_a", &[0], ¤t));Sourcepub fn get_seen(&self, node_name: &str) -> &[u64]
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.
Sourcepub fn get_versions(&self, node_name: &str) -> &[u64]
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.
Sourcepub fn compute_triggered_fields(
&self,
node_name: &str,
trigger_fields: &[usize],
current_versions: &[u64],
) -> Vec<usize>
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 checktrigger_fields- Field indices that the node subscribes tocurrent_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, ¤t);
assert_eq!(triggered, vec![0, 2]); // both fields triggeredTrait Implementations§
Source§impl Clone for VersionsSeen
impl Clone for VersionsSeen
Source§fn clone(&self) -> VersionsSeen
fn clone(&self) -> VersionsSeen
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more