mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sro...@apache.org
Subject svn commit: r1074244 - /mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/CachingRecommender.java
Date Thu, 24 Feb 2011 18:07:57 GMT
Author: srowen
Date: Thu Feb 24 18:07:56 2011
New Revision: 1074244

URL: http://svn.apache.org/viewvc?rev=1074244&view=rev
Log:
Properly clear estimatedPreferenceCache on updates

Modified:
    mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/CachingRecommender.java

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/CachingRecommender.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/CachingRecommender.java?rev=1074244&r1=1074243&r2=1074244&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/CachingRecommender.java
(original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/CachingRecommender.java
Thu Feb 24 18:07:56 2011
@@ -74,7 +74,7 @@ public final class CachingRecommender im
     refreshHelper.addDependency(recommender);
   }
   
-  private  void setCurrentRescorer(IDRescorer rescorer) {
+  private void setCurrentRescorer(IDRescorer rescorer) {
     if (rescorer == null) {
       if (currentRescorer != null) {
         currentRescorer = null;
@@ -157,9 +157,15 @@ public final class CachingRecommender im
    * @param userID
    *          clear cached data associated with this user ID
    */
-  public void clear(long userID) {
+  public void clear(final long userID) {
     log.debug("Clearing recommendations for user ID '{}'", userID);
     recommendationCache.remove(userID);
+    estimatedPrefCache.removeKeysMatching(new Cache.MatchPredicate<LongPair>() {
+      @Override
+      public boolean matches(LongPair userItemPair) {
+        return userItemPair.getFirst() == userID;
+      }
+    });
   }
   
   /**
@@ -170,6 +176,7 @@ public final class CachingRecommender im
   public void clear() {
     log.debug("Clearing all recommendations...");
     recommendationCache.clear();
+    estimatedPrefCache.clear();
   }
   
   @Override



Mime
View raw message