Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.fasterxml.jackson.annotation.{JsonIgnore, JsonInclude, JsonPropertyOr
import com.fasterxml.jackson.annotation.JsonInclude.Include
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.scala.DefaultScalaModule
import com.google.common.base.Objects

import org.apache.spark.{Logging, SparkContext}

Expand Down Expand Up @@ -67,6 +68,8 @@ private[spark] class RDDOperationScope(
}
}

override def hashCode(): Int = Objects.hashCode(id, name, parent)

override def toString: String = toJson
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,15 @@ class AccumulableInfo private[spark] (
override def equals(other: Any): Boolean = other match {
case acc: AccumulableInfo =>
this.id == acc.id && this.name == acc.name &&
this.update == acc.update && this.value == acc.value
this.update == acc.update && this.value == acc.value &&
this.internal == acc.internal
case _ => false
}

override def hashCode(): Int = {
val state = Seq(id, name, update, value, internal)
state.map(_.hashCode).reduceLeft(31 * _ + _)
}
}

object AccumulableInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ class RDDOperationScopeSuite extends SparkFunSuite with BeforeAndAfter {
sc.stop()
}

test("equals and hashCode") {
val opScope1 = new RDDOperationScope("scope1", id = "1")
val opScope2 = new RDDOperationScope("scope1", id = "1")
assert(opScope1 === opScope2)
assert(opScope1.hashCode() === opScope2.hashCode())
}

test("getAllScopes") {
assert(scope1.getAllScopes === Seq(scope1))
assert(scope2.getAllScopes === Seq(scope1, scope2))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,15 @@ class DAGSchedulerSuite
assertDataStructuresEmpty()
}

test("equals and hashCode AccumulableInfo") {
val accInfo1 = new AccumulableInfo(1, " Accumulable " + 1, Some("delta" + 1), "val" + 1, true)
val accInfo2 = new AccumulableInfo(1, " Accumulable " + 1, Some("delta" + 1), "val" + 1, false)
val accInfo3 = new AccumulableInfo(1, " Accumulable " + 1, Some("delta" + 1), "val" + 1, false)
assert(accInfo1 !== accInfo2)
assert(accInfo2 === accInfo3)
assert(accInfo2.hashCode() === accInfo3.hashCode())
}

test("cache location preferences w/ dependency") {
val baseRdd = new MyRDD(sc, 1, Nil).cache()
val finalRdd = new MyRDD(sc, 1, List(new OneToOneDependency(baseRdd)))
Expand Down