Remove Java-specific constructor for Rating.

The scala constructor works for native type java types. Modify examples
to match this.
This commit is contained in:
Shivaram Venkataraman 2013-08-08 14:36:02 -07:00
Родитель 6caec3f441
Коммит e1a209f791
4 изменённых файлов: 6 добавлений и 15 удалений

Просмотреть файл

@ -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);
}
}

Просмотреть файл

@ -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.

Просмотреть файл

@ -34,7 +34,7 @@ public class JavaKMeansSuite implements Serializable {
@Before
public void setUp() {
sc = new JavaSparkContext("local", "JavaLogisticRegressionSuite");
sc = new JavaSparkContext("local", "JavaKMeans");
}
@After

Просмотреть файл

@ -37,7 +37,7 @@ public class JavaALSSuite implements Serializable {
@Before
public void setUp() {
sc = new JavaSparkContext("local", "JavaLogisticRegressionSuite");
sc = new JavaSparkContext("local", "JavaALS");
}
@After