Class TimeWindowUtil
- java.lang.Object
-
- org.apache.flink.table.runtime.util.TimeWindowUtil
-
@Internal public class TimeWindowUtil extends Object
Time util to deals window start and end in different timezone.
-
-
Constructor Summary
Constructors Constructor Description TimeWindowUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
getNextTriggerWatermark(long currentWatermark, long interval, ZoneId shiftTimezone, boolean useDayLightSaving)
Method to get the next watermark to trigger window.static ZoneId
getShiftTimeZone(org.apache.flink.table.types.logical.LogicalType timeAttributeType, ZoneId zoneFromConfig)
Get the shifted timezone of window if the time attribute type is TIMESTAMP_LTZ, always returns UTC timezone if the time attribute type is TIMESTAMP which means do not shift.static boolean
isWindowFired(long windowEnd, long currentProgress, ZoneId shiftTimeZone)
Returns the window should fired or not on current progress.static long
toEpochMills(long utcTimestampMills, ZoneId shiftTimeZone)
Convert a timestamp mills with the given timezone to epoch mills.static long
toEpochMillsForTimer(long utcTimestampMills, ZoneId shiftTimeZone)
Get a timer time according to the timestamp mills and the given shift timezone.static long
toUtcTimestampMills(long epochMills, ZoneId shiftTimeZone)
Convert a epoch mills to timestamp mills which can describe a locate date time.
-
-
-
Method Detail
-
toUtcTimestampMills
public static long toUtcTimestampMills(long epochMills, ZoneId shiftTimeZone)
Convert a epoch mills to timestamp mills which can describe a locate date time.For example: The timestamp string of epoch mills 5 in GMT+08:00 is 1970-01-01 08:00:05, the timestamp mills is 8 * 60 * 60 * 1000 + 5.
- Parameters:
epochMills
- the epoch mills.shiftTimeZone
- the timezone that the given timestamp mills has been shifted.- Returns:
- the mills which can describe the local timestamp string in given timezone.
-
toEpochMillsForTimer
public static long toEpochMillsForTimer(long utcTimestampMills, ZoneId shiftTimeZone)
Get a timer time according to the timestamp mills and the given shift timezone.- Parameters:
utcTimestampMills
- the timestamp mills.shiftTimeZone
- the timezone that the given timestamp mills has been shifted.- Returns:
- the epoch mills.
-
toEpochMills
public static long toEpochMills(long utcTimestampMills, ZoneId shiftTimeZone)
Convert a timestamp mills with the given timezone to epoch mills.- Parameters:
utcTimestampMills
- the timezone that the given timestamp mills has been shifted.shiftTimeZone
- the timezone that the given timestamp mills has been shifted.- Returns:
- the epoch mills.
-
getShiftTimeZone
public static ZoneId getShiftTimeZone(org.apache.flink.table.types.logical.LogicalType timeAttributeType, ZoneId zoneFromConfig)
Get the shifted timezone of window if the time attribute type is TIMESTAMP_LTZ, always returns UTC timezone if the time attribute type is TIMESTAMP which means do not shift.
-
isWindowFired
public static boolean isWindowFired(long windowEnd, long currentProgress, ZoneId shiftTimeZone)
Returns the window should fired or not on current progress.- Parameters:
windowEnd
- the end of the time window.currentProgress
- current progress of the window operator, it is processing time under proctime, it is watermark value under rowtime.shiftTimeZone
- the shifted timezone of the time window.
-
getNextTriggerWatermark
public static long getNextTriggerWatermark(long currentWatermark, long interval, ZoneId shiftTimezone, boolean useDayLightSaving)
Method to get the next watermark to trigger window.
-
-