Interface WatermarkStrategyWithPunctuatedWatermarks<T>

  • Type Parameters:
    T - The type of the elements to which this assigner assigns timestamps.
    All Superinterfaces:
    Serializable, TimestampAssigner<T>, TimestampAssignerSupplier<T>, WatermarkGeneratorSupplier<T>, WatermarkStrategy<T>
    All Known Implementing Classes:
    PunctuatedWatermarkStrategyWrapper

    @Internal
    public interface WatermarkStrategyWithPunctuatedWatermarks<T>
    extends WatermarkStrategy<T>, TimestampAssigner<T>
    The AssignerWithPunctuatedWatermarks assigns event time timestamps to elements, and generates low watermarks that signal event time progress within the stream. These timestamps and watermarks are used by functions and operators that operate on event time, for example event time windows.

    Use this class if certain special elements act as markers that signify event time progress, and when you want to emit watermarks specifically at certain events. The system will generate a new watermark, if the probed value is non-null and has a timestamp larger than that of the previous watermark (to preserve the contract of ascending watermarks).

    For use cases that should periodically emit watermarks based on element timestamps, use the WatermarkStrategyWithPeriodicWatermarks instead.

    The following example illustrates how to use this timestamp extractor and watermark generator. It assumes elements carry a timestamp that describes when they were created, and that some elements carry a flag, marking them as the end of a sequence such that no elements with smaller timestamps can come anymore.

    
     public class WatermarkOnFlagAssigner implements AssignerWithPunctuatedWatermarks<MyElement> {
    
         public long extractTimestamp(MyElement element, long previousElementTimestamp) {
             return element.getSequenceTimestamp();
         }
    
         public Watermark checkAndGetNextWatermark(MyElement lastElement, long extractedTimestamp) {
             return lastElement.isEndOfSequence() ? new Watermark(extractedTimestamp) : null;
         }
     }
     

    Timestamps and watermarks are defined as longs that represent the milliseconds since the Epoch (midnight, January 1, 1970 UTC). A watermark with a certain value t indicates that no elements with event timestamps x, where x is lower or equal to t, will occur any more.

    See Also:
    Watermark