private EvictionPolicy<I, ?> getEvictionPolicy(WindowConfig windowConfig) { if (windowConfig.getWindowLengthCount() != null) { if (this.isEventTime()) { return new WatermarkCountEvictionPolicy<>(windowConfig.getWindowLengthCount()); } else { return new CountEvictionPolicy<>(windowConfig.getWindowLengthCount()); } } else { if (this.isEventTime()) { return new WatermarkTimeEvictionPolicy<>( windowConfig.getWindowLengthDurationMs(), windowConfig.getMaxLagMs()); } else { return new TimeEvictionPolicy<>(windowConfig.getWindowLengthDurationMs()); } } }
public static void validateWindowConfig(WindowConfig windowConfig) { if (windowConfig.getWindowLengthDurationMs() == null && windowConfig.getWindowLengthCount() == null) { throw new IllegalArgumentException("Window length is not specified"); if (windowConfig.getWindowLengthDurationMs() != null && windowConfig.getWindowLengthCount() != null) { throw new IllegalArgumentException( "Window length for time and count are set! Please set one or the other."); if (windowConfig.getWindowLengthCount() != null) { if (windowConfig.getWindowLengthCount() <= 0) { throw new IllegalArgumentException( "Window length must be positive [" + windowConfig.getWindowLengthCount() + "]");
public static void inferDefaultConfigs(WindowConfig windowConfig) { if (windowConfig.getWindowLengthDurationMs() != null && windowConfig.getSlidingIntervalDurationMs() == null) { windowConfig.setSlidingIntervalDurationMs(windowConfig.getWindowLengthDurationMs()); } if (windowConfig.getWindowLengthCount() != null && windowConfig.getSlidingIntervalCount() == null) { windowConfig.setSlidingIntervalCount(windowConfig.getWindowLengthCount()); } if (windowConfig.getTimestampExtractorClassName() != null) { if (windowConfig.getMaxLagMs() == null) { windowConfig.setMaxLagMs(WindowFunctionExecutor.DEFAULT_MAX_LAG_MS); } if (windowConfig.getWatermarkEmitIntervalMs() == null) { windowConfig.setWatermarkEmitIntervalMs(WindowFunctionExecutor.DEFAULT_WATERMARK_EVENT_INTERVAL_MS); } } } }