Package: org.apache.groovy.ginq.provider.collection.runtime

## [Java] Interface Window<T>

- org.apache.groovy.ginq.provider.collection.runtime.Queryable

- All Superinterfaces:
    Queryable

      public interface Window<T>
      extends Queryable

  Represents window which stores elements used by window functions

  Type Parameters:
    `T` - the type of Window element
  Since:
    4.0.0

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public BigDecimal` | `cumeDist()` Returns the cumulative distribution of a value in the window
    `` | `public Long` | `denseRank()` Returns the dense rank in the window
    `<V>` | `public V` | `firstValue(Function<? super T, ? extends V> extractor)` Returns the first value in the window
    `<V>` | `public V` | `lag(Function<? super T, ? extends V> extractor)` Returns the previous value in the window, similar to SQL's `lag()`
    `<V>` | `public V` | `lag(Function<? super T, ? extends V> extractor, long lag)` Returns the previous value in the window, similar to SQL's `lag()`
    `<V>` | `public V` | `lag(Function<? super T, ? extends V> extractor, long lag, V def)` Returns the previous value by `lag` in the window, similar to SQL's `lag()`
    `<V>` | `public V` | `lastValue(Function<? super T, ? extends V> extractor)` Returns the last value in the window
    `<V>` | `public V` | `lead(Function<? super T, ? extends V> extractor)` Returns the next value in the window, similar to SQL's `lead()`
    `<V>` | `public V` | `lead(Function<? super T, ? extends V> extractor, long lead)` Returns the next value in the window, similar to SQL's `lead()`
    `<V>` | `public V` | `lead(Function<? super T, ? extends V> extractor, long lead, V def)` Returns the next value by `lead` in the window, similar to SQL's `lead()`
    `<V>` | `public V` | `nthValue(Function<? super T, ? extends V> extractor, long index)` Returns the nth value in the window
    `` | `public long` | `ntile(long bucketCnt)` Distributes rows of an ordered window into a pre-defined number of roughly equal buckets
    `<T, U extends Comparable<? super U>>` | `public static Window<T>` | `of(Tuple2<T, Long> currentRecord, Partition<Tuple2<T, Long>> partition, WindowDefinition<T, U> windowDefinition)` Factory method to create Window instance
    `` | `public BigDecimal` | `percentRank()` Returns the percent rank in the window
    `` | `public Long` | `rank()` Returns the rank in the window
    `` | `public long` | `rowNumber()` Returns row number in the window, similar to SQL's `row_number()`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `interface Queryable` | `agg, avg, count, count, crossJoin, distinct, emptyQueryable, exists, from, from, from, from, fullHashJoin, fullJoin, groupBy, groupBy, innerHashJoin, innerJoin, intersect, leftHashJoin, leftJoin, limit, limit, max, median, min, minus, orderBy, orderBy, over, rightHashJoin, rightJoin, select, size, stdev, stdevp, stream, sum, toList, union, unionAll, var, varp, where`

- - ### Method Detail

    - #### public BigDecimal cumeDist()

      Returns the cumulative distribution of a value in the window

      Returns:
        the cumulative distribution of a value
      Since:
        4.0.0

    - #### public Long denseRank()

      Returns the dense rank in the window

      Returns:
        the dense rank
      Since:
        4.0.0

    - #### <V> public V firstValue(Function<? super T, ? extends V> extractor)

      Returns the first value in the window

      Type Parameters:
        `V` - the type of field
      Parameters:
        `extractor` - field extractor
      Returns:
        the first value
      Since:
        4.0.0

    - #### <V> public V lag(Function<? super T, ? extends V> extractor)

      Returns the previous value in the window, similar to SQL's `lag()`

      Parameters:
        `extractor` - field extractor
      Type Parameters:
        `V` - the type of field
      Returns:
        the previous value
      Since:
        4.0.0

    - #### <V> public V lag(Function<? super T, ? extends V> extractor, long lag)

      Returns the previous value in the window, similar to SQL's `lag()`

      Parameters:
        `extractor` - field extractor
        `lag` - the offset
      Type Parameters:
        `V` - the type of field
      Returns:
        the previous value
      Since:
        4.0.0

    - #### <V> public V lag(Function<? super T, ? extends V> extractor, long lag, V def)

      Returns the previous value by `lag` in the window, similar to SQL's `lag()`

      Type Parameters:
        `V` - the type of field
      Parameters:
        `extractor` - field extractor
        `lag` - the offset
        `def` - the default value
      Returns:
        the previous value by `lag`
      Since:
        4.0.0

    - #### <V> public V lastValue(Function<? super T, ? extends V> extractor)

      Returns the last value in the window

      Type Parameters:
        `V` - the type of field
      Parameters:
        `extractor` - field extractor
      Returns:
        the last value
      Since:
        4.0.0

    - #### <V> public V lead(Function<? super T, ? extends V> extractor)

      Returns the next value in the window, similar to SQL's `lead()`

      Parameters:
        `extractor` - field extractor
      Type Parameters:
        `V` - the type of field
      Returns:
        the next value
      Since:
        4.0.0

    - #### <V> public V lead(Function<? super T, ? extends V> extractor, long lead)

      Returns the next value in the window, similar to SQL's `lead()`

      Parameters:
        `extractor` - field extractor
        `lead` - the offset
      Type Parameters:
        `V` - the type of field
      Returns:
        the next value
      Since:
        4.0.0

    - #### <V> public V lead(Function<? super T, ? extends V> extractor, long lead, V def)

      Returns the next value by `lead` in the window, similar to SQL's `lead()`

      Type Parameters:
        `V` - the type of field
      Parameters:
        `extractor` - field extractor
        `lead` - the offset
        `def` - the default value
      Returns:
        the next value by `lead`
      Since:
        4.0.0

    - #### <V> public V nthValue(Function<? super T, ? extends V> extractor, long index)

      Returns the nth value in the window

      Type Parameters:
        `V` - the type of field
      Parameters:
        `extractor` - field extractor
        `index` - index for value to fetch, starting with `0`
      Returns:
        the nth value
      Since:
        4.0.0

    - #### public long ntile(long bucketCnt)

      Distributes rows of an ordered window into a pre-defined number of roughly equal buckets

      Parameters:
        `bucketCnt` - bucket count
      Returns:
        bucket index starting with `0`
      Since:
        4.0.0

    - #### <T, U extends Comparable<? super U>> public static Window<T> of(Tuple2<T, Long> currentRecord, Partition<Tuple2<T, Long>> partition, WindowDefinition<T, U> windowDefinition)

      Factory method to create Window instance

      Parameters:
        `currentRecord` - current record
        `partition` - the partition where the window is constructed
        `windowDefinition` - window definition
      Type Parameters:
        `T` - the type of Window element
        `U` - the type of field to sort
      Returns:
        the Window instance
      Since:
        4.0.0

    - #### public BigDecimal percentRank()

      Returns the percent rank in the window

      Returns:
        the percent rank
      Since:
        4.0.0

    - #### public Long rank()

      Returns the rank in the window

      Returns:
        the rank
      Since:
        4.0.0

    - #### public long rowNumber()

      Returns row number in the window, similar to SQL's `row_number()`

      Returns:
        the row number
      Since:
        4.0.0