org.apache.mahout.cf.taste.impl.similarity
Class CachingItemSimilarity

java.lang.Object
  extended by org.apache.mahout.cf.taste.impl.similarity.CachingItemSimilarity
All Implemented Interfaces:
Refreshable, ItemSimilarity

public final class CachingItemSimilarity
extends java.lang.Object
implements ItemSimilarity

Caches the results from an underlying ItemSimilarity implementation.


Constructor Summary
CachingItemSimilarity(ItemSimilarity similarity, DataModel dataModel)
           
 
Method Summary
 double itemSimilarity(long itemID1, long itemID2)
           Returns the degree of similarity, of two items, based on the preferences that users have expressed for the items.
 void refresh(java.util.Collection<Refreshable> alreadyRefreshed)
           Triggers "refresh" -- whatever that means -- of the implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachingItemSimilarity

public CachingItemSimilarity(ItemSimilarity similarity,
                             DataModel dataModel)
                      throws TasteException
Throws:
TasteException
Method Detail

itemSimilarity

public double itemSimilarity(long itemID1,
                             long itemID2)
                      throws TasteException
Description copied from interface: ItemSimilarity

Returns the degree of similarity, of two items, based on the preferences that users have expressed for the items.

Specified by:
itemSimilarity in interface ItemSimilarity
Parameters:
itemID1 - first item ID
itemID2 - second item ID
Returns:
similarity between the items, in [-1,1]
Throws:
TasteException - if an error occurs while accessing the data

refresh

public void refresh(java.util.Collection<Refreshable> alreadyRefreshed)
Description copied from interface: Refreshable

Triggers "refresh" -- whatever that means -- of the implementation. The general contract is that any should always leave itself in a consistent, operational state, and that the refresh atomically updates internal state from old to new.

Specified by:
refresh in interface Refreshable
Parameters:
alreadyRefreshed - s that are known to have already been refreshed as a result of an initial call to a method on some object. This ensure that objects in a refresh dependency graph aren't refreshed twice needlessly.


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