数据划分窗口

image.png

  1. package org.apache.flink.streaming.api.windowing.windows;
  2. /**
  3. * A {@link Window} that represents a time interval from {@code start} (inclusive) to {@code end}
  4. * (exclusive).
  5. */
  6. @PublicEvolving
  7. public class TimeWindow extends Window {
  8. /**
  9. * Method to get the window start for a timestamp.
  10. *
  11. * @param timestamp epoch millisecond to get the window start.
  12. * @param offset The offset which window start would be shifted by.
  13. * @param windowSize The size of the generated windows.
  14. * @return window start
  15. */
  16. public static long getWindowStartWithOffset(long timestamp, long offset, long windowSize) {
  17. return timestamp - (timestamp - offset + windowSize) % windowSize;
  18. }
  19. }

数据划分到窗口时,窗口是左闭右开的,相关代码在上面的类中