mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smar...@apache.org
Subject [1/2] mahout git commit: MAHOUT-1652:Java 7 Upgrade, this closes apache/Mahout #109
Date Sun, 05 Apr 2015 15:52:45 GMT
Repository: mahout
Updated Branches:
  refs/heads/master 88520fb1b -> 4ef9d31ff


http://git-wip-us.apache.org/repos/asf/mahout/blob/4ef9d31f/h2o/src/main/java/org/apache/mahout/h2obindings/H2OHdfs.java
----------------------------------------------------------------------
diff --git a/h2o/src/main/java/org/apache/mahout/h2obindings/H2OHdfs.java b/h2o/src/main/java/org/apache/mahout/h2obindings/H2OHdfs.java
index 56b3745..c0f1ee7 100644
--- a/h2o/src/main/java/org/apache/mahout/h2obindings/H2OHdfs.java
+++ b/h2o/src/main/java/org/apache/mahout/h2obindings/H2OHdfs.java
@@ -17,33 +17,31 @@
 
 package org.apache.mahout.h2obindings;
 
-import java.io.File;
-import java.net.URI;
-
-import water.fvec.Frame;
-import water.fvec.Vec;
-import water.Futures;
-import water.parser.ValueString;
-import water.util.FrameUtils;
-
-import org.apache.mahout.math.Vector;
-import org.apache.mahout.math.DenseVector;
-import org.apache.mahout.math.SequentialAccessSparseVector;
-import org.apache.mahout.math.VectorWritable;
-import org.apache.mahout.h2obindings.drm.H2ODrm;
-
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FSDataInputStream;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.fs.FSDataInputStream;
 import org.apache.hadoop.io.IOUtils;
-import org.apache.hadoop.io.SequenceFile;
-import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.io.IntWritable;
 import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.SequenceFile;
 import org.apache.hadoop.io.Text;
+import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.util.ReflectionUtils;
+import org.apache.mahout.h2obindings.drm.H2ODrm;
+import org.apache.mahout.math.DenseVector;
+import org.apache.mahout.math.SequentialAccessSparseVector;
+import org.apache.mahout.math.Vector;
+import org.apache.mahout.math.VectorWritable;
+import water.Futures;
+import water.fvec.Frame;
+import water.fvec.Vec;
+import water.parser.ValueString;
+import water.util.FrameUtils;
 
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
 
 /**
  * SequenceFile I/O class (on HDFS)
@@ -59,22 +57,17 @@ public class H2OHdfs {
    */
   public static boolean isSeqfile(String filename) {
     try {
-      String uri = filename;
       Configuration conf = new Configuration();
-      Path path = new Path(uri);
-      FileSystem fs = FileSystem.get(URI.create(uri), conf);
+      Path path = new Path(filename);
+      FileSystem fs = FileSystem.get(URI.create(filename), conf);
       FSDataInputStream fin = fs.open(path);
       byte seq[] = new byte[3];
 
       fin.read(seq);
       fin.close();
 
-      if (seq[0] == 'S' && seq[1] == 'E' && seq[2] == 'Q') {
-        return true;
-      } else {
-        return false;
-      }
-    } catch (java.io.IOException e) {
+      return seq[0] == 'S' && seq[1] == 'E' && seq[2] == 'Q';
+    } catch (IOException e) {
       return false;
     }
   }
@@ -95,7 +88,7 @@ public class H2OHdfs {
       } else {
         return new H2ODrm(FrameUtils.parseFrame(null,new File(filename)));
       }
-    } catch (java.io.IOException e) {
+    } catch (IOException e) {
       return null;
     }
   }
@@ -111,10 +104,9 @@ public class H2OHdfs {
 
     SequenceFile.Reader reader = null;
     try {
-      String uri = filename;
       Configuration conf = new Configuration();
-      Path path = new Path(uri);
-      FileSystem fs = FileSystem.get(URI.create(uri), conf);
+      Path path = new Path(filename);
+      FileSystem fs = FileSystem.get(URI.create(filename), conf);
       Vec.Writer writers[];
       Vec.Writer labelwriter = null;
       boolean isIntKey = false, isLongKey = false, isStringKey = false;
@@ -184,7 +176,7 @@ public class H2OHdfs {
           writers[c].set(r, v.getQuick(c));
         }
         if (labels != null) {
-          labelwriter.set(r, ((Text)key).toString());
+          labelwriter.set(r, (key).toString());
         }
         if (isStringKey) {
           r++;
@@ -216,11 +208,10 @@ public class H2OHdfs {
   public static void drmToFile(String filename, H2ODrm drm) throws java.io.IOException {
     Frame frame = drm.frame;
     Vec labels = drm.keys;
-    String uri = filename;
     Configuration conf = new Configuration();
-    Path path = new Path(uri);
-    FileSystem fs = FileSystem.get(URI.create(uri), conf);
-    SequenceFile.Writer writer = null;
+    Path path = new Path(filename);
+    FileSystem fs = FileSystem.get(URI.create(filename), conf);
+    SequenceFile.Writer writer;
     boolean isSparse = H2OHelper.isSparse(frame);
     ValueString vstr = new ValueString();
 
@@ -231,7 +222,7 @@ public class H2OHdfs {
     }
 
     for (long r = 0; r < frame.anyVec().length(); r++) {
-      Vector v = null;
+      Vector v;
       if (isSparse) {
         v = new SequentialAccessSparseVector(frame.numCols());
       } else {

http://git-wip-us.apache.org/repos/asf/mahout/blob/4ef9d31f/h2o/src/main/java/org/apache/mahout/h2obindings/H2OHelper.java
----------------------------------------------------------------------
diff --git a/h2o/src/main/java/org/apache/mahout/h2obindings/H2OHelper.java b/h2o/src/main/java/org/apache/mahout/h2obindings/H2OHelper.java
index 859e5b4..0fae5a8 100644
--- a/h2o/src/main/java/org/apache/mahout/h2obindings/H2OHelper.java
+++ b/h2o/src/main/java/org/apache/mahout/h2obindings/H2OHelper.java
@@ -104,7 +104,7 @@ public class H2OHelper {
     // Fill matrix, column at a time.
     for (Vec v : frame.vecs()) {
       for (int r = 0; r < frame.numRows(); r++) {
-        double d = 0.0;
+        double d;
         if (!v.isNA(r) && ((d = v.at(r)) != 0.0)) {
           m.setQuick(r, c, d);
         }
@@ -114,7 +114,7 @@ public class H2OHelper {
 
     // If string keyed, set the stings as rowlabels.
     if (labels != null) {
-      HashMap<String,Integer> map = new HashMap<String,Integer>();
+      Map<String,Integer> map = new HashMap<>();
       ValueString vstr = new ValueString();
       for (long i = 0; i < labels.length(); i++) {
         map.put(labels.atStr(vstr, i).toString(), (int)i);
@@ -190,9 +190,9 @@ public class H2OHelper {
       public double sumSqr;
       @Override
       public void map(Chunk chks[]) {
-        for (int c = 0; c < chks.length; c++) {
-          for (int r = 0; r < chks[c].len(); r++) {
-            sumSqr += (chks[c].atd(r) * chks[c].atd(r));
+        for (Chunk chk : chks) {
+          for (int r = 0; r < chk.len(); r++) {
+            sumSqr += (chk.atd(r) * chk.atd(r));
           }
         }
       }
@@ -244,7 +244,7 @@ public class H2OHelper {
       return null;
     }
 
-    Map<Integer,String> rmap = new HashMap<Integer,String>();
+    Map<Integer,String> rmap = new HashMap<>();
 
     for(Map.Entry<String,Integer> entry : map.entrySet()) {
       rmap.put(entry.getValue(),entry.getKey());
@@ -259,12 +259,11 @@ public class H2OHelper {
    * Chunk size is the number of elements stored per partition per column.
    *
    * @param nrow Number of rows in the DRM.
-   * @param ncol Number of columns in the DRM.
    * @param minHint Minimum number of partitions to create, if passed value is not -1.
    * @param exactHint Exact number of partitions to create, if passed value is not -1.
    * @return Calculated optimum chunk size.
    */
-  private static int chunkSize(long nrow, int ncol, int minHint, int exactHint) {
+  private static int chunkSize(long nrow, int minHint, int exactHint) {
     int chunkSz;
     int partsHint = Math.max(minHint, exactHint);
 
@@ -332,7 +331,6 @@ public class H2OHelper {
       Vec.Writer writer = labels.open();
       Map<Integer,String> rmap = reverseMap(map);
       for (int r = 0; r < m.rowSize(); r++) {
-        // TODO: fix bug here... Exception is being thrown when setting Strings
         writer.set(r, rmap.get(r));
       }
 
@@ -378,7 +376,7 @@ public class H2OHelper {
    * @return Created Frame.
    */
   public static Frame emptyFrame(long nrow, int ncol, int minHint, int exactHint, Vec.VectorGroup
vg) {
-    int chunkSz = chunkSize(nrow, ncol, minHint, exactHint);
+    int chunkSz = chunkSize(nrow, minHint, exactHint);
     int nchunks = (int)((nrow - 1) / chunkSz) + 1; // Final number of Chunks per Vec
     long espc[] = new long[nchunks + 1];
 

http://git-wip-us.apache.org/repos/asf/mahout/blob/4ef9d31f/h2o/src/main/java/org/apache/mahout/h2obindings/drm/H2OBCast.java
----------------------------------------------------------------------
diff --git a/h2o/src/main/java/org/apache/mahout/h2obindings/drm/H2OBCast.java b/h2o/src/main/java/org/apache/mahout/h2obindings/drm/H2OBCast.java
index fed5da2..523a771 100644
--- a/h2o/src/main/java/org/apache/mahout/h2obindings/drm/H2OBCast.java
+++ b/h2o/src/main/java/org/apache/mahout/h2obindings/drm/H2OBCast.java
@@ -17,19 +17,19 @@
 
 package org.apache.mahout.h2obindings.drm;
 
-import org.apache.mahout.math.drm.BCast;
+import org.apache.hadoop.io.Writable;
 import org.apache.mahout.math.Matrix;
-import org.apache.mahout.math.Vector;
 import org.apache.mahout.math.MatrixWritable;
+import org.apache.mahout.math.Vector;
 import org.apache.mahout.math.VectorWritable;
+import org.apache.mahout.math.drm.BCast;
 
-import org.apache.hadoop.io.Writable;
-
-import java.io.Serializable;
-import java.io.ByteArrayOutputStream;
 import java.io.ByteArrayInputStream;
-import java.io.ObjectOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
 
 /**
  * Broadcast class wrapper around Matrix and Vector.
@@ -54,7 +54,6 @@ public class H2OBCast<T> implements BCast<T>, Serializable {
    */
   public H2OBCast(T o) {
     obj = o;
-
     if (o instanceof Matrix) {
       buf = serialize(new MatrixWritable((Matrix)o));
       isMatrix = true;
@@ -89,7 +88,7 @@ public class H2OBCast<T> implements BCast<T>, Serializable {
       ObjectOutputStream oos = new ObjectOutputStream(bos);
       w.write(oos);
       oos.close();
-    } catch (java.io.IOException e) {
+    } catch (IOException e) {
       return null;
     }
     return bos.toByteArray();
@@ -103,8 +102,7 @@ public class H2OBCast<T> implements BCast<T>, Serializable
{
    */
   private T deserialize(byte buf[]) {
     T ret = null;
-    ByteArrayInputStream bis = new ByteArrayInputStream(buf);
-    try {
+    try (ByteArrayInputStream bis = new ByteArrayInputStream(buf)){
       ObjectInputStream ois = new ObjectInputStream(bis);
       if (isMatrix) {
         MatrixWritable w = new MatrixWritable();
@@ -115,8 +113,8 @@ public class H2OBCast<T> implements BCast<T>, Serializable
{
         w.readFields(ois);
         ret = (T) w.get();
       }
-    } catch (java.io.IOException e) {
-      System.out.println("Caught exception: " + e);
+    } catch (IOException e) {
+      e.printStackTrace();
     }
     return ret;
   }

http://git-wip-us.apache.org/repos/asf/mahout/blob/4ef9d31f/h2o/src/main/scala/org/apache/mahout/common/Hadoop1HDFSUtil.scala
----------------------------------------------------------------------
diff --git a/h2o/src/main/scala/org/apache/mahout/common/Hadoop1HDFSUtil.scala b/h2o/src/main/scala/org/apache/mahout/common/Hadoop1HDFSUtil.scala
index 87977ff..e1ec135 100644
--- a/h2o/src/main/scala/org/apache/mahout/common/Hadoop1HDFSUtil.scala
+++ b/h2o/src/main/scala/org/apache/mahout/common/Hadoop1HDFSUtil.scala
@@ -17,11 +17,9 @@
 
 package org.apache.mahout.common
 
-import org.apache.hadoop.io.{Writable, SequenceFile}
-import org.apache.hadoop.fs.{FileSystem, Path}
 import org.apache.hadoop.conf.Configuration
-import collection._
-import JavaConversions._
+import org.apache.hadoop.fs.Path
+import org.apache.hadoop.io.{SequenceFile, Writable}
 
 /**
  * Deprecated Hadoop 1 api which we currently explicitly import via Mahout dependencies.
May not work
@@ -37,7 +35,7 @@ object Hadoop1HDFSUtil extends HDFSUtil {
     val partFilePath:Path = fs.listStatus(dfsPath)
 
         // Filter out anything starting with .
-        .filter { s => (!s.getPath.getName.startsWith("\\.") && !s.getPath.getName.startsWith("_")
&& !s.isDir)}
+        .filter { s => !s.getPath.getName.startsWith("\\.") && !s.getPath.getName.startsWith("_")
&& !s.isDir }
 
         // Take path
         .map(_.getPath)

http://git-wip-us.apache.org/repos/asf/mahout/blob/4ef9d31f/h2o/src/main/scala/org/apache/mahout/h2obindings/H2ODistributedContext.scala
----------------------------------------------------------------------
diff --git a/h2o/src/main/scala/org/apache/mahout/h2obindings/H2ODistributedContext.scala
b/h2o/src/main/scala/org/apache/mahout/h2obindings/H2ODistributedContext.scala
index e562229..7290f2b 100644
--- a/h2o/src/main/scala/org/apache/mahout/h2obindings/H2ODistributedContext.scala
+++ b/h2o/src/main/scala/org/apache/mahout/h2obindings/H2ODistributedContext.scala
@@ -20,7 +20,7 @@ package org.apache.mahout.h2obindings
 import org.apache.mahout.math.drm._
 
 class H2ODistributedContext(val masterUrl: String) extends DistributedContext {
-  val h2octx = new H2OContext(masterUrl);
+  val h2octx = new H2OContext(masterUrl)
 
   def close(): Unit = return
 

http://git-wip-us.apache.org/repos/asf/mahout/blob/4ef9d31f/h2o/src/main/scala/org/apache/mahout/h2obindings/drm/CheckpointedDrmH2O.scala
----------------------------------------------------------------------
diff --git a/h2o/src/main/scala/org/apache/mahout/h2obindings/drm/CheckpointedDrmH2O.scala
b/h2o/src/main/scala/org/apache/mahout/h2obindings/drm/CheckpointedDrmH2O.scala
index 6d7628e..371e8b4 100644
--- a/h2o/src/main/scala/org/apache/mahout/h2obindings/drm/CheckpointedDrmH2O.scala
+++ b/h2o/src/main/scala/org/apache/mahout/h2obindings/drm/CheckpointedDrmH2O.scala
@@ -1,10 +1,8 @@
 package org.apache.mahout.h2obindings.drm
 
-import org.apache.mahout.math.{Matrix, Vector}
-import org.apache.mahout.math.scalabindings._
-import RLikeOps._
-import org.apache.mahout.math.drm._
 import org.apache.mahout.h2obindings._
+import org.apache.mahout.math.Matrix
+import org.apache.mahout.math.drm._
 
 import scala.reflect._
 

http://git-wip-us.apache.org/repos/asf/mahout/blob/4ef9d31f/h2o/src/main/scala/org/apache/mahout/h2obindings/ops/MapBlockHelper.scala
----------------------------------------------------------------------
diff --git a/h2o/src/main/scala/org/apache/mahout/h2obindings/ops/MapBlockHelper.scala b/h2o/src/main/scala/org/apache/mahout/h2obindings/ops/MapBlockHelper.scala
index f69a844..2bc23e5 100644
--- a/h2o/src/main/scala/org/apache/mahout/h2obindings/ops/MapBlockHelper.scala
+++ b/h2o/src/main/scala/org/apache/mahout/h2obindings/ops/MapBlockHelper.scala
@@ -34,27 +34,25 @@ object MapBlockHelper {
       case `i` => val startint: Int = startlong.asInstanceOf[Int]
         startint until (startint + in.rowSize) toArray
       case `l` => startlong until (startlong + in.rowSize) toArray
-      case `s` => {
+      case `s` =>
         val arr = new Array[String](in.rowSize)
         val vstr = new ValueString
         for (i <- 0 to (in.rowSize - 1)) {
           arr(i) = labels.atStr(vstr, i + startlong).toString
         }
         arr
-      }
     }
 
     val _bmf = bmf.asInstanceOf[BlockMapFunc[K,R]]
     val out = _bmf((inarray.asInstanceOf[Array[K]], in))
 
     implicitly[ClassTag[R]] match {
-      case `s` => {
+      case `s` =>
         val vstr = new ValueString
         for (str <- out._1) {
           nclabel.addStr(vstr.setTo(str.asInstanceOf[String]))
         }
-      }
-      case _ => Unit
+      case _ =>
     }
     out._2
   }

http://git-wip-us.apache.org/repos/asf/mahout/blob/4ef9d31f/h2o/src/test/scala/org/apache/mahout/classifier/naivebayes/NBH2OTestSuite.scala
----------------------------------------------------------------------
diff --git a/h2o/src/test/scala/org/apache/mahout/classifier/naivebayes/NBH2OTestSuite.scala
b/h2o/src/test/scala/org/apache/mahout/classifier/naivebayes/NBH2OTestSuite.scala
index 8759e3e..7a0a3f4 100644
--- a/h2o/src/test/scala/org/apache/mahout/classifier/naivebayes/NBH2OTestSuite.scala
+++ b/h2o/src/test/scala/org/apache/mahout/classifier/naivebayes/NBH2OTestSuite.scala
@@ -16,9 +16,6 @@
  */
 package org.apache.mahout.classifier.naivebayes
 
-import org.apache.mahout.math._
-import org.apache.mahout.math.scalabindings.RLikeOps._
-import org.apache.mahout.math.scalabindings._
 import org.apache.mahout.h2obindings.test.DistributedH2OSuite
 import org.apache.mahout.test.MahoutSuite
 import org.scalatest.FunSuite

http://git-wip-us.apache.org/repos/asf/mahout/blob/4ef9d31f/h2o/src/test/scala/org/apache/mahout/h2obindings/drm/DrmLikeOpsSuite.scala
----------------------------------------------------------------------
diff --git a/h2o/src/test/scala/org/apache/mahout/h2obindings/drm/DrmLikeOpsSuite.scala b/h2o/src/test/scala/org/apache/mahout/h2obindings/drm/DrmLikeOpsSuite.scala
index c6deb35..7b199df 100644
--- a/h2o/src/test/scala/org/apache/mahout/h2obindings/drm/DrmLikeOpsSuite.scala
+++ b/h2o/src/test/scala/org/apache/mahout/h2obindings/drm/DrmLikeOpsSuite.scala
@@ -17,14 +17,9 @@
 
 package org.apache.mahout.h2obindings.drm
 
-import org.apache.mahout.math._
-import scalabindings._
-import drm._
-import RLikeOps._
-import RLikeDrmOps._
-import org.apache.mahout.h2obindings._
-import org.scalatest.FunSuite
 import org.apache.mahout.h2obindings.test.DistributedH2OSuite
+import org.apache.mahout.math.drm._
+import org.scalatest.FunSuite
 
 /** Tests for DrmLikeOps */
 class DrmLikeOpsSuite extends FunSuite with DistributedH2OSuite with DrmLikeOpsSuiteBase

http://git-wip-us.apache.org/repos/asf/mahout/blob/4ef9d31f/h2o/src/test/scala/org/apache/mahout/h2obindings/drm/DrmLikeSuite.scala
----------------------------------------------------------------------
diff --git a/h2o/src/test/scala/org/apache/mahout/h2obindings/drm/DrmLikeSuite.scala b/h2o/src/test/scala/org/apache/mahout/h2obindings/drm/DrmLikeSuite.scala
index 07eb9d7..ea7056e 100644
--- a/h2o/src/test/scala/org/apache/mahout/h2obindings/drm/DrmLikeSuite.scala
+++ b/h2o/src/test/scala/org/apache/mahout/h2obindings/drm/DrmLikeSuite.scala
@@ -17,13 +17,9 @@
 
 package org.apache.mahout.h2obindings.drm
 
-import org.scalatest.FunSuite
-import org.apache.mahout.math._
-import scalabindings._
-import drm._
-import RLikeOps._
-import RLikeDrmOps._
 import org.apache.mahout.h2obindings.test.DistributedH2OSuite
+import org.apache.mahout.math.drm._
+import org.scalatest.FunSuite
 
 
 class DrmLikeSuite extends FunSuite with DistributedH2OSuite with DrmLikeSuiteBase

http://git-wip-us.apache.org/repos/asf/mahout/blob/4ef9d31f/h2o/src/test/scala/org/apache/mahout/h2obindings/drm/RLikeDrmOpsSuite.scala
----------------------------------------------------------------------
diff --git a/h2o/src/test/scala/org/apache/mahout/h2obindings/drm/RLikeDrmOpsSuite.scala b/h2o/src/test/scala/org/apache/mahout/h2obindings/drm/RLikeDrmOpsSuite.scala
index f052247..5cbe47c 100644
--- a/h2o/src/test/scala/org/apache/mahout/h2obindings/drm/RLikeDrmOpsSuite.scala
+++ b/h2o/src/test/scala/org/apache/mahout/h2obindings/drm/RLikeDrmOpsSuite.scala
@@ -23,5 +23,6 @@ import drm._
 import org.apache.mahout.h2obindings._
 import test.DistributedH2OSuite
 
-/** ==R-like DRM DSL operation tests -- H2O== */
+/** ==R-like DRM DSL operation tests -- H2O==
+  * */
 class RLikeDrmOpsSuite extends FunSuite with DistributedH2OSuite with RLikeDrmOpsSuiteBase

http://git-wip-us.apache.org/repos/asf/mahout/blob/4ef9d31f/h2o/src/test/scala/org/apache/mahout/h2obindings/ops/ABtSuite.scala
----------------------------------------------------------------------
diff --git a/h2o/src/test/scala/org/apache/mahout/h2obindings/ops/ABtSuite.scala b/h2o/src/test/scala/org/apache/mahout/h2obindings/ops/ABtSuite.scala
index b0d2ad7..29ae2fd 100644
--- a/h2o/src/test/scala/org/apache/mahout/h2obindings/ops/ABtSuite.scala
+++ b/h2o/src/test/scala/org/apache/mahout/h2obindings/ops/ABtSuite.scala
@@ -21,8 +21,6 @@ import org.apache.mahout.h2obindings.test.DistributedH2OSuite
 import org.scalatest.FunSuite
 import org.apache.mahout.math.scalabindings._
 import org.apache.mahout.math.drm._
-import org.apache.mahout.h2obindings._
-import org.apache.mahout.h2obindings.drm._
 import RLikeOps._
 import RLikeDrmOps._
 import org.apache.mahout.math.drm._

http://git-wip-us.apache.org/repos/asf/mahout/blob/4ef9d31f/h2o/src/test/scala/org/apache/mahout/h2obindings/ops/AewBSuite.scala
----------------------------------------------------------------------
diff --git a/h2o/src/test/scala/org/apache/mahout/h2obindings/ops/AewBSuite.scala b/h2o/src/test/scala/org/apache/mahout/h2obindings/ops/AewBSuite.scala
index 2f2133f..8843c08 100644
--- a/h2o/src/test/scala/org/apache/mahout/h2obindings/ops/AewBSuite.scala
+++ b/h2o/src/test/scala/org/apache/mahout/h2obindings/ops/AewBSuite.scala
@@ -23,7 +23,6 @@ import org.apache.mahout.math.scalabindings._
 import RLikeOps._
 import org.apache.mahout.math.drm._
 import RLikeDrmOps._
-import org.apache.mahout.math.drm.logical._
 
 /** Elementwise matrix operation tests */
 class AewBSuite extends FunSuite with DistributedH2OSuite {

http://git-wip-us.apache.org/repos/asf/mahout/blob/4ef9d31f/h2o/src/test/scala/org/apache/mahout/h2obindings/ops/AtASuite.scala
----------------------------------------------------------------------
diff --git a/h2o/src/test/scala/org/apache/mahout/h2obindings/ops/AtASuite.scala b/h2o/src/test/scala/org/apache/mahout/h2obindings/ops/AtASuite.scala
index 3dc3fcc..514d5b9 100644
--- a/h2o/src/test/scala/org/apache/mahout/h2obindings/ops/AtASuite.scala
+++ b/h2o/src/test/scala/org/apache/mahout/h2obindings/ops/AtASuite.scala
@@ -21,13 +21,11 @@ import org.scalatest.FunSuite
 import org.apache.mahout.h2obindings.test.DistributedH2OSuite
 import org.apache.mahout.math.scalabindings._
 import org.apache.mahout.math.drm._
-import org.apache.mahout.h2obindings._
-import org.apache.mahout.h2obindings.drm._
 import RLikeOps._
 import RLikeDrmOps._
 import org.apache.mahout.math.drm._
 
-/** Tests for {@link XtX} */
+/** Tests for @link XtX */
 class AtASuite extends FunSuite with DistributedH2OSuite {
   test("AtA slim") {
     val inCoreA = dense((1, 2), (2, 3))

http://git-wip-us.apache.org/repos/asf/mahout/blob/4ef9d31f/h2o/src/test/scala/org/apache/mahout/h2obindings/ops/AtSuite.scala
----------------------------------------------------------------------
diff --git a/h2o/src/test/scala/org/apache/mahout/h2obindings/ops/AtSuite.scala b/h2o/src/test/scala/org/apache/mahout/h2obindings/ops/AtSuite.scala
index c521388..91eaa84 100644
--- a/h2o/src/test/scala/org/apache/mahout/h2obindings/ops/AtSuite.scala
+++ b/h2o/src/test/scala/org/apache/mahout/h2obindings/ops/AtSuite.scala
@@ -21,8 +21,6 @@ import org.scalatest.FunSuite
 import org.apache.mahout.h2obindings.test.DistributedH2OSuite
 import org.apache.mahout.math.scalabindings._
 import org.apache.mahout.math.drm._
-import org.apache.mahout.h2obindings._
-import org.apache.mahout.h2obindings.drm._
 import RLikeOps._
 import RLikeDrmOps._
 import org.apache.mahout.math.drm._

http://git-wip-us.apache.org/repos/asf/mahout/blob/4ef9d31f/h2o/src/test/scala/org/apache/mahout/h2obindings/test/LoggerConfiguration.scala
----------------------------------------------------------------------
diff --git a/h2o/src/test/scala/org/apache/mahout/h2obindings/test/LoggerConfiguration.scala
b/h2o/src/test/scala/org/apache/mahout/h2obindings/test/LoggerConfiguration.scala
index b0cfd30..98e5a42 100644
--- a/h2o/src/test/scala/org/apache/mahout/h2obindings/test/LoggerConfiguration.scala
+++ b/h2o/src/test/scala/org/apache/mahout/h2obindings/test/LoggerConfiguration.scala
@@ -1,7 +1,7 @@
 package org.apache.mahout.h2obindings.test
 
 import org.scalatest.{Suite, ConfigMap}
-import org.apache.log4j.{Level, Logger, BasicConfigurator}
+import org.apache.log4j.{Level, Logger}
 
 trait LoggerConfiguration extends org.apache.mahout.test.LoggerConfiguration {
   this: Suite =>

http://git-wip-us.apache.org/repos/asf/mahout/blob/4ef9d31f/h2o/src/test/scala/org/apache/mahout/math/decompositions/DistributedDecompositionsSuite.scala
----------------------------------------------------------------------
diff --git a/h2o/src/test/scala/org/apache/mahout/math/decompositions/DistributedDecompositionsSuite.scala
b/h2o/src/test/scala/org/apache/mahout/math/decompositions/DistributedDecompositionsSuite.scala
index 00cf0ba..20bc0f7 100644
--- a/h2o/src/test/scala/org/apache/mahout/math/decompositions/DistributedDecompositionsSuite.scala
+++ b/h2o/src/test/scala/org/apache/mahout/math/decompositions/DistributedDecompositionsSuite.scala
@@ -17,15 +17,7 @@
 
 package org.apache.mahout.math.decompositions
 
-import org.apache.mahout.math._
-import drm._
-import scalabindings._
-import RLikeOps._
-import RLikeDrmOps._
-import org.apache.mahout.h2obindings._
-import org.apache.mahout.common.RandomUtils
-import scala.math._
-import org.scalatest.{Matchers, FunSuite}
 import org.apache.mahout.h2obindings.test.DistributedH2OSuite
+import org.scalatest.FunSuite
 
 class DistributedDecompositionsSuite extends FunSuite with DistributedH2OSuite with DistributedDecompositionsSuiteBase

http://git-wip-us.apache.org/repos/asf/mahout/blob/4ef9d31f/hdfs/src/main/java/org/apache/mahout/math/MatrixWritable.java
----------------------------------------------------------------------
diff --git a/hdfs/src/main/java/org/apache/mahout/math/MatrixWritable.java b/hdfs/src/main/java/org/apache/mahout/math/MatrixWritable.java
index c521f3e..b8fc461 100644
--- a/hdfs/src/main/java/org/apache/mahout/math/MatrixWritable.java
+++ b/hdfs/src/main/java/org/apache/mahout/math/MatrixWritable.java
@@ -18,13 +18,13 @@
 package org.apache.mahout.math;
 
 import com.google.common.base.Preconditions;
-import com.google.common.collect.Maps;
 import org.apache.hadoop.io.Writable;
 import org.apache.mahout.math.list.IntArrayList;
 
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
+import java.util.HashMap;
 import java.util.Map;
 
 public class MatrixWritable implements Writable {
@@ -139,8 +139,8 @@ public class MatrixWritable implements Writable {
     }
 
     if (hasLabels) {
-      Map<String,Integer> columnLabelBindings = Maps.newHashMap();
-      Map<String,Integer> rowLabelBindings = Maps.newHashMap();
+      Map<String,Integer> columnLabelBindings = new HashMap<>();
+      Map<String,Integer> rowLabelBindings = new HashMap<>();
       readLabels(in, columnLabelBindings, rowLabelBindings);
       if (!columnLabelBindings.isEmpty()) {
         matrix.setColumnLabelBindings(columnLabelBindings);

http://git-wip-us.apache.org/repos/asf/mahout/blob/4ef9d31f/hdfs/src/test/java/org/apache/mahout/math/MatrixWritableTest.java
----------------------------------------------------------------------
diff --git a/hdfs/src/test/java/org/apache/mahout/math/MatrixWritableTest.java b/hdfs/src/test/java/org/apache/mahout/math/MatrixWritableTest.java
index 226d4b1..31e6947 100644
--- a/hdfs/src/test/java/org/apache/mahout/math/MatrixWritableTest.java
+++ b/hdfs/src/test/java/org/apache/mahout/math/MatrixWritableTest.java
@@ -22,10 +22,9 @@ import java.io.ByteArrayOutputStream;
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.HashMap;
 import java.util.Map;
 
-import com.google.common.collect.Maps;
-import com.google.common.io.Closeables;
 import org.apache.hadoop.io.Writable;
 import org.junit.Test;
 
@@ -36,7 +35,7 @@ public final class MatrixWritableTest extends MahoutTestCase {
     Matrix m = new SparseMatrix(5, 5);
     m.set(1, 2, 3.0);
     m.set(3, 4, 5.0);
-    Map<String, Integer> bindings = Maps.newHashMap();
+    Map<String, Integer> bindings = new HashMap<>();
     bindings.put("A", 0);
     bindings.put("B", 1);
     bindings.put("C", 2);
@@ -52,7 +51,7 @@ public final class MatrixWritableTest extends MahoutTestCase {
     Matrix m = new SparseRowMatrix(5, 5);
     m.set(1, 2, 3.0);
     m.set(3, 4, 5.0);
-    Map<String, Integer> bindings = Maps.newHashMap();
+    Map<String, Integer> bindings = new HashMap<>();
     bindings.put("A", 0);
     bindings.put("B", 1);
     bindings.put("C", 2);
@@ -68,7 +67,7 @@ public final class MatrixWritableTest extends MahoutTestCase {
     Matrix m = new DenseMatrix(5,5);
     m.set(1, 2, 3.0);
     m.set(3, 4, 5.0);
-    Map<String, Integer> bindings = Maps.newHashMap();
+    Map<String, Integer> bindings = new HashMap<>();
     bindings.put("A", 0);
     bindings.put("B", 1);
     bindings.put("C", 2);
@@ -128,19 +127,13 @@ public final class MatrixWritableTest extends MahoutTestCase {
 
   private static void writeAndRead(Writable toWrite, Writable toRead) throws IOException
{
     ByteArrayOutputStream baos = new ByteArrayOutputStream();
-    DataOutputStream dos = new DataOutputStream(baos);
-    try {
+    try (DataOutputStream dos = new DataOutputStream(baos)){
       toWrite.write(dos);
-    } finally {
-      Closeables.close(dos, false);
     }
 
     ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-    DataInputStream dis = new DataInputStream(bais);
-    try {
+    try (DataInputStream dis = new DataInputStream(bais)) {
       toRead.readFields(dis);
-    } finally {
-      Closeables.close(dis, true);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/mahout/blob/4ef9d31f/hdfs/src/test/java/org/apache/mahout/math/VectorWritableTest.java
----------------------------------------------------------------------
diff --git a/hdfs/src/test/java/org/apache/mahout/math/VectorWritableTest.java b/hdfs/src/test/java/org/apache/mahout/math/VectorWritableTest.java
index 60fb8b4..991be6e 100644
--- a/hdfs/src/test/java/org/apache/mahout/math/VectorWritableTest.java
+++ b/hdfs/src/test/java/org/apache/mahout/math/VectorWritableTest.java
@@ -27,7 +27,6 @@ import org.junit.Test;
 
 import com.carrotsearch.randomizedtesting.RandomizedTest;
 import com.carrotsearch.randomizedtesting.annotations.Repeat;
-import com.google.common.io.Closeables;
 
 public final class VectorWritableTest extends RandomizedTest {
   private static final int MAX_VECTOR_SIZE = 100;
@@ -105,19 +104,13 @@ public final class VectorWritableTest extends RandomizedTest {
 
   private static void writeAndRead(Writable toWrite, Writable toRead) throws IOException
{
     ByteArrayOutputStream baos = new ByteArrayOutputStream();
-    DataOutputStream dos = new DataOutputStream(baos);
-    try {
+    try (DataOutputStream dos = new DataOutputStream(baos)){
       toWrite.write(dos);
-    } finally {
-      Closeables.close(dos, false);
     }
 
     ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-    DataInputStream dis = new DataInputStream(bais);
-    try {
+    try (DataInputStream dis = new DataInputStream(bais)) {
       toRead.readFields(dis);
-    } finally {
-      Closeables.close(dos, true);
     }
   }
 }


Mime
View raw message