aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShivaram Venkataraman <shivaram@eecs.berkeley.edu>2013-08-08 14:36:02 -0700
committerShivaram Venkataraman <shivaram@eecs.berkeley.edu>2013-08-08 14:36:02 -0700
commite1a209f791a29225c7c75861aa4a18b14739fcc4 (patch)
treeeef0b527b2ae9e9a7a7d66ad4d4aa6df7f801971
parent6caec3f44193a459a2dd10b0393e391979795039 (diff)
downloadspark-e1a209f791a29225c7c75861aa4a18b14739fcc4.tar.gz
spark-e1a209f791a29225c7c75861aa4a18b14739fcc4.tar.bz2
spark-e1a209f791a29225c7c75861aa4a18b14739fcc4.zip
Remove Java-specific constructor for Rating.
The scala constructor works for native type java types. Modify examples to match this.
-rw-r--r--examples/src/main/java/spark/mllib/JavaALS.java6
-rw-r--r--mllib/src/main/scala/spark/mllib/recommendation/ALS.scala11
-rw-r--r--mllib/src/test/scala/spark/mllib/clustering/JavaKMeansSuite.java2
-rw-r--r--mllib/src/test/scala/spark/mllib/recommendation/JavaALSSuite.java2
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<String, Rating> {
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