OUT - The output type of the WindowedDataStreampublic class WindowedDataStream<OUT> extends Object
WindowedDataStream represents a data stream that has been
discretised into windows. User defined function such as
reduceWindow(ReduceFunction), mapWindow(WindowMapFunction) or aggregations
can be applied to the windows. The results of these transformations are also
WindowedDataStreams of the same discretisation unit.| Modifier and Type | Field and Description |
|---|---|
protected DataStream<OUT> |
dataStream |
protected org.apache.flink.api.java.functions.KeySelector<OUT,?> |
discretizerKey |
protected WindowingHelper<OUT> |
evictionHelper |
protected org.apache.flink.api.java.functions.KeySelector<OUT,?> |
groupByKey |
protected boolean |
isLocal |
protected WindowingHelper<OUT> |
triggerHelper |
protected EvictionPolicy<OUT> |
userEvicter |
protected TriggerPolicy<OUT> |
userTrigger |
| Modifier | Constructor and Description |
|---|---|
|
WindowedDataStream() |
protected |
WindowedDataStream(DataStream<OUT> dataStream,
TriggerPolicy<OUT> trigger,
EvictionPolicy<OUT> evicter) |
protected |
WindowedDataStream(DataStream<OUT> dataStream,
WindowingHelper<OUT> policyHelper) |
protected |
WindowedDataStream(WindowedDataStream<OUT> windowedDataStream) |
| Modifier and Type | Method and Description |
|---|---|
<F> F |
clean(F f) |
protected WindowedDataStream<OUT> |
copy() |
WindowedDataStream<OUT> |
every(WindowingHelper policyHelper)
Defines the slide size (trigger frequency) for the windowed data stream.
|
DataStream<OUT> |
flatten()
Flattens the results of the window computations and streams out the
window elements.
|
<R> DiscretizedStream<R> |
foldWindow(R initialValue,
org.apache.flink.api.common.functions.FoldFunction<OUT,R> foldFunction)
Applies a fold transformation on the windowed data stream by folding the
current window at every trigger.The user can also extend the
RichFoldFunction to gain access to other features provided by the
RichFunction interface. |
<R> DiscretizedStream<R> |
foldWindow(R initialValue,
org.apache.flink.api.common.functions.FoldFunction<OUT,R> foldFunction,
org.apache.flink.api.common.typeinfo.TypeInformation<R> outType)
Applies a fold transformation on the windowed data stream by folding the
current window at every trigger.The user can also extend the
RichFoldFunction to gain access to other features provided by the
RichFunction interface. |
protected Class<?> |
getClassAtPos(int pos) |
DataStream<StreamWindow<OUT>> |
getDiscretizedStream()
Returns the
DataStream of StreamWindows which represent
the discretised stream. |
protected EvictionPolicy<OUT> |
getEviction() |
org.apache.flink.api.common.ExecutionConfig |
getExecutionConfig() |
protected TriggerPolicy<OUT> |
getTrigger() |
org.apache.flink.api.common.typeinfo.TypeInformation<OUT> |
getType()
Gets the output type.
|
WindowedDataStream<OUT> |
groupBy(int... fields)
Groups the elements of the
WindowedDataStream by the given key
positions. |
WindowedDataStream<OUT> |
groupBy(org.apache.flink.api.java.functions.KeySelector<OUT,?> keySelector)
Groups the elements of the
WindowedDataStream using the given
KeySelector. |
WindowedDataStream<OUT> |
groupBy(String... fields)
Groups the elements of the
WindowedDataStream by the given field
expressions. |
protected boolean |
isGrouped() |
WindowedDataStream<OUT> |
local()
Sets the window discretisation local, meaning that windows will be
created in parallel at environment parallelism.
|
<R> DiscretizedStream<R> |
mapWindow(WindowMapFunction<OUT,R> windowMapFunction)
Applies a mapWindow transformation on the windowed data stream by calling
the mapWindow function on the window at every trigger.
|
<R> DiscretizedStream<R> |
mapWindow(WindowMapFunction<OUT,R> windowMapFunction,
org.apache.flink.api.common.typeinfo.TypeInformation<R> outType)
Applies a mapWindow transformation on the windowed data stream by calling
the mapWindow function on the window at every trigger.
|
WindowedDataStream<OUT> |
max(int positionToMax)
Applies an aggregation that gives the maximum value of every window of
the data stream at the given position.
|
WindowedDataStream<OUT> |
max(String field)
Applies an aggregation that that gives the maximum value of the pojo data
stream at the given field expression for every window.
|
WindowedDataStream<OUT> |
maxBy(int positionToMaxBy)
Applies an aggregation that gives the maximum element of every window of
the data stream by the given position.
|
WindowedDataStream<OUT> |
maxBy(int positionToMaxBy,
boolean first)
Applies an aggregation that gives the maximum element of every window of
the data stream by the given position.
|
WindowedDataStream<OUT> |
maxBy(String positionToMaxBy)
Applies an aggregation that gives the maximum element of every window of
the data stream by the given position.
|
WindowedDataStream<OUT> |
maxBy(String field,
boolean first)
Applies an aggregation that that gives the maximum element of the pojo
data stream by the given field expression for every window.
|
WindowedDataStream<OUT> |
min(int positionToMin)
Applies an aggregation that that gives the minimum value of every window
of the data stream at the given position.
|
WindowedDataStream<OUT> |
min(String field)
Applies an aggregation that that gives the minimum value of the pojo data
stream at the given field expression for every window.
|
WindowedDataStream<OUT> |
minBy(int positionToMinBy)
Applies an aggregation that gives the minimum element of every window of
the data stream by the given position.
|
WindowedDataStream<OUT> |
minBy(int positionToMinBy,
boolean first)
Applies an aggregation that gives the minimum element of every window of
the data stream by the given position.
|
WindowedDataStream<OUT> |
minBy(String positionToMinBy)
Applies an aggregation that gives the minimum element of every window of
the data stream by the given position.
|
WindowedDataStream<OUT> |
minBy(String field,
boolean first)
Applies an aggregation that that gives the minimum element of the pojo
data stream by the given field expression for every window.
|
DiscretizedStream<OUT> |
reduceWindow(org.apache.flink.api.common.functions.ReduceFunction<OUT> reduceFunction)
Applies a reduce transformation on the windowed data stream by reducing
the current window at every trigger.The user can also extend the
RichReduceFunction to gain access to other features provided by
the RichFunction interface. |
WindowedDataStream<OUT> |
sum(int positionToSum)
Applies an aggregation that sums every window of the data stream at the
given position.
|
WindowedDataStream<OUT> |
sum(String field)
Applies an aggregation that sums every window of the pojo data stream at
the given field for every window.
|
protected DiscretizedStream<OUT> |
timeReduce(org.apache.flink.api.common.functions.ReduceFunction<OUT> reduceFunction)
Dedicated method for applying parallel time reduce transformations on
windows
|
protected DataStream<OUT> dataStream
protected boolean isLocal
protected org.apache.flink.api.java.functions.KeySelector<OUT,?> discretizerKey
protected org.apache.flink.api.java.functions.KeySelector<OUT,?> groupByKey
protected WindowingHelper<OUT> triggerHelper
protected WindowingHelper<OUT> evictionHelper
protected TriggerPolicy<OUT> userTrigger
protected EvictionPolicy<OUT> userEvicter
protected WindowedDataStream(DataStream<OUT> dataStream, WindowingHelper<OUT> policyHelper)
protected WindowedDataStream(DataStream<OUT> dataStream, TriggerPolicy<OUT> trigger, EvictionPolicy<OUT> evicter)
protected WindowedDataStream(WindowedDataStream<OUT> windowedDataStream)
public WindowedDataStream()
public WindowedDataStream<OUT> every(WindowingHelper policyHelper)
ds.window(Count.of(5)).every(Time.of(2,TimeUnit.SECONDS))
The user function in this case will be called on the 5 most
recent elements every 2 secondspolicyHelper - The policy that define the triggering frequencypublic WindowedDataStream<OUT> groupBy(int... fields)
WindowedDataStream by the given key
positions. The window sizes (evictions) and slide sizes (triggers) will
be calculated on the whole stream (in a global fashion), but the user
defined functions will be applied on a per group basis. To get
windows and triggers on a per group basis apply the
DataStream.window(org.apache.flink.streaming.api.windowing.helper.WindowingHelper) operator on an already grouped data stream.fields - The position of the fields to group by.WindowedDataStreampublic WindowedDataStream<OUT> groupBy(String... fields)
WindowedDataStream by the given field
expressions. The window sizes (evictions) and slide sizes (triggers) will
be calculated on the whole stream (in a global fashion), but the user
defined functions will be applied on a per group basis. To get
windows and triggers on a per group basis apply the
DataStream.window(org.apache.flink.streaming.api.windowing.helper.WindowingHelper) operator on an already grouped data stream.
A field expression is either the name of a public field or a
getter method with parentheses of the stream's underlying type. A dot can
be used to drill down into objects, as in
"field1.getInnerField2()" .fields - The fields to group byWindowedDataStreampublic WindowedDataStream<OUT> groupBy(org.apache.flink.api.java.functions.KeySelector<OUT,?> keySelector)
WindowedDataStream using the given
KeySelector. The window sizes (evictions) and slide sizes
(triggers) will be calculated on the whole stream (in a global fashion),
but the user defined functions will be applied on a per group basis.
To get windows and triggers on a per group basis apply the
DataStream.window(org.apache.flink.streaming.api.windowing.helper.WindowingHelper) operator on an already grouped data stream.keySelector - The keySelector used to extract the key for grouping.WindowedDataStreampublic WindowedDataStream<OUT> local()
public DataStream<StreamWindow<OUT>> getDiscretizedStream()
DataStream of StreamWindows which represent
the discretised stream. There is no ordering guarantee for the received
windows.public DataStream<OUT> flatten()
public DiscretizedStream<OUT> reduceWindow(org.apache.flink.api.common.functions.ReduceFunction<OUT> reduceFunction)
RichReduceFunction to gain access to other features provided by
the RichFunction interface.reduceFunction - The reduce function that will be applied to the windows.public <R> DiscretizedStream<R> foldWindow(R initialValue, org.apache.flink.api.common.functions.FoldFunction<OUT,R> foldFunction, org.apache.flink.api.common.typeinfo.TypeInformation<R> outType)
RichFoldFunction to gain access to other features provided by the
RichFunction interface.
This version of foldWindow uses user supplied typeinformation for
serializaton. Use this only when the system is unable to detect type
information.foldFunction - The fold function that will be applied to the windows.initialValue - Initial value given to foldFunctionoutType - The output type of the operatorpublic <R> DiscretizedStream<R> foldWindow(R initialValue, org.apache.flink.api.common.functions.FoldFunction<OUT,R> foldFunction)
RichFoldFunction to gain access to other features provided by the
RichFunction interface.foldFunction - The fold function that will be applied to the windows.initialValue - Initial value given to foldFunctionpublic <R> DiscretizedStream<R> mapWindow(WindowMapFunction<OUT,R> windowMapFunction)
RichWindowMapFunction to gain access
to other features provided by the
RichFunction interface.windowMapFunction - The function that will be applied to the windows.public <R> DiscretizedStream<R> mapWindow(WindowMapFunction<OUT,R> windowMapFunction, org.apache.flink.api.common.typeinfo.TypeInformation<R> outType)
RichWindowMapFunction to gain access
to other features provided by the
RichFunction interface.
This version of mapWindow uses user supplied typeinformation
for serializaton. Use this only when the system is unable to detect type
information.windowMapFunction - The function that will be applied to the windows.outType - The output type of the operator.protected DiscretizedStream<OUT> timeReduce(org.apache.flink.api.common.functions.ReduceFunction<OUT> reduceFunction)
reduceFunction - Reduce function to applypublic WindowedDataStream<OUT> sum(int positionToSum)
positionToSum - The position in the tuple/array to sumpublic WindowedDataStream<OUT> sum(String field)
"field1.getInnerField2()" .field - The field to sumpublic WindowedDataStream<OUT> min(int positionToMin)
positionToMin - The position to minimizepublic WindowedDataStream<OUT> min(String field)
DataStreamS underlying type. A dot can be used
to drill down into objects, as in "field1.getInnerField2()" .field - The field expression based on which the aggregation will be
applied.public WindowedDataStream<OUT> minBy(int positionToMinBy)
positionToMinBy - The position to minimize bypublic WindowedDataStream<OUT> minBy(String positionToMinBy)
positionToMinBy - The position to minimize bypublic WindowedDataStream<OUT> minBy(int positionToMinBy, boolean first)
positionToMinBy - The position to minimizefirst - If true, then the operator return the first element with the
minimum value, otherwise returns the lastpublic WindowedDataStream<OUT> minBy(String field, boolean first)
DataStreamS underlying type. A dot can be used
to drill down into objects, as in "field1.getInnerField2()" .field - The field expression based on which the aggregation will be
applied.first - If True then in case of field equality the first object will
be returnedpublic WindowedDataStream<OUT> max(int positionToMax)
positionToMax - The position to maximizepublic WindowedDataStream<OUT> max(String field)
DataStreamS underlying type. A dot can be used to drill
down into objects, as in "field1.getInnerField2()" .field - The field expression based on which the aggregation will be
applied.public WindowedDataStream<OUT> maxBy(int positionToMaxBy)
positionToMaxBy - The position to maximize bypublic WindowedDataStream<OUT> maxBy(String positionToMaxBy)
positionToMaxBy - The position to maximize bypublic WindowedDataStream<OUT> maxBy(int positionToMaxBy, boolean first)
positionToMaxBy - The position to maximize byfirst - If true, then the operator return the first element with the
maximum value, otherwise returns the lastpublic WindowedDataStream<OUT> maxBy(String field, boolean first)
DataStreamS underlying type. A dot can be used
to drill down into objects, as in "field1.getInnerField2()" .field - The field expression based on which the aggregation will be
applied.first - If True then in case of field equality the first object will
be returnedprotected TriggerPolicy<OUT> getTrigger()
protected EvictionPolicy<OUT> getEviction()
public <F> F clean(F f)
protected boolean isGrouped()
public org.apache.flink.api.common.typeinfo.TypeInformation<OUT> getType()
public org.apache.flink.api.common.ExecutionConfig getExecutionConfig()
protected Class<?> getClassAtPos(int pos)
protected WindowedDataStream<OUT> copy()
Copyright © 2014–2015 The Apache Software Foundation. All rights reserved.