Class LongTimeSeries

  • All Implemented Interfaces:
    TimeSeries<Long>

    public class LongTimeSeries
    extends Object
    implements TimeSeries<Long>
    This is a time series where the values are Longs. When the time series is created, a CommonTimeUtil.TimeBucket is specified. When timestamps are added, they are rounded to the nearest bucket, e.g. if a CommonTimeUtil.TimeBucket of MINUTE is specified, and a timestamp of January 1st 2017, 12:34:56 is added then the seconds are removed so that the value is associated to 12:34.
    • Method Detail

      • put

        public void put​(Instant instant,
                        Long value)
        Puts the provided value into the time series associated to the Instant instant. Note that this overwrites any previous value in that bucket.
        Specified by:
        put in interface TimeSeries<Long>
        Parameters:
        instant - The instant at which the value was observed.
        value - The value observed at the instant.
      • get

        public Long get​(Instant instant)
        Returns the value associated to the given Instant. Note that this instant is rounded to the nearest time bucket.
        Specified by:
        get in interface TimeSeries<Long>
        Parameters:
        instant - The instant that the value is required for.
        Returns:
        The value associated to the instant.
      • upsert

        public void upsert​(Instant instant,
                           long count)
        Adds the given count to the current value associated to the given Instant. If there is no value currently associated to the Instant then the count is simply inserted. Note that the caller of this method is responsible for dealing with the case where adding count would cause an overflow.
        Parameters:
        instant - The instant at which the value was observed.
        count - The value observed at the instant.
      • getNumberOfInstants

        public int getNumberOfInstants()
        Returns the number of instants in the time series.
        Returns:
        The number of instants in the time series.
      • getTimeSeries

        public SortedMap<Instant,​Long> getTimeSeries()
        Returns the time series as a SortedMap where the key is an Instant rounded to the nearest bucket and the value is the associated count.
        Returns:
        The time series.
      • setTimeSeries

        public void setTimeSeries​(Map<Instant,​Long> timeSeries)
        Sets the time series to be the given time series.
        Parameters:
        timeSeries - The time series to copy entries from.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object