private long getNextAlignedWindowTs ( long startTs , long endTs ) { long nextTs = windowManager . getEarliestEventTs ( startTs , endTs ) ; if ( nextTs == Long . MAX_VALUE || ( nextTs % slidingIntervalMs == 0 ) ) { return nextTs ; } return nextTs + ( slidingIntervalMs - ( nextTs % slidingIntervalMs ) ) ; }
Computes the next window by scanning the events in the window and finds the next aligned window between the startTs and endTs . Return the end ts of the next aligned window i . e . the ts when the window should fire .