Class TimeSeries

  • All Implemented Interfaces:
    java.io.Serializable

    @NotThreadSafe
    public final class TimeSeries
    extends java.lang.Object
    implements java.io.Serializable
    Class to record a time series, e.g. traffic over time.
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  TimeSeries.Summary
      Class contains the summary of the TimeSeries.
    • Constructor Summary

      Constructors 
      Constructor Description
      TimeSeries()
      Creates a TimeSeries instance with default width set to 1 second.
      TimeSeries​(long widthNano)
      Creates a TimeSeries instance with given width.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(TimeSeries other)
      Add one histogram to the current one.
      int get​(long timeNano)  
      java.util.TreeMap<java.lang.Long,​java.lang.Integer> getSeries()  
      TimeSeries.Summary getSummary()  
      long getWidthNano()  
      void print​(java.io.PrintStream stream)
      Print the time series densely, i.e.
      void record​(long timeNano)
      Record one event at a timestamp into the time series.
      void record​(long timeNano, int numEvents)
      Record events at a timestamp into the time series.
      void sparsePrint​(java.io.PrintStream stream)
      Print the time series sparsely, i.e.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • TimeSeries

        public TimeSeries​(long widthNano)
        Creates a TimeSeries instance with given width.
        Parameters:
        widthNano - the granularity of the time series. If this is set to 1 min, we count the number of events of every minute.
      • TimeSeries

        public TimeSeries()
        Creates a TimeSeries instance with default width set to 1 second.
    • Method Detail

      • record

        public void record​(long timeNano)
        Record one event at a timestamp into the time series.
        Parameters:
        timeNano - the time in nano seconds
      • record

        public void record​(long timeNano,
                           int numEvents)
        Record events at a timestamp into the time series.
        Parameters:
        timeNano - the time in nano seconds
        numEvents - the number of events happened at timeNano
      • get

        public int get​(long timeNano)
        Parameters:
        timeNano - the time in nano seconds
        Returns:
        the number of event happened in the bucket that includes timeNano
      • getWidthNano

        public long getWidthNano()
        Returns:
        the width
      • getSeries

        public java.util.TreeMap<java.lang.Long,​java.lang.Integer> getSeries()
        Returns:
        the whole time series
      • add

        public void add​(TimeSeries other)
        Add one histogram to the current one. We preserve the width in the current TimeSeries.
        Parameters:
        other - the TimeSeries instance to add
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • sparsePrint

        public void sparsePrint​(java.io.PrintStream stream)
        Print the time series sparsely, i.e. it ignores buckets with 0 events.
        Parameters:
        stream - the print stream
      • print

        public void print​(java.io.PrintStream stream)
        Print the time series densely, i.e. it doesn't ignore buckets with 0 events.
        Parameters:
        stream - the print stream