Class Watermark

java.lang.Object
org.apache.flink.streaming.runtime.streamrecord.StreamElement
org.apache.flink.streaming.api.watermark.Watermark
Direct Known Subclasses:
InternalWatermark

@PublicEvolving public class Watermark extends StreamElement
A Watermark tells operators that no elements with a timestamp older or equal to the watermark timestamp should arrive at the operator. Watermarks are emitted at the sources and propagate through the operators of the topology. Operators must themselves emit watermarks to downstream operators using Output.emitWatermark(Watermark). Operators that do not internally buffer elements can always forward the watermark that they receive. Operators that buffer elements, such as window operators, must forward a watermark after emission of elements that is triggered by the arriving watermark.

In some cases a watermark is only a heuristic and operators should be able to deal with late elements. They can either discard those or update the result and emit updates/retractions to downstream operations.

When a source closes it will emit a final watermark with timestamp Long.MAX_VALUE. When an operator receives this it will know that no more input will be arriving in the future.

  • Field Details

    • MAX_WATERMARK

      public static final Watermark MAX_WATERMARK
      The watermark that signifies end-of-event-time.
    • UNINITIALIZED

      public static final Watermark UNINITIALIZED
      The watermark that signifies is used before any actual watermark has been generated.
    • timestamp

      protected final long timestamp
      The timestamp of the watermark in milliseconds.
  • Constructor Details

    • Watermark

      public Watermark(long timestamp)
      Creates a new watermark with the given timestamp in milliseconds.
  • Method Details

    • getTimestamp

      public long getTimestamp()
      Returns the timestamp associated with this Watermark in milliseconds.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object