From e1a209f791a29225c7c75861aa4a18b14739fcc4 Mon Sep 17 00:00:00 2001 From: Shivaram Venkataraman Date: Thu, 8 Aug 2013 14:36:02 -0700 Subject: [PATCH] Remove Java-specific constructor for Rating. The scala constructor works for native type java types. Modify examples to match this. --- examples/src/main/java/spark/mllib/JavaALS.java | 6 +++--- .../main/scala/spark/mllib/recommendation/ALS.scala | 11 +---------- .../scala/spark/mllib/clustering/JavaKMeansSuite.java | 2 +- .../spark/mllib/recommendation/JavaALSSuite.java | 2 +- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/examples/src/main/java/spark/mllib/JavaALS.java b/examples/src/main/java/spark/mllib/JavaALS.java index 8be079ad39..b48f459cb7 100644 --- a/examples/src/main/java/spark/mllib/JavaALS.java +++ b/examples/src/main/java/spark/mllib/JavaALS.java @@ -39,9 +39,9 @@ public class JavaALS { static class ParseRating extends Function { public Rating call(String line) { StringTokenizer tok = new StringTokenizer(line, ","); - Integer x = Integer.parseInt(tok.nextToken()); - Integer y = Integer.parseInt(tok.nextToken()); - Double rating = Double.parseDouble(tok.nextToken()); + int x = Integer.parseInt(tok.nextToken()); + int y = Integer.parseInt(tok.nextToken()); + double rating = Double.parseDouble(tok.nextToken()); return new Rating(x, y, rating); } } diff --git a/mllib/src/main/scala/spark/mllib/recommendation/ALS.scala b/mllib/src/main/scala/spark/mllib/recommendation/ALS.scala index 7734c9279d..6c71dc1f32 100644 --- a/mllib/src/main/scala/spark/mllib/recommendation/ALS.scala +++ b/mllib/src/main/scala/spark/mllib/recommendation/ALS.scala @@ -17,9 +17,6 @@ package spark.mllib.recommendation -import java.lang.{Integer => JInt} -import java.lang.{Double => JDouble} - import scala.collection.mutable.{ArrayBuffer, BitSet} import scala.util.Random import scala.util.Sorting @@ -58,13 +55,7 @@ private[recommendation] case class InLinkBlock( /** * A more compact class to represent a rating than Tuple3[Int, Int, Double]. */ -case class Rating(val user: Int, val product: Int, val rating: Double) { - - // Constructor to build a rating from java Integers and Doubles. - def this(user: JInt, product: JInt, rating: JDouble) = { - this(user.intValue(), product.intValue(), rating.doubleValue()) - } -} +case class Rating(val user: Int, val product: Int, val rating: Double) /** * Alternating Least Squares matrix factorization. diff --git a/mllib/src/test/scala/spark/mllib/clustering/JavaKMeansSuite.java b/mllib/src/test/scala/spark/mllib/clustering/JavaKMeansSuite.java index a3db0c0f6d..3f2d82bfb4 100644 --- a/mllib/src/test/scala/spark/mllib/clustering/JavaKMeansSuite.java +++ b/mllib/src/test/scala/spark/mllib/clustering/JavaKMeansSuite.java @@ -34,7 +34,7 @@ public class JavaKMeansSuite implements Serializable { @Before public void setUp() { - sc = new JavaSparkContext("local", "JavaLogisticRegressionSuite"); + sc = new JavaSparkContext("local", "JavaKMeans"); } @After diff --git a/mllib/src/test/scala/spark/mllib/recommendation/JavaALSSuite.java b/mllib/src/test/scala/spark/mllib/recommendation/JavaALSSuite.java index 8224519792..7993629a6d 100644 --- a/mllib/src/test/scala/spark/mllib/recommendation/JavaALSSuite.java +++ b/mllib/src/test/scala/spark/mllib/recommendation/JavaALSSuite.java @@ -37,7 +37,7 @@ public class JavaALSSuite implements Serializable { @Before public void setUp() { - sc = new JavaSparkContext("local", "JavaLogisticRegressionSuite"); + sc = new JavaSparkContext("local", "JavaALS"); } @After