Skip to content
Snippets Groups Projects
Commit 02771aa0 authored by Ankur Dave's avatar Ankur Dave
Browse files

Make EdgeDirection val instead of case object for Java compat.

parent 574c0d28
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@ package org.apache.spark.graphx
/**
* The direction of a directed edge relative to a vertex.
*/
sealed abstract class EdgeDirection {
class EdgeDirection private (private val name: String) extends Serializable {
/**
* Reverse the direction of an edge. An in becomes out,
* out becomes in and both remains both.
......@@ -13,16 +13,25 @@ sealed abstract class EdgeDirection {
case EdgeDirection.Out => EdgeDirection.In
case EdgeDirection.Both => EdgeDirection.Both
}
override def toString: String = "EdgeDirection." + name
override def equals(o: Any) = o match {
case other: EdgeDirection => other.name == name
case _ => false
}
override def hashCode = name.hashCode
}
object EdgeDirection {
/** Edges arriving at a vertex. */
case object In extends EdgeDirection
final val In = new EdgeDirection("In")
/** Edges originating from a vertex. */
case object Out extends EdgeDirection
final val Out = new EdgeDirection("Out")
/** All edges adjacent to a vertex. */
case object Both extends EdgeDirection
final val Both = new EdgeDirection("Both")
}
......@@ -23,6 +23,7 @@ class GraphKryoRegistrator extends KryoRegistrator {
kryo.register(classOf[VertexAttributeBlock[Object]])
kryo.register(classOf[PartitionStrategy])
kryo.register(classOf[BoundedPriorityQueue[Object]])
kryo.register(classOf[EdgeDirection])
// This avoids a large number of hash table lookups.
kryo.setReferences(false)
......
......@@ -283,7 +283,7 @@ class GraphImpl[VD: ClassTag, ED: ClassTag] protected (
}
case Some(EdgeDirection.In) =>
edgePartition.iterator.filter(e => vPart.isActive(e.dstId))
case None =>
case _ => // None
edgePartition.iterator
}
......
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