T
- Tuple typeK
- Partition key typepublic interface TWindow<T,K> extends TopologyElement
s.last(10, zero())
declares a window with a single partition that at any time contains the last ten tuples seen on
stream s
.
Windows are partitioned which means the window's configuration
is independently maintained for each key seen on the stream.
For example with a window created using last(3, tuple -> tuple.getId())
then each key has its own window containing the last
three tuples with the same key obtained from the tuple's identity using getId()
.
Count based window
,
Time based window
Modifier and Type | Method and Description |
---|---|
<U> TStream<U> |
aggregate(BiFunction<java.util.List<T>,K,U> aggregator)
Declares a stream that is a continuous, sliding, aggregation of
partitions in this window.
|
<U> TStream<U> |
batch(BiFunction<java.util.List<T>,K,U> batcher)
Declares a stream that represents a batched aggregation of
partitions in this window.
|
TStream<T> |
feeder()
Get the stream that feeds this window.
|
Function<T,K> |
getKeyFunction()
Returns the key function used to map tuples to partitions.
|
topology
<U> TStream<U> aggregate(BiFunction<java.util.List<T>,K,U> aggregator)
Changes in a partition's contents trigger an invocation of
aggregator.apply(tuples, key)
, where tuples
is
a List<T>
containing all the tuples in the partition in
insertion order from oldest to newest. The list is stable
during the aggregator invocation.
aggregator
result is added to the returned stream.
Thus the returned stream will contain a sequence of tuples where the most recent tuple represents the most up to date aggregation of a partition.
U
- Tuple typeaggregator
- Logic to aggregation a partition.<U> TStream<U> batch(BiFunction<java.util.List<T>,K,U> batcher)
Each partition "batch" triggers an invocation of
batcher.apply(tuples, key)
, where tuples
is
a List<T>
containing all the tuples in the partition in
insertion order from oldest to newest The list is stable
during the batcher invocation.
batcher
result is added to the returned stream.
The partition's contents are cleared after a batch is processed.
Thus the returned stream will contain a sequence of tuples where the most recent tuple represents the most up to date aggregation of a partition.
U
- Tuple typebatcher
- Logic to aggregation a partition.Function<T,K> getKeyFunction()
Copyright © 2016 The Apache Software Foundation. All Rights Reserved - bbe71fa-20161201-1641