Skip to main content

WatermarkGenerator

Trait WatermarkGenerator 

Source
pub trait WatermarkGenerator: Send {
    // Required methods
    fn on_event(&mut self, timestamp: i64) -> Option<Watermark>;
    fn on_periodic(&mut self) -> Option<Watermark>;
    fn current_watermark(&self) -> i64;
    fn advance_watermark(&mut self, timestamp: i64) -> Option<Watermark>;

    // Provided method
    fn is_processing_time(&self) -> bool { ... }
}
Expand description

Trait for generating watermarks from event timestamps.

Implementations track observed timestamps and produce watermarks that indicate event-time progress. The watermark is an assertion that no events with timestamps earlier than the watermark are expected.

Required Methods§

Source

fn on_event(&mut self, timestamp: i64) -> Option<Watermark>

Process an event timestamp and potentially emit a new watermark.

Called for each event processed. Returns Some(watermark) if the watermark should advance, None otherwise.

Source

fn on_periodic(&mut self) -> Option<Watermark>

Called periodically to emit watermarks based on wall-clock time.

Useful for generating watermarks even when no events are arriving.

Source

fn current_watermark(&self) -> i64

Returns the current watermark value without advancing it.

Source

fn advance_watermark(&mut self, timestamp: i64) -> Option<Watermark>

Advances the watermark to at least the given timestamp from an external source.

Called when the source provides an explicit watermark (e.g., Source::watermark()). Returns Some(Watermark) if the watermark advanced, None if the timestamp was not higher than the current watermark.

Provided Methods§

Source

fn is_processing_time(&self) -> bool

Whether the watermark is processing-time based (wall clock), rather than derived from the event-time column. Such a watermark lives in a different time domain than the event timestamps, so comparing the two to drop “late” rows would discard every event — callers skip source-side late-filtering when this is true. Defaults to false (event-time generators).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§