diff options
author | Michael Armbrust <michael@databricks.com> | 2014-03-14 11:40:26 -0700 |
---|---|---|
committer | Reynold Xin <rxin@apache.org> | 2014-03-14 11:40:26 -0700 |
commit | e19044cb1048c3755d1ea2cb43879d2225d49b54 (patch) | |
tree | 7be203b0179096d24ffb677788439602eecab624 /core/src | |
parent | 181b130a0c2a0752009fdf5602e5d6d87f5b1212 (diff) | |
download | spark-e19044cb1048c3755d1ea2cb43879d2225d49b54.tar.gz spark-e19044cb1048c3755d1ea2cb43879d2225d49b54.tar.bz2 spark-e19044cb1048c3755d1ea2cb43879d2225d49b54.zip |
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.
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/scala/org/apache/spark/util/MutablePair.scala | 12 |
1 files changed, 11 insertions, 1 deletions
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 b053266f12..2c1a6f8fd0 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[_,_]] |