mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sro...@apache.org
Subject svn commit: r765142 - in /lucene/mahout/trunk: core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/ core/src/main/java/org/apache/mahout/clustering/dirichlet/ core/src/test/java/org/apache/mahout/classifier/bayes/ core/src/test/java/org/apac...
Date Wed, 15 Apr 2009 11:37:49 GMT
Author: srowen
Date: Wed Apr 15 11:37:49 2009
New Revision: 765142

URL: http://svn.apache.org/viewvc?rev=765142&view=rev
Log:
More small refinements or potential bug fixes suggested by FindBugs

Modified:
    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/clustering/dirichlet/JsonModelDistributionAdapter.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/bayes/BayesFileFormatterTest.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/dirichlet/TestMapReduce.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/dirichlet/Job.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/meanshift/InputMapper.java
    lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/FileInfosDatasetTest.java

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=765142&r1=765141&r2=765142&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
Wed Apr 15 11:37:49 2009
@@ -76,6 +76,10 @@
     this.refreshHelper.addDependency(recommender);
   }
 
+  private synchronized Rescorer<Item> getCurrentRescorer() {
+    return currentRescorer;
+  }
+
   private synchronized void setCurrentRescorer(Rescorer<Item> rescorer) {
     if (rescorer == null) {
       if (currentRescorer != null) {
@@ -190,9 +194,10 @@
     public Recommendations get(Object key) throws TasteException {
       log.debug("Retrieving new recommendations for user ID '{}'", key);
       int howMany = maxHowMany.get();
-      List<RecommendedItem> recommendations = currentRescorer == null ?
+      Rescorer<Item> rescorer = getCurrentRescorer();
+      List<RecommendedItem> recommendations = rescorer == null ?
           recommender.recommend(key, howMany) :
-          recommender.recommend(key, howMany, currentRescorer);
+          recommender.recommend(key, howMany, rescorer);
       return new Recommendations(Collections.unmodifiableList(recommendations));
     }
   }

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/dirichlet/JsonModelDistributionAdapter.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/dirichlet/JsonModelDistributionAdapter.java?rev=765142&r1=765141&r2=765142&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/dirichlet/JsonModelDistributionAdapter.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/dirichlet/JsonModelDistributionAdapter.java
Wed Apr 15 11:37:49 2009
@@ -50,6 +50,7 @@
       cl = ccl.loadClass(json.getAsString());
     } catch (ClassNotFoundException e) {
       log.warn("Error while loading class", e);
+      return null;
     }
     try {
       return (ModelDistribution<?>) cl.newInstance();

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/bayes/BayesFileFormatterTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/bayes/BayesFileFormatterTest.java?rev=765142&r1=765141&r2=765142&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/bayes/BayesFileFormatterTest.java
(original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/bayes/BayesFileFormatterTest.java
Wed Apr 15 11:37:49 2009
@@ -75,7 +75,10 @@
     for (File file : files) {
       //should only be one line in the file, and it should be label label
       BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file),
charset));
-      String line = reader.readLine().trim();
+      String line = reader.readLine();
+      if (line != null) {
+        line = line.trim();
+      }
       String label = "animal" + '\t' + file.getName();
       assertEquals(line + ":::: is not equal to " + label + "::::", line, label);
       reader.close();

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/dirichlet/TestMapReduce.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/dirichlet/TestMapReduce.java?rev=765142&r1=765141&r2=765142&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/dirichlet/TestMapReduce.java
(original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/dirichlet/TestMapReduce.java
Wed Apr 15 11:37:49 2009
@@ -357,7 +357,7 @@
     printResults(clusters, 0);
   }
 
-  private void printResults(List<List<DirichletCluster<Vector>>> clusters,
+  private static void printResults(List<List<DirichletCluster<Vector>>>
clusters,
       int significant) {
     int row = 0;
     for (List<DirichletCluster<Vector>> r : clusters) {
@@ -365,8 +365,8 @@
       for (int k = 0; k < r.size(); k++) {
         Model<Vector> model = r.get(k).model;
         if (model.count() > significant) {
-          int total = new Double(r.get(k).totalCount).intValue();
-          System.out.print("m" + k + "(" + total + ")" + model.toString()
+          int total = (int) r.get(k).totalCount;
+          System.out.print("m" + k + '(' + total + ')' + model.toString()
               + ", ");
         }
       }

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/dirichlet/Job.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/dirichlet/Job.java?rev=765142&r1=765141&r2=765142&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/dirichlet/Job.java
(original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/dirichlet/Job.java
Wed Apr 15 11:37:49 2009
@@ -127,8 +127,8 @@
       for (int k = 0; k < r.size(); k++) {
         Model<Vector> model = r.get(k).model;
         if (model.count() > significant) {
-          int total = new Double(r.get(k).totalCount).intValue();
-          System.out.print("m" + k + "(" + total + ")" + model.toString()
+          int total = (int) r.get(k).totalCount;
+          System.out.print("m" + k + '(' + total + ')' + model.toString()
               + ", ");
         }
       }

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/meanshift/InputMapper.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/meanshift/InputMapper.java?rev=765142&r1=765141&r2=765142&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/meanshift/InputMapper.java
(original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/meanshift/InputMapper.java
Wed Apr 15 11:37:49 2009
@@ -50,6 +50,7 @@
       point.set(index++, d);
     MeanShiftCanopy canopy = new MeanShiftCanopy(point);
     output.collect(null, new Text(canopy.toString()));
+    // TODO srowen: FindBugs says line above will definitely cause an NPE due to null param?
   }
 
 }

Modified: lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/FileInfosDatasetTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/FileInfosDatasetTest.java?rev=765142&r1=765141&r2=765142&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/FileInfosDatasetTest.java
(original)
+++ lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/FileInfosDatasetTest.java
Wed Apr 15 11:37:49 2009
@@ -53,6 +53,7 @@
         }
       }
     }
+    in.close();
   }
 
   private void assertInRange(double value, double min, double max) {



Mime
View raw message