Class UniformTimeReservoir

    • Constructor Detail

      • UniformTimeReservoir

        public UniformTimeReservoir​(long startTime,
                                    TimeUnit startTimeUnit)
        Creates a new UniformTimeReservoir instance of 1024 elements, which offers a 99.9% confidence level with a 5% margin of error assuming a normal distribution.
        Parameters:
        startTime - The start time
        startTimeUnit - The start time unit
      • UniformTimeReservoir

        public UniformTimeReservoir​(int size,
                                    long startTime,
                                    TimeUnit startTimeUnit)
        Creates a new UniformTimeReservoir instance.
        Parameters:
        size - the number of samples to keep in the sampling reservoir
        startTime - The start time
        startTimeUnit - The start time unit
    • Method Detail

      • size

        public int size​(long time,
                        TimeUnit timeUnit)
        Description copied from interface: TimeReservoir
        Returns the number of values recorded at given time or newer. It may not be supported to return a size in past due to performance optimizations.
        Specified by:
        size in interface TimeReservoir<Long>
        Parameters:
        time - The time to get the size for
        timeUnit - Time unit of the provided time
        Returns:
        the number of values recorded for given time or newer
      • update

        public void update​(Long value,
                           long time,
                           TimeUnit timeUnit)
        Description copied from interface: TimeReservoir
        Adds a new recorded value to the reservoir bound to a given time.
        Specified by:
        update in interface TimeReservoir<Long>
        Parameters:
        value - a new recorded value
        time - The time the recorded value occurred at
        timeUnit - Time unit of the provided time
      • getSnapshot

        public UniformTimeSnapshot getSnapshot​(long time,
                                               TimeUnit timeUnit)
        Description copied from interface: TimeReservoir
        Returns a snapshot of the reservoir's values at given time or newer. It may not be supported to return a snapshot in past due to performance optimizations.
        Specified by:
        getSnapshot in interface TimeReservoir<Long>
        Parameters:
        time - The time for which to get the snapshot
        timeUnit - Time unit of the provided time
        Returns:
        a snapshot of the reservoir's values for given time or newer
      • interval

        public long interval​(TimeUnit timeUnit)
        Description copied from interface: TimeReservoir
        The time interval this reservoir stores data of.
        Specified by:
        interval in interface TimeReservoir<Long>
        Parameters:
        timeUnit - The time unit in which to get the interval
        Returns:
        The time interval of this time reservoir