Class MovingWindowProcessor

  • All Implemented Interfaces:
    DataHandler, DataProcessor

    public class MovingWindowProcessor
    extends AbstractEmittingProcessor
    This process has a certain window size. As values are put in, for each window, the Min/Max/Avg are emmitted. If a value is not provided for a window, the previous value is returned as the average. Cannot deal with backfill data - it is ignored.
    • Constructor Detail

      • MovingWindowProcessor

        public MovingWindowProcessor()
      • MovingWindowProcessor

        public MovingWindowProcessor​(int windowSizeMS)
    • Method Detail

      • configure

        public void configure​(int windowSizeMS,
                              long windowAlignmentTime)
        Sets the parameters of this processor. Window size is the width of the window, and must be >0. WindowAlignment is a time that should be used as the first window, and aligned to for other values. That is, all values will have timestamps that are window size multiples away from this time. If <=0, the first value time will be used for the alignment.
      • putValue

        public void putValue​(RawTagValue inValue)
        Description copied from interface: DataHandler
        Insert a value into the handler.
      • flush

        public void flush()
                   throws java.lang.Exception
        Description copied from interface: DataHandler
        Indicate that the handler won't get any more data, at least for a while.
        Throws:
        java.lang.Exception
      • isAveragable

        protected boolean isAveragable​(RawTagValue value)
      • processValue

        protected void processValue​(RawTagValue value)
        When this function is called, we know that we're in the current window. It evaluates min, max, and updates the running average.
      • updateAverage

        protected void updateAverage​(RawTagValue newValue)
      • finishUpTo

        protected void finishUpTo​(long time)