mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sro...@apache.org
Subject svn commit: r667985 - in /lucene/mahout/trunk/core/src/main: examples/org/apache/mahout/cf/taste/example/grouplens/ java/org/apache/mahout/cf/taste/impl/common/ java/org/apache/mahout/cf/taste/impl/correlation/ java/org/apache/mahout/cf/taste/impl/eval...
Date Sun, 15 Jun 2008 18:20:13 GMT
Author: srowen
Date: Sun Jun 15 11:20:12 2008
New Revision: 667985

URL: http://svn.apache.org/viewvc?rev=667985&view=rev
Log:
Switch to use FastMap entirely. Remove some arbirary initial map size choices.

Modified:
    lucene/mahout/trunk/core/src/main/examples/org/apache/mahout/cf/taste/example/grouplens/GroupLensDataModel.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/common/FastMap.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/correlation/GenericItemCorrelation.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/AbstractDifferenceRecommenderEvaluator.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/GenericRecommenderIRStatsEvaluator.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/GenericDataModel.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/GenericUser.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/file/FileDataModel.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/ItemAverageRecommender.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/ItemUserAverageRecommender.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/TreeClusteringRecommender.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/TreeClusteringRecommender2.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/MemoryDiffStorage.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/transforms/Counters.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/transforms/InverseUserFrequency.java

Modified: lucene/mahout/trunk/core/src/main/examples/org/apache/mahout/cf/taste/example/grouplens/GroupLensDataModel.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/examples/org/apache/mahout/cf/taste/example/grouplens/GroupLensDataModel.java?rev=667985&r1=667984&r2=667985&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/examples/org/apache/mahout/cf/taste/example/grouplens/GroupLensDataModel.java
(original)
+++ lucene/mahout/trunk/core/src/main/examples/org/apache/mahout/cf/taste/example/grouplens/GroupLensDataModel.java
Sun Jun 15 11:20:12 2008
@@ -17,6 +17,7 @@
 
 package org.apache.mahout.cf.taste.example.grouplens;
 
+import org.apache.mahout.cf.taste.impl.common.FastMap;
 import org.apache.mahout.cf.taste.impl.common.IOUtils;
 import org.apache.mahout.cf.taste.impl.model.file.FileDataModel;
 import org.apache.mahout.cf.taste.model.Item;
@@ -32,7 +33,6 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.PrintWriter;
-import java.util.HashMap;
 import java.util.Map;
 import java.util.NoSuchElementException;
 
@@ -54,7 +54,7 @@
     super(convertGLFile(ratingsFile, true));
     File convertedMoviesFile = convertGLFile(moviesFile, false);
     BufferedReader reader = new BufferedReader(new FileReader(convertedMoviesFile));
-    movieMap = new HashMap<String, Movie>(5001);
+    movieMap = new FastMap<String, Movie>(5001);
     try {
       for (String line; (line = reader.readLine()) != null;) {
         String[] tokens = line.split(",");

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/common/FastMap.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/common/FastMap.java?rev=667985&r1=667984&r2=667985&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/common/FastMap.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/common/FastMap.java
Sun Jun 15 11:20:12 2008
@@ -49,8 +49,7 @@
   public static final int NO_MAX_SIZE = Integer.MAX_VALUE;
 
   /**
-   * Dummy object used to represent a key that has been removed. Package-private to allow
direct access
-   * by inner classes. No harm in exposing it.
+   * Dummy object used to represent a key that has been removed.
    */
   private static final Object REMOVED = new Object();
 

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/correlation/GenericItemCorrelation.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/correlation/GenericItemCorrelation.java?rev=667985&r1=667984&r2=667985&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/correlation/GenericItemCorrelation.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/correlation/GenericItemCorrelation.java
Sun Jun 15 11:20:12 2008
@@ -21,11 +21,11 @@
 import org.apache.mahout.cf.taste.correlation.ItemCorrelation;
 import org.apache.mahout.cf.taste.impl.common.IteratorIterable;
 import org.apache.mahout.cf.taste.impl.common.IteratorUtils;
+import org.apache.mahout.cf.taste.impl.common.FastMap;
 import org.apache.mahout.cf.taste.impl.recommender.TopItems;
 import org.apache.mahout.cf.taste.model.DataModel;
 import org.apache.mahout.cf.taste.model.Item;
 
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -43,7 +43,7 @@
  */
 public final class GenericItemCorrelation implements ItemCorrelation {
 
-  private final Map<Item, Map<Item, Double>> correlationMaps = new HashMap<Item,
Map<Item, Double>>(1009);
+  private final Map<Item, Map<Item, Double>> correlationMaps = new FastMap<Item,
Map<Item, Double>>();
 
   /**
    * <p>Creates a {@link GenericItemCorrelation} from a precomputed list of {@link
ItemItemCorrelation}s. Each
@@ -88,8 +88,7 @@
    * @param dataModel data model to get {@link Item}s from
    * @throws TasteException if an error occurs while accessing the {@link DataModel} items
    */
-  public GenericItemCorrelation(ItemCorrelation otherCorrelation, DataModel dataModel)
-          throws TasteException {
+  public GenericItemCorrelation(ItemCorrelation otherCorrelation, DataModel dataModel) throws
TasteException {
     List<? extends Item> items = IteratorUtils.iterableToList(dataModel.getItems());
     Iterator<ItemItemCorrelation> it = new DataModelCorrelationsIterator(otherCorrelation,
items);
     initCorrelationMaps(new IteratorIterable<ItemItemCorrelation>(it));
@@ -134,7 +133,7 @@
         }
         Map<Item, Double> map = correlationMaps.get(item1);
         if (map == null) {
-          map = new HashMap<Item, Double>(1009);
+          map = new FastMap<Item, Double>();
           correlationMaps.put(item1, map);
         }
         map.put(item2, iic.getValue());

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/AbstractDifferenceRecommenderEvaluator.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/AbstractDifferenceRecommenderEvaluator.java?rev=667985&r1=667984&r2=667985&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/AbstractDifferenceRecommenderEvaluator.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/AbstractDifferenceRecommenderEvaluator.java
Sun Jun 15 11:20:12 2008
@@ -21,6 +21,7 @@
 import org.apache.mahout.cf.taste.eval.RecommenderBuilder;
 import org.apache.mahout.cf.taste.eval.RecommenderEvaluator;
 import org.apache.mahout.cf.taste.impl.common.RandomUtils;
+import org.apache.mahout.cf.taste.impl.common.FastMap;
 import org.apache.mahout.cf.taste.impl.model.GenericDataModel;
 import org.apache.mahout.cf.taste.impl.model.GenericItem;
 import org.apache.mahout.cf.taste.impl.model.GenericPreference;
@@ -35,9 +36,9 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashMap;
 import java.util.Map;
 import java.util.Random;
+import java.util.List;
 
 /**
  * <p>Abstract superclass of a couple implementations, providing shared functionality.</p>
@@ -75,12 +76,12 @@
     int numUsers = dataModel.getNumUsers();
     Collection<User> trainingUsers = new ArrayList<User>(1 + (int) (trainingPercentage
* (double) numUsers));
     Map<User, Collection<Preference>> testUserPrefs =
-            new HashMap<User, Collection<Preference>>(1 + (int) ((1.0 - trainingPercentage)
* (double) numUsers));
+            new FastMap<User, Collection<Preference>>(1 + (int) ((1.0 - trainingPercentage)
* (double) numUsers));
 
     for (User user : dataModel.getUsers()) {
       if (random.nextDouble() < evaluationPercentage) {
-        Collection<Preference> trainingPrefs = new ArrayList<Preference>();
-        Collection<Preference> testPrefs = new ArrayList<Preference>();
+        List<Preference> trainingPrefs = new ArrayList<Preference>();
+        List<Preference> testPrefs = new ArrayList<Preference>();
         Preference[] prefs = user.getPreferencesAsArray();
         for (int i = 0; i < prefs.length; i++) {
           Preference pref = prefs[i];

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/GenericRecommenderIRStatsEvaluator.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/GenericRecommenderIRStatsEvaluator.java?rev=667985&r1=667984&r2=667985&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/GenericRecommenderIRStatsEvaluator.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/eval/GenericRecommenderIRStatsEvaluator.java
Sun Jun 15 11:20:12 2008
@@ -38,6 +38,7 @@
 import java.util.HashSet;
 import java.util.NoSuchElementException;
 import java.util.Random;
+import java.util.List;
 
 /**
  * <p>For each {@link org.apache.mahout.cf.taste.model.User}, these implementation
determine the top <code>n</code> preferences,
@@ -91,10 +92,10 @@
         }
         int numRelevantItems = relevantItems.size();
         if (numRelevantItems > 0) {
-          Collection<User> trainingUsers = new ArrayList<User>(dataModel.getNumUsers());
+          List<User> trainingUsers = new ArrayList<User>(dataModel.getNumUsers());
           for (User user2 : dataModel.getUsers()) {
             if (id.equals(user2.getID())) {
-              Collection<Preference> trainingPrefs = new ArrayList<Preference>();
+              List<Preference> trainingPrefs = new ArrayList<Preference>();
               Preference[] prefs2 = user2.getPreferencesAsArray();
               for (int i = 0; i < prefs2.length; i++) {
                 Preference pref = prefs2[i];

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/GenericDataModel.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/GenericDataModel.java?rev=667985&r1=667984&r2=667985&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/GenericDataModel.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/GenericDataModel.java
Sun Jun 15 11:20:12 2008
@@ -20,6 +20,7 @@
 import org.apache.mahout.cf.taste.common.TasteException;
 import org.apache.mahout.cf.taste.impl.common.ArrayIterator;
 import org.apache.mahout.cf.taste.impl.common.EmptyIterable;
+import org.apache.mahout.cf.taste.impl.common.FastMap;
 import org.apache.mahout.cf.taste.model.DataModel;
 import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.model.Preference;
@@ -29,7 +30,6 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.NoSuchElementException;
@@ -63,11 +63,11 @@
       throw new IllegalArgumentException("users is null");
     }
 
-    this.userMap = new HashMap<Object, User>();
-    this.itemMap = new HashMap<Object, Item>();
+    this.userMap = new FastMap<Object, User>();
+    this.itemMap = new FastMap<Object, Item>();
     // I'm abusing generics a little here since I want to use this (huge) map to hold Lists,
     // then arrays, and don't want to allocate two Maps at once here.
-    Map<Object, Object> prefsForItems = new HashMap<Object, Object>();
+    Map<Object, Object> prefsForItems = new FastMap<Object, Object>();
     for (User user : users) {
       userMap.put(user.getID(), user);
       Preference[] prefsArray = user.getPreferencesAsArray();

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/GenericUser.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/GenericUser.java?rev=667985&r1=667984&r2=667985&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/GenericUser.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/GenericUser.java
Sun Jun 15 11:20:12 2008
@@ -18,6 +18,7 @@
 package org.apache.mahout.cf.taste.impl.model;
 
 import org.apache.mahout.cf.taste.impl.common.ArrayIterator;
+import org.apache.mahout.cf.taste.impl.common.FastMap;
 import org.apache.mahout.cf.taste.model.Preference;
 import org.apache.mahout.cf.taste.model.User;
 
@@ -25,8 +26,8 @@
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.Map;
+import java.util.List;
 
 /**
  * <p>A simple {@link User} which has simply an ID and some {@link Collection} of
@@ -41,7 +42,7 @@
   // Use an array for maximum performance
   private final Preference[] values;
 
-  public GenericUser(K id, Collection<Preference> preferences) {
+  public GenericUser(K id, List<Preference> preferences) {
     if (id == null) {
       throw new IllegalArgumentException("id is null");
     }
@@ -50,9 +51,12 @@
       data = Collections.emptyMap();
       values = NO_PREFS;
     } else {
-      data = new HashMap<Object, Preference>();
-      values = preferences.toArray(new Preference[preferences.size()]);
-      for (Preference preference : values) {
+      data = new FastMap<Object, Preference>();
+      int size = preferences.size();
+      values = new Preference[size];
+      for (int i = 0; i < size; i++) {
+        Preference preference = preferences.get(i);
+        values[i] = preference;
         // Is this hacky?
         if (preference instanceof SettableUserPreference) {
           ((SettableUserPreference) preference).setUser(this);

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/file/FileDataModel.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/file/FileDataModel.java?rev=667985&r1=667984&r2=667985&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/file/FileDataModel.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/file/FileDataModel.java
Sun Jun 15 11:20:12 2008
@@ -19,6 +19,7 @@
 
 import org.apache.mahout.cf.taste.common.TasteException;
 import org.apache.mahout.cf.taste.impl.common.IOUtils;
+import org.apache.mahout.cf.taste.impl.common.FastMap;
 import org.apache.mahout.cf.taste.impl.model.GenericDataModel;
 import org.apache.mahout.cf.taste.impl.model.GenericItem;
 import org.apache.mahout.cf.taste.impl.model.GenericPreference;
@@ -36,7 +37,6 @@
 import java.io.FileReader;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.NoSuchElementException;
@@ -95,7 +95,7 @@
   protected void reload() throws IOException {
     try {
       reloadLock.lock();
-      Map<String, List<Preference>> data = new HashMap<String, List<Preference>>(1003);
+      Map<String, List<Preference>> data = new FastMap<String, List<Preference>>();
 
       processFile(data);
 

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/ItemAverageRecommender.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/ItemAverageRecommender.java?rev=667985&r1=667984&r2=667985&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/ItemAverageRecommender.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/ItemAverageRecommender.java
Sun Jun 15 11:20:12 2008
@@ -20,6 +20,7 @@
 import org.apache.mahout.cf.taste.common.TasteException;
 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.FastMap;
 import org.apache.mahout.cf.taste.model.DataModel;
 import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.model.Preference;
@@ -29,7 +30,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.NoSuchElementException;
@@ -55,7 +55,7 @@
 
   public ItemAverageRecommender(DataModel dataModel) {
     super(dataModel);
-    this.itemAverages = new HashMap<Object, RunningAverage>(1003);
+    this.itemAverages = new FastMap<Object, RunningAverage>();
     this.refreshLock = new ReentrantLock();
     this.buildAveragesLock = new ReentrantReadWriteLock();
   }

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/ItemUserAverageRecommender.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/ItemUserAverageRecommender.java?rev=667985&r1=667984&r2=667985&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/ItemUserAverageRecommender.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/ItemUserAverageRecommender.java
Sun Jun 15 11:20:12 2008
@@ -20,6 +20,7 @@
 import org.apache.mahout.cf.taste.common.TasteException;
 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.FastMap;
 import org.apache.mahout.cf.taste.model.DataModel;
 import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.model.Preference;
@@ -29,7 +30,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.NoSuchElementException;
@@ -58,8 +58,8 @@
 
   public ItemUserAverageRecommender(DataModel dataModel) {
     super(dataModel);
-    this.itemAverages = new HashMap<Object, RunningAverage>(1003);
-    this.userAverages = new HashMap<Object, RunningAverage>(1003);
+    this.itemAverages = new FastMap<Object, RunningAverage>();
+    this.userAverages = new FastMap<Object, RunningAverage>();
     this.overallAveragePrefValue = new FullRunningAverage();
     this.refreshLock = new ReentrantLock();
     this.buildAveragesLock = new ReentrantReadWriteLock();

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/TreeClusteringRecommender.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/TreeClusteringRecommender.java?rev=667985&r1=667984&r2=667985&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/TreeClusteringRecommender.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/TreeClusteringRecommender.java
Sun Jun 15 11:20:12 2008
@@ -22,6 +22,7 @@
 import org.apache.mahout.cf.taste.impl.common.Pair;
 import org.apache.mahout.cf.taste.impl.common.RandomUtils;
 import org.apache.mahout.cf.taste.impl.common.RunningAverage;
+import org.apache.mahout.cf.taste.impl.common.FastMap;
 import org.apache.mahout.cf.taste.model.DataModel;
 import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.model.Preference;
@@ -35,7 +36,6 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -341,7 +341,7 @@
 
   private static Map<Object, List<RecommendedItem>> computeTopRecsPerUserID(
           Iterable<Collection<User>> clusters) throws TasteException {
-    Map<Object, List<RecommendedItem>> recsPerUser = new HashMap<Object, List<RecommendedItem>>();
+    Map<Object, List<RecommendedItem>> recsPerUser = new FastMap<Object, List<RecommendedItem>>();
     for (Collection<User> cluster : clusters) {
       List<RecommendedItem> recs = computeTopRecsForCluster(cluster);
       for (User user : cluster) {
@@ -372,7 +372,7 @@
   }
 
   private static Map<Object, Collection<User>> computeClustersPerUserID(Collection<Collection<User>>
clusters) {
-    Map<Object, Collection<User>> clustersPerUser = new HashMap<Object, Collection<User>>(clusters.size());
+    Map<Object, Collection<User>> clustersPerUser = new FastMap<Object, Collection<User>>(clusters.size());
     for (Collection<User> cluster : clusters) {
       for (User user : cluster) {
         clustersPerUser.put(user.getID(), cluster);

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/TreeClusteringRecommender2.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/TreeClusteringRecommender2.java?rev=667985&r1=667984&r2=667985&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/TreeClusteringRecommender2.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/TreeClusteringRecommender2.java
Sun Jun 15 11:20:12 2008
@@ -20,6 +20,7 @@
 import org.apache.mahout.cf.taste.common.TasteException;
 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.FastMap;
 import org.apache.mahout.cf.taste.model.DataModel;
 import org.apache.mahout.cf.taste.model.Item;
 import org.apache.mahout.cf.taste.model.Preference;
@@ -33,7 +34,6 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -417,7 +417,7 @@
 
   private static Map<Object, List<RecommendedItem>> computeTopRecsPerUserID(Iterable<Collection<User>>
clusters)
           throws TasteException {
-    Map<Object, List<RecommendedItem>> recsPerUser = new HashMap<Object, List<RecommendedItem>>();
+    Map<Object, List<RecommendedItem>> recsPerUser = new FastMap<Object, List<RecommendedItem>>();
     for (Collection<User> cluster : clusters) {
       List<RecommendedItem> recs = computeTopRecsForCluster(cluster);
       for (User user : cluster) {
@@ -448,7 +448,7 @@
   }
 
   private static Map<Object, Collection<User>> computeClustersPerUserID(Collection<Collection<User>>
clusters) {
-    Map<Object, Collection<User>> clustersPerUser = new HashMap<Object, Collection<User>>(clusters.size());
+    Map<Object, Collection<User>> clustersPerUser = new FastMap<Object, Collection<User>>(clusters.size());
     for (Collection<User> cluster : clusters) {
       for (User user : cluster) {
         clustersPerUser.put(user.getID(), cluster);

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/MemoryDiffStorage.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/MemoryDiffStorage.java?rev=667985&r1=667984&r2=667985&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/MemoryDiffStorage.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/MemoryDiffStorage.java
Sun Jun 15 11:20:12 2008
@@ -33,7 +33,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
@@ -100,8 +99,8 @@
     this.stdDevWeighted = stdDevWeighted;
     this.compactAverages = compactAverages;
     this.maxEntries = maxEntries;
-    this.averageDiffs = new FastMap<Object, Map<Object, RunningAverage>>(1003);
-    this.averageItemPref = new FastMap<Object, RunningAverage>(101);
+    this.averageDiffs = new FastMap<Object, Map<Object, RunningAverage>>();
+    this.averageItemPref = new FastMap<Object, RunningAverage>();
     this.buildAverageDiffsLock = new ReentrantReadWriteLock();
     this.refreshLock = new ReentrantLock();
     buildAverageDiffs();
@@ -213,7 +212,7 @@
           Object itemIDA = prefA.getItem().getID();
           Map<Object, RunningAverage> aMap = averageDiffs.get(itemIDA);
           if (aMap == null) {
-            aMap = new HashMap<Object, RunningAverage>();
+            aMap = new FastMap<Object, RunningAverage>();
             averageDiffs.put(itemIDA, aMap);
           }
           for (int j = i + 1; j < length; j++) {

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/transforms/Counters.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/transforms/Counters.java?rev=667985&r1=667984&r2=667985&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/transforms/Counters.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/transforms/Counters.java
Sun Jun 15 11:20:12 2008
@@ -17,7 +17,8 @@
 
 package org.apache.mahout.cf.taste.impl.transforms;
 
-import java.util.HashMap;
+import org.apache.mahout.cf.taste.impl.common.FastMap;
+
 import java.util.Map;
 
 /**
@@ -25,7 +26,7 @@
  */
 final class Counters<T> {
 
-  private final Map<T, MutableInteger> counts = new HashMap<T, MutableInteger>(1009);
+  private final Map<T, MutableInteger> counts = new FastMap<T, MutableInteger>();
 
   void increment(T key) {
     MutableInteger count = counts.get(key);

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/transforms/InverseUserFrequency.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/transforms/InverseUserFrequency.java?rev=667985&r1=667984&r2=667985&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/transforms/InverseUserFrequency.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/transforms/InverseUserFrequency.java
Sun Jun 15 11:20:12 2008
@@ -23,11 +23,11 @@
 import org.apache.mahout.cf.taste.model.Preference;
 import org.apache.mahout.cf.taste.model.User;
 import org.apache.mahout.cf.taste.transforms.PreferenceTransform;
+import org.apache.mahout.cf.taste.impl.common.FastMap;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicReference;
 
@@ -69,7 +69,7 @@
     }
     this.dataModel = dataModel;
     this.logBase = logBase;
-    this.iufFactors = new AtomicReference<Map<Item, Double>>(new HashMap<Item,
Double>(1009));
+    this.iufFactors = new AtomicReference<Map<Item, Double>>(new FastMap<Item,
Double>());
     refresh();
   }
 
@@ -100,8 +100,7 @@
           }
           numUsers++;
         }
-        Map<Item, Double> newIufFactors =
-                new HashMap<Item, Double>(1 + (4 * itemPreferenceCounts.size()) / 3,
0.75f);
+        Map<Item, Double> newIufFactors = new FastMap<Item, Double>(itemPreferenceCounts.size());
         double logFactor = Math.log(logBase);
         for (Map.Entry<Item, Counters.MutableInteger> entry : itemPreferenceCounts.getEntrySet())
{
           newIufFactors.put(entry.getKey(),



Mime
View raw message