一、源码展示:
可以看到计算公式如下
/**
* Method to get the window start for a timestamp.
*
* @param timestamp epoch millisecond to get the window start.
* @param offset The offset which window start would be shifted by.
* @param windowSize The size of the generated windows.
* @return window start
*/
public static long getWindowStartWithOffset(long timestamp, long offset, long windowSize) {
return timestamp - (timestamp - offset + windowSize) % windowSize;
}
二、代码测试:
import java.time.Duration
import org.apache.flink.api.common.eventtime.{
SerializableTimestampAssigner, WatermarkStrategy}
import org.apache.flink.streaming.api.TimeChar