org.apache.solr.util.stats

## Class ExponentiallyDecayingSample

- java.lang.Object
- - org.apache.solr.util.stats.ExponentiallyDecayingSample

- All Implemented Interfaces:
    Sample

      public class ExponentiallyDecayingSample
      extends Object
      implements Sample

  An exponentially-decaying random sample of `long`s. Uses Cormode et al's forward-decaying priority reservoir sampling method to produce a statistically representative sample, exponentially biased towards newer entries. See Cormode et al. Forward Decay: A Practical Time Decay Model for Streaming Systems. ICDE '09: Proceedings of the 2009 IEEE International Conference on Data Engineering (2009)

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ExponentiallyDecayingSample(int reservoirSize, double alpha)` Creates a new `ExponentiallyDecayingSample`.
    `ExponentiallyDecayingSample(int reservoirSize, double alpha, Clock clock)` Creates a new `ExponentiallyDecayingSample`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()` Clears all recorded values.
    `Snapshot` | `getSnapshot()` Returns a snapshot of the sample's values.
    `int` | `size()` Returns the number of values recorded.
    `void` | `update(long value)` Adds a new recorded value to the sample.
    `void` | `update(long value, long timestamp)` Adds an old value with a fixed timestamp to the sample.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ExponentiallyDecayingSample

          public ExponentiallyDecayingSample(int reservoirSize,
                                             double alpha)

      Creates a new `ExponentiallyDecayingSample`.
      Parameters:
        `reservoirSize` - the number of samples to keep in the sampling reservoir
        `alpha` - the exponential decay factor; the higher this is, the more biased the sample will be towards newer values

    - #### ExponentiallyDecayingSample

          public ExponentiallyDecayingSample(int reservoirSize,
                                             double alpha,
                                             Clock clock)

      Creates a new `ExponentiallyDecayingSample`.
      Parameters:
        `reservoirSize` - the number of samples to keep in the sampling reservoir
        `alpha` - the exponential decay factor; the higher this is, the more biased the sample will be towards newer values

  - ### Method Detail

    - #### clear

          public void clear()

      Description copied from interface: `Sample`
      Clears all recorded values.
      Specified by:
        `clear` in interface `Sample`

    - #### size

          public int size()

      Description copied from interface: `Sample`
      Returns the number of values recorded.
      Specified by:
        `size` in interface `Sample`
      Returns:
        the number of values recorded

    - #### update

          public void update(long value)

      Description copied from interface: `Sample`
      Adds a new recorded value to the sample.
      Specified by:
        `update` in interface `Sample`
      Parameters:
        `value` - a new recorded value

    - #### update

          public void update(long value,
                             long timestamp)

      Adds an old value with a fixed timestamp to the sample.
      Parameters:
        `value` - the value to be added
        `timestamp` - the epoch timestamp of `value` in seconds

    - #### getSnapshot

          public Snapshot getSnapshot()

      Description copied from interface: `Sample`
      Returns a snapshot of the sample's values.
      Specified by:
        `getSnapshot` in interface `Sample`
      Returns:
        a snapshot of the sample's values

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.