Class Window


  • public abstract class Window
    extends Object
    A single window instance, defined by its start and end timestamp. Window is agnostic if start/end boundaries are inclusive or exclusive; this is defined by concrete window implementations.

    To specify how Window boundaries are defined use Windows. For time semantics, see TimestampExtractor.

    See Also:
    Windows, TimeWindow, SessionWindow, UnlimitedWindow, TimestampExtractor
    • Field Detail

      • startMs

        protected final long startMs
      • endMs

        protected final long endMs
    • Constructor Detail

      • Window

        public Window​(long startMs,
                      long endMs)
               throws IllegalArgumentException
        Create a new window for the given start and end time.
        Parameters:
        startMs - the start timestamp of the window
        endMs - the end timestamp of the window
        Throws:
        IllegalArgumentException - if startMs is negative or if endMs is smaller than startMs
    • Method Detail

      • start

        public long start()
        Return the start timestamp of this window.
        Returns:
        The start timestamp of this window.
      • end

        public long end()
        Return the end timestamp of this window.
        Returns:
        The end timestamp of this window.
      • startTime

        public Instant startTime()
        Return the start time of this window.
        Returns:
        The start time of this window.
      • endTime

        public Instant endTime()
        Return the end time of this window.
        Returns:
        The end time of this window.
      • overlap

        public abstract boolean overlap​(Window other)
        Check if the given window overlaps with this window. Should throw an IllegalArgumentException if the other window has a different type than this window.
        Parameters:
        other - another window of the same type
        Returns:
        true if other overlaps with this window—false otherwise
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object