org.apache.mahout.cf.taste.impl.common
Class CompactRunningAverage

java.lang.Object
  extended by org.apache.mahout.cf.taste.impl.common.CompactRunningAverage
All Implemented Interfaces:
java.io.Serializable, RunningAverage
Direct Known Subclasses:
CompactRunningAverageAndStdDev

public class CompactRunningAverage
extends java.lang.Object
implements RunningAverage, java.io.Serializable

Like FullRunningAverage but uses smaller values (short, float) to conserve memory. This is used in SlopeOneRecommender since it may allocate tens of millions of such objects.

See Also:
Serialized Form

Constructor Summary
CompactRunningAverage()
           
 
Method Summary
 void addDatum(double datum)
           
 void changeDatum(double delta)
           
 double getAverage()
           
 int getCount()
           
 void removeDatum(double datum)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CompactRunningAverage

public CompactRunningAverage()
Method Detail

addDatum

public void addDatum(double datum)
Specified by:
addDatum in interface RunningAverage
Parameters:
datum - new item to add to the running average

removeDatum

public void removeDatum(double datum)
Specified by:
removeDatum in interface RunningAverage
Parameters:
datum - item to remove to the running average

changeDatum

public void changeDatum(double delta)
Specified by:
changeDatum in interface RunningAverage
Parameters:
delta - amount by which to change a datum in the running average

getCount

public int getCount()
Specified by:
getCount in interface RunningAverage

getAverage

public double getAverage()
Specified by:
getAverage in interface RunningAverage

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.