Class SliceAssigners.HoppingSliceAssigner

    • Constructor Detail

      • HoppingSliceAssigner

        protected HoppingSliceAssigner​(int rowtimeIndex,
                                       ZoneId shiftTimeZone,
                                       long size,
                                       long slide,
                                       long offset)
    • Method Detail

      • assignSliceEnd

        public long assignSliceEnd​(long timestamp)
      • getLastWindowEnd

        public long getLastWindowEnd​(long sliceEnd)
        Description copied from interface: SliceAssigner
        Returns the last window which the slice belongs to. The window and slices are both identified by the end timestamp.
        Specified by:
        getLastWindowEnd in interface SliceAssigner
      • getWindowStart

        public long getWindowStart​(long windowEnd)
        Description copied from interface: SliceAssigner
        Returns the corresponding window start timestamp of the given window end timestamp.
        Specified by:
        getWindowStart in interface SliceAssigner
      • expiredSlices

        public Iterable<Long> expiredSlices​(long windowEnd)
        Description copied from interface: SliceAssigner
        Returns an iterator of slices to expire when the given window is emitted. The window and slices are both identified by the end timestamp.
        Specified by:
        expiredSlices in interface SliceAssigner
        Parameters:
        windowEnd - the end timestamp of window emitted.
      • getSliceEndInterval

        public long getSliceEndInterval()
        Description copied from interface: SliceAssigner
        Returns the interval of slice ends, i.e. the step size to advance of the slice end when a new slice assigned.
        Specified by:
        getSliceEndInterval in interface SliceAssigner
      • nextTriggerWindow

        public Optional<Long> nextTriggerWindow​(long windowEnd,
                                                Supplier<Boolean> isWindowEmpty)
        Description copied from interface: SliceSharedAssigner
        Returns the optional end timestamp of next window which should be triggered. Empty if no following window to trigger for now.

        The purpose of this method is avoid register too many timers for each hopping and cumulative slice, e.g. HOP(1day, 10s) needs register 8640 timers for every slice. In order to improve this, we only register one timer for the next window. For hopping windows we don't register next window if current window is empty (i.e. no records in current window). That means we will have one more unnecessary window triggered for hopping windows if no elements arrives for a key for a long time. We will skip to emit window result for the triggered empty window, see SliceSharedWindowAggProcessor#fireWindow(Long).

        Specified by:
        nextTriggerWindow in interface SliceSharedAssigner
        Parameters:
        windowEnd - the current triggered window, identified by end timestamp
        isWindowEmpty - a supplier that can be invoked to get whether the triggered window is empty (i.e. no records in the window).