com.hazelcast.jet.pipeline

## Class WindowDefinition

- java.lang.Object
- - com.hazelcast.jet.pipeline.WindowDefinition

- Direct Known Subclasses:
    SessionWindowDefinition, SlidingWindowDefinition

      public abstract class WindowDefinition
      extends Object

  The definition of the window for a windowed aggregation operation. To obtain a window definition, use the factory methods provided in this interface.
  Since:
    3.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `WindowDefinition()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `long` | `earlyResultsPeriod()` Returns the early results period for this window definition.
    `static SessionWindowDefinition` | `session(long sessionTimeout)` Returns a window definition that aggregates events into session windows.
    `WindowDefinition` | `setEarlyResultsPeriod(long earlyResultPeriod)` Sets the period in milliseconds at which the windowed aggregation stage will emit partial results of all the windows that contain some data, but the watermark hasn't yet advanced enough to close them and emit the final results.
    `static SlidingWindowDefinition` | `sliding(long windowSize, long slideBy)` Returns a sliding window definition with the given parameters.
    `static SlidingWindowDefinition` | `tumbling(long windowSize)` Returns a tumbling window definition with the given parameters.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### WindowDefinition

          public WindowDefinition()

  - ### Method Detail

    - #### earlyResultsPeriod

          public long earlyResultsPeriod()

      Returns the early results period for this window definition. A return value of zero means that the stage won't emit early window results.
      Since:
        3.1

    - #### setEarlyResultsPeriod

          public WindowDefinition setEarlyResultsPeriod(long earlyResultPeriod)

      Sets the period in milliseconds at which the windowed aggregation stage will emit partial results of all the windows that contain some data, but the watermark hasn't yet advanced enough to close them and emit the final results.

      Consider this example: we're collecting a 1-minute tumbling window of stock exchange data. The results we're getting pertain to the minute that just elapsed, but we'd also like to detect any sudden changes within the running minute. We can set the early results period to 1000 ms and get an update every second for the window that's currently being filled with data.

      Note that, for a sliding window, there will be many incomplete windows that contain some data and you'll get the early results for all of them. Similarly, if you configure a high-enough `maxLag` for the event timestamps, there can be more than one tumbling/session window with early results.

      The default value is zero, which means "don't emit early results".

      Parameters:
        `earlyResultPeriod` - the period in milliseconds from one start of the emission of early results to the next one
      Returns:
        `this`
      Since:
        3.1

    - #### sliding

          @Nonnull
          public static SlidingWindowDefinition sliding(long windowSize,
                                                                 long slideBy)

      Returns a sliding window definition with the given parameters. In a sliding window, the incoming items are grouped by fixed-size and overlapping intervals where the windows "slide" by the given size.

      For example, given the timestamps `[0, 1, 2, 3, 4, 5, 6]`, `windowSize` of 4 and `@slideBy` of 2, the timestamps would be grouped into the following windows:

               [0, 1], [0, 1, 2, 3], [2, 3, 4, 5], [4, 5, 6], [6]

      A sliding window where window size and slide by are the same is equivalent to a tumbling window.

      Find more information see the Hazelcast Jet Reference Manual section Sliding and Tumbling Window.

      Parameters:
        `windowSize` - the size of the window in the items' timestamp unit (typically milliseconds)
        `slideBy` - the size of the sliding step. Window size must be multiple of this number.

    - #### tumbling

          @Nonnull
          public static SlidingWindowDefinition tumbling(long windowSize)

      Returns a tumbling window definition with the given parameters. In a tumbling window the incoming items are grouped by fixed size, contiguous and non-overlapping intervals.

      For example, given the timestamps `[0, 1, 2, 3, 4, 5, 6]` and a `windowSize` of 2, the timestamps would be grouped into the following windows:

               [0, 1], [2, 3], [4, 5], [6]

      Parameters:
        `windowSize` - the size of the window in the items' timestamp unit (typically milliseconds)

    - #### session

          @Nonnull
          public static SessionWindowDefinition session(long sessionTimeout)

      Returns a window definition that aggregates events into session windows. In a session window, the items are grouped into variable size, non-overlapping windows which are formed by periods of activity followed by inactivity. A session window is kept open as long as the gap between the events remains less than the given `sessionTimeout` and is closed when the gap exceeds the timeout.

      For example, given the timestamps `[0, 1, 4, 8, 9, 10, 15]` and a `sessionTimeout` of 2, the timestamps would be grouped into the following windows:

               [0, 1], [4], [8, 9, 10], [15]

      Parameters:
        `sessionTimeout` - the upper bound on the difference between any two consecutive timestamps in a window, given in the items' timestamp unit (typically milliseconds)

Copyright © 2020. All rights reserved.