org.apache.solr.util.stats
Class UniformSample

java.lang.Object
  extended by org.apache.solr.util.stats.UniformSample
All Implemented Interfaces:
Sample

public class UniformSample
extends Object
implements Sample

A random sample of a stream of longs. Uses Vitter's Algorithm R to produce a statistically representative sample.

See Also:
Random Sampling with a Reservoir

Constructor Summary
UniformSample(int reservoirSize)
          Creates a new UniformSample.
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UniformSample

public UniformSample(int reservoirSize)
Creates a new UniformSample.

Parameters:
reservoirSize - the number of samples to keep in the sampling reservoir
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

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-2013 Apache Software Foundation. All Rights Reserved.