spark-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject [04/28] git commit: Un-semicolon PythonMLLibAPI.
Date Thu, 26 Dec 2013 06:31:21 GMT
Un-semicolon PythonMLLibAPI.


Project: http://git-wip-us.apache.org/repos/asf/incubator-spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-spark/commit/2a41c9aa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-spark/tree/2a41c9aa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-spark/diff/2a41c9aa

Branch: refs/heads/master
Commit: 2a41c9aad3d0a8477a11bf910fa57b49ea4dc6dc
Parents: bf20591
Author: Tor Myklebust <tmyklebu@gmail.com>
Authored: Thu Dec 19 21:27:11 2013 -0500
Committer: Tor Myklebust <tmyklebu@gmail.com>
Committed: Thu Dec 19 21:27:11 2013 -0500

----------------------------------------------------------------------
 .../apache/spark/mllib/api/PythonMLLibAPI.scala | 54 ++++++++++----------
 1 file changed, 27 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-spark/blob/2a41c9aa/mllib/src/main/scala/org/apache/spark/mllib/api/PythonMLLibAPI.scala
----------------------------------------------------------------------
diff --git a/mllib/src/main/scala/org/apache/spark/mllib/api/PythonMLLibAPI.scala b/mllib/src/main/scala/org/apache/spark/mllib/api/PythonMLLibAPI.scala
index 19d2e9a..3daf5dc 100644
--- a/mllib/src/main/scala/org/apache/spark/mllib/api/PythonMLLibAPI.scala
+++ b/mllib/src/main/scala/org/apache/spark/mllib/api/PythonMLLibAPI.scala
@@ -6,46 +6,46 @@ import java.nio.DoubleBuffer
 
 class PythonMLLibAPI extends Serializable {
   def deserializeDoubleVector(bytes: Array[Byte]): Array[Double] = {
-    val packetLength = bytes.length;
+    val packetLength = bytes.length
     if (packetLength < 16) {
-      throw new IllegalArgumentException("Byte array too short.");
+      throw new IllegalArgumentException("Byte array too short.")
     }
-    val bb = ByteBuffer.wrap(bytes);
-    bb.order(ByteOrder.nativeOrder());
-    val magic = bb.getLong();
+    val bb = ByteBuffer.wrap(bytes)
+    bb.order(ByteOrder.nativeOrder())
+    val magic = bb.getLong()
     if (magic != 1) {
-      throw new IllegalArgumentException("Magic " + magic + " is wrong.");
+      throw new IllegalArgumentException("Magic " + magic + " is wrong.")
     }
-    val length = bb.getLong();
+    val length = bb.getLong()
     if (packetLength != 16 + 8 * length) {
-      throw new IllegalArgumentException("Length " + length + "is wrong.");
+      throw new IllegalArgumentException("Length " + length + "is wrong.")
     }
-    val db = bb.asDoubleBuffer();
-    val ans = new Array[Double](length.toInt);
-    db.get(ans);
-    return ans;
+    val db = bb.asDoubleBuffer()
+    val ans = new Array[Double](length.toInt)
+    db.get(ans)
+    return ans
   }
 
   def serializeDoubleVector(doubles: Array[Double]): Array[Byte] = {
-    val len = doubles.length;
-    val bytes = new Array[Byte](16 + 8 * len);
-    val bb = ByteBuffer.wrap(bytes);
-    bb.order(ByteOrder.nativeOrder());
-    bb.putLong(1);
-    bb.putLong(len);
-    val db = bb.asDoubleBuffer();
-    db.put(doubles);
-    return bytes;
+    val len = doubles.length
+    val bytes = new Array[Byte](16 + 8 * len)
+    val bb = ByteBuffer.wrap(bytes)
+    bb.order(ByteOrder.nativeOrder())
+    bb.putLong(1)
+    bb.putLong(len)
+    val db = bb.asDoubleBuffer()
+    db.put(doubles)
+    return bytes
   }
 
   def trainLinearRegressionModel(dataBytesJRDD: JavaRDD[Array[Byte]]):
       java.util.List[java.lang.Object] = {
     val data = dataBytesJRDD.rdd.map(x => deserializeDoubleVector(x))
-        .map(v => LabeledPoint(v(0), v.slice(1, v.length)));
-    val model = LinearRegressionWithSGD.train(data, 222);
-    val ret = new java.util.LinkedList[java.lang.Object]();
-    ret.add(serializeDoubleVector(model.weights));
-    ret.add(model.intercept: java.lang.Double);
-    return ret;
+        .map(v => LabeledPoint(v(0), v.slice(1, v.length)))
+    val model = LinearRegressionWithSGD.train(data, 222)
+    val ret = new java.util.LinkedList[java.lang.Object]()
+    ret.add(serializeDoubleVector(model.weights))
+    ret.add(model.intercept: java.lang.Double)
+    return ret
   }
 }


Mime
View raw message