pub struct WatermarkTracker { /* private fields */ }Expand description
Tracks watermarks across multiple input sources.
For operators with multiple inputs (e.g., joins, unions), the combined watermark is the minimum across all sources. This ensures no late events from any source are missed.
§Example
use laminar_core::time::{WatermarkTracker, Watermark};
let mut tracker = WatermarkTracker::new(3); // 3 sources
// Source 0 advances to 1000
let wm = tracker.update_source(0, 1000);
assert_eq!(wm, None); // Other sources still at MIN
// Source 1 advances to 2000
tracker.update_source(1, 2000);
// Source 2 advances to 500
let wm = tracker.update_source(2, 500);
assert_eq!(wm, Some(Watermark::new(500))); // Min of all sourcesImplementations§
Source§impl WatermarkTracker
impl WatermarkTracker
Sourcepub fn new(num_sources: usize) -> Self
pub fn new(num_sources: usize) -> Self
Creates a new tracker for the specified number of sources.
Sourcepub fn with_idle_timeout(num_sources: usize, idle_timeout: Duration) -> Self
pub fn with_idle_timeout(num_sources: usize, idle_timeout: Duration) -> Self
Creates a new tracker with a custom idle timeout.
Sourcepub fn update_source(
&mut self,
source_id: usize,
watermark: i64,
) -> Option<Watermark>
pub fn update_source( &mut self, source_id: usize, watermark: i64, ) -> Option<Watermark>
Updates the watermark for a specific source.
Returns Some(Watermark) if the combined watermark advances.
Sourcepub fn mark_idle(&mut self, source_id: usize) -> Option<Watermark>
pub fn mark_idle(&mut self, source_id: usize) -> Option<Watermark>
Marks a source as idle, excluding it from watermark calculation.
Idle sources don’t hold back the combined watermark.
Sourcepub fn check_idle_sources(&mut self) -> Option<Watermark>
pub fn check_idle_sources(&mut self) -> Option<Watermark>
Checks for sources that have been idle longer than the timeout.
Should be called periodically to detect stalled sources.
Sourcepub fn current_watermark(&self) -> Option<Watermark>
pub fn current_watermark(&self) -> Option<Watermark>
Returns the current combined watermark.
Sourcepub fn source_watermark(&self, source_id: usize) -> Option<i64>
pub fn source_watermark(&self, source_id: usize) -> Option<i64>
Returns the watermark for a specific source.
Sourcepub fn num_sources(&self) -> usize
pub fn num_sources(&self) -> usize
Returns the number of sources being tracked.
Sourcepub fn active_source_count(&self) -> usize
pub fn active_source_count(&self) -> usize
Returns the number of active (non-idle) sources.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WatermarkTracker
impl RefUnwindSafe for WatermarkTracker
impl Send for WatermarkTracker
impl Sync for WatermarkTracker
impl Unpin for WatermarkTracker
impl UnwindSafe for WatermarkTracker
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.