Class WindowImpl<T>

java.lang.Object
org.jooq.lambda.WindowImpl<T>
All Implemented Interfaces:
Collectable<T>, Window<T>

class WindowImpl<T> extends Object implements Window<T>
  • Field Details

    • value

      final Tuple2<T,Long> value
    • index

      final int index
    • partition

      final Partition<T> partition
    • order

      final Comparator<? super T> order
    • lower

      final long lower
    • upper

      final long upper
  • Constructor Details

  • Method Details

    • value

      public T value()
      Description copied from interface: Window
      The value of the current row in the window.
      Specified by:
      value in interface Window<T>
    • window

      public Seq<T> window()
      Description copied from interface: Window
      Stream all elements in the window.
      Specified by:
      window in interface Window<T>
    • lower

      private int lower()
    • lowerInPartition

      private boolean lowerInPartition()
    • upper

      private int upper()
    • upperInPartition

      private boolean upperInPartition()
    • completePartition

      private boolean completePartition()
    • rowNumber

      public long rowNumber()
      Description copied from interface: Window
      The row number of the current row within the partition.

      
       // (1, 2, 3, 4, 5)
       Seq.of(1, 2, 4, 2, 3).window().map(w -> w.rowNumber());
       
      Specified by:
      rowNumber in interface Window<T>
    • rank

      public long rank()
      Description copied from interface: Window
      The rank of the current row within the partition.

      
       // (1, 2, 2, 4, 5)
       Seq.of(1, 2, 2, 3, 4).window(naturalOrder()).map(w -> w.rank());
       
      Specified by:
      rank in interface Window<T>
    • denseRank

      public long denseRank()
      Description copied from interface: Window
      The dense rank of the current row within the partition.

      
       // (1, 2, 2, 3, 4)
       Seq.of(1, 2, 2, 3, 4).window(naturalOrder()).map(w -> w.denseRank());
       
      Specified by:
      denseRank in interface Window<T>
    • percentRank

      public double percentRank()
      Description copied from interface: Window
      The precent rank of the current row within the partition.

      
       // (0.0, 0.25, 0.25, 0.75, 1.0)
       Seq.of(1, 2, 2, 3, 4).window(naturalOrder()).map(w -> w.percentRank());
       
      Specified by:
      percentRank in interface Window<T>
    • ntile

      public long ntile(long bucket)
      Description copied from interface: Window
      The bucket number ("ntile") of the current row within the partition.

      
       // (0, 0, 1, 1, 2)
       Seq.of(1, 2, 2, 3, 4).window(naturalOrder()).map(w -> w.ntile(3));
       
      Specified by:
      ntile in interface Window<T>
    • lead

      public Optional<T> lead()
      Description copied from interface: Window
      The next value in the window.

      This is the same as calling lead(1)

      
       // (2, 2, 3, 4, empty)
       Seq.of(1, 2, 2, 3, 4).window().map(w -> w.lead());
       
      Specified by:
      lead in interface Window<T>
    • lead

      public Optional<T> lead(long lead)
      Description copied from interface: Window
      The next value by lead in the window.

      
       // (2, 2, 3, 4, empty)
       Seq.of(1, 2, 2, 3, 4).window().map(w -> w.lead());
       
      Specified by:
      lead in interface Window<T>
    • lag

      public Optional<T> lag()
      Description copied from interface: Window
      The previous value in the window.

      This is the same as calling lag(1)

      
       // (empty, 1, 2, 2, 3)
       Seq.of(1, 2, 2, 3, 4).window().map(w -> w.lag());
       
      Specified by:
      lag in interface Window<T>
    • lag

      public Optional<T> lag(long lag)
      Description copied from interface: Window
      The previous value by lag in the window.

      
       // (empty, 1, 2, 2, 3)
       Seq.of(1, 2, 2, 3, 4).window().map(w -> w.lag());
       
      Specified by:
      lag in interface Window<T>
    • lead0

      private Optional<T> lead0(long lead)
    • firstValue

      public Optional<T> firstValue()
      Description copied from interface: Window
      The first value in the window.

      
       // (1, 1, 1, 1, 1)
       Seq.of(1, 2, 4, 2, 3).window().map(w -> w.firstValue());
       
      Specified by:
      firstValue in interface Window<T>
    • firstValue

      public <U> Optional<U> firstValue(Function<? super T,? extends U> function)
      Description copied from interface: Window
      The first value in the window.

      
       // (1, 1, 1, 1, 1)
       Seq.of(1, 2, 4, 2, 3).window().map(w -> w.firstValue());
       
      Specified by:
      firstValue in interface Window<T>
    • lastValue

      public Optional<T> lastValue()
      Description copied from interface: Window
      The last value in the window.

      
       // (3, 3, 3, 3, 3)
       Seq.of(1, 2, 4, 2, 3).window().map(w -> w.lastValue());
       
      Specified by:
      lastValue in interface Window<T>
    • lastValue

      public <U> Optional<U> lastValue(Function<? super T,? extends U> function)
      Description copied from interface: Window
      The last value in the window.

      
       // (3, 3, 3, 3, 3)
       Seq.of(1, 2, 4, 2, 3).window().map(w -> w.lastValue());
       
      Specified by:
      lastValue in interface Window<T>
    • nthValue

      public Optional<T> nthValue(long n)
      Description copied from interface: Window
      The nth value in the window.

      
       // (4, 4, 4, 4, 4)
       Seq.of(1, 2, 4, 2, 3).window().map(w -> w.nthValue(2));
       
      Specified by:
      nthValue in interface Window<T>
    • nthValue

      public <U> Optional<U> nthValue(long n, Function<? super T,? extends U> function)
      Description copied from interface: Window
      The nth value in the window.

      
       // (4, 4, 4, 4, 4)
       Seq.of(1, 2, 4, 2, 3).window().map(w -> w.nthValue(2));
       
      Specified by:
      nthValue in interface Window<T>
    • count

      public long count()
      Description copied from interface: Collectable
      Count the values in this collectable.
      Specified by:
      count in interface Collectable<T>
    • count

      public long count(Predicate<? super T> predicate)
      Description copied from interface: Collectable
      Count the values in this collectable, for which a predicate evaluates to true.
      Specified by:
      count in interface Collectable<T>
    • countDistinct

      public long countDistinct()
      Description copied from interface: Collectable
      Count the distinct values in this collectable.
      Specified by:
      countDistinct in interface Collectable<T>
    • countDistinct

      public long countDistinct(Predicate<? super T> predicate)
      Description copied from interface: Collectable
      Count the distinct values in this collectable, for which a predicate evaluates to true.
      Specified by:
      countDistinct in interface Collectable<T>
    • countDistinctBy

      public <U> long countDistinctBy(Function<? super T,? extends U> function)
      Description copied from interface: Collectable
      Count the distinct values of a given expression in this collectable.
      Specified by:
      countDistinctBy in interface Collectable<T>
    • countDistinctBy

      public <U> long countDistinctBy(Function<? super T,? extends U> function, Predicate<? super U> predicate)
      Description copied from interface: Collectable
      Count the distinct values of a given expression in this collectable, for which a predicate evaluates to true.
      Specified by:
      countDistinctBy in interface Collectable<T>
    • sum

      public Optional<T> sum()
      Description copied from interface: Collectable
      Get the sum of the elements in this collectable.
      Specified by:
      sum in interface Collectable<T>
    • sum

      public <U> Optional<U> sum(Function<? super T,? extends U> function)
      Description copied from interface: Collectable
      Get the sum of the elements in this collectable.
      Specified by:
      sum in interface Collectable<T>
    • sumInt

      public int sumInt(ToIntFunction<? super T> function)
      Description copied from interface: Collectable
      Get the sum of the elements in this collectable as int.
      Specified by:
      sumInt in interface Collectable<T>
    • sumLong

      public long sumLong(ToLongFunction<? super T> function)
      Description copied from interface: Collectable
      Get the sum of the elements in this collectable as long.
      Specified by:
      sumLong in interface Collectable<T>
    • sumDouble

      public double sumDouble(ToDoubleFunction<? super T> function)
      Description copied from interface: Collectable
      Get the sum of the elements in this collectable as double.
      Specified by:
      sumDouble in interface Collectable<T>
    • avg

      public Optional<T> avg()
      Description copied from interface: Collectable
      Get the average of the elements in this collectable.
      Specified by:
      avg in interface Collectable<T>
    • avg

      public <U> Optional<U> avg(Function<? super T,? extends U> function)
      Description copied from interface: Collectable
      Get the average of the elements in this collectable.
      Specified by:
      avg in interface Collectable<T>
    • avgInt

      public double avgInt(ToIntFunction<? super T> function)
      Description copied from interface: Collectable
      Get the average of the elements in this collectable as int.
      Specified by:
      avgInt in interface Collectable<T>
    • avgLong

      public double avgLong(ToLongFunction<? super T> function)
      Description copied from interface: Collectable
      Get the average of the elements in this collectable as long.
      Specified by:
      avgLong in interface Collectable<T>
    • avgDouble

      public double avgDouble(ToDoubleFunction<? super T> function)
      Description copied from interface: Collectable
      Get the average of the elements in this collectable as double.
      Specified by:
      avgDouble in interface Collectable<T>
    • min

      public Optional<T> min()
      Description copied from interface: Collectable
      Get the minimum value.

      This makes the unsafe assumption that <T extends Comparable<? super T>>

      Specified by:
      min in interface Collectable<T>
    • min

      public Optional<T> min(Comparator<? super T> comparator)
      Description copied from interface: Collectable
      Get the minimum value by a function.
      Specified by:
      min in interface Collectable<T>
    • min

      public <U extends Comparable<? super U>> Optional<U> min(Function<? super T,? extends U> function)
      Description copied from interface: Collectable
      Get the minimum value by a function.
      Specified by:
      min in interface Collectable<T>
    • min

      public <U> Optional<U> min(Function<? super T,? extends U> function, Comparator<? super U> comparator)
      Description copied from interface: Collectable
      Get the minimum value by a function.
      Specified by:
      min in interface Collectable<T>
    • minBy

      public <U extends Comparable<? super U>> Optional<T> minBy(Function<? super T,? extends U> function)
      Description copied from interface: Collectable
      Get the minimum value by a function.
      Specified by:
      minBy in interface Collectable<T>
    • minBy

      public <U> Optional<T> minBy(Function<? super T,? extends U> function, Comparator<? super U> comparator)
      Description copied from interface: Collectable
      Get the minimum value by a function.
      Specified by:
      minBy in interface Collectable<T>
    • minAll

      public Seq<T> minAll()
      Description copied from interface: Collectable
      Get the minimum values.

      This makes the unsafe assumption that <T extends Comparable<? super T>>

      Specified by:
      minAll in interface Collectable<T>
    • minAll

      public Seq<T> minAll(Comparator<? super T> comparator)
      Description copied from interface: Collectable
      Get the minimum values by a function.
      Specified by:
      minAll in interface Collectable<T>
    • minAll

      public <U extends Comparable<? super U>> Seq<U> minAll(Function<? super T,? extends U> function)
      Description copied from interface: Collectable
      Get the minimum values by a function.
      Specified by:
      minAll in interface Collectable<T>
    • minAll

      public <U> Seq<U> minAll(Function<? super T,? extends U> function, Comparator<? super U> comparator)
      Description copied from interface: Collectable
      Get the minimum values by a function.
      Specified by:
      minAll in interface Collectable<T>
    • minAllBy

      public <U extends Comparable<? super U>> Seq<T> minAllBy(Function<? super T,? extends U> function)
      Description copied from interface: Collectable
      Get the minimum values by a function.
      Specified by:
      minAllBy in interface Collectable<T>
    • minAllBy

      public <U> Seq<T> minAllBy(Function<? super T,? extends U> function, Comparator<? super U> comparator)
      Description copied from interface: Collectable
      Get the minimum values by a function.
      Specified by:
      minAllBy in interface Collectable<T>
    • max

      public Optional<T> max()
      Description copied from interface: Collectable
      Get the maximum value.

      This makes the unsafe assumption that <T extends Comparable<? super T>>

      Specified by:
      max in interface Collectable<T>
    • max

      public Optional<T> max(Comparator<? super T> comparator)
      Description copied from interface: Collectable
      Get the maximum value by a function.
      Specified by:
      max in interface Collectable<T>
    • max

      public <U extends Comparable<? super U>> Optional<U> max(Function<? super T,? extends U> function)
      Description copied from interface: Collectable
      Get the maximum value by a function.
      Specified by:
      max in interface Collectable<T>
    • max

      public <U> Optional<U> max(Function<? super T,? extends U> function, Comparator<? super U> comparator)
      Description copied from interface: Collectable
      Get the maximum value by a function.
      Specified by:
      max in interface Collectable<T>
    • maxBy

      public <U extends Comparable<? super U>> Optional<T> maxBy(Function<? super T,? extends U> function)
      Description copied from interface: Collectable
      Get the maximum value by a function.
      Specified by:
      maxBy in interface Collectable<T>
    • maxBy

      public <U> Optional<T> maxBy(Function<? super T,? extends U> function, Comparator<? super U> comparator)
      Description copied from interface: Collectable
      Get the maximum value by a function.
      Specified by:
      maxBy in interface Collectable<T>
    • maxAll

      public Seq<T> maxAll()
      Description copied from interface: Collectable
      Get the maximum values.

      This makes the unsafe assumption that <T extends Comparable<? super T>>

      Specified by:
      maxAll in interface Collectable<T>
    • maxAll

      public Seq<T> maxAll(Comparator<? super T> comparator)
      Description copied from interface: Collectable
      Get the maximum values by a function.
      Specified by:
      maxAll in interface Collectable<T>
    • maxAll

      public <U extends Comparable<? super U>> Seq<U> maxAll(Function<? super T,? extends U> function)
      Description copied from interface: Collectable
      Get the maximum values by a function.
      Specified by:
      maxAll in interface Collectable<T>
    • maxAll

      public <U> Seq<U> maxAll(Function<? super T,? extends U> function, Comparator<? super U> comparator)
      Description copied from interface: Collectable
      Get the maximum values by a function.
      Specified by:
      maxAll in interface Collectable<T>
    • maxAllBy

      public <U extends Comparable<? super U>> Seq<T> maxAllBy(Function<? super T,? extends U> function)
      Description copied from interface: Collectable
      Get the maximum values by a function.
      Specified by:
      maxAllBy in interface Collectable<T>
    • maxAllBy

      public <U> Seq<T> maxAllBy(Function<? super T,? extends U> function, Comparator<? super U> comparator)
      Description copied from interface: Collectable
      Get the maximum values by a function.
      Specified by:
      maxAllBy in interface Collectable<T>
    • median

      public Optional<T> median()
      Description copied from interface: Collectable
      Get the median value.

      This makes the unsafe assumption that <T extends Comparable<? super T>>

      Specified by:
      median in interface Collectable<T>
    • median

      public Optional<T> median(Comparator<? super T> comparator)
      Description copied from interface: Collectable
      Get the median value.
      Specified by:
      median in interface Collectable<T>
    • medianBy

      public <U extends Comparable<? super U>> Optional<T> medianBy(Function<? super T,? extends U> function)
      Description copied from interface: Collectable
      Get the median value by a function.
      Specified by:
      medianBy in interface Collectable<T>
    • medianBy

      public <U> Optional<T> medianBy(Function<? super T,? extends U> function, Comparator<? super U> comparator)
      Description copied from interface: Collectable
      Get the median value by a function.
      Specified by:
      medianBy in interface Collectable<T>
    • percentile

      public Optional<T> percentile(double percentile)
      Description copied from interface: Collectable
      Get the discrete percentile value.

      This makes the unsafe assumption that <T extends Comparable<? super T>>

      Specified by:
      percentile in interface Collectable<T>
    • percentile

      public Optional<T> percentile(double percentile, Comparator<? super T> comparator)
      Description copied from interface: Collectable
      Get the discrete percentile value.
      Specified by:
      percentile in interface Collectable<T>
    • percentileBy

      public <U extends Comparable<? super U>> Optional<T> percentileBy(double percentile, Function<? super T,? extends U> function)
      Description copied from interface: Collectable
      Get the discrete percentile value by a function.
      Specified by:
      percentileBy in interface Collectable<T>
    • percentileBy

      public <U> Optional<T> percentileBy(double percentile, Function<? super T,? extends U> function, Comparator<? super U> comparator)
      Description copied from interface: Collectable
      Get the discrete percentile value by a function.
      Specified by:
      percentileBy in interface Collectable<T>
    • mode

      public Optional<T> mode()
      Description copied from interface: Collectable
      Get the mode, i.e. the value that appears most often in the collectable.
      Specified by:
      mode in interface Collectable<T>
    • modeBy

      public <U> Optional<T> modeBy(Function<? super T,? extends U> function)
      Description copied from interface: Collectable
      Get the mode, i.e. the value that appears most often in the collectable.
      Specified by:
      modeBy in interface Collectable<T>
    • modeAll

      public Seq<T> modeAll()
      Description copied from interface: Collectable
      Get the mode, i.e. the values that appear most often in the collectable.
      Specified by:
      modeAll in interface Collectable<T>
    • modeAllBy

      public <U> Seq<T> modeAllBy(Function<? super T,? extends U> function)
      Description copied from interface: Collectable
      Get the mode, i.e. the values that appear most often in the collectable.
      Specified by:
      modeAllBy in interface Collectable<T>
    • allMatch

      public boolean allMatch(Predicate<? super T> predicate)
      Description copied from interface: Collectable
      Whether all elements in the collectable match a given predicate.
      Specified by:
      allMatch in interface Collectable<T>
    • anyMatch

      public boolean anyMatch(Predicate<? super T> predicate)
      Description copied from interface: Collectable
      Whether any element in the collectable matches a given predicate.
      Specified by:
      anyMatch in interface Collectable<T>
    • noneMatch

      public boolean noneMatch(Predicate<? super T> predicate)
      Description copied from interface: Collectable
      Whether no element in the collectable matches a given predicate.
      Specified by:
      noneMatch in interface Collectable<T>
    • bitAnd

      public Optional<T> bitAnd()
      Description copied from interface: Collectable
      Collect all bits in this stream into a single value by applying bitwise and.
      Specified by:
      bitAnd in interface Collectable<T>
    • bitAnd

      public <U> Optional<U> bitAnd(Function<? super T,? extends U> function)
      Description copied from interface: Collectable
      Collect all bits in this stream into a single value by applying bitwise and.
      Specified by:
      bitAnd in interface Collectable<T>
    • bitAndInt

      public int bitAndInt(ToIntFunction<? super T> function)
      Description copied from interface: Collectable
      Collect all bits in this stream into a single value by applying bitwise and.
      Specified by:
      bitAndInt in interface Collectable<T>
    • bitAndLong

      public long bitAndLong(ToLongFunction<? super T> function)
      Description copied from interface: Collectable
      Collect all bits in this stream into a single value by applying bitwise and.
      Specified by:
      bitAndLong in interface Collectable<T>
    • bitOr

      public Optional<T> bitOr()
      Description copied from interface: Collectable
      Collect all bits in this stream into a single value by applying bitwise or.
      Specified by:
      bitOr in interface Collectable<T>
    • bitOr

      public <U> Optional<U> bitOr(Function<? super T,? extends U> function)
      Description copied from interface: Collectable
      Collect all bits in this stream into a single value by applying bitwise or.
      Specified by:
      bitOr in interface Collectable<T>
    • bitOrInt

      public int bitOrInt(ToIntFunction<? super T> function)
      Description copied from interface: Collectable
      Collect all bits in this stream into a single value by applying bitwise or.
      Specified by:
      bitOrInt in interface Collectable<T>
    • bitOrLong

      public long bitOrLong(ToLongFunction<? super T> function)
      Description copied from interface: Collectable
      Collect all bits in this stream into a single value by applying bitwise or.
      Specified by:
      bitOrLong in interface Collectable<T>
    • collect

      public <R, A> R collect(Collector<? super T,A,R> collector)
      Description copied from interface: Collectable
      Collect this collectable.
      Specified by:
      collect in interface Collectable<T>
    • toList

      public List<T> toList()
      Description copied from interface: Collectable
      Collect the collectable into an ArrayList.
      Specified by:
      toList in interface Collectable<T>
    • toList

      public <L extends List<T>> L toList(Supplier<L> factory)
      Description copied from interface: Collectable
      Collect the collectable into a List.
      Specified by:
      toList in interface Collectable<T>
    • toUnmodifiableList

      public List<T> toUnmodifiableList()
      Description copied from interface: Collectable
      Collect the collectable into an unmodifiable List.
      Specified by:
      toUnmodifiableList in interface Collectable<T>
    • toSet

      public Set<T> toSet()
      Description copied from interface: Collectable
      Collect the collectable into a LinkedHashSet.
      Specified by:
      toSet in interface Collectable<T>
    • toSet

      public <S extends Set<T>> S toSet(Supplier<S> factory)
      Description copied from interface: Collectable
      Collect the collectable into a Set.
      Specified by:
      toSet in interface Collectable<T>
    • toUnmodifiableSet

      public Set<T> toUnmodifiableSet()
      Description copied from interface: Collectable
      Collect the collectable into an unmodifiable Set.
      Specified by:
      toUnmodifiableSet in interface Collectable<T>
    • toCollection

      public <C extends Collection<T>> C toCollection(Supplier<C> factory)
      Description copied from interface: Collectable
      Collect the collectable into a Collection.
      Specified by:
      toCollection in interface Collectable<T>
    • toMap

      public <K, V> Map<K,V> toMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends V> valueMapper)
      Description copied from interface: Collectable
      Collect the collectable into a Map.
      Specified by:
      toMap in interface Collectable<T>
    • toMap

      public <K> Map<K,T> toMap(Function<? super T,? extends K> keyMapper)
      Description copied from interface: Collectable
      Collect the collectable into a Map with the given keys and the self element as value.
      Specified by:
      toMap in interface Collectable<T>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toString

      public String toString(CharSequence delimiter)
      Description copied from interface: Collectable
      Consume a stream and concatenate all elements using a separator.
      Specified by:
      toString in interface Collectable<T>
    • toString

      public String toString(CharSequence delimiter, CharSequence prefix, CharSequence suffix)
      Description copied from interface: Collectable
      Specified by:
      toString in interface Collectable<T>
    • commonPrefix

      public String commonPrefix()
      Description copied from interface: Collectable
      Get the common prefix of all strings (or to-stringed values) in this stream.
      Specified by:
      commonPrefix in interface Collectable<T>
    • commonSuffix

      public String commonSuffix()
      Description copied from interface: Collectable
      Get the common prefix of all strings (or to-stringed values) in this stream.
      Specified by:
      commonSuffix in interface Collectable<T>