mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sro...@apache.org
Subject svn commit: r667967 - in /lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl: common/ correlation/ neighborhood/ recommender/ transforms/
Date Sun, 15 Jun 2008 16:17:46 GMT
Author: srowen
Date: Sun Jun 15 09:17:43 2008
New Revision: 667967

URL: http://svn.apache.org/viewvc?rev=667967&view=rev
Log:
Rename SoftCache to Cache

Added:
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/common/Cache.java
  (contents, props changed)
      - copied, changed from r662612, lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/common/SoftCache.java
Modified:
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/correlation/AveragingPreferenceInferrer.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/neighborhood/NearestNUserNeighborhood.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/neighborhood/ThresholdUserNeighborhood.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/CachingRecommender.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/transforms/ZScore.java

Copied: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/common/Cache.java
(from r662612, lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/common/SoftCache.java)
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/common/Cache.java?p2=lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/common/Cache.java&p1=lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/common/SoftCache.java&r1=662612&r2=667967&rev=667967&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/common/SoftCache.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/common/Cache.java
Sun Jun 15 09:17:43 2008
@@ -20,19 +20,16 @@
 import org.apache.mahout.cf.taste.common.TasteException;
 
 /**
- * <p>An efficient Map-like class which caches values for keys. Values are not "put"
into a {@link SoftCache};
+ * <p>An efficient Map-like class which caches values for keys. Values are not "put"
into a {@link Cache};
  * instead the caller supplies the instance with an implementation of {@link Retriever} which
can load the
  * value for a given key.</p>
  *
- * <p>This class is a bit misnamed at this point since it no longer uses <code>SoftReference</code>
internally,
- * but hey.</p>
- *
  * <p>The cache does not support <code>null</code> values or keys.</p>
  *
  * <p>Thanks to Amila Jayasooriya for helping evaluate performance of the rewrite of
this class, as part of a
  * Google Summer of Code 2007 project.</p>
  */
-public final class SoftCache<K, V> {
+public final class Cache<K, V> {
 
   private final FastMap<K, V> cache;
   private final Retriever<? super K, ? extends V> retriever;
@@ -42,7 +39,7 @@
    *
    * @param retriever object which can retrieve values for keys
    */
-  public SoftCache(Retriever<? super K, ? extends V> retriever) {
+  public Cache(Retriever<? super K, ? extends V> retriever) {
     this(retriever, FastMap.NO_MAX_SIZE);
   }
 
@@ -52,7 +49,7 @@
    * @param retriever object which can retrieve values for keys
    * @param maxEntries maximum number of entries the cache will store before evicting some
    */
-  public SoftCache(Retriever<? super K, ? extends V> retriever, int maxEntries) {
+  public Cache(Retriever<? super K, ? extends V> retriever, int maxEntries) {
     if (retriever == null) {
       throw new IllegalArgumentException("retriever is null");
     }
@@ -111,7 +108,7 @@
 
   @Override
   public String toString() {
-    return "SoftCache[retriever:" + retriever + ']';
+    return "Cache[retriever:" + retriever + ']';
   }
 
   /**

Propchange: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/common/Cache.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/correlation/AveragingPreferenceInferrer.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/correlation/AveragingPreferenceInferrer.java?rev=667967&r1=667966&r2=667967&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/correlation/AveragingPreferenceInferrer.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/correlation/AveragingPreferenceInferrer.java
Sun Jun 15 09:17:43 2008
@@ -21,7 +21,7 @@
 import org.apache.mahout.cf.taste.correlation.PreferenceInferrer;
 import org.apache.mahout.cf.taste.impl.common.FullRunningAverage;
 import org.apache.mahout.cf.taste.impl.common.RunningAverage;
-import org.apache.mahout.cf.taste.impl.common.SoftCache;
+import org.apache.mahout.cf.taste.impl.common.Cache;
 import org.apache.mahout.cf.taste.model.DataModel;
 import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.model.Preference;
@@ -34,12 +34,12 @@
  */
 public final class AveragingPreferenceInferrer implements PreferenceInferrer {
 
-  private static final SoftCache.Retriever<User, Double> RETRIEVER = new PrefRetriever();
+  private static final Cache.Retriever<User, Double> RETRIEVER = new PrefRetriever();
 
-  private final SoftCache<User, Double> averagePreferenceValue;
+  private final Cache<User, Double> averagePreferenceValue;
 
   public AveragingPreferenceInferrer(DataModel dataModel) throws TasteException {
-    averagePreferenceValue = new SoftCache<User, Double>(RETRIEVER, dataModel.getNumUsers());
+    averagePreferenceValue = new Cache<User, Double>(RETRIEVER, dataModel.getNumUsers());
     refresh();
   }
 
@@ -54,7 +54,7 @@
     averagePreferenceValue.clear();
   }
 
-  private static final class PrefRetriever implements SoftCache.Retriever<User, Double>
{
+  private static final class PrefRetriever implements Cache.Retriever<User, Double>
{
 
     public Double getValue(User key) {
       RunningAverage average = new FullRunningAverage();

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/neighborhood/NearestNUserNeighborhood.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/neighborhood/NearestNUserNeighborhood.java?rev=667967&r1=667966&r2=667967&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/neighborhood/NearestNUserNeighborhood.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/neighborhood/NearestNUserNeighborhood.java
Sun Jun 15 09:17:43 2008
@@ -19,7 +19,7 @@
 
 import org.apache.mahout.cf.taste.common.TasteException;
 import org.apache.mahout.cf.taste.correlation.UserCorrelation;
-import org.apache.mahout.cf.taste.impl.common.SoftCache;
+import org.apache.mahout.cf.taste.impl.common.Cache;
 import org.apache.mahout.cf.taste.model.DataModel;
 import org.apache.mahout.cf.taste.model.User;
 import org.slf4j.Logger;
@@ -40,7 +40,7 @@
 
   private static final Logger log = LoggerFactory.getLogger(NearestNUserNeighborhood.class);
 
-  private final SoftCache<Object, Collection<User>> cache;
+  private final Cache<Object, Collection<User>> cache;
 
   /**
    * @param n neighborhood size
@@ -71,7 +71,7 @@
     if (n < 1) {
       throw new IllegalArgumentException("n must be at least 1");
     }
-    this.cache = new SoftCache<Object, Collection<User>>(new Retriever(n), dataModel.getNumUsers());
+    this.cache = new Cache<Object, Collection<User>>(new Retriever(n), dataModel.getNumUsers());
   }
 
   public Collection<User> getUserNeighborhood(Object userID) throws TasteException
{
@@ -84,7 +84,7 @@
   }
 
 
-  private final class Retriever implements SoftCache.Retriever<Object, Collection<User>>
{
+  private final class Retriever implements Cache.Retriever<Object, Collection<User>>
{
 
     private final int n;
 

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/neighborhood/ThresholdUserNeighborhood.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/neighborhood/ThresholdUserNeighborhood.java?rev=667967&r1=667966&r2=667967&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/neighborhood/ThresholdUserNeighborhood.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/neighborhood/ThresholdUserNeighborhood.java
Sun Jun 15 09:17:43 2008
@@ -19,7 +19,7 @@
 
 import org.apache.mahout.cf.taste.common.TasteException;
 import org.apache.mahout.cf.taste.correlation.UserCorrelation;
-import org.apache.mahout.cf.taste.impl.common.SoftCache;
+import org.apache.mahout.cf.taste.impl.common.Cache;
 import org.apache.mahout.cf.taste.model.DataModel;
 import org.apache.mahout.cf.taste.model.User;
 import org.slf4j.Logger;
@@ -40,7 +40,7 @@
 
   private static final Logger log = LoggerFactory.getLogger(ThresholdUserNeighborhood.class);
 
-  private final SoftCache<Object, Collection<User>> cache;
+  private final Cache<Object, Collection<User>> cache;
 
   /**
    * @param threshold similarity threshold
@@ -74,7 +74,7 @@
     if (Double.isNaN(threshold)) {
       throw new IllegalArgumentException("threshold must not be NaN");
     }
-    this.cache = new SoftCache<Object, Collection<User>>(new Retriever(threshold),
dataModel.getNumUsers());
+    this.cache = new Cache<Object, Collection<User>>(new Retriever(threshold),
dataModel.getNumUsers());
   }
 
   public Collection<User> getUserNeighborhood(Object userID) throws TasteException
{
@@ -87,7 +87,7 @@
   }
 
 
-  private final class Retriever implements SoftCache.Retriever<Object, Collection<User>>
{
+  private final class Retriever implements Cache.Retriever<Object, Collection<User>>
{
 
     private final double threshold;
 

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/CachingRecommender.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/CachingRecommender.java?rev=667967&r1=667966&r2=667967&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/CachingRecommender.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/CachingRecommender.java
Sun Jun 15 09:17:43 2008
@@ -19,7 +19,7 @@
 
 import org.apache.mahout.cf.taste.common.TasteException;
 import org.apache.mahout.cf.taste.impl.common.Pair;
-import org.apache.mahout.cf.taste.impl.common.SoftCache;
+import org.apache.mahout.cf.taste.impl.common.Cache;
 import org.apache.mahout.cf.taste.model.DataModel;
 import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.recommender.RecommendedItem;
@@ -45,8 +45,8 @@
 
   private final Recommender recommender;
   private final AtomicInteger maxHowMany;
-  private final SoftCache<Object, Recommendations> recommendationCache;
-  private final SoftCache<Pair<?, ?>, Double> estimatedPrefCache;
+  private final Cache<Object, Recommendations> recommendationCache;
+  private final Cache<Pair<?, ?>, Double> estimatedPrefCache;
   private final ReentrantLock refreshLock;
 
   public CachingRecommender(Recommender recommender) throws TasteException {
@@ -58,11 +58,11 @@
     // Use "num users" as an upper limit on cache size. Rough guess.
     int numUsers = recommender.getDataModel().getNumUsers();
     this.recommendationCache =
-            new SoftCache<Object, Recommendations>(
+            new Cache<Object, Recommendations>(
                     new RecommendationRetriever(this.recommender, this.maxHowMany),
                     numUsers);
     this.estimatedPrefCache =
-            new SoftCache<Pair<?, ?>, Double>(new EstimatedPrefRetriever(this.recommender),
numUsers);
+            new Cache<Pair<?, ?>, Double>(new EstimatedPrefRetriever(this.recommender),
numUsers);
     this.refreshLock = new ReentrantLock();
   }
 
@@ -154,7 +154,7 @@
     return "CachingRecommender[recommender:" + recommender + ']';
   }
 
-  private static final class RecommendationRetriever implements SoftCache.Retriever<Object,
Recommendations> {
+  private static final class RecommendationRetriever implements Cache.Retriever<Object,
Recommendations> {
 
     private final Recommender recommender;
     private final AtomicInteger maxHowMany;
@@ -170,7 +170,7 @@
     }
   }
 
-  private static final class EstimatedPrefRetriever implements SoftCache.Retriever<Pair<?,
?>, Double> {
+  private static final class EstimatedPrefRetriever implements Cache.Retriever<Pair<?,
?>, Double> {
 
     private final Recommender recommender;
 

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/transforms/ZScore.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/transforms/ZScore.java?rev=667967&r1=667966&r2=667967&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/transforms/ZScore.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/transforms/ZScore.java
Sun Jun 15 09:17:43 2008
@@ -20,7 +20,7 @@
 import org.apache.mahout.cf.taste.common.TasteException;
 import org.apache.mahout.cf.taste.impl.common.FullRunningAverageAndStdDev;
 import org.apache.mahout.cf.taste.impl.common.RunningAverageAndStdDev;
-import org.apache.mahout.cf.taste.impl.common.SoftCache;
+import org.apache.mahout.cf.taste.impl.common.Cache;
 import org.apache.mahout.cf.taste.model.Preference;
 import org.apache.mahout.cf.taste.model.User;
 import org.apache.mahout.cf.taste.transforms.PreferenceTransform;
@@ -38,10 +38,10 @@
  */
 public final class ZScore implements PreferenceTransform {
 
-  private final SoftCache<User, RunningAverageAndStdDev> meanAndStdevs;
+  private final Cache<User, RunningAverageAndStdDev> meanAndStdevs;
 
   public ZScore() {
-    this.meanAndStdevs = new SoftCache<User, RunningAverageAndStdDev>(new MeanStdevRetriever());
+    this.meanAndStdevs = new Cache<User, RunningAverageAndStdDev>(new MeanStdevRetriever());
     refresh();
   }
 
@@ -65,7 +65,7 @@
     return "ZScore";
   }
 
-  private static class MeanStdevRetriever implements SoftCache.Retriever<User, RunningAverageAndStdDev>
{
+  private static class MeanStdevRetriever implements Cache.Retriever<User, RunningAverageAndStdDev>
{
 
     public RunningAverageAndStdDev getValue(User user) throws TasteException {
       RunningAverageAndStdDev running = new FullRunningAverageAndStdDev();



Mime
View raw message