spark-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject git commit: Fix serialization of MutablePair. Also provide an interface for easy updating.
Date Fri, 14 Mar 2014 18:40:26 GMT
Repository: spark
Updated Branches:
  refs/heads/master 181b130a0 -> e19044cb1


Fix serialization of MutablePair. Also provide an interface for easy updating.

Author: Michael Armbrust <michael@databricks.com>

Closes #141 from marmbrus/mutablePair and squashes the following commits:

f5c4783 [Michael Armbrust] Change function name to update
8bfd973 [Michael Armbrust] Fix serialization of MutablePair.  Also provide an interface for
easy updating.


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

Branch: refs/heads/master
Commit: e19044cb1048c3755d1ea2cb43879d2225d49b54
Parents: 181b130
Author: Michael Armbrust <michael@databricks.com>
Authored: Fri Mar 14 11:40:26 2014 -0700
Committer: Reynold Xin <rxin@apache.org>
Committed: Fri Mar 14 11:40:26 2014 -0700

----------------------------------------------------------------------
 .../main/scala/org/apache/spark/util/MutablePair.scala  | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/e19044cb/core/src/main/scala/org/apache/spark/util/MutablePair.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/org/apache/spark/util/MutablePair.scala b/core/src/main/scala/org/apache/spark/util/MutablePair.scala
index b053266..2c1a6f8 100644
--- a/core/src/main/scala/org/apache/spark/util/MutablePair.scala
+++ b/core/src/main/scala/org/apache/spark/util/MutablePair.scala
@@ -25,10 +25,20 @@ package org.apache.spark.util
  * @param  _2   Element 2 of this MutablePair
  */
 case class MutablePair[@specialized(Int, Long, Double, Char, Boolean/*, AnyRef*/) T1,
-                      @specialized(Int, Long, Double, Char, Boolean/*, AnyRef*/) T2]
+                       @specialized(Int, Long, Double, Char, Boolean/*, AnyRef*/) T2]
   (var _1: T1, var _2: T2)
   extends Product2[T1, T2]
 {
+  /** No-arg constructor for serialization */
+  def this() = this(null.asInstanceOf[T1], null.asInstanceOf[T2])
+
+  /** Updates this pair with new values and returns itself */
+  def update(n1: T1, n2: T2): MutablePair[T1, T2] = {
+    _1 = n1
+    _2 = n2
+    this
+  }
+
   override def toString = "(" + _1 + "," + _2 + ")"
 
   override def canEqual(that: Any): Boolean = that.isInstanceOf[MutablePair[_,_]]


Mime
View raw message