You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by sr...@apache.org on 2010/02/16 16:56:52 UTC

svn commit: r910569 - in /lucene/mahout/trunk/core/src/main/java/org/apache/mahout: classifier/bayes/mapreduce/bayes/ classifier/bayes/mapreduce/cbayes/ classifier/bayes/mapreduce/common/ clustering/meanshift/ df/mapred/partial/

Author: srowen
Date: Tue Feb 16 15:56:52 2010
New Revision: 910569

URL: http://svn.apache.org/viewvc?rev=910569&view=rev
Log:
FindBugs changes: one minor possible NPE fix, Map.Entry iteration improvement, dead store removal

Modified:
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/bayes/BayesThetaNormalizerMapper.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/cbayes/CBayesThetaNormalizerMapper.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesTfIdfMapper.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyClusterer.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapred/partial/PartialBuilder.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapred/partial/Step2Job.java

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/bayes/BayesThetaNormalizerMapper.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/bayes/BayesThetaNormalizerMapper.java?rev=910569&r1=910568&r2=910569&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/bayes/BayesThetaNormalizerMapper.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/bayes/BayesThetaNormalizerMapper.java Tue Feb 16 15:56:52 2010
@@ -86,8 +86,8 @@
       String labelWeightSumString = mapStringifier.toString(labelWeightSumTemp);
       labelWeightSumString = job.get("cnaivebayes.sigma_k", labelWeightSumString);
       labelWeightSumTemp = mapStringifier.fromString(labelWeightSumString);
-      for (String key : labelWeightSumTemp.keySet()) {
-        this.labelWeightSum.put(key, labelWeightSumTemp.get(key));
+      for (Map.Entry<String, Double> stringDoubleEntry : labelWeightSumTemp.entrySet()) {
+        this.labelWeightSum.put(stringDoubleEntry.getKey(), stringDoubleEntry.getValue());
       }
       DefaultStringifier<Double> stringifier = new DefaultStringifier<Double>(job, GenericsUtil
           .getClass(sigmaJSigmaK));

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/cbayes/CBayesThetaNormalizerMapper.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/cbayes/CBayesThetaNormalizerMapper.java?rev=910569&r1=910568&r2=910569&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/cbayes/CBayesThetaNormalizerMapper.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/cbayes/CBayesThetaNormalizerMapper.java Tue Feb 16 15:56:52 2010
@@ -115,8 +115,8 @@
       String labelWeightSumString = mapStringifier.toString(labelWeightSumTemp);
       labelWeightSumString = job.get("cnaivebayes.sigma_k", labelWeightSumString);
       labelWeightSumTemp = mapStringifier.fromString(labelWeightSumString);
-      for (String key : labelWeightSumTemp.keySet()) {
-        this.labelWeightSum.put(key, labelWeightSumTemp.get(key));
+      for (Map.Entry<String, Double> stringDoubleEntry : labelWeightSumTemp.entrySet()) {
+        this.labelWeightSum.put(stringDoubleEntry.getKey(), stringDoubleEntry.getValue());
       }
       
       DefaultStringifier<Double> stringifier = new DefaultStringifier<Double>(job, GenericsUtil

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesTfIdfMapper.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesTfIdfMapper.java?rev=910569&r1=910568&r2=910569&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesTfIdfMapper.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesTfIdfMapper.java Tue Feb 16 15:56:52 2010
@@ -99,8 +99,8 @@
       labelDocumentCountString = job.get("cnaivebayes.labelDocumentCounts", labelDocumentCountString);
       
       labelDocCountTemp = mapStringifier.fromString(labelDocumentCountString);
-      for (String key : labelDocCountTemp.keySet()) {
-        this.labelDocumentCounts.put(key, labelDocCountTemp.get(key));
+      for (Map.Entry<String, Double> stringDoubleEntry : labelDocCountTemp.entrySet()) {
+        this.labelDocumentCounts.put(stringDoubleEntry.getKey(), stringDoubleEntry.getValue());
       }
       
     } catch (IOException ex) {

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyClusterer.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyClusterer.java?rev=910569&r1=910568&r2=910569&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyClusterer.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyClusterer.java Tue Feb 16 15:56:52 2010
@@ -15,7 +15,7 @@
   
   private double convergenceDelta = 0;
   // the next canopyId to be allocated
-  private int nextCanopyId = 0;
+  //private int nextCanopyId = 0;
   // the T1 distance threshold
   private double t1;
   // the T2 distance threshold
@@ -57,7 +57,7 @@
     } catch (InstantiationException e) {
       throw new IllegalStateException(e);
     }
-    nextCanopyId = 0;
+    //nextCanopyId = 0; // never read?
     t1 = Double.parseDouble(job.get(MeanShiftCanopyConfigKeys.T1_KEY));
     t2 = Double.parseDouble(job.get(MeanShiftCanopyConfigKeys.T2_KEY));
     convergenceDelta = Double.parseDouble(job.get(MeanShiftCanopyConfigKeys.CLUSTER_CONVERGENCE_KEY));
@@ -70,7 +70,7 @@
    *          the convergence criteria
    */
   public void config(DistanceMeasure aMeasure, double aT1, double aT2, double aDelta) {
-    nextCanopyId = 100; // so canopyIds will sort properly
+    //nextCanopyId = 100; // so canopyIds will sort properly  // never read?
     measure = aMeasure;
     t1 = aT1;
     t2 = aT2;

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapred/partial/PartialBuilder.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapred/partial/PartialBuilder.java?rev=910569&r1=910568&r2=910569&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapred/partial/PartialBuilder.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapred/partial/PartialBuilder.java Tue Feb 16 15:56:52 2010
@@ -187,7 +187,7 @@
     }
     
     // make sure we got all the keys/values
-    if (index != keys.length) {
+    if (keys != null && index != keys.length) {
       throw new IllegalStateException();
     }
   }

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapred/partial/Step2Job.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapred/partial/Step2Job.java?rev=910569&r1=910568&r2=910569&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapred/partial/Step2Job.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapred/partial/Step2Job.java Tue Feb 16 15:56:52 2010
@@ -143,9 +143,10 @@
     int numTrees = Builder.getNbTrees(job);
     
     // compute the total number of output values
-    int total = 0;
+    //int total = 0;
     for (int partition = 0; partition < numMaps; partition++) {
-      total += Step2Mapper.nbConcerned(numMaps, numTrees, partition);
+      //total += Step2Mapper.nbConcerned(numMaps, numTrees, partition);
+      Step2Mapper.nbConcerned(numMaps, numTrees, partition);
     }
     
     int[] firstIds = Step0Output.extractFirstIds(partitions);