Class KeyedWindowOperator
- java.lang.Object
-
- stream.nebula.operators.Operator
-
- stream.nebula.operators.KeyedWindowOperator
-
- Direct Known Subclasses:
WindowOperator
public class KeyedWindowOperator extends Operator
Base class to encode aQuery.window(stream.nebula.operators.window.WindowDefinition)
operation.This class stores the data to define a window, i.e., the
WindowDefinition
(getWindowDefinition()
) , a list of attribute names on which the window is grouped (getKeyFields()
), and a list ofAggregation
functions (getAggregations()
).This class and its subtype
WindowOperator
follow the builder pattern.Query.window(stream.nebula.operators.window.WindowDefinition)
returns aWindowOperator
instance on which the user can either callapply(stream.nebula.operators.Aggregation...)
orWindowOperator.byKey(java.lang.String...)
.apply(stream.nebula.operators.Aggregation...)
finishes the specification of the window and returns the originalQuery
instance.WindowOperator.byKey(java.lang.String...)
sets the grouping attributes of the window and returns aKeyedWindowOperator
on which the user has to callapply(stream.nebula.operators.Aggregation...)
to finish the specification of the window.
-
-
Field Summary
-
Fields inherited from class stream.nebula.operators.Operator
childOperator
-
-
Constructor Summary
Constructors Constructor Description KeyedWindowOperator(@NonNull Operator childOperator, @NonNull WindowDefinition windowDefinition, @NonNull Query query)
Create a newKeyedWindowOperator
and set the window definition to define the extent of the window.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Query
apply(Aggregation... aggregations)
Set the aggregation functions for this window.java.util.List<Aggregation>
getAggregations()
Access the window aggregation functions.java.util.List<java.lang.String>
getKeyFields()
Access the attribute names on which the window is grouped.WindowDefinition
getWindowDefinition()
Access the window definition.protected void
setKeyFields(@NonNull java.util.List<java.lang.String> keyFields)
Set the stream attribute names on which the window is grouped.-
Methods inherited from class stream.nebula.operators.Operator
getChildOperator
-
-
-
-
Constructor Detail
-
KeyedWindowOperator
public KeyedWindowOperator(@NonNull Operator childOperator, @NonNull WindowDefinition windowDefinition, @NonNull Query query) throws java.lang.IllegalArgumentException
Create a newKeyedWindowOperator
and set the window definition to define the extent of the window.- Parameters:
childOperator
- The previous operator in the operator chain ofquery
.windowDefinition
- The window definition.query
- TheQuery
instance on whichQuery.window(stream.nebula.operators.window.WindowDefinition)
was called.- Throws:
java.lang.IllegalArgumentException
- IfwindowDefinition
is null.
-
-
Method Detail
-
apply
public Query apply(Aggregation... aggregations) throws java.lang.IllegalArgumentException
Set the aggregation functions for this window.- Parameters:
aggregations
- A variable number ofAggregation
instances.- Returns:
- The original
Query
instance on whichQuery.window(stream.nebula.operators.window.WindowDefinition)
was called. - Throws:
java.lang.IllegalArgumentException
- Ifaggregations
is null or empty, or if an element ofaggregations
is null.
-
getWindowDefinition
public WindowDefinition getWindowDefinition()
Access the window definition.- Returns:
- The window definition.
-
setKeyFields
protected void setKeyFields(@NonNull java.util.List<java.lang.String> keyFields)
Set the stream attribute names on which the window is grouped.This method is protected so that it can only be called in
WindowOperator
but not from the Query API.- Parameters:
keyFields
- The grouping key names.
-
getKeyFields
public java.util.List<java.lang.String> getKeyFields()
Access the attribute names on which the window is grouped.- Returns:
- The grouping key names.
-
getAggregations
public java.util.List<Aggregation> getAggregations()
Access the window aggregation functions.- Returns:
- A list of
Aggregation
instances for this window.
-
-