mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sro...@apache.org
Subject svn commit: r1067485 - in /mahout/trunk: buildtools/src/main/resources/ core/src/main/java/org/apache/mahout/cf/taste/hadoop/ core/src/main/java/org/apache/mahout/cf/taste/impl/model/jdbc/ core/src/main/java/org/apache/mahout/classifier/ core/src/main/...
Date Sat, 05 Feb 2011 19:06:35 GMT
Author: srowen
Date: Sat Feb  5 19:06:34 2011
New Revision: 1067485

URL: http://svn.apache.org/viewvc?rev=1067485&view=rev
Log:
Attack on PMD / findbugs warnings

Modified:
    mahout/trunk/buildtools/src/main/resources/mahout-pmd-ruleset.xml
    mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/hadoop/MaybePruneRowsMapper.java
    mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/jdbc/AbstractJDBCDataModel.java
    mahout/trunk/core/src/main/java/org/apache/mahout/classifier/ConfusionMatrix.java
    mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesFeatureReducer.java
    mahout/trunk/core/src/main/java/org/apache/mahout/classifier/discriminative/LinearModel.java
    mahout/trunk/core/src/main/java/org/apache/mahout/classifier/sgd/ModelDissector.java
    mahout/trunk/core/src/main/java/org/apache/mahout/df/builder/DefaultTreeBuilder.java
    mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/inmem/InMemInputFormat.java
    mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth/FPTree.java
    mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth/FrequentPatternMaxHeap.java
    mahout/trunk/core/src/main/java/org/apache/mahout/math/VarLongWritable.java
    mahout/trunk/core/src/main/java/org/apache/mahout/math/hadoop/DistributedRowMatrix.java
    mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/common/FastMapTest.java
    mahout/trunk/core/src/test/java/org/apache/mahout/classifier/sgd/AdaptiveLogisticRegressionTest.java
    mahout/trunk/core/src/test/java/org/apache/mahout/clustering/kmeans/TestKmeansClustering.java
    mahout/trunk/core/src/test/java/org/apache/mahout/df/builder/DefaultTreeBuilderTest.java
    mahout/trunk/core/src/test/java/org/apache/mahout/math/VectorWritableTest.java
    mahout/trunk/eclipse/src/main/resources/findbugs-exclude.xml
    mahout/trunk/eclipse/src/main/resources/mahout-pmd-ruleset.xml
    mahout/trunk/etc/findbugs-exclude.xml
    mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/SplitBayesInput.java
    mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/WikipediaXmlSplitter.java
    mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/sequencelearning/hmm/PosTagger.java
    mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/sgd/SimpleCsvExamples.java
    mahout/trunk/math/src/main/java/org/apache/mahout/math/function/Functions.java
    mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/Property.java
    mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/random/NegativeBinomialTest.java
    mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/stat/GammaTest.java
    mahout/trunk/utils/src/main/java/org/apache/mahout/text/SequenceFilesFromDirectory.java

Modified: mahout/trunk/buildtools/src/main/resources/mahout-pmd-ruleset.xml
URL: http://svn.apache.org/viewvc/mahout/trunk/buildtools/src/main/resources/mahout-pmd-ruleset.xml?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/buildtools/src/main/resources/mahout-pmd-ruleset.xml (original)
+++ mahout/trunk/buildtools/src/main/resources/mahout-pmd-ruleset.xml Sat Feb  5 19:06:34 2011
@@ -145,7 +145,7 @@
     <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
     <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
     <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
-    <rule ref="rulesets/naming.xml/VariableNamingConventions"/>
+    <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
     <rule ref="rulesets/naming.xml/MethodNamingConventions"/>
     <rule ref="rulesets/naming.xml/ClassNamingConventions"/>
     <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/hadoop/MaybePruneRowsMapper.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/hadoop/MaybePruneRowsMapper.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/hadoop/MaybePruneRowsMapper.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/hadoop/MaybePruneRowsMapper.java Sat Feb  5 19:06:34 2011
@@ -42,8 +42,8 @@ public class MaybePruneRowsMapper
   private int maxCooccurrences;
   private final OpenIntIntHashMap indexCounts = new OpenIntIntHashMap();
 
-  static enum Elements {
-    USED, NEGLECTED;
+  enum Elements {
+    USED, NEGLECTED
   }
 
   @Override

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/jdbc/AbstractJDBCDataModel.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/jdbc/AbstractJDBCDataModel.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/jdbc/AbstractJDBCDataModel.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/jdbc/AbstractJDBCDataModel.java Sat Feb  5 19:06:34 2011
@@ -96,7 +96,7 @@ public abstract class AbstractJDBCDataMo
   private final String getUsersSQL;
   private final String getItemsSQL;
   private final String getPrefsForItemSQL;
-  private final String getNumPreferenceForItemSQL;
+  //private final String getNumPreferenceForItemSQL;
   private final String getNumPreferenceForItemsSQL;
   private final String getMaxPreferenceSQL;
   private final String getMinPreferenceSQL;
@@ -212,7 +212,7 @@ public abstract class AbstractJDBCDataMo
     this.getUsersSQL = getUsersSQL;
     this.getItemsSQL = getItemsSQL;
     this.getPrefsForItemSQL = getPrefsForItemSQL;
-    this.getNumPreferenceForItemSQL = getNumPreferenceForItemSQL;
+    //this.getNumPreferenceForItemSQL = getNumPreferenceForItemSQL;
     this.getNumPreferenceForItemsSQL = getNumPreferenceForItemsSQL;
     this.getMaxPreferenceSQL = getMaxPreferenceSQL;
     this.getMinPreferenceSQL = getMinPreferenceSQL;

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/classifier/ConfusionMatrix.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/ConfusionMatrix.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/classifier/ConfusionMatrix.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/classifier/ConfusionMatrix.java Sat Feb  5 19:06:34 2011
@@ -19,7 +19,6 @@ package org.apache.mahout.classifier;
 
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
 

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesFeatureReducer.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesFeatureReducer.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesFeatureReducer.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesFeatureReducer.java Sat Feb  5 19:06:34 2011
@@ -40,8 +40,8 @@ public class BayesFeatureReducer extends
   
   private static final Logger log = LoggerFactory.getLogger(BayesFeatureReducer.class);
   
-  private double minSupport = -1;  
-  private double minDf      = -1;
+  private double minSupport = -1.0;
+  private double minDf      = -1.0;
   
   private String currentDfFeature;
   private double currentCorpusDf;
@@ -65,7 +65,8 @@ public class BayesFeatureReducer extends
     }
     reporter.setStatus("Bayes Feature Reducer: " + key + " => " + sum);
 
-    Preconditions.checkArgument(key.length() >= 2 && key.length() <= 3, "StringTuple length out of bounds, not (2 < length < 3)");
+    Preconditions.checkArgument(key.length() >= 2 && key.length() <= 3,
+                                "StringTuple length out of bounds, not (2 < length < 3)");
     
     int featureIndex = key.length() == 2 ? 1 : 2;
     
@@ -75,35 +76,45 @@ public class BayesFeatureReducer extends
     // the FeaturePartitioner guarantees that all tuples containing a given term
     // will be handled by the same reducer.
     if (key.stringAt(0).equals(BayesConstants.LABEL_COUNT)) {
-      /* no-op, just collect */
+      // no-op, just collect
+      output.collect(key, new DoubleWritable(sum));
+
     } else if (key.stringAt(0).equals(BayesConstants.FEATURE_TF)) {
       currentDfFeature = key.stringAt(1);
       currentCorpusTf = sum;
       currentCorpusDf = -1;
       
-      if (minSupport > 0 && currentCorpusTf < minSupport) {
+      if (minSupport > 0.0 && currentCorpusTf < minSupport) {
         reporter.incrCounter("skipped", "less_than_minSupport", 1);
       }
-      return; // never emit FEATURE_TF tuples.
+      // never emit FEATURE_TF tuples.
+
     } else if (!key.stringAt(featureIndex).equals(currentDfFeature)) {
       throw new IllegalStateException("Found feature data " + key + " prior to feature tf");
-    } else if (minSupport > 0 && currentCorpusTf < minSupport) {
+
+    } else if (minSupport > 0.0 && currentCorpusTf < minSupport) {
       reporter.incrCounter("skipped", "less_than_minSupport_label-term", 1);
-      return; // skip items that have less than a specified frequency.
+      // skip items that have less than a specified frequency.
+
     } else if (key.stringAt(0).equals(BayesConstants.FEATURE_COUNT)) {
       currentCorpusDf = sum;
-      
-      if (minDf > 0 && currentCorpusDf < minDf) {
+      if (minDf > 0.0 && currentCorpusDf < minDf) {
         reporter.incrCounter("skipped", "less_than_minDf", 1);
-        return; // skip items that have less than the specified minSupport.
+        // skip items that have less than the specified minSupport.
+      } else {
+        output.collect(key, new DoubleWritable(sum));
       }
-    } else if (currentCorpusDf == -1) {
+
+    } else if (currentCorpusDf == -1.0) {
       throw new IllegalStateException("Found feature data " + key + " prior to feature count");
-    } else if (minDf > 0 && currentCorpusDf < minDf) {
+
+    } else if (minDf > 0.0 && currentCorpusDf < minDf) {
       reporter.incrCounter("skipped", "less_than_minDf_label-term", 1);
-      return; // skip items that have less than a specified frequency.
-    } 
-    output.collect(key, new DoubleWritable(sum));
+      // skip items that have less than a specified frequency.
+
+    } else {
+      output.collect(key, new DoubleWritable(sum));
+    }
   }
 
   @Override

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/classifier/discriminative/LinearModel.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/discriminative/LinearModel.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/classifier/discriminative/LinearModel.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/classifier/discriminative/LinearModel.java Sat Feb  5 19:06:34 2011
@@ -86,7 +86,7 @@ public class LinearModel {
    * Shift the bias of the model.
    * @param factor factor to multiply the bias by.
    */
-  public synchronized void shiftBias(double factor) {
+  public void shiftBias(double factor) {
     this.bias += factor;
   }
   

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/classifier/sgd/ModelDissector.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/sgd/ModelDissector.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/classifier/sgd/ModelDissector.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/classifier/sgd/ModelDissector.java Sat Feb  5 19:06:34 2011
@@ -21,6 +21,7 @@ import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Ordering;
 import org.apache.mahout.classifier.AbstractVectorClassifier;
+import org.apache.mahout.common.RandomUtils;
 import org.apache.mahout.math.Vector;
 
 import java.util.Collections;
@@ -64,7 +65,8 @@ public class ModelDissector {
    * 1 and then look at the resulting score.  This tells us the weight the model places
    * on that variable.
    * @param features               A feature vector to use (destructively)
-   * @param traceDictionary        A trace dictionary containing variables and what locations in the feature vector are affected by them
+   * @param traceDictionary        A trace dictionary containing variables and what locations
+   *                               in the feature vector are affected by them
    * @param learner                The model that we are probing to find weights on features
    */
 
@@ -127,12 +129,31 @@ public class ModelDissector {
     @Override
     public int compareTo(Category o) {
       int r = Double.compare(Math.abs(weight), Math.abs(o.weight));
-      if (r != 0) {
-        return r;
-      } else {
-        return o.index - index;
+      if (r == 0) {
+        if (o.index < index) {
+          return -1;
+        } else if (o.index > index) {
+          return 1;
+        }
+        return 0;
       }
+      return r;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+      if (!(o instanceof Category)) {
+        return false;
+      }
+      Category other = (Category) o;
+      return index == other.index && weight == other.weight;
+    }
+
+    @Override
+    public int hashCode() {
+      return RandomUtils.hashDouble(weight) ^ index;
     }
+
   }
 
   public static class Weight implements Comparable<Weight> {
@@ -166,9 +187,25 @@ public class ModelDissector {
       int r = Double.compare(Math.abs(this.value), Math.abs(other.value));
       if (r == 0) {
         return feature.compareTo(other.feature);
-      } else {
-        return r;
       }
+      return r;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+      if (!(o instanceof Weight)) {
+        return false;
+      }
+      Weight other = (Weight) o;
+      return feature.equals(other.feature)
+          && value == other.value
+          && maxIndex == other.maxIndex
+          && categories.equals(other.categories);
+    }
+
+    @Override
+    public int hashCode() {
+      return feature.hashCode() ^ RandomUtils.hashDouble(value) ^ maxIndex ^ categories.hashCode();
     }
 
     public String getFeature() {

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/df/builder/DefaultTreeBuilder.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/df/builder/DefaultTreeBuilder.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/df/builder/DefaultTreeBuilder.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/df/builder/DefaultTreeBuilder.java Sat Feb  5 19:06:34 2011
@@ -42,13 +42,13 @@ import org.slf4j.LoggerFactory;
 public class DefaultTreeBuilder implements TreeBuilder {
   
   private static final Logger log = LoggerFactory.getLogger(DefaultTreeBuilder.class);
-  
+
+  private static final int[] NO_ATTRIBUTES = new int[0];
+
   /** indicates which CATEGORICAL attributes have already been selected in the parent nodes */
   private boolean[] selected;
-  
   /** number of attributes to select randomly at each node */
   private int m = 1;
-  
   /** IgSplit implementation */
   private IgSplit igSplit;
   
@@ -82,7 +82,8 @@ public class DefaultTreeBuilder implemen
     }
     
     int[] attributes = randomAttributes(rng, selected, m);
-    if (attributes == null) { // we tried all the attributes and could not split the data anymore
+    if (attributes == null || attributes.length == 0) {
+      // we tried all the attributes and could not split the data anymore
       return new Leaf(data.majorityLabel(rng));
     }
 
@@ -212,7 +213,7 @@ public class DefaultTreeBuilder implemen
     
     if (nbNonSelected == 0) {
       log.warn("All attributes are selected !");
-      return null;
+      return NO_ATTRIBUTES;
     }
     
     int[] result;

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/inmem/InMemInputFormat.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/inmem/InMemInputFormat.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/inmem/InMemInputFormat.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/inmem/InMemInputFormat.java Sat Feb  5 19:06:34 2011
@@ -232,9 +232,14 @@ public class InMemInputFormat extends In
       
       InMemInputSplit split = (InMemInputSplit) obj;
 
-      return firstId == split.firstId
-          && nbTrees == split.nbTrees
-          && ((seed == null && split.seed == null) || seed.equals(split.seed));
+      if (firstId != split.firstId || nbTrees != split.nbTrees) {
+        return false;
+      }
+      if (seed == null) {
+        return split.seed == null;
+      } else {
+        return seed.equals(split.seed);
+      }
 
     }
     

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth/FPTree.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth/FPTree.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth/FPTree.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth/FPTree.java Sat Feb  5 19:06:34 2011
@@ -29,60 +29,35 @@ import java.util.TreeSet;
 public class FPTree {
   
   public static final int ROOTNODEID = 0;
-  
   private static final int DEFAULT_CHILDREN_INITIAL_SIZE = 2;
-  
   private static final int DEFAULT_HEADER_TABLE_INITIAL_SIZE = 4;
-  
   private static final int DEFAULT_INITIAL_SIZE = 8;
-  
   private static final float GROWTH_RATE = 1.5f;
-  
   private static final int HEADERTABLEBLOCKSIZE = 2;
-  
   private static final int HT_LAST = 1;
-  
   private static final int HT_NEXT = 0;
   
   private int[] attribute;
-  
   private int[] childCount;
-  
   private int[] conditional;
-  
   private long[] headerTableAttributeCount;
-  
   private int[] headerTableAttributes;
-  
   private int headerTableCount;
-  
   private int[] headerTableLookup;
-  
   private int[][] headerTableProperties;
-  
   private int[] next;
-  
   private int[][] nodeChildren;
-  
   private long[] nodeCount;
-  
   private int nodes;
-  
   private int[] parent;
-  
   private boolean singlePath;
-  
   private final Collection<Integer> sortedSet = new TreeSet<Integer>();
   
   public FPTree() {
-    this(DEFAULT_INITIAL_SIZE, DEFAULT_HEADER_TABLE_INITIAL_SIZE);
+    this(DEFAULT_INITIAL_SIZE);
   }
   
   public FPTree(int size) {
-    this(size, DEFAULT_HEADER_TABLE_INITIAL_SIZE);
-  }
-  
-  private FPTree(int size, int headersize) {
     if (size < DEFAULT_INITIAL_SIZE) {
       size = DEFAULT_INITIAL_SIZE;
     }

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth/FrequentPatternMaxHeap.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth/FrequentPatternMaxHeap.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth/FrequentPatternMaxHeap.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth/FrequentPatternMaxHeap.java Sat Feb  5 19:06:34 2011
@@ -27,15 +27,10 @@ import org.apache.mahout.math.map.OpenLo
 public final class FrequentPatternMaxHeap {
   
   private int count;
-  
   private Pattern least;
-  
   private final int maxSize;
-  
   private final boolean subPatternCheck;
-  
   private final OpenLongObjectHashMap<Set<Pattern>> patternIndex;
-  
   private final PriorityQueue<Pattern> queue;
   
   public FrequentPatternMaxHeap(int numResults, boolean subPatternCheck) {
@@ -64,15 +59,13 @@ public final class FrequentPatternMaxHea
     if (subPatternCheck) {
       PriorityQueue<Pattern> ret = new PriorityQueue<Pattern>(maxSize);
       for (Pattern p : queue) {
-        
         if (patternIndex.get(p.support()).contains(p)) {
           ret.add(p);
         }
       }
       return ret;
-    } else {
-      return queue;
     }
+    return queue;
   }
   
   public void addAll(FrequentPatternMaxHeap patterns,
@@ -93,25 +86,22 @@ public final class FrequentPatternMaxHea
     }
     
     if (count == maxSize) {
-      if (frequentPattern.compareTo(least) > 0) {
-        if (addPattern(frequentPattern)) {
-          Pattern evictedItem = queue.poll();
-          least = queue.peek();
-          if (subPatternCheck) {
-            patternIndex.get(evictedItem.support()).remove(evictedItem);
-          }
-          
+      if (frequentPattern.compareTo(least) > 0 && addPattern(frequentPattern)) {
+        Pattern evictedItem = queue.poll();
+        least = queue.peek();
+        if (subPatternCheck) {
+          patternIndex.get(evictedItem.support()).remove(evictedItem);
         }
       }
     } else {
       if (addPattern(frequentPattern)) {
         count++;
-        if (least != null) {
+        if (least == null) {
+          least = frequentPattern;
+        } else {
           if (least.compareTo(frequentPattern) < 0) {
             least = frequentPattern;
           }
-        } else {
-          least = frequentPattern;
         }
       }
     }
@@ -157,7 +147,6 @@ public final class FrequentPatternMaxHea
         }
         queue.add(frequentPattern);
         indexSet.add(frequentPattern);
-        return true;
       } else {
         queue.add(frequentPattern);
         Set<Pattern> patternList;
@@ -167,12 +156,10 @@ public final class FrequentPatternMaxHea
         }
         patternList = patternIndex.get(index);
         patternList.add(frequentPattern);
-
-        return true;
       }
     } else {
       queue.add(frequentPattern);
-      return true;
     }
+    return true;
   }
 }

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/math/VarLongWritable.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/math/VarLongWritable.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/math/VarLongWritable.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/math/VarLongWritable.java Sat Feb  5 19:06:34 2011
@@ -44,7 +44,7 @@ public class VarLongWritable implements 
 
   @Override
   public boolean equals(Object other) {
-    return other != null && VarLongWritable.class.equals(other.getClass()) && ((VarLongWritable) other).value == value;
+    return other != null && getClass().equals(other.getClass()) && ((VarLongWritable) other).value == value;
   }
 
   @Override

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/math/hadoop/DistributedRowMatrix.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/math/hadoop/DistributedRowMatrix.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/math/hadoop/DistributedRowMatrix.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/math/hadoop/DistributedRowMatrix.java Sat Feb  5 19:06:34 2011
@@ -219,6 +219,7 @@ public class DistributedRowMatrix implem
       this.fs = fs;
       this.conf = conf;
       statuses = fs.globStatus(new Path(rowPath, "*"));
+      statusIndex = 0;
       reader = new SequenceFile.Reader(fs, statuses[statusIndex].getPath(), conf);
     }
 

Modified: mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/common/FastMapTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/common/FastMapTest.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/common/FastMapTest.java (original)
+++ mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/common/FastMapTest.java Sat Feb  5 19:06:34 2011
@@ -135,7 +135,7 @@ public final class FastMapTest extends T
     Iterator<String> it = actual.iterator();
     while (it.hasNext()) {
       String value = it.next();
-      if (!value.equals("baz")) {
+      if (!"baz".equals(value)) {
         it.remove();
       }
     }
@@ -157,7 +157,7 @@ public final class FastMapTest extends T
     Iterator<String> it = actual.iterator();
     while (it.hasNext()) {
       String value = it.next();
-      if (!value.equals("bang")) {
+      if (!"bang".equals(value)) {
         it.remove();
       }
     }

Modified: mahout/trunk/core/src/test/java/org/apache/mahout/classifier/sgd/AdaptiveLogisticRegressionTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/sgd/AdaptiveLogisticRegressionTest.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/core/src/test/java/org/apache/mahout/classifier/sgd/AdaptiveLogisticRegressionTest.java (original)
+++ mahout/trunk/core/src/test/java/org/apache/mahout/classifier/sgd/AdaptiveLogisticRegressionTest.java Sat Feb  5 19:06:34 2011
@@ -61,12 +61,10 @@ public final class AdaptiveLogisticRegre
     for (int i = 0; i < 20000; i++) {
       AdaptiveLogisticRegression.TrainingExample r = getExample(i, gen, beta);
       x.train(r.getKey(), r.getActual(), r.getInstance());
-      if (i % 1000 == 0) {
-        if (x.getBest() != null) {
-          System.out.printf("%10d %10.4f %10.8f %.3f\n",
-                            i, x.auc(),
-                            Math.log10(x.getBest().getMappedParams()[0]), x.getBest().getMappedParams()[1]);
-        }
+      if (i % 1000 == 0 && x.getBest() != null) {
+        System.out.printf("%10d %10.4f %10.8f %.3f\n",
+                          i, x.auc(),
+                          Math.log10(x.getBest().getMappedParams()[0]), x.getBest().getMappedParams()[1]);
       }
     }
     assertEquals(1, x.auc(), 0.1);

Modified: mahout/trunk/core/src/test/java/org/apache/mahout/clustering/kmeans/TestKmeansClustering.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/kmeans/TestKmeansClustering.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/core/src/test/java/org/apache/mahout/clustering/kmeans/TestKmeansClustering.java (original)
+++ mahout/trunk/core/src/test/java/org/apache/mahout/clustering/kmeans/TestKmeansClustering.java Sat Feb  5 19:06:34 2011
@@ -97,7 +97,7 @@ public final class TestKmeansClustering 
    * Tests {@link KMeansClusterer#runKMeansIteration) single run convergence with a given distance threshold.
    */
   @Test
-  public void testRunKMeansIteration_convergesInOneRunWithGivenDistanceThreshold() {
+  public void testRunKMeansIterationConvergesInOneRunWithGivenDistanceThreshold() {
     double[][] rawPoints = { {0,0}, {0,0.25}, {0,0.75}, {0, 1}};
     List<Vector> points = getPoints(rawPoints);
 

Modified: mahout/trunk/core/src/test/java/org/apache/mahout/df/builder/DefaultTreeBuilderTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/test/java/org/apache/mahout/df/builder/DefaultTreeBuilderTest.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/core/src/test/java/org/apache/mahout/df/builder/DefaultTreeBuilderTest.java (original)
+++ mahout/trunk/core/src/test/java/org/apache/mahout/df/builder/DefaultTreeBuilderTest.java Sat Feb  5 19:06:34 2011
@@ -55,6 +55,7 @@ public final class DefaultTreeBuilderTes
 
       int[] attrs = DefaultTreeBuilder.randomAttributes(rng, selected, m);
 
+      assertNotNull(attrs);
       assertEquals(Math.min(m, nbAttributes - nbSelected), attrs.length);
 
       for (int attr : attrs) {

Modified: mahout/trunk/core/src/test/java/org/apache/mahout/math/VectorWritableTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/test/java/org/apache/mahout/math/VectorWritableTest.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/core/src/test/java/org/apache/mahout/math/VectorWritableTest.java (original)
+++ mahout/trunk/core/src/test/java/org/apache/mahout/math/VectorWritableTest.java Sat Feb  5 19:06:34 2011
@@ -22,9 +22,7 @@ import org.junit.Test;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.DataInput;
 import java.io.DataInputStream;
-import java.io.DataOutput;
 import java.io.DataOutputStream;
 import java.io.IOException;
 

Modified: mahout/trunk/eclipse/src/main/resources/findbugs-exclude.xml
URL: http://svn.apache.org/viewvc/mahout/trunk/eclipse/src/main/resources/findbugs-exclude.xml?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/eclipse/src/main/resources/findbugs-exclude.xml (original)
+++ mahout/trunk/eclipse/src/main/resources/findbugs-exclude.xml Sat Feb  5 19:06:34 2011
@@ -37,6 +37,9 @@
     <Bug pattern="SE_NO_SERIALVERSIONID"/>
   </Match>
   <Match>
+    <Bug pattern="SE_NO_SUITABLE_CONSTRUCTOR"/>
+  </Match>
+  <Match>
     <Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON"/>
   </Match>
   <Match>

Modified: mahout/trunk/eclipse/src/main/resources/mahout-pmd-ruleset.xml
URL: http://svn.apache.org/viewvc/mahout/trunk/eclipse/src/main/resources/mahout-pmd-ruleset.xml?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/eclipse/src/main/resources/mahout-pmd-ruleset.xml (original)
+++ mahout/trunk/eclipse/src/main/resources/mahout-pmd-ruleset.xml Sat Feb  5 19:06:34 2011
@@ -145,7 +145,7 @@
     <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
     <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
     <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
-    <rule ref="rulesets/naming.xml/VariableNamingConventions"/>
+    <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
     <rule ref="rulesets/naming.xml/MethodNamingConventions"/>
     <rule ref="rulesets/naming.xml/ClassNamingConventions"/>
     <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->

Modified: mahout/trunk/etc/findbugs-exclude.xml
URL: http://svn.apache.org/viewvc/mahout/trunk/etc/findbugs-exclude.xml?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/etc/findbugs-exclude.xml (original)
+++ mahout/trunk/etc/findbugs-exclude.xml Sat Feb  5 19:06:34 2011
@@ -37,6 +37,9 @@
     <Bug pattern="SE_NO_SERIALVERSIONID"/>
   </Match>
   <Match>
+    <Bug pattern="SE_NO_SUITABLE_CONSTRUCTOR"/>
+  </Match>
+  <Match>
     <Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON"/>
   </Match>
   <Match>

Modified: mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/SplitBayesInput.java
URL: http://svn.apache.org/viewvc/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/SplitBayesInput.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/SplitBayesInput.java (original)
+++ mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/SplitBayesInput.java Sat Feb  5 19:06:34 2011
@@ -348,40 +348,45 @@ public class SplitBayesInput {
     Writer trainingWriter = new OutputStreamWriter(fs.create(trainingOutputFile), charset);
     Writer testWriter     = new OutputStreamWriter(fs.create(testOutputFile), charset);
 
-    int pos = 0;
     int trainCount = 0;
     int testCount = 0;
 
-    String line;
-    while ((line = reader.readLine()) != null) {
-      pos++;
-
-      Writer writer;
-      if (testRandomSelectionPct > 0) { // Randomly choose
-        writer =  randomSel.get(pos) ? testWriter : trainingWriter;
-      } else { // Choose based on location
-        writer = pos > testSplitStart ? testWriter : trainingWriter;
-      }
+    try {
 
-      if (writer == testWriter) {
-        if (testCount >= testSplitSize) {
-          writer = trainingWriter;
-        } else {
-          testCount++;
+      String line;
+      int pos = 0;
+      while ((line = reader.readLine()) != null) {
+        pos++;
+
+        Writer writer;
+        if (testRandomSelectionPct > 0) { // Randomly choose
+          writer =  randomSel.get(pos) ? testWriter : trainingWriter;
+        } else { // Choose based on location
+          writer = pos > testSplitStart ? testWriter : trainingWriter;
         }
+
+        if (writer == testWriter) {
+          if (testCount >= testSplitSize) {
+            writer = trainingWriter;
+          } else {
+            testCount++;
+          }
+        }
+
+        if (writer == trainingWriter) {
+          trainCount++;
+        }
+
+        writer.write(line);
+        writer.write('\n');
       }
-      
-      if (writer == trainingWriter) {
-        trainCount++;
-      }
-      
-      writer.write(line);
-      writer.write('\n');
+
+    } finally {
+      IOUtils.quietClose(reader);
+      IOUtils.quietClose(trainingWriter);
+      IOUtils.quietClose(testWriter);
     }
     
-    IOUtils.quietClose(trainingWriter);
-    IOUtils.quietClose(testWriter);
-    
     log.info("file: {}, input: {} train: {}, test: {} starting at {}",
              new Object[] {inputFile.getName(), lineCount, trainCount, testCount, testSplitStart});
     

Modified: mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/WikipediaXmlSplitter.java
URL: http://svn.apache.org/viewvc/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/WikipediaXmlSplitter.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/WikipediaXmlSplitter.java (original)
+++ mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/WikipediaXmlSplitter.java Sat Feb  5 19:06:34 2011
@@ -190,11 +190,13 @@ public final class WikipediaXmlSplitter 
           content.append("</mediawiki>");
           filenumber++;
           String filename = outputDirPath + "/chunk-" + decimalFormatter.format(filenumber) + ".xml";
-          BufferedWriter chunkWriter = new BufferedWriter(new OutputStreamWriter(fs
-              .create(new Path(filename)), "UTF-8"));
-          
-          chunkWriter.write(content.toString(), 0, content.length());
-          chunkWriter.close();
+          BufferedWriter chunkWriter =
+              new BufferedWriter(new OutputStreamWriter(fs.create(new Path(filename)), "UTF-8"));
+          try {
+            chunkWriter.write(content.toString(), 0, content.length());
+          } finally {
+            chunkWriter.close();
+          }
           if (filenumber >= numChunks) {
             break;
           }

Modified: mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/sequencelearning/hmm/PosTagger.java
URL: http://svn.apache.org/viewvc/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/sequencelearning/hmm/PosTagger.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/sequencelearning/hmm/PosTagger.java (original)
+++ mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/sequencelearning/hmm/PosTagger.java Sat Feb  5 19:06:34 2011
@@ -22,12 +22,15 @@ import java.io.IOException;
 import java.io.InputStreamReader;
 import java.net.URL;
 import java.net.URLConnection;
+import java.nio.charset.Charset;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.regex.Pattern;
 
+import org.apache.mahout.common.IOUtils;
 import org.apache.mahout.math.Matrix;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -47,6 +50,9 @@ public final class PosTagger {
 
   private static final Logger log = LoggerFactory.getLogger(PosTagger.class);
 
+  private static final Pattern SPACE = Pattern.compile(" ");
+  private static final Pattern SPACES = Pattern.compile("[ ]+");
+
   /**
    * No public constructors for utility classes.
    */
@@ -110,54 +116,60 @@ public final class PosTagger {
    */
   private static void readFromURL(String url, boolean assignIDs) throws IOException {
     URLConnection connection = (new URL(url)).openConnection();
-    BufferedReader input = new BufferedReader(new InputStreamReader(connection.getInputStream()));
     // initialize the data structure
     hiddenSequences = new LinkedList<int[]>();
     observedSequences = new LinkedList<int[]>();
     readLines = 0;
 
     // now read line by line of the input file
-    String line;
     List<Integer> observedSequence = new LinkedList<Integer>();
     List<Integer> hiddenSequence = new LinkedList<Integer>();
-    while ((line = input.readLine()) != null) {
-      if (line.isEmpty()) {
-        // new sentence starts
-        int[] observedSequenceArray = new int[observedSequence.size()];
-        int[] hiddenSequenceArray = new int[hiddenSequence.size()];
-        for (int i = 0; i < observedSequence.size(); ++i) {
-          observedSequenceArray[i] = observedSequence.get(i);
-          hiddenSequenceArray[i] = hiddenSequence.get(i);
-        }
-        // now register those arrays
-        hiddenSequences.add(hiddenSequenceArray);
-        observedSequences.add(observedSequenceArray);
-        // and reset the linked lists
-        observedSequence.clear();
-        hiddenSequence.clear();
-        continue;
-      }
-      readLines++;
-      // we expect the format [word] [POS tag] [NP tag]
-      String[] tags = line.split(" ");
-      // when analyzing the training set, assign IDs
-      if (assignIDs) {
-        if (!wordIDs.containsKey(tags[0])) {
-          wordIDs.put(tags[0], nextWordId++);
+
+    BufferedReader input =
+        new BufferedReader(new InputStreamReader(connection.getInputStream(), Charset.forName("UTF-8")));
+    try {
+      String line;
+      while ((line = input.readLine()) != null) {
+        if (line.isEmpty()) {
+          // new sentence starts
+          int[] observedSequenceArray = new int[observedSequence.size()];
+          int[] hiddenSequenceArray = new int[hiddenSequence.size()];
+          for (int i = 0; i < observedSequence.size(); ++i) {
+            observedSequenceArray[i] = observedSequence.get(i);
+            hiddenSequenceArray[i] = hiddenSequence.get(i);
+          }
+          // now register those arrays
+          hiddenSequences.add(hiddenSequenceArray);
+          observedSequences.add(observedSequenceArray);
+          // and reset the linked lists
+          observedSequence.clear();
+          hiddenSequence.clear();
+          continue;
         }
-        if (!tagIDs.containsKey(tags[1])) {
-          tagIDs.put(tags[1], nextTagId++);
+        readLines++;
+        // we expect the format [word] [POS tag] [NP tag]
+        String[] tags = SPACE.split(line);
+        // when analyzing the training set, assign IDs
+        if (assignIDs) {
+          if (!wordIDs.containsKey(tags[0])) {
+            wordIDs.put(tags[0], nextWordId++);
+          }
+          if (!tagIDs.containsKey(tags[1])) {
+            tagIDs.put(tags[1], nextTagId++);
+          }
         }
+        // determine the IDs
+        Integer wordID = wordIDs.get(tags[0]);
+        Integer tagID = tagIDs.get(tags[1]);
+        // handle unknown values
+        wordID = (wordID == null) ? 0 : wordID;
+        tagID = (tagID == null) ? 0 : tagID;
+        // now construct the current sequence
+        observedSequence.add(wordID);
+        hiddenSequence.add(tagID);
       }
-      // determine the IDs
-      Integer wordID = wordIDs.get(tags[0]);
-      Integer tagID = tagIDs.get(tags[1]);
-      // handle unknown values
-      wordID = (wordID == null) ? 0 : wordID;
-      tagID = (tagID == null) ? 0 : tagID;
-      // now construct the current sequence
-      observedSequence.add(wordID);
-      hiddenSequence.add(tagID);
+    } finally {
+      IOUtils.quietClose(input);
     }
     // if there is still something in the pipe, register it
     if (!observedSequence.isEmpty()) {
@@ -244,7 +256,7 @@ public final class PosTagger {
     sentence = sentence.replaceAll("[,.!?:;\"]", " $0 ");
     sentence = sentence.replaceAll("''", " '' ");
     // now we tokenize the sentence
-    String[] tokens = sentence.split("[ ]+");
+    String[] tokens = SPACES.split(sentence);
     // now generate the observed sequence
     int[] observedSequence = HmmUtils.encodeStateSequence(taggingModel, Arrays.asList(tokens), true, 0);
     // POS tag this observedSequence
@@ -259,7 +271,7 @@ public final class PosTagger {
     testModel("http://www.jaist.ac.jp/~hieuxuan/flexcrfs/CoNLL2000-NP/test.txt");
     // tag an exemplary sentence
     String test = "McDonalds is a huge company with many employees .";
-    String[] testWords = test.split(" ");
+    String[] testWords = SPACE.split(test);
     List<String> posTags = tagSentence(test);
     for (int i = 0; i < posTags.size(); ++i) {
       log.info("{}[{}]", testWords[i], posTags.get(i));

Modified: mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/sgd/SimpleCsvExamples.java
URL: http://svn.apache.org/viewvc/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/sgd/SimpleCsvExamples.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/sgd/SimpleCsvExamples.java (original)
+++ mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/sgd/SimpleCsvExamples.java Sat Feb  5 19:06:34 2011
@@ -20,6 +20,7 @@ package org.apache.mahout.classifier.sgd
 import com.google.common.base.Joiner;
 import com.google.common.base.Splitter;
 import com.google.common.collect.Lists;
+import org.apache.mahout.common.IOUtils;
 import org.apache.mahout.common.RandomUtils;
 import org.apache.mahout.math.DenseVector;
 import org.apache.mahout.math.Vector;
@@ -29,6 +30,7 @@ import org.apache.mahout.vectorizer.enco
 import org.apache.mahout.vectorizer.encoders.FeatureVectorEncoder;
 
 import java.io.BufferedReader;
+import java.io.Closeable;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -78,24 +80,31 @@ public class SimpleCsvExamples {
     Vector v = new DenseVector(1000);
     if (args[0].equals("--generate")) {
       PrintWriter out = new PrintWriter(new File(args[2]));
-      int n = Integer.parseInt(args[1]);
-      for (int i = 0; i < n; i++) {
-        Line x = Line.generate();
-        out.println(x);
+      try {
+        int n = Integer.parseInt(args[1]);
+        for (int i = 0; i < n; i++) {
+          Line x = Line.generate();
+          out.println(x);
+        }
+      } finally {
+        IOUtils.quietClose(out);
       }
-      out.close();
     } else if ("--parse".equals(args[0])) {
       BufferedReader in = new BufferedReader(
           new InputStreamReader(new FileInputStream(new File(args[1])), Charset.forName("UTF-8")));
-      String line = in.readLine();
-      while (line != null) {
-        v.assign(0);
-        Line x = new Line(line);
-        for (int i = 0; i < FIELDS; i++) {
-          s[i].add(x.getDouble(i));
-          encoder[i].addToVector(x.get(i), v);
+      try {
+        String line = in.readLine();
+        while (line != null) {
+          v.assign(0);
+          Line x = new Line(line);
+          for (int i = 0; i < FIELDS; i++) {
+            s[i].add(x.getDouble(i));
+            encoder[i].addToVector(x.get(i), v);
+          }
+          line = in.readLine();
         }
-        line = in.readLine();
+      } finally {
+        IOUtils.quietClose(in);
       }
       String separator = "";
       for (int i = 0; i < FIELDS; i++) {
@@ -104,15 +113,19 @@ public class SimpleCsvExamples {
       }
     } else if ("--fast".equals(args[0])) {
       FastLineReader in = new FastLineReader(new FileInputStream(args[1]));
-      FastLine line = in.read();
-      while (line != null) {
-        v.assign(0);
-        for (int i = 0; i < FIELDS; i++) {
-          double z = line.getDouble(i);
-          s[i].add(z);
-          encoder[i].addToVector((byte[]) null, z, v);
+      try {
+        FastLine line = in.read();
+        while (line != null) {
+          v.assign(0);
+          for (int i = 0; i < FIELDS; i++) {
+            double z = line.getDouble(i);
+            s[i].add(z);
+            encoder[i].addToVector((byte[]) null, z, v);
+          }
+          line = in.read();
         }
-        line = in.read();
+      } finally {
+        IOUtils.quietClose(in);
       }
       String separator = "";
       for (int i = 0; i < FIELDS; i++) {
@@ -228,7 +241,7 @@ public class SimpleCsvExamples {
     }
   }
 
-  private static class FastLineReader {
+  private static class FastLineReader implements Closeable {
     private final InputStream in;
     private final ByteBuffer buf = ByteBuffer.allocate(100000);
 
@@ -259,5 +272,10 @@ public class SimpleCsvExamples {
         }
       }
     }
+
+    @Override
+    public void close() throws IOException {
+      in.close();
+    }
   }
 }

Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/function/Functions.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/function/Functions.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/math/src/main/java/org/apache/mahout/math/function/Functions.java (original)
+++ mahout/trunk/math/src/main/java/org/apache/mahout/math/function/Functions.java Sat Feb  5 19:06:34 2011
@@ -571,7 +571,7 @@ public final class Functions {
    * Constructs a function that returns <tt>Math.IEEEremainder(a,b)</tt>. <tt>a</tt> is a variable, <tt>b</tt> is
    * fixed.
    */
-  public static DoubleFunction IEEEremainder(final double b) {
+  public static DoubleFunction mathIEEEremainder(final double b) {
     return new DoubleFunction() {
 
       public double apply(double a) {

Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/Property.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/Property.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/Property.java (original)
+++ mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/Property.java Sat Feb  5 19:06:34 2011
@@ -14,11 +14,6 @@ import org.apache.mahout.math.matrix.Dou
 import org.apache.mahout.math.matrix.impl.AbstractMatrix2D;
 import org.apache.mahout.math.matrix.impl.DenseDoubleMatrix2D;
 
-import java.util.Formatter;
-import java.util.Locale;
-import java.util.Map;
-import java.util.TreeMap;
-
 /** @deprecated until unit tests are in place.  Until this time, this class/interface is unsupported. */
 @Deprecated
 public final class Property {

Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/random/NegativeBinomialTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/random/NegativeBinomialTest.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/random/NegativeBinomialTest.java (original)
+++ mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/random/NegativeBinomialTest.java Sat Feb  5 19:06:34 2011
@@ -17,7 +17,6 @@
 
 package org.apache.mahout.math.jet.random;
 
-import com.google.common.base.Charsets;
 import com.google.common.base.Splitter;
 import com.google.common.collect.Iterables;
 import com.google.common.io.CharStreams;
@@ -28,6 +27,7 @@ import org.apache.mahout.math.MahoutTest
 import org.junit.Test;
 
 import java.io.InputStreamReader;
+import java.nio.charset.Charset;
 
 public final class NegativeBinomialTest extends MahoutTestCase {
 
@@ -37,7 +37,7 @@ public final class NegativeBinomialTest 
   @Test
   public void testDistributionFunctions() throws Exception {
     InputSupplier<InputStreamReader> input =
-        Resources.newReaderSupplier(Resources.getResource("negative-binomial-test-data.csv"), Charsets.UTF_8);
+        Resources.newReaderSupplier(Resources.getResource("negative-binomial-test-data.csv"), Charset.forName("UTF-8"));
     boolean header = true;
     for (String line : CharStreams.readLines(input)) {
       if (header) {

Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/stat/GammaTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/stat/GammaTest.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/stat/GammaTest.java (original)
+++ mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/stat/GammaTest.java Sat Feb  5 19:06:34 2011
@@ -17,7 +17,6 @@
 
 package org.apache.mahout.math.jet.stat;
 
-import com.google.common.base.Charsets;
 import com.google.common.base.Splitter;
 import com.google.common.collect.Iterables;
 import com.google.common.io.CharStreams;
@@ -29,6 +28,7 @@ import org.junit.Test;
 
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.nio.charset.Charset;
 import java.util.Random;
 
 public final class GammaTest extends MahoutTestCase {
@@ -36,7 +36,9 @@ public final class GammaTest extends Mah
   @Test
   public void testGamma() {
     double[] x = {1, 2, 5, 10, 20, 50, 100};
-    double[] expected = {1.000000e+00, 1.000000e+00, 2.400000e+01, 3.628800e+05, 1.216451e+17, 6.082819e+62, 9.332622e+155};
+    double[] expected = {
+        1.000000e+00, 1.000000e+00, 2.400000e+01, 3.628800e+05, 1.216451e+17, 6.082819e+62, 9.332622e+155
+    };
 
     for (int i = 0; i < x.length; i++) {
       assertEquals(expected[i], Gamma.gamma(x[i]), expected[i] * 1.0e-5);
@@ -48,7 +50,9 @@ public final class GammaTest extends Mah
   @Test
   public void testNegativeArgForGamma() {
     double[] x = {-30.3, -20.7, -10.5, -1.1, 0.5, 0.99, -0.999};
-    double[] expected = {-5.243216e-33, -1.904051e-19, -2.640122e-07, 9.714806e+00, 1.772454e+00, 1.005872e+00, -1.000424e+03};
+    double[] expected = {
+        -5.243216e-33, -1.904051e-19, -2.640122e-07, 9.714806e+00, 1.772454e+00, 1.005872e+00, -1.000424e+03
+    };
 
     for (int i = 0; i < x.length; i++) {
       assertEquals(expected[i], Gamma.gamma(x[i]), Math.abs(expected[i] * 1.0e-5));
@@ -112,7 +116,7 @@ public final class GammaTest extends Mah
     Splitter onComma = Splitter.on(",").trimResults();
 
     InputSupplier<InputStreamReader> input =
-        Resources.newReaderSupplier(Resources.getResource("beta-test-data.csv"), Charsets.UTF_8);
+        Resources.newReaderSupplier(Resources.getResource("beta-test-data.csv"), Charset.forName("UTF-8"));
     boolean header = true;
     for (String line : CharStreams.readLines(input)) {
       if (header) {

Modified: mahout/trunk/utils/src/main/java/org/apache/mahout/text/SequenceFilesFromDirectory.java
URL: http://svn.apache.org/viewvc/mahout/trunk/utils/src/main/java/org/apache/mahout/text/SequenceFilesFromDirectory.java?rev=1067485&r1=1067484&r2=1067485&view=diff
==============================================================================
--- mahout/trunk/utils/src/main/java/org/apache/mahout/text/SequenceFilesFromDirectory.java (original)
+++ mahout/trunk/utils/src/main/java/org/apache/mahout/text/SequenceFilesFromDirectory.java Sat Feb  5 19:06:34 2011
@@ -167,7 +167,7 @@ public final class SequenceFilesFromDire
             writer.write(prefix + Path.SEPARATOR + name, file.toString());
           }
         }
-      } catch (Exception e) {
+      } catch (IOException e) {
         throw new IllegalStateException(e);
       }
       return false;



Mime
View raw message