Skip to content
Snippets Groups Projects
Commit e19044cb authored by Michael Armbrust's avatar Michael Armbrust Committed by Reynold Xin
Browse files

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.
parent 181b130a
No related branches found
No related tags found
No related merge requests found
......@@ -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[_,_]]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment