Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion core/src/main/scala/org/apache/spark/util/MutablePair.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 apply(n1: T1, n2: T2): MutablePair[T1, T2] = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really a good idea? apply usually does not modify the object you called it on. Maybe we should call this set or update.

_1 = n1
_2 = n2
this
}

override def toString = "(" + _1 + "," + _2 + ")"

override def canEqual(that: Any): Boolean = that.isInstanceOf[MutablePair[_,_]]
Expand Down