Interface WindowedStream<T>

  • All Superinterfaces:
    Stream<T>

    public interface WindowedStream<T>
    extends Stream<T>
    A stream that is windowed.
    • Method Detail

      • reduce

        default <K,​V> WindowedStream<Pair<K,​V>> reduce​(groovy.lang.Closure<K> keyExtractor,
                                                                   groovy.lang.Closure<V> valueExtractor,
                                                                   V initialValue,
                                                                   groovy.lang.Closure<V> reducer)
        Reduce stream via given reducer.
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        keyExtractor - extractor of key
        valueExtractor - extractor of value
        initialValue - zero element
        reducer - the reduce function
        Returns:
        reduced stream
      • reduce

        <K,​V> WindowedStream<Pair<K,​V>> reduce​(@Nullable
                                                           java.lang.String name,
                                                           groovy.lang.Closure<K> keyExtractor,
                                                           groovy.lang.Closure<V> valueExtractor,
                                                           V initialValue,
                                                           groovy.lang.Closure<V> reducer)
        Reduce stream via given reducer.
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        name - name of the reduce operator
        keyExtractor - extractor of key
        valueExtractor - extractor of value
        initialValue - zero element
        reducer - the reduce function
        Returns:
        reduced stream
      • reduce

        default <K,​V> WindowedStream<Pair<K,​V>> reduce​(groovy.lang.Closure<K> keyExtractor,
                                                                   V initialValue,
                                                                   groovy.lang.Closure<V> reducer)
        Reduce stream via given reducer.
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        keyExtractor - extractor of key
        initialValue - zero element
        reducer - the reduce function
        Returns:
        reduced stream
      • reduce

        <K,​V> WindowedStream<Pair<K,​V>> reduce​(@Nullable
                                                           java.lang.String name,
                                                           groovy.lang.Closure<K> keyExtractor,
                                                           V initialValue,
                                                           groovy.lang.Closure<V> reducer)
        Reduce stream via given reducer.
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        name - name of the reduce operator
        keyExtractor - extractor of key
        initialValue - zero element
        reducer - the reduce function
        Returns:
        reduced stream
      • reduceToLatest

        WindowedStream<StreamElement> reduceToLatest​(@Nullable
                                                     java.lang.String name)
        Reduce stream to latest values only.
        Parameters:
        name - name of the reduce operator
        Returns:
        reduced stream
      • groupReduce

        default <K,​V> WindowedStream<Pair<K,​V>> groupReduce​(groovy.lang.Closure<K> keyExtractor,
                                                                        groovy.lang.Closure<java.lang.Iterable<V>> listReduce)
        Reduce stream with reduce function taking list of values.
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        keyExtractor - extractor of key
        listReduce - the reduce function taking list of elements
        Returns:
        reduced stream
      • groupReduce

        <K,​V> WindowedStream<Pair<K,​V>> groupReduce​(@Nullable
                                                                java.lang.String name,
                                                                groovy.lang.Closure<K> keyExtractor,
                                                                groovy.lang.Closure<java.lang.Iterable<V>> listReduce)
        Reduce stream with reduce function taking list of values.
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        name - name of the group reduce operator
        keyExtractor - extractor of key
        listReduce - the reduce function taking list of elements
        Returns:
        reduced stream
      • combine

        default <K,​V> WindowedStream<Pair<K,​V>> combine​(groovy.lang.Closure<K> keyExtractor,
                                                                    groovy.lang.Closure<V> valueExtractor,
                                                                    V initial,
                                                                    groovy.lang.Closure<V> combine)
        Apply combine transform to stream.
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        keyExtractor - extractor of key
        valueExtractor - extractor of value
        initial - zero element
        combine - combine function
        Returns:
        the new stream
      • combine

        <K,​V> WindowedStream<Pair<K,​V>> combine​(@Nullable
                                                            java.lang.String name,
                                                            groovy.lang.Closure<K> keyExtractor,
                                                            groovy.lang.Closure<V> valueExtractor,
                                                            V initial,
                                                            groovy.lang.Closure<V> combine)
        Apply combine transform to stream.
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        name - name of the combine operator
        keyExtractor - extractor of key
        valueExtractor - extractor of value
        initial - zero element
        combine - combine function
        Returns:
        the new stream
      • combine

        default <K> WindowedStream<Pair<K,​T>> combine​(groovy.lang.Closure<K> keyExtractor,
                                                            T initial,
                                                            groovy.lang.Closure<T> combine)
        Apply combine transform to stream.
        Type Parameters:
        K - key type
        Parameters:
        keyExtractor - extractor of key
        initial - zero element
        combine - combine function
        Returns:
        the new stream
      • combine

        <K> WindowedStream<Pair<K,​T>> combine​(@Nullable
                                                    java.lang.String name,
                                                    groovy.lang.Closure<K> keyExtractor,
                                                    T initial,
                                                    groovy.lang.Closure<T> combine)
        Apply combine transform to stream.
        Type Parameters:
        K - key type
        Parameters:
        name - name of the combine operator
        keyExtractor - extractor of key
        initial - zero element
        combine - combine function
        Returns:
        the new stream
      • countByKey

        default <K> WindowedStream<Pair<K,​java.lang.Long>> countByKey​(groovy.lang.Closure<K> keyExtractor)
        Count elements of stream by key.
        Type Parameters:
        K - key type
        Parameters:
        keyExtractor - extractor of key
        Returns:
        stream with elements counted
      • countByKey

        <K> WindowedStream<Pair<K,​java.lang.Long>> countByKey​(@Nullable
                                                                    java.lang.String name,
                                                                    groovy.lang.Closure<K> keyExtractor)
        Count elements of stream by key.
        Type Parameters:
        K - key type
        Parameters:
        name - name of the countByKey operator
        keyExtractor - extractor of key
        Returns:
        stream with elements counted
      • average

        default WindowedStream<java.lang.Double> average​(groovy.lang.Closure<java.lang.Double> valueExtractor)
        Average elements of stream.
        Parameters:
        valueExtractor - extractor of double value to be averaged
        Returns:
        the stream with average values
      • average

        WindowedStream<java.lang.Double> average​(@Nullable
                                                 java.lang.String name,
                                                 groovy.lang.Closure<java.lang.Double> valueExtractor)
        Average elements of stream.
        Parameters:
        name - name of the average operator
        valueExtractor - extractor of double value to be averaged
        Returns:
        the stream with average values
      • averageByKey

        default <K> WindowedStream<Pair<K,​java.lang.Double>> averageByKey​(groovy.lang.Closure<K> keyExtractor,
                                                                                groovy.lang.Closure<java.lang.Double> valueExtractor)
        Average elements of stream by key.
        Type Parameters:
        K - key type
        Parameters:
        keyExtractor - extractor of key
        valueExtractor - extractor of double value
        Returns:
        stream with average values per key
      • averageByKey

        <K> WindowedStream<Pair<K,​java.lang.Double>> averageByKey​(@Nullable
                                                                        java.lang.String name,
                                                                        groovy.lang.Closure<K> keyExtractor,
                                                                        groovy.lang.Closure<java.lang.Double> valueExtractor)
        Average elements of stream by key.
        Type Parameters:
        K - key type
        Parameters:
        name - name of the averageByKey operator
        keyExtractor - extractor of key
        valueExtractor - extractor of double value
        Returns:
        stream with average values per key
      • join

        default <K,​OTHER> WindowedStream<Pair<T,​OTHER>> join​(WindowedStream<OTHER> right,
                                                                         groovy.lang.Closure<K> leftKey,
                                                                         groovy.lang.Closure<K> rightKey)
        Join with other stream.
        Type Parameters:
        K - type of join key
        OTHER - type of other stream
        Parameters:
        right - the right stream
        leftKey - extractor applied on left stream
        rightKey - extractor applied on right stream
        Returns:
        joined stream
      • join

        <K,​OTHER> WindowedStream<Pair<T,​OTHER>> join​(@Nullable
                                                                 java.lang.String name,
                                                                 WindowedStream<OTHER> right,
                                                                 groovy.lang.Closure<K> leftKey,
                                                                 groovy.lang.Closure<K> rightKey)
        Join with other stream.
        Type Parameters:
        K - type of join key
        OTHER - type of other stream
        Parameters:
        name - name of the join operator
        right - the right stream
        leftKey - extractor applied on left stream
        rightKey - extractor applied on right stream
        Returns:
        joined stream
      • leftJoin

        default <K,​OTHER> WindowedStream<Pair<T,​OTHER>> leftJoin​(WindowedStream<OTHER> right,
                                                                             groovy.lang.Closure<K> leftKey,
                                                                             groovy.lang.Closure<K> rightKey)
        Left join with other stream.
        Type Parameters:
        K - type of join key
        OTHER - type of other stream
        Parameters:
        right - the right stream
        leftKey - extractor applied on left stream
        rightKey - extractor applied on right stream
        Returns:
        joined stream
      • leftJoin

        <K,​OTHER> WindowedStream<Pair<T,​OTHER>> leftJoin​(@Nullable
                                                                     java.lang.String name,
                                                                     WindowedStream<OTHER> right,
                                                                     groovy.lang.Closure<K> leftKey,
                                                                     groovy.lang.Closure<K> rightKey)
        Left join with other stream.
        Type Parameters:
        K - type of join key
        OTHER - type of other stream
        Parameters:
        name - name of the join operator
        right - the right stream
        leftKey - extractor applied on left stream
        rightKey - extractor applied on right stream
        Returns:
        joined stream
      • sorted

        default WindowedStream<T> sorted​(groovy.lang.Closure<java.lang.Integer> compareFn)
        Sort stream.
        Parameters:
        compareFn - comparison function
        Returns:
        sorted stram
      • sorted

        WindowedStream<T> sorted​(@Nullable
                                 java.lang.String name,
                                 groovy.lang.Closure<java.lang.Integer> compareFn)
        Sort stream.
        Parameters:
        name - name of the sort operator
        compareFn - comparison function
        Returns:
        sorted stram
      • sorted

        default WindowedStream<java.lang.Comparable<T>> sorted()
        Sort stream consisting of Comparables.
        Returns:
        sorted stream
      • sorted

        WindowedStream<java.lang.Comparable<T>> sorted​(@Nullable
                                                       java.lang.String name)
        Sort stream consisting of Comparables.
        Parameters:
        name - name of the sort operator
        Returns:
        sorted stream
      • count

        default WindowedStream<java.lang.Long> count()
        Count elements.
        Returns:
        stream with element counts
      • count

        WindowedStream<java.lang.Long> count​(@Nullable
                                             java.lang.String name)
        Count elements.
        Parameters:
        name - name of the count operator
        Returns:
        stream with element counts
      • sum

        default WindowedStream<java.lang.Double> sum​(groovy.lang.Closure<java.lang.Double> valueExtractor)
        Sum elements.
        Parameters:
        valueExtractor - extractor of double value
        Returns:
        stream with sums
      • sum

        WindowedStream<java.lang.Double> sum​(@Nullable
                                             java.lang.String name,
                                             groovy.lang.Closure<java.lang.Double> valueExtractor)
        Sum elements.
        Parameters:
        name - name of the sum operator
        valueExtractor - extractor of double value
        Returns:
        stream with sums
      • sumByKey

        default <K> WindowedStream<Pair<K,​java.lang.Double>> sumByKey​(groovy.lang.Closure<K> keyExtractor,
                                                                            groovy.lang.Closure<java.lang.Double> valueExtractor)
        Sum elements by key.
        Type Parameters:
        K - type of key
        Parameters:
        keyExtractor - extractor of key
        valueExtractor - extractor of double value
        Returns:
        stream with sums per key
      • sumByKey

        <K> WindowedStream<Pair<K,​java.lang.Double>> sumByKey​(@Nullable
                                                                    java.lang.String name,
                                                                    groovy.lang.Closure<K> keyExtractor,
                                                                    groovy.lang.Closure<java.lang.Double> valueExtractor)
        Sum elements by key.
        Type Parameters:
        K - type of key
        Parameters:
        name - name of the sumByKey operator
        keyExtractor - extractor of key
        valueExtractor - extractor of double value
        Returns:
        stream with sums per key
      • distinct

        default WindowedStream<T> distinct()
        Output distinct elements.
        Returns:
        stream with distinct elements
      • distinct

        WindowedStream<T> distinct​(@Nullable
                                   java.lang.String name)
        Output distinct elements.
        Parameters:
        name - name of the distinct operator
        Returns:
        stream with distinct elements
      • distinct

        default WindowedStream<T> distinct​(groovy.lang.Closure<?> mapper)
        Output distinct elements through given mapper.
        Parameters:
        mapper - map values by given function before comparison
        Returns:
        distinct stream
      • distinct

        WindowedStream<T> distinct​(@Nullable
                                   java.lang.String name,
                                   groovy.lang.Closure<?> mapper)
        Output distinct elements through given mapper.
        Parameters:
        name - name of the distinct operator
        mapper - map values by given function before comparison
        Returns:
        distinct stream
      • withEarlyEmitting

        WindowedStream<T> withEarlyEmitting​(long duration)
        Specify early emitting for windowed operations
        Parameters:
        duration - the duration (in processing time) of the early emitting
        Returns:
        stream with early emitting specified
      • withAllowedLateness

        WindowedStream<T> withAllowedLateness​(long lateness)
        Specify allowed lateness for windowed operations.
        Parameters:
        lateness - the allowed lateness
        Returns:
        stream with allowed lateness specified
      • flatMap

        default <X> WindowedStream<X> flatMap​(groovy.lang.Closure<java.lang.Iterable<X>> mapper)
        Description copied from interface: Stream
        Remap the stream.
        Specified by:
        flatMap in interface Stream<T>
        Type Parameters:
        X - type parameter
        Parameters:
        mapper - mapper returning iterable of values to be flattened into output
        Returns:
        the remapped stream
      • flatMap

        <X> WindowedStream<X> flatMap​(@Nullable
                                      java.lang.String name,
                                      groovy.lang.Closure<java.lang.Iterable<X>> mapper)
        Description copied from interface: Stream
        Remap the stream.
        Specified by:
        flatMap in interface Stream<T>
        Type Parameters:
        X - type parameter
        Parameters:
        name - name of the operation
        mapper - mapper returning iterable of values to be flattened into output
        Returns:
        the remapped stream
      • map

        default <X> WindowedStream<X> map​(groovy.lang.Closure<X> mapper)
        Description copied from interface: Stream
        Remap the stream.
        Specified by:
        map in interface Stream<T>
        Type Parameters:
        X - type parameter
        Parameters:
        mapper - the mapping closure
        Returns:
        remapped stream
      • map

        <X> WindowedStream<X> map​(@Nullable
                                  java.lang.String name,
                                  groovy.lang.Closure<X> mapper)
        Description copied from interface: Stream
        Remap the stream.
        Specified by:
        map in interface Stream<T>
        Type Parameters:
        X - type parameter
        Parameters:
        name - stable name of the mapping operator
        mapper - the mapping closure
        Returns:
        remapped stream
      • filter

        default WindowedStream<T> filter​(groovy.lang.Closure<java.lang.Boolean> predicate)
        Description copied from interface: Stream
        Filter stream based on predicate
        Specified by:
        filter in interface Stream<T>
        Parameters:
        predicate - the predicate to filter on
        Returns:
        filtered stream
      • filter

        WindowedStream<T> filter​(@Nullable
                                 java.lang.String name,
                                 groovy.lang.Closure<java.lang.Boolean> predicate)
        Description copied from interface: Stream
        Filter stream based on predicate
        Specified by:
        filter in interface Stream<T>
        Parameters:
        name - name of the filter operator
        predicate - the predicate to filter on
        Returns:
        filtered stream
      • assignEventTime

        default WindowedStream<T> assignEventTime​(groovy.lang.Closure<java.lang.Long> assigner)
        Description copied from interface: Stream
        Assign event time to elements.
        Specified by:
        assignEventTime in interface Stream<T>
        Parameters:
        assigner - assigner of event time
        Returns:
        stream with elements assigned event time
      • assignEventTime

        WindowedStream<T> assignEventTime​(@Nullable
                                          java.lang.String name,
                                          groovy.lang.Closure<java.lang.Long> assigner)
        Description copied from interface: Stream
        Assign event time to elements.
        Specified by:
        assignEventTime in interface Stream<T>
        Parameters:
        name - name of the assign event time operator
        assigner - assigner of event time
        Returns:
        stream with elements assigned event time
      • withWindow

        default WindowedStream<Pair<java.lang.Object,​T>> withWindow()
        Description copied from interface: Stream
        Add window to each element in the stream.
        Specified by:
        withWindow in interface Stream<T>
        Returns:
        stream of pairs with window
      • withWindow

        WindowedStream<Pair<java.lang.Object,​T>> withWindow​(@Nullable
                                                                  java.lang.String name)
        Description copied from interface: Stream
        Add window to each element in the stream.
        Specified by:
        withWindow in interface Stream<T>
        Parameters:
        name - stable name of the mapping operator
        Returns:
        stream of pairs with window
      • withTimestamp

        default WindowedStream<Pair<T,​java.lang.Long>> withTimestamp()
        Description copied from interface: Stream
        Add timestamp to each element in the stream.
        Specified by:
        withTimestamp in interface Stream<T>
        Returns:
        stream of pairs with timestamp
      • withTimestamp

        WindowedStream<Pair<T,​java.lang.Long>> withTimestamp​(@Nullable
                                                                   java.lang.String name)
        Description copied from interface: Stream
        Add timestamp to each element in the stream.
        Specified by:
        withTimestamp in interface Stream<T>
        Parameters:
        name - stable name of mapping operator
        Returns:
        stream of pairs with timestamp
      • asUnbounded

        default WindowedStream<T> asUnbounded()
        Description copied from interface: Stream
        Process this stream as it was unbounded stream.

        This is a no-op if Stream.isBounded() returns false, otherwise it turns the stream into being processed as unbounded, although being bounded.

        This is an optional operation and might be ignored if not supported by underlying implementation.

        Specified by:
        asUnbounded in interface Stream<T>
        Returns:
        Stream viewed as unbounded stream, if supported
      • asStreamElements

        <V> WindowedStream<StreamElement> asStreamElements​(RepositoryProvider repoProvider,
                                                           EntityDescriptor entity,
                                                           groovy.lang.Closure<java.lang.CharSequence> keyExtractor,
                                                           groovy.lang.Closure<java.lang.CharSequence> attributeExtractor,
                                                           groovy.lang.Closure<V> valueExtractor,
                                                           groovy.lang.Closure<java.lang.Long> timeExtractor)
        Description copied from interface: Stream
        Convert elements to StreamElements.
        Specified by:
        asStreamElements in interface Stream<T>
        Type Parameters:
        V - type of value
        Parameters:
        repoProvider - provider of Repository
        entity - the entity of elements
        keyExtractor - extractor of keys
        attributeExtractor - extractor of attributes
        valueExtractor - extractor of values
        timeExtractor - extractor of time
        Returns:
        stream with StreamElements inside