Class TumblingWindowAssigner
java.lang.Object
org.apache.flink.table.runtime.operators.window.groupwindow.assigners.GroupWindowAssigner<TimeWindow>
org.apache.flink.table.runtime.operators.window.groupwindow.assigners.TumblingWindowAssigner
- All Implemented Interfaces:
Serializable,InternalTimeWindowAssigner
public class TumblingWindowAssigner
extends GroupWindowAssigner<TimeWindow>
implements InternalTimeWindowAssigner
A
GroupWindowAssigner that windows elements into fixed-size windows based on the
timestamp of the elements. Windows cannot overlap.- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTumblingWindowAssigner(long size, long offset, boolean isEventTime) -
Method Summary
Modifier and TypeMethodDescriptionassignWindows(org.apache.flink.table.data.RowData element, long timestamp) Given the timestamp and element, returns the set of windows into which it should be placed.org.apache.flink.api.common.typeutils.TypeSerializer<TimeWindow>getWindowSerializer(org.apache.flink.api.common.ExecutionConfig executionConfig) Returns aTypeSerializerfor serializing windows that are assigned by thisWindowAssigner.booleanReturnstrueif elements are assigned to windows based on event time,falseotherwise.static TumblingWindowAssignerCreates a newTumblingWindowAssignerGroupWindowAssignerthat assigns elements to time windows based on the element timestamp.toString()withOffset(Duration offset) Creates a newTumblingWindowAssignerGroupWindowAssignerthat assigns elements to time windows based on the element timestamp and offset.Methods inherited from class org.apache.flink.table.runtime.operators.window.groupwindow.assigners.GroupWindowAssigner
open
-
Constructor Details
-
TumblingWindowAssigner
protected TumblingWindowAssigner(long size, long offset, boolean isEventTime)
-
-
Method Details
-
assignWindows
public Collection<TimeWindow> assignWindows(org.apache.flink.table.data.RowData element, long timestamp) Description copied from class:GroupWindowAssignerGiven the timestamp and element, returns the set of windows into which it should be placed.- Specified by:
assignWindowsin classGroupWindowAssigner<TimeWindow>- Parameters:
element- The element to which windows should be assigned.timestamp- The timestamp of the element whenGroupWindowAssigner.isEventTime()returns true, or the current system time whenGroupWindowAssigner.isEventTime()returns false. The timestamp value is mapping to UTC milliseconds for splitting windows simply.
-
getWindowSerializer
public org.apache.flink.api.common.typeutils.TypeSerializer<TimeWindow> getWindowSerializer(org.apache.flink.api.common.ExecutionConfig executionConfig) Description copied from class:GroupWindowAssignerReturns aTypeSerializerfor serializing windows that are assigned by thisWindowAssigner.- Specified by:
getWindowSerializerin classGroupWindowAssigner<TimeWindow>
-
isEventTime
public boolean isEventTime()Description copied from class:GroupWindowAssignerReturnstrueif elements are assigned to windows based on event time,falseotherwise.- Specified by:
isEventTimein classGroupWindowAssigner<TimeWindow>
-
toString
- Specified by:
toStringin classGroupWindowAssigner<TimeWindow>
-
of
Creates a newTumblingWindowAssignerGroupWindowAssignerthat assigns elements to time windows based on the element timestamp.- Parameters:
size- The size of the generated windows.- Returns:
- The time policy.
-
withOffset
Creates a newTumblingWindowAssignerGroupWindowAssignerthat assigns elements to time windows based on the element timestamp and offset.For example, if you want window a stream by hour,but window begins at the 15th minutes of each hour, you can use
of(Time.hours(1),Time.minutes(15)),then you will get time windows start at 0:15:00,1:15:00,2:15:00,etc.Rather than that,if you are living in somewhere which is not using UTC±00:00 time, such as China which is using GMT+08:00,and you want a time window with size of one day, and window begins at every 00:00:00 of local time,you may use
of(Time.days(1),Time.hours(-8)). The parameter of offset isTime.hours(-8))since UTC+08:00 is 8 hours earlier than UTC time.- Parameters:
offset- The offset which window start would be shifted by.- Returns:
- The time policy.
-
withEventTime
- Specified by:
withEventTimein interfaceInternalTimeWindowAssigner- Returns:
- an InternalTimeWindowAssigner which in event time mode.
-
withProcessingTime
- Specified by:
withProcessingTimein interfaceInternalTimeWindowAssigner- Returns:
- an InternalTimeWindowAssigner which in processing time mode.
-