com.grandcentral.appstats.calculators
Class HistogramCalculator

java.lang.Object
  |
  +--com.grandcentral.appstats.StatCalculator
        |
        +--com.grandcentral.appstats.calculators.HistogramCalculator
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ModeCalculator

public class HistogramCalculator
extends StatCalculator

A calculator to generate a histogram of the stat data received. You must intialize this class either with the buckets into which you want the stat data grouped, or a bucket size to allow the class to auto-generate the histogram. Note that auto-generated histograms are implement with Maps, and so are much less space and speed efficient than the array based counterparts.

The author would like to thank Genesis for "Trick of the Tail," which was playing for most of his contributions to this package

See Also:
Serialized Form

Field Summary
static java.lang.String SUFFIX_DHIST_PFX
           
static java.lang.String SUFFIX_HIST_EXTRA
           
static java.lang.String SUFFIX_LHIST_PFX
           
static java.lang.String SUFFIX_OHIST_PFX
           
 
Fields inherited from class com.grandcentral.appstats.StatCalculator
m_parent
 
Constructor Summary
HistogramCalculator()
           
 
Method Summary
 void calculate(Task destination, Stat newSample, java.lang.String prependName)
           
 void clear()
          resets this object to clean state
 java.util.List getSuffices()
           
 int getType()
           
protected  long incrBucketCounter(Task destination, java.lang.String prefix, double bucket)
           
protected  long incrBucketCounter(Task destination, java.lang.String prefix, long bucket)
           
protected  long incrBucketCounter(Task destination, java.lang.String prefix, java.lang.Object bucket)
           
protected  long incrCounter(Task destination, java.lang.String statName)
           
 void removeType(int dataType)
          removes the type from this calculator and deletes any corresponding values
 void setAutoGenBuckets(boolean val)
          convenience method to instuct this class to auto generate all buckets (if the user hasn't already assigned bucket arrays, that is) with bucket size = 1
 void setAutoGenObjectBuckets(boolean val)
          if there are no object buckets set for this instance, signals this class that Object buckets should be automatically generated.
 void setBuckets(double[] buckets)
          set the buckets for this calculator to use for creating the histogram.
 void setBuckets(long[] buckets)
          set the buckets for this calculator to use for creating the histogram.
 void setBuckets(java.lang.Object[] buckets)
          set the buckets for this calculator to use for creating the histogram.
 void setBucketSize(double bucketSize)
          if there are no double buckets set for this instance, if bucketSize>0, signals this class that double buckets should be automatically generated.
 void setBucketSize(long bucketSize)
          if there are no long buckets set for this instance, if bucketSize>0, signals this class that long buckets should be automatically generated.
 void setObjectComparator(java.util.Comparator c)
          sets the comparator for Arrays.binarySearch algorith when locating Objects in the bucket array
 
Methods inherited from class com.grandcentral.appstats.StatCalculator
getParent, getTopMostParent, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUFFIX_LHIST_PFX

public static final java.lang.String SUFFIX_LHIST_PFX

SUFFIX_DHIST_PFX

public static final java.lang.String SUFFIX_DHIST_PFX

SUFFIX_OHIST_PFX

public static final java.lang.String SUFFIX_OHIST_PFX

SUFFIX_HIST_EXTRA

public static final java.lang.String SUFFIX_HIST_EXTRA
Constructor Detail

HistogramCalculator

public HistogramCalculator()
Method Detail

setBuckets

public void setBuckets(long[] buckets)
set the buckets for this calculator to use for creating the histogram.
Parameters:
buckets - a sorted array of bucket values, or null to unset previous buckets

setBuckets

public void setBuckets(double[] buckets)
set the buckets for this calculator to use for creating the histogram.
Parameters:
buckets - a sorted array of bucket values, or null to unset previous buckets

setBuckets

public void setBuckets(java.lang.Object[] buckets)
set the buckets for this calculator to use for creating the histogram.
Parameters:
buckets - a sorted array of bucket values, or null to unset previous buckets

setObjectComparator

public void setObjectComparator(java.util.Comparator c)
sets the comparator for Arrays.binarySearch algorith when locating Objects in the bucket array

setBucketSize

public void setBucketSize(long bucketSize)
if there are no long buckets set for this instance, if bucketSize>0, signals this class that long buckets should be automatically generated.

setBucketSize

public void setBucketSize(double bucketSize)
if there are no double buckets set for this instance, if bucketSize>0, signals this class that double buckets should be automatically generated.

setAutoGenObjectBuckets

public void setAutoGenObjectBuckets(boolean val)
if there are no object buckets set for this instance, signals this class that Object buckets should be automatically generated.

setAutoGenBuckets

public void setAutoGenBuckets(boolean val)
convenience method to instuct this class to auto generate all buckets (if the user hasn't already assigned bucket arrays, that is) with bucket size = 1

getType

public int getType()

removeType

public void removeType(int dataType)
removes the type from this calculator and deletes any corresponding values

getSuffices

public java.util.List getSuffices()
Overrides:
getSuffices in class StatCalculator
Throws:
UnsupportedOperationException() - -- this method may go away from the interface

calculate

public void calculate(Task destination,
                      Stat newSample,
                      java.lang.String prependName)
               throws DatatypeMismatchException
Overrides:
calculate in class StatCalculator

incrBucketCounter

protected long incrBucketCounter(Task destination,
                                 java.lang.String prefix,
                                 long bucket)

incrBucketCounter

protected long incrBucketCounter(Task destination,
                                 java.lang.String prefix,
                                 double bucket)

incrBucketCounter

protected long incrBucketCounter(Task destination,
                                 java.lang.String prefix,
                                 java.lang.Object bucket)

incrCounter

protected long incrCounter(Task destination,
                           java.lang.String statName)

clear

public void clear()
resets this object to clean state
Overrides:
clear in class StatCalculator