Window functions as exposed in this type are inspired by their counterparts in SQL. They include:
| Function | Description |
|---|---|
rowNumber() | The distinct row number of the row within
the partition, counting from 0. |
rank() | The rank with gaps of a row within the partition,
counting from 0. |
denseRank() | The rank without gaps of a row within the
partition, counting from 0. |
percentRank() | Relative rank of a row:
rank() / count(). |
ntile(long) | Divides the partition in equal buckets and
assigns values between 0 and buckets - 1. |
lead() | Gets the value after the current row. |
lag() | Gets the value before the current row. |
firstValue() | Gets the first value in the window. |
lastValue() | Gets the last value in the window. |
nthValue(long) | Gets the nth value in the window,
counting from 0. |
Note: In Java, indexes are always counted from
0, not from 1 as in SQL. This means that the above
ranking functions also rank rows from zero. This is particularly true for:
Seq or from Agg is also
available as an aggregate function on the window. For instance,
count() is the same as calling Seq#count() on
window()
| Modifier and Type | Method and Description |
|---|---|
| public long | |
| public Optional | |
| public <U> Optional | |
| public Optional | |
| public Optional | |
| public Optional | |
| public <U> Optional | |
| public Optional | |
| public Optional | |
| public Optional | |
| public <U> Optional | |
| public long | |
| public static <T> WindowSpecification | |
| public static <T> WindowSpecification | |
| public static <T> WindowSpecification | |
| public static <T> WindowSpecification | |
| public static <T, U> WindowSpecification | |
| public static <T, U> WindowSpecification | |
| public static <T, U> WindowSpecification | |
| public static <T, U> WindowSpecification | of(Function<? super T, ? extends U> partitionBy, Comparator<? super T> orderBy, long lower, long upper)
|
| public double | |
| public long | |
| public long | |
| public T | |
| public Seq |
| denseRank | back to summary |
|---|---|
| public long denseRank() The dense rank of the current row within the partition.
| |
| firstValue | back to summary |
|---|---|
| public Optional The first value in the window.
| |
| firstValue | back to summary |
|---|---|
| public <U> Optional The first value in the window.
| |
| lag | back to summary |
|---|---|
| public Optional The previous value in the window.
This is the same as calling
| |
| lag | back to summary |
|---|---|
| public Optional The previous value by
| |
| lastValue | back to summary |
|---|---|
| public Optional The last value in the window.
| |
| lastValue | back to summary |
|---|---|
| public <U> Optional The last value in the window.
| |
| lead | back to summary |
|---|---|
| public Optional The next value in the window.
This is the same as calling
| |
| lead | back to summary |
|---|---|
| public Optional The next value by
| |
| nthValue | back to summary |
|---|---|
| public Optional The nth value in the window.
| |
| nthValue | back to summary |
|---|---|
| public <U> Optional The nth value in the window.
| |
| ntile | back to summary |
|---|---|
| public long ntile(long buckets) The bucket number ("ntile") of the current row within the partition.
| |
| of | back to summary |
|---|---|
| public static <T> WindowSpecification | |
| of | back to summary |
|---|---|
| public static <T> WindowSpecification | |
| of | back to summary |
|---|---|
| public static <T> WindowSpecification | |
| of | back to summary |
|---|---|
| public static <T> WindowSpecification | |
| of | back to summary |
|---|---|
| public static <T, U> WindowSpecification | |
| of | back to summary |
|---|---|
| public static <T, U> WindowSpecification | |
| of | back to summary |
|---|---|
| public static <T, U> WindowSpecification | |
| of | back to summary |
|---|---|
| public static <T, U> WindowSpecification | |
| percentRank | back to summary |
|---|---|
| public double percentRank() The precent rank of the current row within the partition.
| |
| rank | back to summary |
|---|---|
| public long rank() The rank of the current row within the partition.
| |
| rowNumber | back to summary |
|---|---|
| public long rowNumber() The row number of the current row within the partition.
| |
| value | back to summary |
|---|---|
| public T value() The value of the current row in the window. | |
| window | back to summary |
|---|---|
| public Seq Stream all elements in the window. | |